Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sysctl.c: General linux system control interface |
| 3 | * |
| 4 | * Begun 24 March 1995, Stephen Tweedie |
| 5 | * Added /proc support, Dec 1995 |
| 6 | * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. |
| 7 | * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. |
| 8 | * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. |
| 9 | * Dynamic registration fixes, Stephen Tweedie. |
| 10 | * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. |
| 11 | * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris |
| 12 | * Horn. |
| 13 | * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. |
| 14 | * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. |
| 15 | * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill |
| 16 | * Wendling. |
| 17 | * The list_for_each() macro wasn't appropriate for the sysctl loop. |
| 18 | * Removed it and replaced it with older style, 03/23/00, Bill Wendling |
| 19 | */ |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/mm.h> |
| 23 | #include <linux/swap.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/sysctl.h> |
| 26 | #include <linux/proc_fs.h> |
Andrew Morgan | 72c2d58 | 2007-10-18 03:05:59 -0700 | [diff] [blame] | 27 | #include <linux/security.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/ctype.h> |
| 29 | #include <linux/utsname.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/smp_lock.h> |
Adrian Bunk | 62239ac | 2007-07-17 04:03:45 -0700 | [diff] [blame] | 31 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/init.h> |
| 33 | #include <linux/kernel.h> |
Kay Sievers | 0296b22 | 2005-11-11 05:33:52 +0100 | [diff] [blame] | 34 | #include <linux/kobject.h> |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 35 | #include <linux/net.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/sysrq.h> |
| 37 | #include <linux/highuid.h> |
| 38 | #include <linux/writeback.h> |
| 39 | #include <linux/hugetlb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/initrd.h> |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 41 | #include <linux/key.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <linux/times.h> |
| 43 | #include <linux/limits.h> |
| 44 | #include <linux/dcache.h> |
| 45 | #include <linux/syscalls.h> |
Adrian Bunk | c748e13 | 2008-07-23 21:27:03 -0700 | [diff] [blame] | 46 | #include <linux/vmstat.h> |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 47 | #include <linux/nfs_fs.h> |
| 48 | #include <linux/acpi.h> |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 49 | #include <linux/reboot.h> |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 50 | #include <linux/ftrace.h> |
David Howells | 12e22c5 | 2009-04-03 16:42:35 +0100 | [diff] [blame] | 51 | #include <linux/slow-work.h> |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 52 | #include <linux/perf_counter.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | #include <asm/uaccess.h> |
| 55 | #include <asm/processor.h> |
| 56 | |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 57 | #ifdef CONFIG_X86 |
| 58 | #include <asm/nmi.h> |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 59 | #include <asm/stacktrace.h> |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 60 | #include <asm/io.h> |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 61 | #endif |
| 62 | |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 63 | static int deprecated_sysctl_warning(struct __sysctl_args *args); |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #if defined(CONFIG_SYSCTL) |
| 66 | |
| 67 | /* External variables not in a header file. */ |
| 68 | extern int C_A_D; |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 69 | extern int print_fatal_signals; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | extern int sysctl_overcommit_memory; |
| 71 | extern int sysctl_overcommit_ratio; |
KAMEZAWA Hiroyuki | fadd8fb | 2006-06-23 02:03:13 -0700 | [diff] [blame] | 72 | extern int sysctl_panic_on_oom; |
David Rientjes | fe071d7 | 2007-10-16 23:25:56 -0700 | [diff] [blame] | 73 | extern int sysctl_oom_kill_allocating_task; |
David Rientjes | fef1bdd | 2008-02-07 00:14:07 -0800 | [diff] [blame] | 74 | extern int sysctl_oom_dump_tasks; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | extern int max_threads; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | extern int core_uses_pid; |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 77 | extern int suid_dumpable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | extern char core_pattern[]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | extern int pid_max; |
| 80 | extern int min_free_kbytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | extern int pid_max_min, pid_max_max; |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 82 | extern int sysctl_drop_caches; |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 83 | extern int percpu_pagelist_fraction; |
Andi Kleen | bebfa10 | 2006-06-26 13:56:52 +0200 | [diff] [blame] | 84 | extern int compat_log; |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 85 | extern int latencytop_enabled; |
Al Viro | eceea0b | 2008-05-10 10:08:32 -0400 | [diff] [blame] | 86 | extern int sysctl_nr_open_min, sysctl_nr_open_max; |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 87 | #ifndef CONFIG_MMU |
| 88 | extern int sysctl_nr_trim_pages; |
| 89 | #endif |
Paul E. McKenney | 31a72bc | 2008-06-18 09:26:49 -0700 | [diff] [blame] | 90 | #ifdef CONFIG_RCU_TORTURE_TEST |
| 91 | extern int rcutorture_runnable; |
| 92 | #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 94 | /* Constants used for minimum and maximum */ |
Bron Gondwana | 195cf453 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 95 | #ifdef CONFIG_DETECT_SOFTLOCKUP |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 96 | static int sixty = 60; |
Dimitri Sivanich | 9383d96 | 2008-05-12 21:21:14 +0200 | [diff] [blame] | 97 | static int neg_one = -1; |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 98 | #endif |
| 99 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 100 | static int zero; |
Linus Torvalds | cd5f9a4 | 2009-04-06 13:38:46 -0700 | [diff] [blame] | 101 | static int __maybe_unused one = 1; |
| 102 | static int __maybe_unused two = 2; |
Sven Wegener | fc3501d | 2009-02-11 13:04:23 -0800 | [diff] [blame] | 103 | static unsigned long one_ul = 1; |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 104 | static int one_hundred = 100; |
| 105 | |
Andrea Righi | 9e4a5bd | 2009-04-30 15:08:57 -0700 | [diff] [blame] | 106 | /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ |
| 107 | static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ |
| 110 | static int maxolduid = 65535; |
| 111 | static int minolduid; |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 112 | static int min_percpu_pagelist_fract = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | static int ngroups_max = NGROUPS_MAX; |
| 115 | |
Johannes Berg | a1ef5ad | 2008-07-08 19:00:17 +0200 | [diff] [blame] | 116 | #ifdef CONFIG_MODULES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | extern char modprobe_path[]; |
| 118 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | #ifdef CONFIG_CHR_DEV_SG |
| 120 | extern int sg_big_buff; |
| 121 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
David S. Miller | 72c57ed | 2008-09-11 23:29:54 -0700 | [diff] [blame] | 123 | #ifdef CONFIG_SPARC |
David S. Miller | 17f04fb | 2008-09-11 23:33:53 -0700 | [diff] [blame] | 124 | #include <asm/system.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | #endif |
| 126 | |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 127 | #ifdef CONFIG_SPARC64 |
| 128 | extern int sysctl_tsb_ratio; |
| 129 | #endif |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | #ifdef __hppa__ |
| 132 | extern int pwrsw_enabled; |
| 133 | extern int unaligned_enabled; |
| 134 | #endif |
| 135 | |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 136 | #ifdef CONFIG_S390 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #ifdef CONFIG_MATHEMU |
| 138 | extern int sysctl_ieee_emulation_warnings; |
| 139 | #endif |
| 140 | extern int sysctl_userprocess_debug; |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 141 | extern int spin_retry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | #endif |
| 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | #ifdef CONFIG_BSD_PROCESS_ACCT |
| 145 | extern int acct_parm[]; |
| 146 | #endif |
| 147 | |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 148 | #ifdef CONFIG_IA64 |
| 149 | extern int no_unaligned_warning; |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 150 | extern int unaligned_dump_stack; |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 151 | #endif |
| 152 | |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 153 | #ifdef CONFIG_RT_MUTEXES |
| 154 | extern int max_lock_depth; |
| 155 | #endif |
| 156 | |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 157 | #ifdef CONFIG_PROC_SYSCTL |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 158 | static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 159 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 160 | static int proc_taint(struct ctl_table *table, int write, struct file *filp, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 161 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 162 | #endif |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 163 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 164 | static struct ctl_table root_table[]; |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 165 | static struct ctl_table_root sysctl_table_root; |
| 166 | static struct ctl_table_header root_table_header = { |
Al Viro | b380b0d | 2008-09-04 17:05:57 +0100 | [diff] [blame] | 167 | .count = 1, |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 168 | .ctl_table = root_table, |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 169 | .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 170 | .root = &sysctl_table_root, |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 171 | .set = &sysctl_table_root.default_set, |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 172 | }; |
| 173 | static struct ctl_table_root sysctl_table_root = { |
| 174 | .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 175 | .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 176 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 178 | static struct ctl_table kern_table[]; |
| 179 | static struct ctl_table vm_table[]; |
| 180 | static struct ctl_table fs_table[]; |
| 181 | static struct ctl_table debug_table[]; |
| 182 | static struct ctl_table dev_table[]; |
| 183 | extern struct ctl_table random_table[]; |
Amy Griffis | 2d9048e | 2006-06-01 13:10:59 -0700 | [diff] [blame] | 184 | #ifdef CONFIG_INOTIFY_USER |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 185 | extern struct ctl_table inotify_table[]; |
Robert Love | 0399cb0 | 2005-07-13 12:38:18 -0400 | [diff] [blame] | 186 | #endif |
Davide Libenzi | 7ef9964 | 2008-12-01 13:13:55 -0800 | [diff] [blame] | 187 | #ifdef CONFIG_EPOLL |
| 188 | extern struct ctl_table epoll_table[]; |
| 189 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
| 191 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
| 192 | int sysctl_legacy_va_layout; |
| 193 | #endif |
| 194 | |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 195 | extern int prove_locking; |
| 196 | extern int lock_stat; |
Eric W. Biederman | 9bc9a6b | 2006-12-08 02:39:56 -0800 | [diff] [blame] | 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | /* The default sysctl tables: */ |
| 199 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 200 | static struct ctl_table root_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | { |
| 202 | .ctl_name = CTL_KERN, |
| 203 | .procname = "kernel", |
| 204 | .mode = 0555, |
| 205 | .child = kern_table, |
| 206 | }, |
| 207 | { |
| 208 | .ctl_name = CTL_VM, |
| 209 | .procname = "vm", |
| 210 | .mode = 0555, |
| 211 | .child = vm_table, |
| 212 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | .ctl_name = CTL_FS, |
| 215 | .procname = "fs", |
| 216 | .mode = 0555, |
| 217 | .child = fs_table, |
| 218 | }, |
| 219 | { |
| 220 | .ctl_name = CTL_DEBUG, |
| 221 | .procname = "debug", |
| 222 | .mode = 0555, |
| 223 | .child = debug_table, |
| 224 | }, |
| 225 | { |
| 226 | .ctl_name = CTL_DEV, |
| 227 | .procname = "dev", |
| 228 | .mode = 0555, |
| 229 | .child = dev_table, |
| 230 | }, |
Andrew Morton | 2be7fe0 | 2007-07-15 23:41:21 -0700 | [diff] [blame] | 231 | /* |
| 232 | * NOTE: do not add new entries to this table unless you have read |
| 233 | * Documentation/sysctl/ctl_unnumbered.txt |
| 234 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | { .ctl_name = 0 } |
| 236 | }; |
| 237 | |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 238 | #ifdef CONFIG_SCHED_DEBUG |
Eric Dumazet | 73c4efd | 2007-12-18 15:21:13 +0100 | [diff] [blame] | 239 | static int min_sched_granularity_ns = 100000; /* 100 usecs */ |
| 240 | static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
| 241 | static int min_wakeup_granularity_ns; /* 0 usecs */ |
| 242 | static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 243 | #endif |
| 244 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 245 | static struct ctl_table kern_table[] = { |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 246 | #ifdef CONFIG_SCHED_DEBUG |
| 247 | { |
| 248 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 249 | .procname = "sched_min_granularity_ns", |
| 250 | .data = &sysctl_sched_min_granularity, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 251 | .maxlen = sizeof(unsigned int), |
| 252 | .mode = 0644, |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 253 | .proc_handler = &sched_nr_latency_handler, |
| 254 | .strategy = &sysctl_intvec, |
| 255 | .extra1 = &min_sched_granularity_ns, |
| 256 | .extra2 = &max_sched_granularity_ns, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 257 | }, |
| 258 | { |
| 259 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | 2180508 | 2007-08-25 18:41:53 +0200 | [diff] [blame] | 260 | .procname = "sched_latency_ns", |
| 261 | .data = &sysctl_sched_latency, |
| 262 | .maxlen = sizeof(unsigned int), |
| 263 | .mode = 0644, |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 264 | .proc_handler = &sched_nr_latency_handler, |
Peter Zijlstra | 2180508 | 2007-08-25 18:41:53 +0200 | [diff] [blame] | 265 | .strategy = &sysctl_intvec, |
| 266 | .extra1 = &min_sched_granularity_ns, |
| 267 | .extra2 = &max_sched_granularity_ns, |
| 268 | }, |
| 269 | { |
| 270 | .ctl_name = CTL_UNNUMBERED, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 271 | .procname = "sched_wakeup_granularity_ns", |
| 272 | .data = &sysctl_sched_wakeup_granularity, |
| 273 | .maxlen = sizeof(unsigned int), |
| 274 | .mode = 0644, |
| 275 | .proc_handler = &proc_dointvec_minmax, |
| 276 | .strategy = &sysctl_intvec, |
| 277 | .extra1 = &min_wakeup_granularity_ns, |
| 278 | .extra2 = &max_wakeup_granularity_ns, |
| 279 | }, |
| 280 | { |
| 281 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | 2398f2c | 2008-06-27 13:41:35 +0200 | [diff] [blame] | 282 | .procname = "sched_shares_ratelimit", |
| 283 | .data = &sysctl_sched_shares_ratelimit, |
| 284 | .maxlen = sizeof(unsigned int), |
| 285 | .mode = 0644, |
| 286 | .proc_handler = &proc_dointvec, |
| 287 | }, |
| 288 | { |
| 289 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | ffda12a | 2008-10-17 19:27:02 +0200 | [diff] [blame] | 290 | .procname = "sched_shares_thresh", |
| 291 | .data = &sysctl_sched_shares_thresh, |
| 292 | .maxlen = sizeof(unsigned int), |
| 293 | .mode = 0644, |
| 294 | .proc_handler = &proc_dointvec_minmax, |
| 295 | .strategy = &sysctl_intvec, |
| 296 | .extra1 = &zero, |
| 297 | }, |
| 298 | { |
| 299 | .ctl_name = CTL_UNNUMBERED, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 300 | .procname = "sched_child_runs_first", |
| 301 | .data = &sysctl_sched_child_runs_first, |
| 302 | .maxlen = sizeof(unsigned int), |
| 303 | .mode = 0644, |
| 304 | .proc_handler = &proc_dointvec, |
| 305 | }, |
Peter Zijlstra | 1fc84aa | 2007-08-25 18:41:52 +0200 | [diff] [blame] | 306 | { |
| 307 | .ctl_name = CTL_UNNUMBERED, |
| 308 | .procname = "sched_features", |
| 309 | .data = &sysctl_sched_features, |
| 310 | .maxlen = sizeof(unsigned int), |
| 311 | .mode = 0644, |
| 312 | .proc_handler = &proc_dointvec, |
| 313 | }, |
Ingo Molnar | da84d96 | 2007-10-15 17:00:18 +0200 | [diff] [blame] | 314 | { |
| 315 | .ctl_name = CTL_UNNUMBERED, |
| 316 | .procname = "sched_migration_cost", |
| 317 | .data = &sysctl_sched_migration_cost, |
| 318 | .maxlen = sizeof(unsigned int), |
| 319 | .mode = 0644, |
| 320 | .proc_handler = &proc_dointvec, |
| 321 | }, |
Peter Zijlstra | b82d9fd | 2007-11-09 22:39:39 +0100 | [diff] [blame] | 322 | { |
| 323 | .ctl_name = CTL_UNNUMBERED, |
| 324 | .procname = "sched_nr_migrate", |
| 325 | .data = &sysctl_sched_nr_migrate, |
| 326 | .maxlen = sizeof(unsigned int), |
Peter Zijlstra | fa85ae2 | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 327 | .mode = 0644, |
| 328 | .proc_handler = &proc_dointvec, |
| 329 | }, |
Peter Zijlstra | 1fc84aa | 2007-08-25 18:41:52 +0200 | [diff] [blame] | 330 | #endif |
Ingo Molnar | 1799e35 | 2007-09-19 23:34:46 +0200 | [diff] [blame] | 331 | { |
| 332 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 333 | .procname = "sched_rt_period_us", |
| 334 | .data = &sysctl_sched_rt_period, |
| 335 | .maxlen = sizeof(unsigned int), |
| 336 | .mode = 0644, |
Peter Zijlstra | d0b27fa | 2008-04-19 19:44:57 +0200 | [diff] [blame] | 337 | .proc_handler = &sched_rt_handler, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 338 | }, |
| 339 | { |
| 340 | .ctl_name = CTL_UNNUMBERED, |
| 341 | .procname = "sched_rt_runtime_us", |
| 342 | .data = &sysctl_sched_rt_runtime, |
| 343 | .maxlen = sizeof(int), |
| 344 | .mode = 0644, |
Peter Zijlstra | d0b27fa | 2008-04-19 19:44:57 +0200 | [diff] [blame] | 345 | .proc_handler = &sched_rt_handler, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 346 | }, |
| 347 | { |
| 348 | .ctl_name = CTL_UNNUMBERED, |
Ingo Molnar | 1799e35 | 2007-09-19 23:34:46 +0200 | [diff] [blame] | 349 | .procname = "sched_compat_yield", |
| 350 | .data = &sysctl_sched_compat_yield, |
| 351 | .maxlen = sizeof(unsigned int), |
| 352 | .mode = 0644, |
| 353 | .proc_handler = &proc_dointvec, |
| 354 | }, |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 355 | #ifdef CONFIG_PROVE_LOCKING |
| 356 | { |
| 357 | .ctl_name = CTL_UNNUMBERED, |
| 358 | .procname = "prove_locking", |
| 359 | .data = &prove_locking, |
| 360 | .maxlen = sizeof(int), |
| 361 | .mode = 0644, |
| 362 | .proc_handler = &proc_dointvec, |
| 363 | }, |
| 364 | #endif |
| 365 | #ifdef CONFIG_LOCK_STAT |
| 366 | { |
| 367 | .ctl_name = CTL_UNNUMBERED, |
| 368 | .procname = "lock_stat", |
| 369 | .data = &lock_stat, |
| 370 | .maxlen = sizeof(int), |
| 371 | .mode = 0644, |
| 372 | .proc_handler = &proc_dointvec, |
| 373 | }, |
| 374 | #endif |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 375 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | .ctl_name = KERN_PANIC, |
| 377 | .procname = "panic", |
| 378 | .data = &panic_timeout, |
| 379 | .maxlen = sizeof(int), |
| 380 | .mode = 0644, |
| 381 | .proc_handler = &proc_dointvec, |
| 382 | }, |
| 383 | { |
| 384 | .ctl_name = KERN_CORE_USES_PID, |
| 385 | .procname = "core_uses_pid", |
| 386 | .data = &core_uses_pid, |
| 387 | .maxlen = sizeof(int), |
| 388 | .mode = 0644, |
| 389 | .proc_handler = &proc_dointvec, |
| 390 | }, |
| 391 | { |
| 392 | .ctl_name = KERN_CORE_PATTERN, |
| 393 | .procname = "core_pattern", |
| 394 | .data = core_pattern, |
Dan Aloni | 71ce92f | 2007-05-16 22:11:16 -0700 | [diff] [blame] | 395 | .maxlen = CORENAME_MAX_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | .mode = 0644, |
| 397 | .proc_handler = &proc_dostring, |
| 398 | .strategy = &sysctl_string, |
| 399 | }, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 400 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | .procname = "tainted", |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 403 | .maxlen = sizeof(long), |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 404 | .mode = 0644, |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 405 | .proc_handler = &proc_taint, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | }, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 407 | #endif |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 408 | #ifdef CONFIG_LATENCYTOP |
| 409 | { |
| 410 | .procname = "latencytop", |
| 411 | .data = &latencytop_enabled, |
| 412 | .maxlen = sizeof(int), |
| 413 | .mode = 0644, |
| 414 | .proc_handler = &proc_dointvec, |
| 415 | }, |
| 416 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | #ifdef CONFIG_BLK_DEV_INITRD |
| 418 | { |
| 419 | .ctl_name = KERN_REALROOTDEV, |
| 420 | .procname = "real-root-dev", |
| 421 | .data = &real_root_dev, |
| 422 | .maxlen = sizeof(int), |
| 423 | .mode = 0644, |
| 424 | .proc_handler = &proc_dointvec, |
| 425 | }, |
| 426 | #endif |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 427 | { |
| 428 | .ctl_name = CTL_UNNUMBERED, |
| 429 | .procname = "print-fatal-signals", |
| 430 | .data = &print_fatal_signals, |
| 431 | .maxlen = sizeof(int), |
| 432 | .mode = 0644, |
| 433 | .proc_handler = &proc_dointvec, |
| 434 | }, |
David S. Miller | 72c57ed | 2008-09-11 23:29:54 -0700 | [diff] [blame] | 435 | #ifdef CONFIG_SPARC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | { |
| 437 | .ctl_name = KERN_SPARC_REBOOT, |
| 438 | .procname = "reboot-cmd", |
| 439 | .data = reboot_command, |
| 440 | .maxlen = 256, |
| 441 | .mode = 0644, |
| 442 | .proc_handler = &proc_dostring, |
| 443 | .strategy = &sysctl_string, |
| 444 | }, |
| 445 | { |
| 446 | .ctl_name = KERN_SPARC_STOP_A, |
| 447 | .procname = "stop-a", |
| 448 | .data = &stop_a_enabled, |
| 449 | .maxlen = sizeof (int), |
| 450 | .mode = 0644, |
| 451 | .proc_handler = &proc_dointvec, |
| 452 | }, |
| 453 | { |
| 454 | .ctl_name = KERN_SPARC_SCONS_PWROFF, |
| 455 | .procname = "scons-poweroff", |
| 456 | .data = &scons_pwroff, |
| 457 | .maxlen = sizeof (int), |
| 458 | .mode = 0644, |
| 459 | .proc_handler = &proc_dointvec, |
| 460 | }, |
| 461 | #endif |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 462 | #ifdef CONFIG_SPARC64 |
| 463 | { |
| 464 | .ctl_name = CTL_UNNUMBERED, |
| 465 | .procname = "tsb-ratio", |
| 466 | .data = &sysctl_tsb_ratio, |
| 467 | .maxlen = sizeof (int), |
| 468 | .mode = 0644, |
| 469 | .proc_handler = &proc_dointvec, |
| 470 | }, |
| 471 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | #ifdef __hppa__ |
| 473 | { |
| 474 | .ctl_name = KERN_HPPA_PWRSW, |
| 475 | .procname = "soft-power", |
| 476 | .data = &pwrsw_enabled, |
| 477 | .maxlen = sizeof (int), |
| 478 | .mode = 0644, |
| 479 | .proc_handler = &proc_dointvec, |
| 480 | }, |
| 481 | { |
| 482 | .ctl_name = KERN_HPPA_UNALIGNED, |
| 483 | .procname = "unaligned-trap", |
| 484 | .data = &unaligned_enabled, |
| 485 | .maxlen = sizeof (int), |
| 486 | .mode = 0644, |
| 487 | .proc_handler = &proc_dointvec, |
| 488 | }, |
| 489 | #endif |
| 490 | { |
| 491 | .ctl_name = KERN_CTLALTDEL, |
| 492 | .procname = "ctrl-alt-del", |
| 493 | .data = &C_A_D, |
| 494 | .maxlen = sizeof(int), |
| 495 | .mode = 0644, |
| 496 | .proc_handler = &proc_dointvec, |
| 497 | }, |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 498 | #ifdef CONFIG_FUNCTION_TRACER |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 499 | { |
| 500 | .ctl_name = CTL_UNNUMBERED, |
| 501 | .procname = "ftrace_enabled", |
| 502 | .data = &ftrace_enabled, |
| 503 | .maxlen = sizeof(int), |
| 504 | .mode = 0644, |
| 505 | .proc_handler = &ftrace_enable_sysctl, |
| 506 | }, |
| 507 | #endif |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 508 | #ifdef CONFIG_STACK_TRACER |
| 509 | { |
| 510 | .ctl_name = CTL_UNNUMBERED, |
| 511 | .procname = "stack_tracer_enabled", |
| 512 | .data = &stack_tracer_enabled, |
| 513 | .maxlen = sizeof(int), |
| 514 | .mode = 0644, |
| 515 | .proc_handler = &stack_trace_sysctl, |
| 516 | }, |
| 517 | #endif |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 518 | #ifdef CONFIG_TRACING |
| 519 | { |
| 520 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | 3299b4d | 2008-11-04 11:58:21 +0100 | [diff] [blame] | 521 | .procname = "ftrace_dump_on_oops", |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 522 | .data = &ftrace_dump_on_oops, |
| 523 | .maxlen = sizeof(int), |
| 524 | .mode = 0644, |
| 525 | .proc_handler = &proc_dointvec, |
| 526 | }, |
| 527 | #endif |
Johannes Berg | a1ef5ad | 2008-07-08 19:00:17 +0200 | [diff] [blame] | 528 | #ifdef CONFIG_MODULES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | { |
| 530 | .ctl_name = KERN_MODPROBE, |
| 531 | .procname = "modprobe", |
| 532 | .data = &modprobe_path, |
| 533 | .maxlen = KMOD_PATH_LEN, |
| 534 | .mode = 0644, |
| 535 | .proc_handler = &proc_dostring, |
| 536 | .strategy = &sysctl_string, |
| 537 | }, |
| 538 | #endif |
Andrew Morton | 57ae250 | 2006-06-23 02:05:47 -0700 | [diff] [blame] | 539 | #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
| 541 | .ctl_name = KERN_HOTPLUG, |
| 542 | .procname = "hotplug", |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 543 | .data = &uevent_helper, |
| 544 | .maxlen = UEVENT_HELPER_PATH_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | .mode = 0644, |
| 546 | .proc_handler = &proc_dostring, |
| 547 | .strategy = &sysctl_string, |
| 548 | }, |
| 549 | #endif |
| 550 | #ifdef CONFIG_CHR_DEV_SG |
| 551 | { |
| 552 | .ctl_name = KERN_SG_BIG_BUFF, |
| 553 | .procname = "sg-big-buff", |
| 554 | .data = &sg_big_buff, |
| 555 | .maxlen = sizeof (int), |
| 556 | .mode = 0444, |
| 557 | .proc_handler = &proc_dointvec, |
| 558 | }, |
| 559 | #endif |
| 560 | #ifdef CONFIG_BSD_PROCESS_ACCT |
| 561 | { |
| 562 | .ctl_name = KERN_ACCT, |
| 563 | .procname = "acct", |
| 564 | .data = &acct_parm, |
| 565 | .maxlen = 3*sizeof(int), |
| 566 | .mode = 0644, |
| 567 | .proc_handler = &proc_dointvec, |
| 568 | }, |
| 569 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | #ifdef CONFIG_MAGIC_SYSRQ |
| 571 | { |
| 572 | .ctl_name = KERN_SYSRQ, |
| 573 | .procname = "sysrq", |
Ingo Molnar | 5d6f647 | 2006-12-13 00:34:36 -0800 | [diff] [blame] | 574 | .data = &__sysrq_enabled, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | .maxlen = sizeof (int), |
| 576 | .mode = 0644, |
| 577 | .proc_handler = &proc_dointvec, |
| 578 | }, |
| 579 | #endif |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 580 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | .procname = "cad_pid", |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 583 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | .maxlen = sizeof (int), |
| 585 | .mode = 0600, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 586 | .proc_handler = &proc_do_cad_pid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | }, |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 588 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | { |
| 590 | .ctl_name = KERN_MAX_THREADS, |
| 591 | .procname = "threads-max", |
| 592 | .data = &max_threads, |
| 593 | .maxlen = sizeof(int), |
| 594 | .mode = 0644, |
| 595 | .proc_handler = &proc_dointvec, |
| 596 | }, |
| 597 | { |
| 598 | .ctl_name = KERN_RANDOM, |
| 599 | .procname = "random", |
| 600 | .mode = 0555, |
| 601 | .child = random_table, |
| 602 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | { |
| 604 | .ctl_name = KERN_OVERFLOWUID, |
| 605 | .procname = "overflowuid", |
| 606 | .data = &overflowuid, |
| 607 | .maxlen = sizeof(int), |
| 608 | .mode = 0644, |
| 609 | .proc_handler = &proc_dointvec_minmax, |
| 610 | .strategy = &sysctl_intvec, |
| 611 | .extra1 = &minolduid, |
| 612 | .extra2 = &maxolduid, |
| 613 | }, |
| 614 | { |
| 615 | .ctl_name = KERN_OVERFLOWGID, |
| 616 | .procname = "overflowgid", |
| 617 | .data = &overflowgid, |
| 618 | .maxlen = sizeof(int), |
| 619 | .mode = 0644, |
| 620 | .proc_handler = &proc_dointvec_minmax, |
| 621 | .strategy = &sysctl_intvec, |
| 622 | .extra1 = &minolduid, |
| 623 | .extra2 = &maxolduid, |
| 624 | }, |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 625 | #ifdef CONFIG_S390 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | #ifdef CONFIG_MATHEMU |
| 627 | { |
| 628 | .ctl_name = KERN_IEEE_EMULATION_WARNINGS, |
| 629 | .procname = "ieee_emulation_warnings", |
| 630 | .data = &sysctl_ieee_emulation_warnings, |
| 631 | .maxlen = sizeof(int), |
| 632 | .mode = 0644, |
| 633 | .proc_handler = &proc_dointvec, |
| 634 | }, |
| 635 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | { |
| 637 | .ctl_name = KERN_S390_USER_DEBUG_LOGGING, |
| 638 | .procname = "userprocess_debug", |
| 639 | .data = &sysctl_userprocess_debug, |
| 640 | .maxlen = sizeof(int), |
| 641 | .mode = 0644, |
| 642 | .proc_handler = &proc_dointvec, |
| 643 | }, |
| 644 | #endif |
| 645 | { |
| 646 | .ctl_name = KERN_PIDMAX, |
| 647 | .procname = "pid_max", |
| 648 | .data = &pid_max, |
| 649 | .maxlen = sizeof (int), |
| 650 | .mode = 0644, |
| 651 | .proc_handler = &proc_dointvec_minmax, |
| 652 | .strategy = sysctl_intvec, |
| 653 | .extra1 = &pid_max_min, |
| 654 | .extra2 = &pid_max_max, |
| 655 | }, |
| 656 | { |
| 657 | .ctl_name = KERN_PANIC_ON_OOPS, |
| 658 | .procname = "panic_on_oops", |
| 659 | .data = &panic_on_oops, |
| 660 | .maxlen = sizeof(int), |
| 661 | .mode = 0644, |
| 662 | .proc_handler = &proc_dointvec, |
| 663 | }, |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 664 | #if defined CONFIG_PRINTK |
| 665 | { |
| 666 | .ctl_name = KERN_PRINTK, |
| 667 | .procname = "printk", |
| 668 | .data = &console_loglevel, |
| 669 | .maxlen = 4*sizeof(int), |
| 670 | .mode = 0644, |
| 671 | .proc_handler = &proc_dointvec, |
| 672 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | { |
| 674 | .ctl_name = KERN_PRINTK_RATELIMIT, |
| 675 | .procname = "printk_ratelimit", |
Dave Young | 717115e | 2008-07-25 01:45:58 -0700 | [diff] [blame] | 676 | .data = &printk_ratelimit_state.interval, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | .maxlen = sizeof(int), |
| 678 | .mode = 0644, |
| 679 | .proc_handler = &proc_dointvec_jiffies, |
| 680 | .strategy = &sysctl_jiffies, |
| 681 | }, |
| 682 | { |
| 683 | .ctl_name = KERN_PRINTK_RATELIMIT_BURST, |
| 684 | .procname = "printk_ratelimit_burst", |
Dave Young | 717115e | 2008-07-25 01:45:58 -0700 | [diff] [blame] | 685 | .data = &printk_ratelimit_state.burst, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | .maxlen = sizeof(int), |
| 687 | .mode = 0644, |
| 688 | .proc_handler = &proc_dointvec, |
| 689 | }, |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 690 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | { |
| 692 | .ctl_name = KERN_NGROUPS_MAX, |
| 693 | .procname = "ngroups_max", |
| 694 | .data = &ngroups_max, |
| 695 | .maxlen = sizeof (int), |
| 696 | .mode = 0444, |
| 697 | .proc_handler = &proc_dointvec, |
| 698 | }, |
| 699 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) |
| 700 | { |
| 701 | .ctl_name = KERN_UNKNOWN_NMI_PANIC, |
| 702 | .procname = "unknown_nmi_panic", |
| 703 | .data = &unknown_nmi_panic, |
| 704 | .maxlen = sizeof (int), |
| 705 | .mode = 0644, |
Don Zickus | 2fbe7b2 | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 706 | .proc_handler = &proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | }, |
Don Zickus | 407984f | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 708 | { |
Don Zickus | 407984f | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 709 | .procname = "nmi_watchdog", |
| 710 | .data = &nmi_watchdog_enabled, |
| 711 | .maxlen = sizeof (int), |
| 712 | .mode = 0644, |
| 713 | .proc_handler = &proc_nmi_enabled, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | }, |
| 715 | #endif |
| 716 | #if defined(CONFIG_X86) |
| 717 | { |
Don Zickus | 8da5add | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 718 | .ctl_name = KERN_PANIC_ON_NMI, |
| 719 | .procname = "panic_on_unrecovered_nmi", |
| 720 | .data = &panic_on_unrecovered_nmi, |
| 721 | .maxlen = sizeof(int), |
| 722 | .mode = 0644, |
| 723 | .proc_handler = &proc_dointvec, |
| 724 | }, |
| 725 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | .ctl_name = KERN_BOOTLOADER_TYPE, |
| 727 | .procname = "bootloader_type", |
| 728 | .data = &bootloader_type, |
| 729 | .maxlen = sizeof (int), |
| 730 | .mode = 0444, |
| 731 | .proc_handler = &proc_dointvec, |
| 732 | }, |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 733 | { |
| 734 | .ctl_name = CTL_UNNUMBERED, |
| 735 | .procname = "kstack_depth_to_print", |
| 736 | .data = &kstack_depth_to_print, |
| 737 | .maxlen = sizeof(int), |
| 738 | .mode = 0644, |
| 739 | .proc_handler = &proc_dointvec, |
| 740 | }, |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 741 | { |
| 742 | .ctl_name = CTL_UNNUMBERED, |
| 743 | .procname = "io_delay_type", |
| 744 | .data = &io_delay_type, |
| 745 | .maxlen = sizeof(int), |
| 746 | .mode = 0644, |
| 747 | .proc_handler = &proc_dointvec, |
| 748 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | #endif |
Luke Yang | 7a9166e | 2006-02-20 18:28:07 -0800 | [diff] [blame] | 750 | #if defined(CONFIG_MMU) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | { |
| 752 | .ctl_name = KERN_RANDOMIZE, |
| 753 | .procname = "randomize_va_space", |
| 754 | .data = &randomize_va_space, |
| 755 | .maxlen = sizeof(int), |
| 756 | .mode = 0644, |
| 757 | .proc_handler = &proc_dointvec, |
| 758 | }, |
Luke Yang | 7a9166e | 2006-02-20 18:28:07 -0800 | [diff] [blame] | 759 | #endif |
Martin Schwidefsky | 0152fb3 | 2006-01-14 13:21:00 -0800 | [diff] [blame] | 760 | #if defined(CONFIG_S390) && defined(CONFIG_SMP) |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 761 | { |
| 762 | .ctl_name = KERN_SPIN_RETRY, |
| 763 | .procname = "spin_retry", |
| 764 | .data = &spin_retry, |
| 765 | .maxlen = sizeof (int), |
| 766 | .mode = 0644, |
| 767 | .proc_handler = &proc_dointvec, |
| 768 | }, |
| 769 | #endif |
Len Brown | 673d5b4 | 2007-07-28 03:33:16 -0400 | [diff] [blame] | 770 | #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 771 | { |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 772 | .procname = "acpi_video_flags", |
Pavel Machek | 77afcf7 | 2007-07-19 01:47:41 -0700 | [diff] [blame] | 773 | .data = &acpi_realmode_flags, |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 774 | .maxlen = sizeof (unsigned long), |
| 775 | .mode = 0644, |
Stefan Seyfried | 7f99f06 | 2006-03-02 02:54:34 -0800 | [diff] [blame] | 776 | .proc_handler = &proc_doulongvec_minmax, |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 777 | }, |
| 778 | #endif |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 779 | #ifdef CONFIG_IA64 |
| 780 | { |
| 781 | .ctl_name = KERN_IA64_UNALIGNED, |
| 782 | .procname = "ignore-unaligned-usertrap", |
| 783 | .data = &no_unaligned_warning, |
| 784 | .maxlen = sizeof (int), |
| 785 | .mode = 0644, |
| 786 | .proc_handler = &proc_dointvec, |
| 787 | }, |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 788 | { |
| 789 | .ctl_name = CTL_UNNUMBERED, |
| 790 | .procname = "unaligned-dump-stack", |
| 791 | .data = &unaligned_dump_stack, |
| 792 | .maxlen = sizeof (int), |
| 793 | .mode = 0644, |
| 794 | .proc_handler = &proc_dointvec, |
| 795 | }, |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 796 | #endif |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 797 | #ifdef CONFIG_DETECT_SOFTLOCKUP |
| 798 | { |
| 799 | .ctl_name = CTL_UNNUMBERED, |
Ingo Molnar | 9c44bc0 | 2008-05-12 21:21:04 +0200 | [diff] [blame] | 800 | .procname = "softlockup_panic", |
| 801 | .data = &softlockup_panic, |
| 802 | .maxlen = sizeof(int), |
| 803 | .mode = 0644, |
Hiroshi Shimamoto | 4dca10a | 2008-07-07 18:37:04 -0700 | [diff] [blame] | 804 | .proc_handler = &proc_dointvec_minmax, |
Ingo Molnar | 9c44bc0 | 2008-05-12 21:21:04 +0200 | [diff] [blame] | 805 | .strategy = &sysctl_intvec, |
| 806 | .extra1 = &zero, |
| 807 | .extra2 = &one, |
| 808 | }, |
| 809 | { |
| 810 | .ctl_name = CTL_UNNUMBERED, |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 811 | .procname = "softlockup_thresh", |
| 812 | .data = &softlockup_thresh, |
Dimitri Sivanich | 9383d96 | 2008-05-12 21:21:14 +0200 | [diff] [blame] | 813 | .maxlen = sizeof(int), |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 814 | .mode = 0644, |
Mandeep Singh Baines | baf48f6 | 2009-01-12 21:15:17 -0800 | [diff] [blame] | 815 | .proc_handler = &proc_dosoftlockup_thresh, |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 816 | .strategy = &sysctl_intvec, |
Dimitri Sivanich | 9383d96 | 2008-05-12 21:21:14 +0200 | [diff] [blame] | 817 | .extra1 = &neg_one, |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 818 | .extra2 = &sixty, |
| 819 | }, |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 820 | #endif |
| 821 | #ifdef CONFIG_DETECT_HUNG_TASK |
| 822 | { |
| 823 | .ctl_name = CTL_UNNUMBERED, |
| 824 | .procname = "hung_task_panic", |
| 825 | .data = &sysctl_hung_task_panic, |
| 826 | .maxlen = sizeof(int), |
| 827 | .mode = 0644, |
| 828 | .proc_handler = &proc_dointvec_minmax, |
| 829 | .strategy = &sysctl_intvec, |
| 830 | .extra1 = &zero, |
| 831 | .extra2 = &one, |
| 832 | }, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 833 | { |
| 834 | .ctl_name = CTL_UNNUMBERED, |
| 835 | .procname = "hung_task_check_count", |
| 836 | .data = &sysctl_hung_task_check_count, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 837 | .maxlen = sizeof(unsigned long), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 838 | .mode = 0644, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 839 | .proc_handler = &proc_doulongvec_minmax, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 840 | .strategy = &sysctl_intvec, |
| 841 | }, |
| 842 | { |
| 843 | .ctl_name = CTL_UNNUMBERED, |
| 844 | .procname = "hung_task_timeout_secs", |
| 845 | .data = &sysctl_hung_task_timeout_secs, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 846 | .maxlen = sizeof(unsigned long), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 847 | .mode = 0644, |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 848 | .proc_handler = &proc_dohung_task_timeout_secs, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 849 | .strategy = &sysctl_intvec, |
| 850 | }, |
| 851 | { |
| 852 | .ctl_name = CTL_UNNUMBERED, |
| 853 | .procname = "hung_task_warnings", |
| 854 | .data = &sysctl_hung_task_warnings, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 855 | .maxlen = sizeof(unsigned long), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 856 | .mode = 0644, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 857 | .proc_handler = &proc_doulongvec_minmax, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 858 | .strategy = &sysctl_intvec, |
| 859 | }, |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 860 | #endif |
Andi Kleen | bebfa10 | 2006-06-26 13:56:52 +0200 | [diff] [blame] | 861 | #ifdef CONFIG_COMPAT |
| 862 | { |
| 863 | .ctl_name = KERN_COMPAT_LOG, |
| 864 | .procname = "compat-log", |
| 865 | .data = &compat_log, |
| 866 | .maxlen = sizeof (int), |
| 867 | .mode = 0644, |
| 868 | .proc_handler = &proc_dointvec, |
| 869 | }, |
| 870 | #endif |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 871 | #ifdef CONFIG_RT_MUTEXES |
| 872 | { |
| 873 | .ctl_name = KERN_MAX_LOCK_DEPTH, |
| 874 | .procname = "max_lock_depth", |
| 875 | .data = &max_lock_depth, |
| 876 | .maxlen = sizeof(int), |
| 877 | .mode = 0644, |
| 878 | .proc_handler = &proc_dointvec, |
| 879 | }, |
| 880 | #endif |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 881 | { |
| 882 | .ctl_name = CTL_UNNUMBERED, |
| 883 | .procname = "poweroff_cmd", |
| 884 | .data = &poweroff_cmd, |
| 885 | .maxlen = POWEROFF_CMD_PATH_LEN, |
| 886 | .mode = 0644, |
| 887 | .proc_handler = &proc_dostring, |
| 888 | .strategy = &sysctl_string, |
| 889 | }, |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 890 | #ifdef CONFIG_KEYS |
| 891 | { |
| 892 | .ctl_name = CTL_UNNUMBERED, |
| 893 | .procname = "keys", |
| 894 | .mode = 0555, |
| 895 | .child = key_sysctls, |
| 896 | }, |
| 897 | #endif |
Paul E. McKenney | 31a72bc | 2008-06-18 09:26:49 -0700 | [diff] [blame] | 898 | #ifdef CONFIG_RCU_TORTURE_TEST |
| 899 | { |
| 900 | .ctl_name = CTL_UNNUMBERED, |
| 901 | .procname = "rcutorture_runnable", |
| 902 | .data = &rcutorture_runnable, |
| 903 | .maxlen = sizeof(int), |
| 904 | .mode = 0644, |
| 905 | .proc_handler = &proc_dointvec, |
| 906 | }, |
| 907 | #endif |
David Howells | 12e22c5 | 2009-04-03 16:42:35 +0100 | [diff] [blame] | 908 | #ifdef CONFIG_SLOW_WORK |
| 909 | { |
| 910 | .ctl_name = CTL_UNNUMBERED, |
| 911 | .procname = "slow-work", |
| 912 | .mode = 0555, |
| 913 | .child = slow_work_sysctls, |
| 914 | }, |
| 915 | #endif |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 916 | #ifdef CONFIG_PERF_COUNTERS |
| 917 | { |
| 918 | .ctl_name = CTL_UNNUMBERED, |
Peter Zijlstra | 0764771 | 2009-06-11 11:18:36 +0200 | [diff] [blame^] | 919 | .procname = "perf_counter_paranoid", |
| 920 | .data = &sysctl_perf_counter_paranoid, |
| 921 | .maxlen = sizeof(sysctl_perf_counter_paranoid), |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 922 | .mode = 0644, |
| 923 | .proc_handler = &proc_dointvec, |
| 924 | }, |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 925 | { |
| 926 | .ctl_name = CTL_UNNUMBERED, |
| 927 | .procname = "perf_counter_mlock_kb", |
| 928 | .data = &sysctl_perf_counter_mlock, |
| 929 | .maxlen = sizeof(sysctl_perf_counter_mlock), |
| 930 | .mode = 0644, |
| 931 | .proc_handler = &proc_dointvec, |
| 932 | }, |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 933 | { |
| 934 | .ctl_name = CTL_UNNUMBERED, |
| 935 | .procname = "perf_counter_int_limit", |
| 936 | .data = &sysctl_perf_counter_limit, |
| 937 | .maxlen = sizeof(sysctl_perf_counter_limit), |
| 938 | .mode = 0644, |
| 939 | .proc_handler = &proc_dointvec, |
| 940 | }, |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 941 | #endif |
Andrew Morton | ed2c12f | 2007-07-19 01:50:35 -0700 | [diff] [blame] | 942 | /* |
| 943 | * NOTE: do not add new entries to this table unless you have read |
| 944 | * Documentation/sysctl/ctl_unnumbered.txt |
| 945 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | { .ctl_name = 0 } |
| 947 | }; |
| 948 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 949 | static struct ctl_table vm_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | { |
| 951 | .ctl_name = VM_OVERCOMMIT_MEMORY, |
| 952 | .procname = "overcommit_memory", |
| 953 | .data = &sysctl_overcommit_memory, |
| 954 | .maxlen = sizeof(sysctl_overcommit_memory), |
| 955 | .mode = 0644, |
| 956 | .proc_handler = &proc_dointvec, |
| 957 | }, |
| 958 | { |
KAMEZAWA Hiroyuki | fadd8fb | 2006-06-23 02:03:13 -0700 | [diff] [blame] | 959 | .ctl_name = VM_PANIC_ON_OOM, |
| 960 | .procname = "panic_on_oom", |
| 961 | .data = &sysctl_panic_on_oom, |
| 962 | .maxlen = sizeof(sysctl_panic_on_oom), |
| 963 | .mode = 0644, |
| 964 | .proc_handler = &proc_dointvec, |
| 965 | }, |
| 966 | { |
David Rientjes | fe071d7 | 2007-10-16 23:25:56 -0700 | [diff] [blame] | 967 | .ctl_name = CTL_UNNUMBERED, |
| 968 | .procname = "oom_kill_allocating_task", |
| 969 | .data = &sysctl_oom_kill_allocating_task, |
| 970 | .maxlen = sizeof(sysctl_oom_kill_allocating_task), |
| 971 | .mode = 0644, |
| 972 | .proc_handler = &proc_dointvec, |
| 973 | }, |
| 974 | { |
David Rientjes | fef1bdd | 2008-02-07 00:14:07 -0800 | [diff] [blame] | 975 | .ctl_name = CTL_UNNUMBERED, |
| 976 | .procname = "oom_dump_tasks", |
| 977 | .data = &sysctl_oom_dump_tasks, |
| 978 | .maxlen = sizeof(sysctl_oom_dump_tasks), |
| 979 | .mode = 0644, |
| 980 | .proc_handler = &proc_dointvec, |
| 981 | }, |
| 982 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | .ctl_name = VM_OVERCOMMIT_RATIO, |
| 984 | .procname = "overcommit_ratio", |
| 985 | .data = &sysctl_overcommit_ratio, |
| 986 | .maxlen = sizeof(sysctl_overcommit_ratio), |
| 987 | .mode = 0644, |
| 988 | .proc_handler = &proc_dointvec, |
| 989 | }, |
| 990 | { |
| 991 | .ctl_name = VM_PAGE_CLUSTER, |
| 992 | .procname = "page-cluster", |
| 993 | .data = &page_cluster, |
| 994 | .maxlen = sizeof(int), |
| 995 | .mode = 0644, |
| 996 | .proc_handler = &proc_dointvec, |
| 997 | }, |
| 998 | { |
| 999 | .ctl_name = VM_DIRTY_BACKGROUND, |
| 1000 | .procname = "dirty_background_ratio", |
| 1001 | .data = &dirty_background_ratio, |
| 1002 | .maxlen = sizeof(dirty_background_ratio), |
| 1003 | .mode = 0644, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1004 | .proc_handler = &dirty_background_ratio_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | .strategy = &sysctl_intvec, |
| 1006 | .extra1 = &zero, |
| 1007 | .extra2 = &one_hundred, |
| 1008 | }, |
| 1009 | { |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1010 | .ctl_name = CTL_UNNUMBERED, |
| 1011 | .procname = "dirty_background_bytes", |
| 1012 | .data = &dirty_background_bytes, |
| 1013 | .maxlen = sizeof(dirty_background_bytes), |
| 1014 | .mode = 0644, |
| 1015 | .proc_handler = &dirty_background_bytes_handler, |
| 1016 | .strategy = &sysctl_intvec, |
Sven Wegener | fc3501d | 2009-02-11 13:04:23 -0800 | [diff] [blame] | 1017 | .extra1 = &one_ul, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1018 | }, |
| 1019 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | .ctl_name = VM_DIRTY_RATIO, |
| 1021 | .procname = "dirty_ratio", |
| 1022 | .data = &vm_dirty_ratio, |
| 1023 | .maxlen = sizeof(vm_dirty_ratio), |
| 1024 | .mode = 0644, |
Peter Zijlstra | 04fbfdc | 2007-10-16 23:25:50 -0700 | [diff] [blame] | 1025 | .proc_handler = &dirty_ratio_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | .strategy = &sysctl_intvec, |
| 1027 | .extra1 = &zero, |
| 1028 | .extra2 = &one_hundred, |
| 1029 | }, |
| 1030 | { |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1031 | .ctl_name = CTL_UNNUMBERED, |
| 1032 | .procname = "dirty_bytes", |
| 1033 | .data = &vm_dirty_bytes, |
| 1034 | .maxlen = sizeof(vm_dirty_bytes), |
| 1035 | .mode = 0644, |
| 1036 | .proc_handler = &dirty_bytes_handler, |
| 1037 | .strategy = &sysctl_intvec, |
Andrea Righi | 9e4a5bd | 2009-04-30 15:08:57 -0700 | [diff] [blame] | 1038 | .extra1 = &dirty_bytes_min, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1039 | }, |
| 1040 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | .procname = "dirty_writeback_centisecs", |
Bart Samwel | f6ef943 | 2006-03-24 03:15:48 -0800 | [diff] [blame] | 1042 | .data = &dirty_writeback_interval, |
| 1043 | .maxlen = sizeof(dirty_writeback_interval), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | .mode = 0644, |
| 1045 | .proc_handler = &dirty_writeback_centisecs_handler, |
| 1046 | }, |
| 1047 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | .procname = "dirty_expire_centisecs", |
Bart Samwel | f6ef943 | 2006-03-24 03:15:48 -0800 | [diff] [blame] | 1049 | .data = &dirty_expire_interval, |
| 1050 | .maxlen = sizeof(dirty_expire_interval), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | .mode = 0644, |
Alexey Dobriyan | 704503d | 2009-03-31 15:23:18 -0700 | [diff] [blame] | 1052 | .proc_handler = &proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | }, |
| 1054 | { |
| 1055 | .ctl_name = VM_NR_PDFLUSH_THREADS, |
| 1056 | .procname = "nr_pdflush_threads", |
| 1057 | .data = &nr_pdflush_threads, |
| 1058 | .maxlen = sizeof nr_pdflush_threads, |
| 1059 | .mode = 0444 /* read-only*/, |
| 1060 | .proc_handler = &proc_dointvec, |
| 1061 | }, |
| 1062 | { |
| 1063 | .ctl_name = VM_SWAPPINESS, |
| 1064 | .procname = "swappiness", |
| 1065 | .data = &vm_swappiness, |
| 1066 | .maxlen = sizeof(vm_swappiness), |
| 1067 | .mode = 0644, |
| 1068 | .proc_handler = &proc_dointvec_minmax, |
| 1069 | .strategy = &sysctl_intvec, |
| 1070 | .extra1 = &zero, |
| 1071 | .extra2 = &one_hundred, |
| 1072 | }, |
| 1073 | #ifdef CONFIG_HUGETLB_PAGE |
| 1074 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | .procname = "nr_hugepages", |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1076 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | .maxlen = sizeof(unsigned long), |
| 1078 | .mode = 0644, |
| 1079 | .proc_handler = &hugetlb_sysctl_handler, |
| 1080 | .extra1 = (void *)&hugetlb_zero, |
| 1081 | .extra2 = (void *)&hugetlb_infinity, |
| 1082 | }, |
| 1083 | { |
| 1084 | .ctl_name = VM_HUGETLB_GROUP, |
| 1085 | .procname = "hugetlb_shm_group", |
| 1086 | .data = &sysctl_hugetlb_shm_group, |
| 1087 | .maxlen = sizeof(gid_t), |
| 1088 | .mode = 0644, |
| 1089 | .proc_handler = &proc_dointvec, |
| 1090 | }, |
Mel Gorman | 396faf0 | 2007-07-17 04:03:13 -0700 | [diff] [blame] | 1091 | { |
| 1092 | .ctl_name = CTL_UNNUMBERED, |
| 1093 | .procname = "hugepages_treat_as_movable", |
| 1094 | .data = &hugepages_treat_as_movable, |
| 1095 | .maxlen = sizeof(int), |
| 1096 | .mode = 0644, |
| 1097 | .proc_handler = &hugetlb_treat_movable_handler, |
| 1098 | }, |
Adam Litke | 54f9f80 | 2007-10-16 01:26:20 -0700 | [diff] [blame] | 1099 | { |
| 1100 | .ctl_name = CTL_UNNUMBERED, |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1101 | .procname = "nr_overcommit_hugepages", |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1102 | .data = NULL, |
| 1103 | .maxlen = sizeof(unsigned long), |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1104 | .mode = 0644, |
Nishanth Aravamudan | a3d0c6a | 2008-02-08 04:18:18 -0800 | [diff] [blame] | 1105 | .proc_handler = &hugetlb_overcommit_handler, |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1106 | .extra1 = (void *)&hugetlb_zero, |
| 1107 | .extra2 = (void *)&hugetlb_infinity, |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1108 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | #endif |
| 1110 | { |
| 1111 | .ctl_name = VM_LOWMEM_RESERVE_RATIO, |
| 1112 | .procname = "lowmem_reserve_ratio", |
| 1113 | .data = &sysctl_lowmem_reserve_ratio, |
| 1114 | .maxlen = sizeof(sysctl_lowmem_reserve_ratio), |
| 1115 | .mode = 0644, |
| 1116 | .proc_handler = &lowmem_reserve_ratio_sysctl_handler, |
| 1117 | .strategy = &sysctl_intvec, |
| 1118 | }, |
| 1119 | { |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1120 | .ctl_name = VM_DROP_PAGECACHE, |
| 1121 | .procname = "drop_caches", |
| 1122 | .data = &sysctl_drop_caches, |
| 1123 | .maxlen = sizeof(int), |
| 1124 | .mode = 0644, |
| 1125 | .proc_handler = drop_caches_sysctl_handler, |
| 1126 | .strategy = &sysctl_intvec, |
| 1127 | }, |
| 1128 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | .ctl_name = VM_MIN_FREE_KBYTES, |
| 1130 | .procname = "min_free_kbytes", |
| 1131 | .data = &min_free_kbytes, |
| 1132 | .maxlen = sizeof(min_free_kbytes), |
| 1133 | .mode = 0644, |
| 1134 | .proc_handler = &min_free_kbytes_sysctl_handler, |
| 1135 | .strategy = &sysctl_intvec, |
| 1136 | .extra1 = &zero, |
| 1137 | }, |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1138 | { |
| 1139 | .ctl_name = VM_PERCPU_PAGELIST_FRACTION, |
| 1140 | .procname = "percpu_pagelist_fraction", |
| 1141 | .data = &percpu_pagelist_fraction, |
| 1142 | .maxlen = sizeof(percpu_pagelist_fraction), |
| 1143 | .mode = 0644, |
| 1144 | .proc_handler = &percpu_pagelist_fraction_sysctl_handler, |
| 1145 | .strategy = &sysctl_intvec, |
| 1146 | .extra1 = &min_percpu_pagelist_fract, |
| 1147 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | #ifdef CONFIG_MMU |
| 1149 | { |
| 1150 | .ctl_name = VM_MAX_MAP_COUNT, |
| 1151 | .procname = "max_map_count", |
| 1152 | .data = &sysctl_max_map_count, |
| 1153 | .maxlen = sizeof(sysctl_max_map_count), |
| 1154 | .mode = 0644, |
| 1155 | .proc_handler = &proc_dointvec |
| 1156 | }, |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1157 | #else |
| 1158 | { |
| 1159 | .ctl_name = CTL_UNNUMBERED, |
| 1160 | .procname = "nr_trim_pages", |
| 1161 | .data = &sysctl_nr_trim_pages, |
| 1162 | .maxlen = sizeof(sysctl_nr_trim_pages), |
| 1163 | .mode = 0644, |
| 1164 | .proc_handler = &proc_dointvec_minmax, |
| 1165 | .strategy = &sysctl_intvec, |
| 1166 | .extra1 = &zero, |
| 1167 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | #endif |
| 1169 | { |
| 1170 | .ctl_name = VM_LAPTOP_MODE, |
| 1171 | .procname = "laptop_mode", |
| 1172 | .data = &laptop_mode, |
| 1173 | .maxlen = sizeof(laptop_mode), |
| 1174 | .mode = 0644, |
Bart Samwel | ed5b43f | 2006-03-24 03:15:49 -0800 | [diff] [blame] | 1175 | .proc_handler = &proc_dointvec_jiffies, |
| 1176 | .strategy = &sysctl_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | }, |
| 1178 | { |
| 1179 | .ctl_name = VM_BLOCK_DUMP, |
| 1180 | .procname = "block_dump", |
| 1181 | .data = &block_dump, |
| 1182 | .maxlen = sizeof(block_dump), |
| 1183 | .mode = 0644, |
| 1184 | .proc_handler = &proc_dointvec, |
| 1185 | .strategy = &sysctl_intvec, |
| 1186 | .extra1 = &zero, |
| 1187 | }, |
| 1188 | { |
| 1189 | .ctl_name = VM_VFS_CACHE_PRESSURE, |
| 1190 | .procname = "vfs_cache_pressure", |
| 1191 | .data = &sysctl_vfs_cache_pressure, |
| 1192 | .maxlen = sizeof(sysctl_vfs_cache_pressure), |
| 1193 | .mode = 0644, |
| 1194 | .proc_handler = &proc_dointvec, |
| 1195 | .strategy = &sysctl_intvec, |
| 1196 | .extra1 = &zero, |
| 1197 | }, |
| 1198 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
| 1199 | { |
| 1200 | .ctl_name = VM_LEGACY_VA_LAYOUT, |
| 1201 | .procname = "legacy_va_layout", |
| 1202 | .data = &sysctl_legacy_va_layout, |
| 1203 | .maxlen = sizeof(sysctl_legacy_va_layout), |
| 1204 | .mode = 0644, |
| 1205 | .proc_handler = &proc_dointvec, |
| 1206 | .strategy = &sysctl_intvec, |
| 1207 | .extra1 = &zero, |
| 1208 | }, |
| 1209 | #endif |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1210 | #ifdef CONFIG_NUMA |
| 1211 | { |
| 1212 | .ctl_name = VM_ZONE_RECLAIM_MODE, |
| 1213 | .procname = "zone_reclaim_mode", |
| 1214 | .data = &zone_reclaim_mode, |
| 1215 | .maxlen = sizeof(zone_reclaim_mode), |
| 1216 | .mode = 0644, |
| 1217 | .proc_handler = &proc_dointvec, |
Christoph Lameter | c84db23 | 2006-02-01 03:05:29 -0800 | [diff] [blame] | 1218 | .strategy = &sysctl_intvec, |
| 1219 | .extra1 = &zero, |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1220 | }, |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1221 | { |
| 1222 | .ctl_name = VM_MIN_UNMAPPED, |
| 1223 | .procname = "min_unmapped_ratio", |
| 1224 | .data = &sysctl_min_unmapped_ratio, |
| 1225 | .maxlen = sizeof(sysctl_min_unmapped_ratio), |
| 1226 | .mode = 0644, |
| 1227 | .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler, |
| 1228 | .strategy = &sysctl_intvec, |
| 1229 | .extra1 = &zero, |
| 1230 | .extra2 = &one_hundred, |
| 1231 | }, |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1232 | { |
| 1233 | .ctl_name = VM_MIN_SLAB, |
| 1234 | .procname = "min_slab_ratio", |
| 1235 | .data = &sysctl_min_slab_ratio, |
| 1236 | .maxlen = sizeof(sysctl_min_slab_ratio), |
| 1237 | .mode = 0644, |
| 1238 | .proc_handler = &sysctl_min_slab_ratio_sysctl_handler, |
| 1239 | .strategy = &sysctl_intvec, |
| 1240 | .extra1 = &zero, |
| 1241 | .extra2 = &one_hundred, |
| 1242 | }, |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1243 | #endif |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1244 | #ifdef CONFIG_SMP |
| 1245 | { |
| 1246 | .ctl_name = CTL_UNNUMBERED, |
| 1247 | .procname = "stat_interval", |
| 1248 | .data = &sysctl_stat_interval, |
| 1249 | .maxlen = sizeof(sysctl_stat_interval), |
| 1250 | .mode = 0644, |
| 1251 | .proc_handler = &proc_dointvec_jiffies, |
| 1252 | .strategy = &sysctl_jiffies, |
| 1253 | }, |
| 1254 | #endif |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1255 | #ifdef CONFIG_SECURITY |
| 1256 | { |
| 1257 | .ctl_name = CTL_UNNUMBERED, |
| 1258 | .procname = "mmap_min_addr", |
| 1259 | .data = &mmap_min_addr, |
| 1260 | .maxlen = sizeof(unsigned long), |
| 1261 | .mode = 0644, |
| 1262 | .proc_handler = &proc_doulongvec_minmax, |
| 1263 | }, |
Lee Schermerhorn | 8daec96 | 2007-08-10 13:00:51 -0700 | [diff] [blame] | 1264 | #endif |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1265 | #ifdef CONFIG_NUMA |
| 1266 | { |
| 1267 | .ctl_name = CTL_UNNUMBERED, |
| 1268 | .procname = "numa_zonelist_order", |
| 1269 | .data = &numa_zonelist_order, |
| 1270 | .maxlen = NUMA_ZONELIST_ORDER_LEN, |
| 1271 | .mode = 0644, |
| 1272 | .proc_handler = &numa_zonelist_order_handler, |
| 1273 | .strategy = &sysctl_string, |
| 1274 | }, |
| 1275 | #endif |
Al Viro | 2b8232c | 2007-10-13 08:16:04 +0100 | [diff] [blame] | 1276 | #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ |
Paul Mundt | 5c36e65 | 2007-03-01 10:07:42 +0900 | [diff] [blame] | 1277 | (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1278 | { |
| 1279 | .ctl_name = VM_VDSO_ENABLED, |
| 1280 | .procname = "vdso_enabled", |
| 1281 | .data = &vdso_enabled, |
| 1282 | .maxlen = sizeof(vdso_enabled), |
| 1283 | .mode = 0644, |
| 1284 | .proc_handler = &proc_dointvec, |
| 1285 | .strategy = &sysctl_intvec, |
| 1286 | .extra1 = &zero, |
| 1287 | }, |
| 1288 | #endif |
Bron Gondwana | 195cf453 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1289 | #ifdef CONFIG_HIGHMEM |
| 1290 | { |
| 1291 | .ctl_name = CTL_UNNUMBERED, |
| 1292 | .procname = "highmem_is_dirtyable", |
| 1293 | .data = &vm_highmem_is_dirtyable, |
| 1294 | .maxlen = sizeof(vm_highmem_is_dirtyable), |
| 1295 | .mode = 0644, |
| 1296 | .proc_handler = &proc_dointvec_minmax, |
| 1297 | .strategy = &sysctl_intvec, |
| 1298 | .extra1 = &zero, |
| 1299 | .extra2 = &one, |
| 1300 | }, |
| 1301 | #endif |
Peter Zijlstra | 4be6f6b | 2009-04-13 14:39:33 -0700 | [diff] [blame] | 1302 | #ifdef CONFIG_UNEVICTABLE_LRU |
| 1303 | { |
| 1304 | .ctl_name = CTL_UNNUMBERED, |
| 1305 | .procname = "scan_unevictable_pages", |
| 1306 | .data = &scan_unevictable_pages, |
| 1307 | .maxlen = sizeof(scan_unevictable_pages), |
| 1308 | .mode = 0644, |
| 1309 | .proc_handler = &scan_unevictable_handler, |
| 1310 | }, |
| 1311 | #endif |
Andrew Morton | 2be7fe0 | 2007-07-15 23:41:21 -0700 | [diff] [blame] | 1312 | /* |
| 1313 | * NOTE: do not add new entries to this table unless you have read |
| 1314 | * Documentation/sysctl/ctl_unnumbered.txt |
| 1315 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1316 | { .ctl_name = 0 } |
| 1317 | }; |
| 1318 | |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 1319 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1320 | static struct ctl_table binfmt_misc_table[] = { |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 1321 | { .ctl_name = 0 } |
| 1322 | }; |
| 1323 | #endif |
| 1324 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1325 | static struct ctl_table fs_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1326 | { |
| 1327 | .ctl_name = FS_NRINODE, |
| 1328 | .procname = "inode-nr", |
| 1329 | .data = &inodes_stat, |
| 1330 | .maxlen = 2*sizeof(int), |
| 1331 | .mode = 0444, |
| 1332 | .proc_handler = &proc_dointvec, |
| 1333 | }, |
| 1334 | { |
| 1335 | .ctl_name = FS_STATINODE, |
| 1336 | .procname = "inode-state", |
| 1337 | .data = &inodes_stat, |
| 1338 | .maxlen = 7*sizeof(int), |
| 1339 | .mode = 0444, |
| 1340 | .proc_handler = &proc_dointvec, |
| 1341 | }, |
| 1342 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | .procname = "file-nr", |
| 1344 | .data = &files_stat, |
| 1345 | .maxlen = 3*sizeof(int), |
| 1346 | .mode = 0444, |
Dipankar Sarma | 529bf6b | 2006-03-07 21:55:35 -0800 | [diff] [blame] | 1347 | .proc_handler = &proc_nr_files, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | }, |
| 1349 | { |
| 1350 | .ctl_name = FS_MAXFILE, |
| 1351 | .procname = "file-max", |
| 1352 | .data = &files_stat.max_files, |
| 1353 | .maxlen = sizeof(int), |
| 1354 | .mode = 0644, |
| 1355 | .proc_handler = &proc_dointvec, |
| 1356 | }, |
| 1357 | { |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1358 | .ctl_name = CTL_UNNUMBERED, |
| 1359 | .procname = "nr_open", |
| 1360 | .data = &sysctl_nr_open, |
| 1361 | .maxlen = sizeof(int), |
| 1362 | .mode = 0644, |
Al Viro | eceea0b | 2008-05-10 10:08:32 -0400 | [diff] [blame] | 1363 | .proc_handler = &proc_dointvec_minmax, |
| 1364 | .extra1 = &sysctl_nr_open_min, |
| 1365 | .extra2 = &sysctl_nr_open_max, |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1366 | }, |
| 1367 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | .ctl_name = FS_DENTRY, |
| 1369 | .procname = "dentry-state", |
| 1370 | .data = &dentry_stat, |
| 1371 | .maxlen = 6*sizeof(int), |
| 1372 | .mode = 0444, |
| 1373 | .proc_handler = &proc_dointvec, |
| 1374 | }, |
| 1375 | { |
| 1376 | .ctl_name = FS_OVERFLOWUID, |
| 1377 | .procname = "overflowuid", |
| 1378 | .data = &fs_overflowuid, |
| 1379 | .maxlen = sizeof(int), |
| 1380 | .mode = 0644, |
| 1381 | .proc_handler = &proc_dointvec_minmax, |
| 1382 | .strategy = &sysctl_intvec, |
| 1383 | .extra1 = &minolduid, |
| 1384 | .extra2 = &maxolduid, |
| 1385 | }, |
| 1386 | { |
| 1387 | .ctl_name = FS_OVERFLOWGID, |
| 1388 | .procname = "overflowgid", |
| 1389 | .data = &fs_overflowgid, |
| 1390 | .maxlen = sizeof(int), |
| 1391 | .mode = 0644, |
| 1392 | .proc_handler = &proc_dointvec_minmax, |
| 1393 | .strategy = &sysctl_intvec, |
| 1394 | .extra1 = &minolduid, |
| 1395 | .extra2 = &maxolduid, |
| 1396 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1397 | #ifdef CONFIG_FILE_LOCKING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1398 | { |
| 1399 | .ctl_name = FS_LEASES, |
| 1400 | .procname = "leases-enable", |
| 1401 | .data = &leases_enable, |
| 1402 | .maxlen = sizeof(int), |
| 1403 | .mode = 0644, |
| 1404 | .proc_handler = &proc_dointvec, |
| 1405 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1406 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | #ifdef CONFIG_DNOTIFY |
| 1408 | { |
| 1409 | .ctl_name = FS_DIR_NOTIFY, |
| 1410 | .procname = "dir-notify-enable", |
| 1411 | .data = &dir_notify_enable, |
| 1412 | .maxlen = sizeof(int), |
| 1413 | .mode = 0644, |
| 1414 | .proc_handler = &proc_dointvec, |
| 1415 | }, |
| 1416 | #endif |
| 1417 | #ifdef CONFIG_MMU |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1418 | #ifdef CONFIG_FILE_LOCKING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | { |
| 1420 | .ctl_name = FS_LEASE_TIME, |
| 1421 | .procname = "lease-break-time", |
| 1422 | .data = &lease_break_time, |
| 1423 | .maxlen = sizeof(int), |
| 1424 | .mode = 0644, |
Matthew Wilcox | 8e654fb | 2009-04-02 16:58:33 -0700 | [diff] [blame] | 1425 | .proc_handler = &proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1427 | #endif |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 1428 | #ifdef CONFIG_AIO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | .procname = "aio-nr", |
| 1431 | .data = &aio_nr, |
| 1432 | .maxlen = sizeof(aio_nr), |
| 1433 | .mode = 0444, |
Zach Brown | d55b5fd | 2005-11-07 00:59:31 -0800 | [diff] [blame] | 1434 | .proc_handler = &proc_doulongvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | }, |
| 1436 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | .procname = "aio-max-nr", |
| 1438 | .data = &aio_max_nr, |
| 1439 | .maxlen = sizeof(aio_max_nr), |
| 1440 | .mode = 0644, |
Zach Brown | d55b5fd | 2005-11-07 00:59:31 -0800 | [diff] [blame] | 1441 | .proc_handler = &proc_doulongvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | }, |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 1443 | #endif /* CONFIG_AIO */ |
Amy Griffis | 2d9048e | 2006-06-01 13:10:59 -0700 | [diff] [blame] | 1444 | #ifdef CONFIG_INOTIFY_USER |
Robert Love | 0399cb0 | 2005-07-13 12:38:18 -0400 | [diff] [blame] | 1445 | { |
| 1446 | .ctl_name = FS_INOTIFY, |
| 1447 | .procname = "inotify", |
| 1448 | .mode = 0555, |
| 1449 | .child = inotify_table, |
| 1450 | }, |
| 1451 | #endif |
Davide Libenzi | 7ef9964 | 2008-12-01 13:13:55 -0800 | [diff] [blame] | 1452 | #ifdef CONFIG_EPOLL |
| 1453 | { |
| 1454 | .procname = "epoll", |
| 1455 | .mode = 0555, |
| 1456 | .child = epoll_table, |
| 1457 | }, |
| 1458 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | #endif |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 1460 | { |
| 1461 | .ctl_name = KERN_SETUID_DUMPABLE, |
| 1462 | .procname = "suid_dumpable", |
| 1463 | .data = &suid_dumpable, |
| 1464 | .maxlen = sizeof(int), |
| 1465 | .mode = 0644, |
Matthew Wilcox | 8e654fb | 2009-04-02 16:58:33 -0700 | [diff] [blame] | 1466 | .proc_handler = &proc_dointvec_minmax, |
| 1467 | .strategy = &sysctl_intvec, |
| 1468 | .extra1 = &zero, |
| 1469 | .extra2 = &two, |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 1470 | }, |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 1471 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
| 1472 | { |
| 1473 | .ctl_name = CTL_UNNUMBERED, |
| 1474 | .procname = "binfmt_misc", |
| 1475 | .mode = 0555, |
| 1476 | .child = binfmt_misc_table, |
| 1477 | }, |
| 1478 | #endif |
Andrew Morton | 2be7fe0 | 2007-07-15 23:41:21 -0700 | [diff] [blame] | 1479 | /* |
| 1480 | * NOTE: do not add new entries to this table unless you have read |
| 1481 | * Documentation/sysctl/ctl_unnumbered.txt |
| 1482 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | { .ctl_name = 0 } |
| 1484 | }; |
| 1485 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1486 | static struct ctl_table debug_table[] = { |
Olof Johansson | d0c3d53 | 2007-10-12 10:20:07 +1000 | [diff] [blame] | 1487 | #if defined(CONFIG_X86) || defined(CONFIG_PPC) |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 1488 | { |
| 1489 | .ctl_name = CTL_UNNUMBERED, |
| 1490 | .procname = "exception-trace", |
| 1491 | .data = &show_unhandled_signals, |
| 1492 | .maxlen = sizeof(int), |
| 1493 | .mode = 0644, |
| 1494 | .proc_handler = proc_dointvec |
| 1495 | }, |
| 1496 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | { .ctl_name = 0 } |
| 1498 | }; |
| 1499 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1500 | static struct ctl_table dev_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | { .ctl_name = 0 } |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 1502 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1504 | static DEFINE_SPINLOCK(sysctl_lock); |
| 1505 | |
| 1506 | /* called under sysctl_lock */ |
| 1507 | static int use_table(struct ctl_table_header *p) |
| 1508 | { |
| 1509 | if (unlikely(p->unregistering)) |
| 1510 | return 0; |
| 1511 | p->used++; |
| 1512 | return 1; |
| 1513 | } |
| 1514 | |
| 1515 | /* called under sysctl_lock */ |
| 1516 | static void unuse_table(struct ctl_table_header *p) |
| 1517 | { |
| 1518 | if (!--p->used) |
| 1519 | if (unlikely(p->unregistering)) |
| 1520 | complete(p->unregistering); |
| 1521 | } |
| 1522 | |
| 1523 | /* called under sysctl_lock, will reacquire if has to wait */ |
| 1524 | static void start_unregistering(struct ctl_table_header *p) |
| 1525 | { |
| 1526 | /* |
| 1527 | * if p->used is 0, nobody will ever touch that entry again; |
| 1528 | * we'll eliminate all paths to it before dropping sysctl_lock |
| 1529 | */ |
| 1530 | if (unlikely(p->used)) { |
| 1531 | struct completion wait; |
| 1532 | init_completion(&wait); |
| 1533 | p->unregistering = &wait; |
| 1534 | spin_unlock(&sysctl_lock); |
| 1535 | wait_for_completion(&wait); |
| 1536 | spin_lock(&sysctl_lock); |
Al Viro | f7e6ced | 2008-07-15 01:44:23 -0400 | [diff] [blame] | 1537 | } else { |
| 1538 | /* anything non-NULL; we'll never dereference it */ |
| 1539 | p->unregistering = ERR_PTR(-EINVAL); |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1540 | } |
| 1541 | /* |
| 1542 | * do not remove from the list until nobody holds it; walking the |
| 1543 | * list in do_sysctl() relies on that. |
| 1544 | */ |
| 1545 | list_del_init(&p->ctl_entry); |
| 1546 | } |
| 1547 | |
Al Viro | f7e6ced | 2008-07-15 01:44:23 -0400 | [diff] [blame] | 1548 | void sysctl_head_get(struct ctl_table_header *head) |
| 1549 | { |
| 1550 | spin_lock(&sysctl_lock); |
| 1551 | head->count++; |
| 1552 | spin_unlock(&sysctl_lock); |
| 1553 | } |
| 1554 | |
| 1555 | void sysctl_head_put(struct ctl_table_header *head) |
| 1556 | { |
| 1557 | spin_lock(&sysctl_lock); |
| 1558 | if (!--head->count) |
| 1559 | kfree(head); |
| 1560 | spin_unlock(&sysctl_lock); |
| 1561 | } |
| 1562 | |
| 1563 | struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) |
| 1564 | { |
| 1565 | if (!head) |
| 1566 | BUG(); |
| 1567 | spin_lock(&sysctl_lock); |
| 1568 | if (!use_table(head)) |
| 1569 | head = ERR_PTR(-ENOENT); |
| 1570 | spin_unlock(&sysctl_lock); |
| 1571 | return head; |
| 1572 | } |
| 1573 | |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1574 | void sysctl_head_finish(struct ctl_table_header *head) |
| 1575 | { |
| 1576 | if (!head) |
| 1577 | return; |
| 1578 | spin_lock(&sysctl_lock); |
| 1579 | unuse_table(head); |
| 1580 | spin_unlock(&sysctl_lock); |
| 1581 | } |
| 1582 | |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 1583 | static struct ctl_table_set * |
| 1584 | lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) |
| 1585 | { |
| 1586 | struct ctl_table_set *set = &root->default_set; |
| 1587 | if (root->lookup) |
| 1588 | set = root->lookup(root, namespaces); |
| 1589 | return set; |
| 1590 | } |
| 1591 | |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1592 | static struct list_head * |
| 1593 | lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1594 | { |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 1595 | struct ctl_table_set *set = lookup_header_set(root, namespaces); |
| 1596 | return &set->list; |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1597 | } |
| 1598 | |
| 1599 | struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, |
| 1600 | struct ctl_table_header *prev) |
| 1601 | { |
| 1602 | struct ctl_table_root *root; |
| 1603 | struct list_head *header_list; |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1604 | struct ctl_table_header *head; |
| 1605 | struct list_head *tmp; |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1606 | |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1607 | spin_lock(&sysctl_lock); |
| 1608 | if (prev) { |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1609 | head = prev; |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1610 | tmp = &prev->ctl_entry; |
| 1611 | unuse_table(prev); |
| 1612 | goto next; |
| 1613 | } |
| 1614 | tmp = &root_table_header.ctl_entry; |
| 1615 | for (;;) { |
| 1616 | head = list_entry(tmp, struct ctl_table_header, ctl_entry); |
| 1617 | |
| 1618 | if (!use_table(head)) |
| 1619 | goto next; |
| 1620 | spin_unlock(&sysctl_lock); |
| 1621 | return head; |
| 1622 | next: |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1623 | root = head->root; |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1624 | tmp = tmp->next; |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1625 | header_list = lookup_header_list(root, namespaces); |
| 1626 | if (tmp != header_list) |
| 1627 | continue; |
| 1628 | |
| 1629 | do { |
| 1630 | root = list_entry(root->root_list.next, |
| 1631 | struct ctl_table_root, root_list); |
| 1632 | if (root == &sysctl_table_root) |
| 1633 | goto out; |
| 1634 | header_list = lookup_header_list(root, namespaces); |
| 1635 | } while (list_empty(header_list)); |
| 1636 | tmp = header_list->next; |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1637 | } |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1638 | out: |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1639 | spin_unlock(&sysctl_lock); |
| 1640 | return NULL; |
| 1641 | } |
| 1642 | |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1643 | struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) |
| 1644 | { |
| 1645 | return __sysctl_head_next(current->nsproxy, prev); |
| 1646 | } |
| 1647 | |
| 1648 | void register_sysctl_root(struct ctl_table_root *root) |
| 1649 | { |
| 1650 | spin_lock(&sysctl_lock); |
| 1651 | list_add_tail(&root->root_list, &sysctl_table_root.root_list); |
| 1652 | spin_unlock(&sysctl_lock); |
| 1653 | } |
| 1654 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 1655 | #ifdef CONFIG_SYSCTL_SYSCALL |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1656 | /* Perform the actual read/write of a sysctl table entry. */ |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1657 | static int do_sysctl_strategy(struct ctl_table_root *root, |
| 1658 | struct ctl_table *table, |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1659 | void __user *oldval, size_t __user *oldlenp, |
| 1660 | void __user *newval, size_t newlen) |
| 1661 | { |
| 1662 | int op = 0, rc; |
| 1663 | |
| 1664 | if (oldval) |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1665 | op |= MAY_READ; |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1666 | if (newval) |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1667 | op |= MAY_WRITE; |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1668 | if (sysctl_perm(root, table, op)) |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1669 | return -EPERM; |
| 1670 | |
| 1671 | if (table->strategy) { |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 1672 | rc = table->strategy(table, oldval, oldlenp, newval, newlen); |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1673 | if (rc < 0) |
| 1674 | return rc; |
| 1675 | if (rc > 0) |
| 1676 | return 0; |
| 1677 | } |
| 1678 | |
| 1679 | /* If there is no strategy routine, or if the strategy returns |
| 1680 | * zero, proceed with automatic r/w */ |
| 1681 | if (table->data && table->maxlen) { |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 1682 | rc = sysctl_data(table, oldval, oldlenp, newval, newlen); |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1683 | if (rc < 0) |
| 1684 | return rc; |
| 1685 | } |
| 1686 | return 0; |
| 1687 | } |
| 1688 | |
| 1689 | static int parse_table(int __user *name, int nlen, |
| 1690 | void __user *oldval, size_t __user *oldlenp, |
| 1691 | void __user *newval, size_t newlen, |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1692 | struct ctl_table_root *root, |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1693 | struct ctl_table *table) |
| 1694 | { |
| 1695 | int n; |
| 1696 | repeat: |
| 1697 | if (!nlen) |
| 1698 | return -ENOTDIR; |
| 1699 | if (get_user(n, name)) |
| 1700 | return -EFAULT; |
| 1701 | for ( ; table->ctl_name || table->procname; table++) { |
| 1702 | if (!table->ctl_name) |
| 1703 | continue; |
| 1704 | if (n == table->ctl_name) { |
| 1705 | int error; |
| 1706 | if (table->child) { |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1707 | if (sysctl_perm(root, table, MAY_EXEC)) |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1708 | return -EPERM; |
| 1709 | name++; |
| 1710 | nlen--; |
| 1711 | table = table->child; |
| 1712 | goto repeat; |
| 1713 | } |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 1714 | error = do_sysctl_strategy(root, table, |
Pavel Emelyanov | 2c4c715 | 2008-04-29 01:02:41 -0700 | [diff] [blame] | 1715 | oldval, oldlenp, |
| 1716 | newval, newlen); |
| 1717 | return error; |
| 1718 | } |
| 1719 | } |
| 1720 | return -ENOTDIR; |
| 1721 | } |
| 1722 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
| 1724 | void __user *newval, size_t newlen) |
| 1725 | { |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1726 | struct ctl_table_header *head; |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1727 | int error = -ENOTDIR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1728 | |
| 1729 | if (nlen <= 0 || nlen >= CTL_MAXNAME) |
| 1730 | return -ENOTDIR; |
| 1731 | if (oldval) { |
| 1732 | int old_len; |
| 1733 | if (!oldlenp || get_user(old_len, oldlenp)) |
| 1734 | return -EFAULT; |
| 1735 | } |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1736 | |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1737 | for (head = sysctl_head_next(NULL); head; |
| 1738 | head = sysctl_head_next(head)) { |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1739 | error = parse_table(name, nlen, oldval, oldlenp, |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1740 | newval, newlen, |
| 1741 | head->root, head->ctl_table); |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1742 | if (error != -ENOTDIR) { |
| 1743 | sysctl_head_finish(head); |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1744 | break; |
Eric W. Biederman | 805b5d5 | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1745 | } |
| 1746 | } |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1747 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | } |
| 1749 | |
Heiko Carstens | 1e7bfb2 | 2009-01-14 14:14:29 +0100 | [diff] [blame] | 1750 | SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | { |
| 1752 | struct __sysctl_args tmp; |
| 1753 | int error; |
| 1754 | |
| 1755 | if (copy_from_user(&tmp, args, sizeof(tmp))) |
| 1756 | return -EFAULT; |
| 1757 | |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 1758 | error = deprecated_sysctl_warning(&tmp); |
| 1759 | if (error) |
| 1760 | goto out; |
| 1761 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1762 | lock_kernel(); |
| 1763 | error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, |
| 1764 | tmp.newval, tmp.newlen); |
| 1765 | unlock_kernel(); |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 1766 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | return error; |
| 1768 | } |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 1769 | #endif /* CONFIG_SYSCTL_SYSCALL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1770 | |
| 1771 | /* |
Eric W. Biederman | 1ff007e | 2007-02-14 00:34:11 -0800 | [diff] [blame] | 1772 | * sysctl_perm does NOT grant the superuser all rights automatically, because |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | * some sysctl variables are readonly even to root. |
| 1774 | */ |
| 1775 | |
| 1776 | static int test_perm(int mode, int op) |
| 1777 | { |
David Howells | 76aac0e | 2008-11-14 10:39:12 +1100 | [diff] [blame] | 1778 | if (!current_euid()) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | mode >>= 6; |
| 1780 | else if (in_egroup_p(0)) |
| 1781 | mode >>= 3; |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1782 | if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | return 0; |
| 1784 | return -EACCES; |
| 1785 | } |
| 1786 | |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1787 | int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | { |
| 1789 | int error; |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1790 | int mode; |
| 1791 | |
Al Viro | e6305c4 | 2008-07-15 21:03:57 -0400 | [diff] [blame] | 1792 | error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1793 | if (error) |
| 1794 | return error; |
Pavel Emelyanov | d7321cd | 2008-04-29 01:02:44 -0700 | [diff] [blame] | 1795 | |
| 1796 | if (root->permissions) |
| 1797 | mode = root->permissions(root, current->nsproxy, table); |
| 1798 | else |
| 1799 | mode = table->mode; |
| 1800 | |
| 1801 | return test_perm(mode, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | } |
| 1803 | |
Eric W. Biederman | d912b0c | 2007-02-14 00:34:13 -0800 | [diff] [blame] | 1804 | static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) |
| 1805 | { |
| 1806 | for (; table->ctl_name || table->procname; table++) { |
| 1807 | table->parent = parent; |
| 1808 | if (table->child) |
| 1809 | sysctl_set_parent(table, table->child); |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | static __init int sysctl_init(void) |
| 1814 | { |
| 1815 | sysctl_set_parent(NULL, root_table); |
Holger Schurig | 88f458e | 2008-04-29 01:02:36 -0700 | [diff] [blame] | 1816 | #ifdef CONFIG_SYSCTL_SYSCALL_CHECK |
| 1817 | { |
| 1818 | int err; |
| 1819 | err = sysctl_check_table(current->nsproxy, root_table); |
| 1820 | } |
| 1821 | #endif |
Eric W. Biederman | d912b0c | 2007-02-14 00:34:13 -0800 | [diff] [blame] | 1822 | return 0; |
| 1823 | } |
| 1824 | |
| 1825 | core_initcall(sysctl_init); |
| 1826 | |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1827 | static struct ctl_table *is_branch_in(struct ctl_table *branch, |
| 1828 | struct ctl_table *table) |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1829 | { |
| 1830 | struct ctl_table *p; |
| 1831 | const char *s = branch->procname; |
| 1832 | |
| 1833 | /* branch should have named subdirectory as its first element */ |
| 1834 | if (!s || !branch->child) |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1835 | return NULL; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1836 | |
| 1837 | /* ... and nothing else */ |
| 1838 | if (branch[1].procname || branch[1].ctl_name) |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1839 | return NULL; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1840 | |
| 1841 | /* table should contain subdirectory with the same name */ |
| 1842 | for (p = table; p->procname || p->ctl_name; p++) { |
| 1843 | if (!p->child) |
| 1844 | continue; |
| 1845 | if (p->procname && strcmp(p->procname, s) == 0) |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1846 | return p; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1847 | } |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1848 | return NULL; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | /* see if attaching q to p would be an improvement */ |
| 1852 | static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) |
| 1853 | { |
| 1854 | struct ctl_table *to = p->ctl_table, *by = q->ctl_table; |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1855 | struct ctl_table *next; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1856 | int is_better = 0; |
| 1857 | int not_in_parent = !p->attached_by; |
| 1858 | |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1859 | while ((next = is_branch_in(by, to)) != NULL) { |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1860 | if (by == q->attached_by) |
| 1861 | is_better = 1; |
| 1862 | if (to == p->attached_by) |
| 1863 | not_in_parent = 1; |
| 1864 | by = by->child; |
Al Viro | bfbcf03 | 2008-07-27 06:31:22 +0100 | [diff] [blame] | 1865 | to = next->child; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | if (is_better && not_in_parent) { |
| 1869 | q->attached_by = by; |
| 1870 | q->attached_to = to; |
| 1871 | q->parent = p; |
| 1872 | } |
| 1873 | } |
| 1874 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1875 | /** |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1876 | * __register_sysctl_paths - register a sysctl hierarchy |
| 1877 | * @root: List of sysctl headers to register on |
| 1878 | * @namespaces: Data to compute which lists of sysctl entries are visible |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1879 | * @path: The path to the directory the sysctl table is in. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1880 | * @table: the top-level table structure |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | * |
| 1882 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1883 | * array. A completely 0 filled entry terminates the table. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | * |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1885 | * The members of the &struct ctl_table structure are used as follows: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1886 | * |
| 1887 | * ctl_name - This is the numeric sysctl value used by sysctl(2). The number |
| 1888 | * must be unique within that level of sysctl |
| 1889 | * |
| 1890 | * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not |
| 1891 | * enter a sysctl file |
| 1892 | * |
| 1893 | * data - a pointer to data for use by proc_handler |
| 1894 | * |
| 1895 | * maxlen - the maximum size in bytes of the data |
| 1896 | * |
| 1897 | * mode - the file permissions for the /proc/sys file, and for sysctl(2) |
| 1898 | * |
| 1899 | * child - a pointer to the child sysctl table if this entry is a directory, or |
| 1900 | * %NULL. |
| 1901 | * |
| 1902 | * proc_handler - the text handler routine (described below) |
| 1903 | * |
| 1904 | * strategy - the strategy routine (described below) |
| 1905 | * |
| 1906 | * de - for internal use by the sysctl routines |
| 1907 | * |
| 1908 | * extra1, extra2 - extra pointers usable by the proc handler routines |
| 1909 | * |
| 1910 | * Leaf nodes in the sysctl tree will be represented by a single file |
| 1911 | * under /proc; non-leaf nodes will be represented by directories. |
| 1912 | * |
| 1913 | * sysctl(2) can automatically manage read and write requests through |
| 1914 | * the sysctl table. The data and maxlen fields of the ctl_table |
| 1915 | * struct enable minimal validation of the values being written to be |
| 1916 | * performed, and the mode field allows minimal authentication. |
| 1917 | * |
| 1918 | * More sophisticated management can be enabled by the provision of a |
| 1919 | * strategy routine with the table entry. This will be called before |
| 1920 | * any automatic read or write of the data is performed. |
| 1921 | * |
| 1922 | * The strategy routine may return |
| 1923 | * |
| 1924 | * < 0 - Error occurred (error is passed to user process) |
| 1925 | * |
| 1926 | * 0 - OK - proceed with automatic read or write. |
| 1927 | * |
| 1928 | * > 0 - OK - read or write has been done by the strategy routine, so |
| 1929 | * return immediately. |
| 1930 | * |
| 1931 | * There must be a proc_handler routine for any terminal nodes |
| 1932 | * mirrored under /proc/sys (non-terminals are handled by a built-in |
| 1933 | * directory handler). Several default handlers are available to |
| 1934 | * cover common cases - |
| 1935 | * |
| 1936 | * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), |
| 1937 | * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), |
| 1938 | * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() |
| 1939 | * |
| 1940 | * It is the handler's job to read the input buffer from user memory |
| 1941 | * and process it. The handler should return 0 on success. |
| 1942 | * |
| 1943 | * This routine returns %NULL on a failure to register, and a pointer |
| 1944 | * to the table header on success. |
| 1945 | */ |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1946 | struct ctl_table_header *__register_sysctl_paths( |
| 1947 | struct ctl_table_root *root, |
| 1948 | struct nsproxy *namespaces, |
| 1949 | const struct ctl_path *path, struct ctl_table *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | { |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1951 | struct ctl_table_header *header; |
| 1952 | struct ctl_table *new, **prevp; |
| 1953 | unsigned int n, npath; |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 1954 | struct ctl_table_set *set; |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1955 | |
| 1956 | /* Count the path components */ |
| 1957 | for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath) |
| 1958 | ; |
| 1959 | |
| 1960 | /* |
| 1961 | * For each path component, allocate a 2-element ctl_table array. |
| 1962 | * The first array element will be filled with the sysctl entry |
| 1963 | * for this, the second will be the sentinel (ctl_name == 0). |
| 1964 | * |
| 1965 | * We allocate everything in one go so that we don't have to |
| 1966 | * worry about freeing additional memory in unregister_sysctl_table. |
| 1967 | */ |
| 1968 | header = kzalloc(sizeof(struct ctl_table_header) + |
| 1969 | (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); |
| 1970 | if (!header) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1971 | return NULL; |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1972 | |
| 1973 | new = (struct ctl_table *) (header + 1); |
| 1974 | |
| 1975 | /* Now connect the dots */ |
| 1976 | prevp = &header->ctl_table; |
| 1977 | for (n = 0; n < npath; ++n, ++path) { |
| 1978 | /* Copy the procname */ |
| 1979 | new->procname = path->procname; |
| 1980 | new->ctl_name = path->ctl_name; |
| 1981 | new->mode = 0555; |
| 1982 | |
| 1983 | *prevp = new; |
| 1984 | prevp = &new->child; |
| 1985 | |
| 1986 | new += 2; |
| 1987 | } |
| 1988 | *prevp = table; |
Eric W. Biederman | 23eb06d | 2007-11-30 23:52:10 +1100 | [diff] [blame] | 1989 | header->ctl_table_arg = table; |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1990 | |
| 1991 | INIT_LIST_HEAD(&header->ctl_entry); |
| 1992 | header->used = 0; |
| 1993 | header->unregistering = NULL; |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1994 | header->root = root; |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1995 | sysctl_set_parent(NULL, header->ctl_table); |
Al Viro | f7e6ced | 2008-07-15 01:44:23 -0400 | [diff] [blame] | 1996 | header->count = 1; |
Holger Schurig | 88f458e | 2008-04-29 01:02:36 -0700 | [diff] [blame] | 1997 | #ifdef CONFIG_SYSCTL_SYSCALL_CHECK |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 1998 | if (sysctl_check_table(namespaces, header->ctl_table)) { |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 1999 | kfree(header); |
Eric W. Biederman | fc6cd25 | 2007-10-18 03:05:54 -0700 | [diff] [blame] | 2000 | return NULL; |
| 2001 | } |
Holger Schurig | 88f458e | 2008-04-29 01:02:36 -0700 | [diff] [blame] | 2002 | #endif |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 2003 | spin_lock(&sysctl_lock); |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 2004 | header->set = lookup_header_set(root, namespaces); |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 2005 | header->attached_by = header->ctl_table; |
| 2006 | header->attached_to = root_table; |
| 2007 | header->parent = &root_table_header; |
| 2008 | for (set = header->set; set; set = set->parent) { |
| 2009 | struct ctl_table_header *p; |
| 2010 | list_for_each_entry(p, &set->list, ctl_entry) { |
| 2011 | if (p->unregistering) |
| 2012 | continue; |
| 2013 | try_attach(p, header); |
| 2014 | } |
| 2015 | } |
| 2016 | header->parent->count++; |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 2017 | list_add_tail(&header->ctl_entry, &header->set->list); |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 2018 | spin_unlock(&sysctl_lock); |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 2019 | |
| 2020 | return header; |
| 2021 | } |
| 2022 | |
| 2023 | /** |
Eric W. Biederman | e51b6ba | 2007-11-30 23:54:00 +1100 | [diff] [blame] | 2024 | * register_sysctl_table_path - register a sysctl table hierarchy |
| 2025 | * @path: The path to the directory the sysctl table is in. |
| 2026 | * @table: the top-level table structure |
| 2027 | * |
| 2028 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table |
| 2029 | * array. A completely 0 filled entry terminates the table. |
| 2030 | * |
| 2031 | * See __register_sysctl_paths for more details. |
| 2032 | */ |
| 2033 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, |
| 2034 | struct ctl_table *table) |
| 2035 | { |
| 2036 | return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, |
| 2037 | path, table); |
| 2038 | } |
| 2039 | |
| 2040 | /** |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 2041 | * register_sysctl_table - register a sysctl table hierarchy |
| 2042 | * @table: the top-level table structure |
| 2043 | * |
| 2044 | * Register a sysctl table hierarchy. @table should be a filled in ctl_table |
| 2045 | * array. A completely 0 filled entry terminates the table. |
| 2046 | * |
| 2047 | * See register_sysctl_paths for more details. |
| 2048 | */ |
| 2049 | struct ctl_table_header *register_sysctl_table(struct ctl_table *table) |
| 2050 | { |
| 2051 | static const struct ctl_path null_path[] = { {} }; |
| 2052 | |
| 2053 | return register_sysctl_paths(null_path, table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | } |
| 2055 | |
| 2056 | /** |
| 2057 | * unregister_sysctl_table - unregister a sysctl table hierarchy |
| 2058 | * @header: the header returned from register_sysctl_table |
| 2059 | * |
| 2060 | * Unregisters the sysctl table and all children. proc entries may not |
| 2061 | * actually be removed until they are no longer used by anyone. |
| 2062 | */ |
| 2063 | void unregister_sysctl_table(struct ctl_table_header * header) |
| 2064 | { |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 2065 | might_sleep(); |
Pavel Emelyanov | f1dad16 | 2007-12-04 23:45:24 -0800 | [diff] [blame] | 2066 | |
| 2067 | if (header == NULL) |
| 2068 | return; |
| 2069 | |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 2070 | spin_lock(&sysctl_lock); |
| 2071 | start_unregistering(header); |
Al Viro | ae7edec | 2008-07-15 06:33:31 -0400 | [diff] [blame] | 2072 | if (!--header->parent->count) { |
| 2073 | WARN_ON(1); |
| 2074 | kfree(header->parent); |
| 2075 | } |
Al Viro | f7e6ced | 2008-07-15 01:44:23 -0400 | [diff] [blame] | 2076 | if (!--header->count) |
| 2077 | kfree(header); |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 2078 | spin_unlock(&sysctl_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | } |
| 2080 | |
Al Viro | 9043476f | 2008-07-15 08:54:06 -0400 | [diff] [blame] | 2081 | int sysctl_is_seen(struct ctl_table_header *p) |
| 2082 | { |
| 2083 | struct ctl_table_set *set = p->set; |
| 2084 | int res; |
| 2085 | spin_lock(&sysctl_lock); |
| 2086 | if (p->unregistering) |
| 2087 | res = 0; |
| 2088 | else if (!set->is_seen) |
| 2089 | res = 1; |
| 2090 | else |
| 2091 | res = set->is_seen(set); |
| 2092 | spin_unlock(&sysctl_lock); |
| 2093 | return res; |
| 2094 | } |
| 2095 | |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 2096 | void setup_sysctl_set(struct ctl_table_set *p, |
| 2097 | struct ctl_table_set *parent, |
| 2098 | int (*is_seen)(struct ctl_table_set *)) |
| 2099 | { |
| 2100 | INIT_LIST_HEAD(&p->list); |
| 2101 | p->parent = parent ? parent : &sysctl_table_root.default_set; |
| 2102 | p->is_seen = is_seen; |
| 2103 | } |
| 2104 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2105 | #else /* !CONFIG_SYSCTL */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2106 | struct ctl_table_header *register_sysctl_table(struct ctl_table * table) |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2107 | { |
| 2108 | return NULL; |
| 2109 | } |
| 2110 | |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 2111 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, |
| 2112 | struct ctl_table *table) |
| 2113 | { |
| 2114 | return NULL; |
| 2115 | } |
| 2116 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2117 | void unregister_sysctl_table(struct ctl_table_header * table) |
| 2118 | { |
| 2119 | } |
| 2120 | |
Al Viro | 7345509 | 2008-07-14 21:22:20 -0400 | [diff] [blame] | 2121 | void setup_sysctl_set(struct ctl_table_set *p, |
| 2122 | struct ctl_table_set *parent, |
| 2123 | int (*is_seen)(struct ctl_table_set *)) |
| 2124 | { |
| 2125 | } |
| 2126 | |
Al Viro | f7e6ced | 2008-07-15 01:44:23 -0400 | [diff] [blame] | 2127 | void sysctl_head_put(struct ctl_table_header *head) |
| 2128 | { |
| 2129 | } |
| 2130 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2131 | #endif /* CONFIG_SYSCTL */ |
| 2132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | /* |
| 2134 | * /proc/sys support |
| 2135 | */ |
| 2136 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2137 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | |
Adrian Bunk | b1ba4dd | 2006-10-02 02:18:05 -0700 | [diff] [blame] | 2139 | static int _proc_do_string(void* data, int maxlen, int write, |
| 2140 | struct file *filp, void __user *buffer, |
| 2141 | size_t *lenp, loff_t *ppos) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2142 | { |
| 2143 | size_t len; |
| 2144 | char __user *p; |
| 2145 | char c; |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2146 | |
| 2147 | if (!data || !maxlen || !*lenp) { |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2148 | *lenp = 0; |
| 2149 | return 0; |
| 2150 | } |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2151 | |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2152 | if (write) { |
| 2153 | len = 0; |
| 2154 | p = buffer; |
| 2155 | while (len < *lenp) { |
| 2156 | if (get_user(c, p++)) |
| 2157 | return -EFAULT; |
| 2158 | if (c == 0 || c == '\n') |
| 2159 | break; |
| 2160 | len++; |
| 2161 | } |
| 2162 | if (len >= maxlen) |
| 2163 | len = maxlen-1; |
| 2164 | if(copy_from_user(data, buffer, len)) |
| 2165 | return -EFAULT; |
| 2166 | ((char *) data)[len] = 0; |
| 2167 | *ppos += *lenp; |
| 2168 | } else { |
| 2169 | len = strlen(data); |
| 2170 | if (len > maxlen) |
| 2171 | len = maxlen; |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2172 | |
| 2173 | if (*ppos > len) { |
| 2174 | *lenp = 0; |
| 2175 | return 0; |
| 2176 | } |
| 2177 | |
| 2178 | data += *ppos; |
| 2179 | len -= *ppos; |
| 2180 | |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2181 | if (len > *lenp) |
| 2182 | len = *lenp; |
| 2183 | if (len) |
| 2184 | if(copy_to_user(buffer, data, len)) |
| 2185 | return -EFAULT; |
| 2186 | if (len < *lenp) { |
| 2187 | if(put_user('\n', ((char __user *) buffer) + len)) |
| 2188 | return -EFAULT; |
| 2189 | len++; |
| 2190 | } |
| 2191 | *lenp = len; |
| 2192 | *ppos += len; |
| 2193 | } |
| 2194 | return 0; |
| 2195 | } |
| 2196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | /** |
| 2198 | * proc_dostring - read a string sysctl |
| 2199 | * @table: the sysctl table |
| 2200 | * @write: %TRUE if this is a write to the sysctl file |
| 2201 | * @filp: the file structure |
| 2202 | * @buffer: the user buffer |
| 2203 | * @lenp: the size of the user buffer |
| 2204 | * @ppos: file position |
| 2205 | * |
| 2206 | * Reads/writes a string from/to the user buffer. If the kernel |
| 2207 | * buffer provided is not large enough to hold the string, the |
| 2208 | * string is truncated. The copied string is %NULL-terminated. |
| 2209 | * If the string is being read by the user process, it is copied |
| 2210 | * and a newline '\n' is added. It is truncated if the buffer is |
| 2211 | * not large enough. |
| 2212 | * |
| 2213 | * Returns 0 on success. |
| 2214 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2215 | int proc_dostring(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2217 | { |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2218 | return _proc_do_string(table->data, table->maxlen, write, filp, |
| 2219 | buffer, lenp, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | } |
| 2221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2222 | |
| 2223 | static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, |
| 2224 | int *valp, |
| 2225 | int write, void *data) |
| 2226 | { |
| 2227 | if (write) { |
| 2228 | *valp = *negp ? -*lvalp : *lvalp; |
| 2229 | } else { |
| 2230 | int val = *valp; |
| 2231 | if (val < 0) { |
| 2232 | *negp = -1; |
| 2233 | *lvalp = (unsigned long)-val; |
| 2234 | } else { |
| 2235 | *negp = 0; |
| 2236 | *lvalp = (unsigned long)val; |
| 2237 | } |
| 2238 | } |
| 2239 | return 0; |
| 2240 | } |
| 2241 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2242 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2243 | int write, struct file *filp, void __user *buffer, |
| 2244 | size_t *lenp, loff_t *ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2245 | int (*conv)(int *negp, unsigned long *lvalp, int *valp, |
| 2246 | int write, void *data), |
| 2247 | void *data) |
| 2248 | { |
| 2249 | #define TMPBUFLEN 21 |
| 2250 | int *i, vleft, first=1, neg, val; |
| 2251 | unsigned long lval; |
| 2252 | size_t left, len; |
| 2253 | |
| 2254 | char buf[TMPBUFLEN], *p; |
| 2255 | char __user *s = buffer; |
| 2256 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2257 | if (!tbl_data || !table->maxlen || !*lenp || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2258 | (*ppos && !write)) { |
| 2259 | *lenp = 0; |
| 2260 | return 0; |
| 2261 | } |
| 2262 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2263 | i = (int *) tbl_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2264 | vleft = table->maxlen / sizeof(*i); |
| 2265 | left = *lenp; |
| 2266 | |
| 2267 | if (!conv) |
| 2268 | conv = do_proc_dointvec_conv; |
| 2269 | |
| 2270 | for (; left && vleft--; i++, first=0) { |
| 2271 | if (write) { |
| 2272 | while (left) { |
| 2273 | char c; |
| 2274 | if (get_user(c, s)) |
| 2275 | return -EFAULT; |
| 2276 | if (!isspace(c)) |
| 2277 | break; |
| 2278 | left--; |
| 2279 | s++; |
| 2280 | } |
| 2281 | if (!left) |
| 2282 | break; |
| 2283 | neg = 0; |
| 2284 | len = left; |
| 2285 | if (len > sizeof(buf) - 1) |
| 2286 | len = sizeof(buf) - 1; |
| 2287 | if (copy_from_user(buf, s, len)) |
| 2288 | return -EFAULT; |
| 2289 | buf[len] = 0; |
| 2290 | p = buf; |
| 2291 | if (*p == '-' && left > 1) { |
| 2292 | neg = 1; |
BP, Praveen | bd9b0ba | 2006-12-06 20:39:09 -0800 | [diff] [blame] | 2293 | p++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | } |
| 2295 | if (*p < '0' || *p > '9') |
| 2296 | break; |
| 2297 | |
| 2298 | lval = simple_strtoul(p, &p, 0); |
| 2299 | |
| 2300 | len = p-buf; |
| 2301 | if ((len < left) && *p && !isspace(*p)) |
| 2302 | break; |
| 2303 | if (neg) |
| 2304 | val = -val; |
| 2305 | s += len; |
| 2306 | left -= len; |
| 2307 | |
| 2308 | if (conv(&neg, &lval, i, 1, data)) |
| 2309 | break; |
| 2310 | } else { |
| 2311 | p = buf; |
| 2312 | if (!first) |
| 2313 | *p++ = '\t'; |
| 2314 | |
| 2315 | if (conv(&neg, &lval, i, 0, data)) |
| 2316 | break; |
| 2317 | |
| 2318 | sprintf(p, "%s%lu", neg ? "-" : "", lval); |
| 2319 | len = strlen(buf); |
| 2320 | if (len > left) |
| 2321 | len = left; |
| 2322 | if(copy_to_user(s, buf, len)) |
| 2323 | return -EFAULT; |
| 2324 | left -= len; |
| 2325 | s += len; |
| 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | if (!write && !first && left) { |
| 2330 | if(put_user('\n', s)) |
| 2331 | return -EFAULT; |
| 2332 | left--, s++; |
| 2333 | } |
| 2334 | if (write) { |
| 2335 | while (left) { |
| 2336 | char c; |
| 2337 | if (get_user(c, s++)) |
| 2338 | return -EFAULT; |
| 2339 | if (!isspace(c)) |
| 2340 | break; |
| 2341 | left--; |
| 2342 | } |
| 2343 | } |
| 2344 | if (write && first) |
| 2345 | return -EINVAL; |
| 2346 | *lenp -= left; |
| 2347 | *ppos += *lenp; |
| 2348 | return 0; |
| 2349 | #undef TMPBUFLEN |
| 2350 | } |
| 2351 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2352 | static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2353 | void __user *buffer, size_t *lenp, loff_t *ppos, |
| 2354 | int (*conv)(int *negp, unsigned long *lvalp, int *valp, |
| 2355 | int write, void *data), |
| 2356 | void *data) |
| 2357 | { |
| 2358 | return __do_proc_dointvec(table->data, table, write, filp, |
| 2359 | buffer, lenp, ppos, conv, data); |
| 2360 | } |
| 2361 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | /** |
| 2363 | * proc_dointvec - read a vector of integers |
| 2364 | * @table: the sysctl table |
| 2365 | * @write: %TRUE if this is a write to the sysctl file |
| 2366 | * @filp: the file structure |
| 2367 | * @buffer: the user buffer |
| 2368 | * @lenp: the size of the user buffer |
| 2369 | * @ppos: file position |
| 2370 | * |
| 2371 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2372 | * values from/to the user buffer, treated as an ASCII string. |
| 2373 | * |
| 2374 | * Returns 0 on success. |
| 2375 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2376 | int proc_dointvec(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2377 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2378 | { |
| 2379 | return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, |
| 2380 | NULL,NULL); |
| 2381 | } |
| 2382 | |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2383 | /* |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2384 | * Taint values can only be increased |
| 2385 | * This means we can safely use a temporary. |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2386 | */ |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2387 | static int proc_taint(struct ctl_table *table, int write, struct file *filp, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2388 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2389 | { |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2390 | struct ctl_table t; |
| 2391 | unsigned long tmptaint = get_taint(); |
| 2392 | int err; |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2393 | |
Bastian Blank | 91fcd41 | 2007-04-23 14:41:14 -0700 | [diff] [blame] | 2394 | if (write && !capable(CAP_SYS_ADMIN)) |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2395 | return -EPERM; |
| 2396 | |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2397 | t = *table; |
| 2398 | t.data = &tmptaint; |
| 2399 | err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos); |
| 2400 | if (err < 0) |
| 2401 | return err; |
| 2402 | |
| 2403 | if (write) { |
| 2404 | /* |
| 2405 | * Poor man's atomic or. Not worth adding a primitive |
| 2406 | * to everyone's atomic.h for this |
| 2407 | */ |
| 2408 | int i; |
| 2409 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { |
| 2410 | if ((tmptaint >> i) & 1) |
| 2411 | add_taint(i); |
| 2412 | } |
| 2413 | } |
| 2414 | |
| 2415 | return err; |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2416 | } |
| 2417 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2418 | struct do_proc_dointvec_minmax_conv_param { |
| 2419 | int *min; |
| 2420 | int *max; |
| 2421 | }; |
| 2422 | |
| 2423 | static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, |
| 2424 | int *valp, |
| 2425 | int write, void *data) |
| 2426 | { |
| 2427 | struct do_proc_dointvec_minmax_conv_param *param = data; |
| 2428 | if (write) { |
| 2429 | int val = *negp ? -*lvalp : *lvalp; |
| 2430 | if ((param->min && *param->min > val) || |
| 2431 | (param->max && *param->max < val)) |
| 2432 | return -EINVAL; |
| 2433 | *valp = val; |
| 2434 | } else { |
| 2435 | int val = *valp; |
| 2436 | if (val < 0) { |
| 2437 | *negp = -1; |
| 2438 | *lvalp = (unsigned long)-val; |
| 2439 | } else { |
| 2440 | *negp = 0; |
| 2441 | *lvalp = (unsigned long)val; |
| 2442 | } |
| 2443 | } |
| 2444 | return 0; |
| 2445 | } |
| 2446 | |
| 2447 | /** |
| 2448 | * proc_dointvec_minmax - read a vector of integers with min/max values |
| 2449 | * @table: the sysctl table |
| 2450 | * @write: %TRUE if this is a write to the sysctl file |
| 2451 | * @filp: the file structure |
| 2452 | * @buffer: the user buffer |
| 2453 | * @lenp: the size of the user buffer |
| 2454 | * @ppos: file position |
| 2455 | * |
| 2456 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2457 | * values from/to the user buffer, treated as an ASCII string. |
| 2458 | * |
| 2459 | * This routine will ensure the values are within the range specified by |
| 2460 | * table->extra1 (min) and table->extra2 (max). |
| 2461 | * |
| 2462 | * Returns 0 on success. |
| 2463 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2464 | int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2466 | { |
| 2467 | struct do_proc_dointvec_minmax_conv_param param = { |
| 2468 | .min = (int *) table->extra1, |
| 2469 | .max = (int *) table->extra2, |
| 2470 | }; |
| 2471 | return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, |
| 2472 | do_proc_dointvec_minmax_conv, ¶m); |
| 2473 | } |
| 2474 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2475 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | struct file *filp, |
| 2477 | void __user *buffer, |
| 2478 | size_t *lenp, loff_t *ppos, |
| 2479 | unsigned long convmul, |
| 2480 | unsigned long convdiv) |
| 2481 | { |
| 2482 | #define TMPBUFLEN 21 |
| 2483 | unsigned long *i, *min, *max, val; |
| 2484 | int vleft, first=1, neg; |
| 2485 | size_t len, left; |
| 2486 | char buf[TMPBUFLEN], *p; |
| 2487 | char __user *s = buffer; |
| 2488 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2489 | if (!data || !table->maxlen || !*lenp || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | (*ppos && !write)) { |
| 2491 | *lenp = 0; |
| 2492 | return 0; |
| 2493 | } |
| 2494 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2495 | i = (unsigned long *) data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | min = (unsigned long *) table->extra1; |
| 2497 | max = (unsigned long *) table->extra2; |
| 2498 | vleft = table->maxlen / sizeof(unsigned long); |
| 2499 | left = *lenp; |
| 2500 | |
| 2501 | for (; left && vleft--; i++, min++, max++, first=0) { |
| 2502 | if (write) { |
| 2503 | while (left) { |
| 2504 | char c; |
| 2505 | if (get_user(c, s)) |
| 2506 | return -EFAULT; |
| 2507 | if (!isspace(c)) |
| 2508 | break; |
| 2509 | left--; |
| 2510 | s++; |
| 2511 | } |
| 2512 | if (!left) |
| 2513 | break; |
| 2514 | neg = 0; |
| 2515 | len = left; |
| 2516 | if (len > TMPBUFLEN-1) |
| 2517 | len = TMPBUFLEN-1; |
| 2518 | if (copy_from_user(buf, s, len)) |
| 2519 | return -EFAULT; |
| 2520 | buf[len] = 0; |
| 2521 | p = buf; |
| 2522 | if (*p == '-' && left > 1) { |
| 2523 | neg = 1; |
BP, Praveen | bd9b0ba | 2006-12-06 20:39:09 -0800 | [diff] [blame] | 2524 | p++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2525 | } |
| 2526 | if (*p < '0' || *p > '9') |
| 2527 | break; |
| 2528 | val = simple_strtoul(p, &p, 0) * convmul / convdiv ; |
| 2529 | len = p-buf; |
| 2530 | if ((len < left) && *p && !isspace(*p)) |
| 2531 | break; |
| 2532 | if (neg) |
| 2533 | val = -val; |
| 2534 | s += len; |
| 2535 | left -= len; |
| 2536 | |
| 2537 | if(neg) |
| 2538 | continue; |
| 2539 | if ((min && val < *min) || (max && val > *max)) |
| 2540 | continue; |
| 2541 | *i = val; |
| 2542 | } else { |
| 2543 | p = buf; |
| 2544 | if (!first) |
| 2545 | *p++ = '\t'; |
| 2546 | sprintf(p, "%lu", convdiv * (*i) / convmul); |
| 2547 | len = strlen(buf); |
| 2548 | if (len > left) |
| 2549 | len = left; |
| 2550 | if(copy_to_user(s, buf, len)) |
| 2551 | return -EFAULT; |
| 2552 | left -= len; |
| 2553 | s += len; |
| 2554 | } |
| 2555 | } |
| 2556 | |
| 2557 | if (!write && !first && left) { |
| 2558 | if(put_user('\n', s)) |
| 2559 | return -EFAULT; |
| 2560 | left--, s++; |
| 2561 | } |
| 2562 | if (write) { |
| 2563 | while (left) { |
| 2564 | char c; |
| 2565 | if (get_user(c, s++)) |
| 2566 | return -EFAULT; |
| 2567 | if (!isspace(c)) |
| 2568 | break; |
| 2569 | left--; |
| 2570 | } |
| 2571 | } |
| 2572 | if (write && first) |
| 2573 | return -EINVAL; |
| 2574 | *lenp -= left; |
| 2575 | *ppos += *lenp; |
| 2576 | return 0; |
| 2577 | #undef TMPBUFLEN |
| 2578 | } |
| 2579 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2580 | static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2581 | struct file *filp, |
| 2582 | void __user *buffer, |
| 2583 | size_t *lenp, loff_t *ppos, |
| 2584 | unsigned long convmul, |
| 2585 | unsigned long convdiv) |
| 2586 | { |
| 2587 | return __do_proc_doulongvec_minmax(table->data, table, write, |
| 2588 | filp, buffer, lenp, ppos, convmul, convdiv); |
| 2589 | } |
| 2590 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2591 | /** |
| 2592 | * proc_doulongvec_minmax - read a vector of long integers with min/max values |
| 2593 | * @table: the sysctl table |
| 2594 | * @write: %TRUE if this is a write to the sysctl file |
| 2595 | * @filp: the file structure |
| 2596 | * @buffer: the user buffer |
| 2597 | * @lenp: the size of the user buffer |
| 2598 | * @ppos: file position |
| 2599 | * |
| 2600 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
| 2601 | * values from/to the user buffer, treated as an ASCII string. |
| 2602 | * |
| 2603 | * This routine will ensure the values are within the range specified by |
| 2604 | * table->extra1 (min) and table->extra2 (max). |
| 2605 | * |
| 2606 | * Returns 0 on success. |
| 2607 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2608 | int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2609 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2610 | { |
| 2611 | return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l); |
| 2612 | } |
| 2613 | |
| 2614 | /** |
| 2615 | * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values |
| 2616 | * @table: the sysctl table |
| 2617 | * @write: %TRUE if this is a write to the sysctl file |
| 2618 | * @filp: the file structure |
| 2619 | * @buffer: the user buffer |
| 2620 | * @lenp: the size of the user buffer |
| 2621 | * @ppos: file position |
| 2622 | * |
| 2623 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
| 2624 | * values from/to the user buffer, treated as an ASCII string. The values |
| 2625 | * are treated as milliseconds, and converted to jiffies when they are stored. |
| 2626 | * |
| 2627 | * This routine will ensure the values are within the range specified by |
| 2628 | * table->extra1 (min) and table->extra2 (max). |
| 2629 | * |
| 2630 | * Returns 0 on success. |
| 2631 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2632 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | struct file *filp, |
| 2634 | void __user *buffer, |
| 2635 | size_t *lenp, loff_t *ppos) |
| 2636 | { |
| 2637 | return do_proc_doulongvec_minmax(table, write, filp, buffer, |
| 2638 | lenp, ppos, HZ, 1000l); |
| 2639 | } |
| 2640 | |
| 2641 | |
| 2642 | static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, |
| 2643 | int *valp, |
| 2644 | int write, void *data) |
| 2645 | { |
| 2646 | if (write) { |
Bart Samwel | cba9f33 | 2006-03-24 03:15:50 -0800 | [diff] [blame] | 2647 | if (*lvalp > LONG_MAX / HZ) |
| 2648 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2649 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); |
| 2650 | } else { |
| 2651 | int val = *valp; |
| 2652 | unsigned long lval; |
| 2653 | if (val < 0) { |
| 2654 | *negp = -1; |
| 2655 | lval = (unsigned long)-val; |
| 2656 | } else { |
| 2657 | *negp = 0; |
| 2658 | lval = (unsigned long)val; |
| 2659 | } |
| 2660 | *lvalp = lval / HZ; |
| 2661 | } |
| 2662 | return 0; |
| 2663 | } |
| 2664 | |
| 2665 | static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, |
| 2666 | int *valp, |
| 2667 | int write, void *data) |
| 2668 | { |
| 2669 | if (write) { |
Bart Samwel | cba9f33 | 2006-03-24 03:15:50 -0800 | [diff] [blame] | 2670 | if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) |
| 2671 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2672 | *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); |
| 2673 | } else { |
| 2674 | int val = *valp; |
| 2675 | unsigned long lval; |
| 2676 | if (val < 0) { |
| 2677 | *negp = -1; |
| 2678 | lval = (unsigned long)-val; |
| 2679 | } else { |
| 2680 | *negp = 0; |
| 2681 | lval = (unsigned long)val; |
| 2682 | } |
| 2683 | *lvalp = jiffies_to_clock_t(lval); |
| 2684 | } |
| 2685 | return 0; |
| 2686 | } |
| 2687 | |
| 2688 | static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, |
| 2689 | int *valp, |
| 2690 | int write, void *data) |
| 2691 | { |
| 2692 | if (write) { |
| 2693 | *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); |
| 2694 | } else { |
| 2695 | int val = *valp; |
| 2696 | unsigned long lval; |
| 2697 | if (val < 0) { |
| 2698 | *negp = -1; |
| 2699 | lval = (unsigned long)-val; |
| 2700 | } else { |
| 2701 | *negp = 0; |
| 2702 | lval = (unsigned long)val; |
| 2703 | } |
| 2704 | *lvalp = jiffies_to_msecs(lval); |
| 2705 | } |
| 2706 | return 0; |
| 2707 | } |
| 2708 | |
| 2709 | /** |
| 2710 | * proc_dointvec_jiffies - read a vector of integers as seconds |
| 2711 | * @table: the sysctl table |
| 2712 | * @write: %TRUE if this is a write to the sysctl file |
| 2713 | * @filp: the file structure |
| 2714 | * @buffer: the user buffer |
| 2715 | * @lenp: the size of the user buffer |
| 2716 | * @ppos: file position |
| 2717 | * |
| 2718 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2719 | * values from/to the user buffer, treated as an ASCII string. |
| 2720 | * The values read are assumed to be in seconds, and are converted into |
| 2721 | * jiffies. |
| 2722 | * |
| 2723 | * Returns 0 on success. |
| 2724 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2725 | int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2726 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2727 | { |
| 2728 | return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, |
| 2729 | do_proc_dointvec_jiffies_conv,NULL); |
| 2730 | } |
| 2731 | |
| 2732 | /** |
| 2733 | * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds |
| 2734 | * @table: the sysctl table |
| 2735 | * @write: %TRUE if this is a write to the sysctl file |
| 2736 | * @filp: the file structure |
| 2737 | * @buffer: the user buffer |
| 2738 | * @lenp: the size of the user buffer |
Randy Dunlap | 1e5d533 | 2005-11-07 01:01:06 -0800 | [diff] [blame] | 2739 | * @ppos: pointer to the file position |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2740 | * |
| 2741 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2742 | * values from/to the user buffer, treated as an ASCII string. |
| 2743 | * The values read are assumed to be in 1/USER_HZ seconds, and |
| 2744 | * are converted into jiffies. |
| 2745 | * |
| 2746 | * Returns 0 on success. |
| 2747 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2748 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2749 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2750 | { |
| 2751 | return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, |
| 2752 | do_proc_dointvec_userhz_jiffies_conv,NULL); |
| 2753 | } |
| 2754 | |
| 2755 | /** |
| 2756 | * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds |
| 2757 | * @table: the sysctl table |
| 2758 | * @write: %TRUE if this is a write to the sysctl file |
| 2759 | * @filp: the file structure |
| 2760 | * @buffer: the user buffer |
| 2761 | * @lenp: the size of the user buffer |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 2762 | * @ppos: file position |
| 2763 | * @ppos: the current position in the file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2764 | * |
| 2765 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2766 | * values from/to the user buffer, treated as an ASCII string. |
| 2767 | * The values read are assumed to be in 1/1000 seconds, and |
| 2768 | * are converted into jiffies. |
| 2769 | * |
| 2770 | * Returns 0 on success. |
| 2771 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2772 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2773 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2774 | { |
| 2775 | return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, |
| 2776 | do_proc_dointvec_ms_jiffies_conv, NULL); |
| 2777 | } |
| 2778 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2779 | static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 2780 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2781 | { |
| 2782 | struct pid *new_pid; |
| 2783 | pid_t tmp; |
| 2784 | int r; |
| 2785 | |
Pavel Emelyanov | 6c5f3e7 | 2008-02-08 04:19:20 -0800 | [diff] [blame] | 2786 | tmp = pid_vnr(cad_pid); |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 2787 | |
| 2788 | r = __do_proc_dointvec(&tmp, table, write, filp, buffer, |
| 2789 | lenp, ppos, NULL, NULL); |
| 2790 | if (r || !write) |
| 2791 | return r; |
| 2792 | |
| 2793 | new_pid = find_get_pid(tmp); |
| 2794 | if (!new_pid) |
| 2795 | return -ESRCH; |
| 2796 | |
| 2797 | put_pid(xchg(&cad_pid, new_pid)); |
| 2798 | return 0; |
| 2799 | } |
| 2800 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2801 | #else /* CONFIG_PROC_FS */ |
| 2802 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2803 | int proc_dostring(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2804 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2805 | { |
| 2806 | return -ENOSYS; |
| 2807 | } |
| 2808 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2809 | int proc_dointvec(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2810 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2811 | { |
| 2812 | return -ENOSYS; |
| 2813 | } |
| 2814 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2815 | int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2816 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2817 | { |
| 2818 | return -ENOSYS; |
| 2819 | } |
| 2820 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2821 | int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2822 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2823 | { |
| 2824 | return -ENOSYS; |
| 2825 | } |
| 2826 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2827 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2829 | { |
| 2830 | return -ENOSYS; |
| 2831 | } |
| 2832 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2833 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2834 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2835 | { |
| 2836 | return -ENOSYS; |
| 2837 | } |
| 2838 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2839 | int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2841 | { |
| 2842 | return -ENOSYS; |
| 2843 | } |
| 2844 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2845 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2846 | struct file *filp, |
| 2847 | void __user *buffer, |
| 2848 | size_t *lenp, loff_t *ppos) |
| 2849 | { |
| 2850 | return -ENOSYS; |
| 2851 | } |
| 2852 | |
| 2853 | |
| 2854 | #endif /* CONFIG_PROC_FS */ |
| 2855 | |
| 2856 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2857 | #ifdef CONFIG_SYSCTL_SYSCALL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2858 | /* |
| 2859 | * General sysctl support routines |
| 2860 | */ |
| 2861 | |
Eric W. Biederman | 49a0c45 | 2007-10-18 03:05:23 -0700 | [diff] [blame] | 2862 | /* The generic sysctl data routine (used if no strategy routine supplied) */ |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 2863 | int sysctl_data(struct ctl_table *table, |
Eric W. Biederman | 49a0c45 | 2007-10-18 03:05:23 -0700 | [diff] [blame] | 2864 | void __user *oldval, size_t __user *oldlenp, |
| 2865 | void __user *newval, size_t newlen) |
| 2866 | { |
| 2867 | size_t len; |
| 2868 | |
| 2869 | /* Get out of I don't have a variable */ |
| 2870 | if (!table->data || !table->maxlen) |
| 2871 | return -ENOTDIR; |
| 2872 | |
| 2873 | if (oldval && oldlenp) { |
| 2874 | if (get_user(len, oldlenp)) |
| 2875 | return -EFAULT; |
| 2876 | if (len) { |
| 2877 | if (len > table->maxlen) |
| 2878 | len = table->maxlen; |
| 2879 | if (copy_to_user(oldval, table->data, len)) |
| 2880 | return -EFAULT; |
| 2881 | if (put_user(len, oldlenp)) |
| 2882 | return -EFAULT; |
| 2883 | } |
| 2884 | } |
| 2885 | |
| 2886 | if (newval && newlen) { |
| 2887 | if (newlen > table->maxlen) |
| 2888 | newlen = table->maxlen; |
| 2889 | |
| 2890 | if (copy_from_user(table->data, newval, newlen)) |
| 2891 | return -EFAULT; |
| 2892 | } |
| 2893 | return 1; |
| 2894 | } |
| 2895 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2896 | /* The generic string strategy routine: */ |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 2897 | int sysctl_string(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2898 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 2899 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2900 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | if (!table->data || !table->maxlen) |
| 2902 | return -ENOTDIR; |
| 2903 | |
| 2904 | if (oldval && oldlenp) { |
Linus Torvalds | de9e007 | 2005-12-31 17:00:29 -0800 | [diff] [blame] | 2905 | size_t bufsize; |
| 2906 | if (get_user(bufsize, oldlenp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2907 | return -EFAULT; |
Linus Torvalds | de9e007 | 2005-12-31 17:00:29 -0800 | [diff] [blame] | 2908 | if (bufsize) { |
| 2909 | size_t len = strlen(table->data), copied; |
| 2910 | |
| 2911 | /* This shouldn't trigger for a well-formed sysctl */ |
| 2912 | if (len > table->maxlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2913 | len = table->maxlen; |
Linus Torvalds | de9e007 | 2005-12-31 17:00:29 -0800 | [diff] [blame] | 2914 | |
| 2915 | /* Copy up to a max of bufsize-1 bytes of the string */ |
| 2916 | copied = (len >= bufsize) ? bufsize - 1 : len; |
| 2917 | |
| 2918 | if (copy_to_user(oldval, table->data, copied) || |
| 2919 | put_user(0, (char __user *)(oldval + copied))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2920 | return -EFAULT; |
Linus Torvalds | de9e007 | 2005-12-31 17:00:29 -0800 | [diff] [blame] | 2921 | if (put_user(len, oldlenp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2922 | return -EFAULT; |
| 2923 | } |
| 2924 | } |
| 2925 | if (newval && newlen) { |
Linus Torvalds | de9e007 | 2005-12-31 17:00:29 -0800 | [diff] [blame] | 2926 | size_t len = newlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2927 | if (len > table->maxlen) |
| 2928 | len = table->maxlen; |
| 2929 | if(copy_from_user(table->data, newval, len)) |
| 2930 | return -EFAULT; |
| 2931 | if (len == table->maxlen) |
| 2932 | len--; |
| 2933 | ((char *) table->data)[len] = 0; |
| 2934 | } |
Yi Yang | 82c9df8 | 2005-12-30 16:37:10 +0800 | [diff] [blame] | 2935 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2936 | } |
| 2937 | |
| 2938 | /* |
| 2939 | * This function makes sure that all of the integers in the vector |
| 2940 | * are between the minimum and maximum values given in the arrays |
| 2941 | * table->extra1 and table->extra2, respectively. |
| 2942 | */ |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 2943 | int sysctl_intvec(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2944 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 2945 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2946 | { |
| 2947 | |
| 2948 | if (newval && newlen) { |
| 2949 | int __user *vec = (int __user *) newval; |
| 2950 | int *min = (int *) table->extra1; |
| 2951 | int *max = (int *) table->extra2; |
| 2952 | size_t length; |
| 2953 | int i; |
| 2954 | |
| 2955 | if (newlen % sizeof(int) != 0) |
| 2956 | return -EINVAL; |
| 2957 | |
| 2958 | if (!table->extra1 && !table->extra2) |
| 2959 | return 0; |
| 2960 | |
| 2961 | if (newlen > table->maxlen) |
| 2962 | newlen = table->maxlen; |
| 2963 | length = newlen / sizeof(int); |
| 2964 | |
| 2965 | for (i = 0; i < length; i++) { |
| 2966 | int value; |
| 2967 | if (get_user(value, vec + i)) |
| 2968 | return -EFAULT; |
| 2969 | if (min && value < min[i]) |
| 2970 | return -EINVAL; |
| 2971 | if (max && value > max[i]) |
| 2972 | return -EINVAL; |
| 2973 | } |
| 2974 | } |
| 2975 | return 0; |
| 2976 | } |
| 2977 | |
| 2978 | /* Strategy function to convert jiffies to seconds */ |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 2979 | int sysctl_jiffies(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2980 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 2981 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2982 | { |
Alexey Dobriyan | 3ee75ac | 2007-02-10 01:44:39 -0800 | [diff] [blame] | 2983 | if (oldval && oldlenp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2984 | size_t olen; |
Alexey Dobriyan | 3ee75ac | 2007-02-10 01:44:39 -0800 | [diff] [blame] | 2985 | |
| 2986 | if (get_user(olen, oldlenp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2987 | return -EFAULT; |
Alexey Dobriyan | 3ee75ac | 2007-02-10 01:44:39 -0800 | [diff] [blame] | 2988 | if (olen) { |
| 2989 | int val; |
| 2990 | |
| 2991 | if (olen < sizeof(int)) |
| 2992 | return -EINVAL; |
| 2993 | |
| 2994 | val = *(int *)(table->data) / HZ; |
| 2995 | if (put_user(val, (int __user *)oldval)) |
| 2996 | return -EFAULT; |
| 2997 | if (put_user(sizeof(int), oldlenp)) |
| 2998 | return -EFAULT; |
| 2999 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3000 | } |
| 3001 | if (newval && newlen) { |
| 3002 | int new; |
| 3003 | if (newlen != sizeof(int)) |
| 3004 | return -EINVAL; |
| 3005 | if (get_user(new, (int __user *)newval)) |
| 3006 | return -EFAULT; |
| 3007 | *(int *)(table->data) = new*HZ; |
| 3008 | } |
| 3009 | return 1; |
| 3010 | } |
| 3011 | |
| 3012 | /* Strategy function to convert jiffies to seconds */ |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 3013 | int sysctl_ms_jiffies(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3014 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 3015 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3016 | { |
Alexey Dobriyan | 3ee75ac | 2007-02-10 01:44:39 -0800 | [diff] [blame] | 3017 | if (oldval && oldlenp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3018 | size_t olen; |
Alexey Dobriyan | 3ee75ac | 2007-02-10 01:44:39 -0800 | [diff] [blame] | 3019 | |
| 3020 | if (get_user(olen, oldlenp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3021 | return -EFAULT; |
Alexey Dobriyan | 3ee75ac | 2007-02-10 01:44:39 -0800 | [diff] [blame] | 3022 | if (olen) { |
| 3023 | int val; |
| 3024 | |
| 3025 | if (olen < sizeof(int)) |
| 3026 | return -EINVAL; |
| 3027 | |
| 3028 | val = jiffies_to_msecs(*(int *)(table->data)); |
| 3029 | if (put_user(val, (int __user *)oldval)) |
| 3030 | return -EFAULT; |
| 3031 | if (put_user(sizeof(int), oldlenp)) |
| 3032 | return -EFAULT; |
| 3033 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | } |
| 3035 | if (newval && newlen) { |
| 3036 | int new; |
| 3037 | if (newlen != sizeof(int)) |
| 3038 | return -EINVAL; |
| 3039 | if (get_user(new, (int __user *)newval)) |
| 3040 | return -EFAULT; |
| 3041 | *(int *)(table->data) = msecs_to_jiffies(new); |
| 3042 | } |
| 3043 | return 1; |
| 3044 | } |
| 3045 | |
Eric W. Biederman | c4b8b76 | 2006-12-08 02:39:55 -0800 | [diff] [blame] | 3046 | |
Eric W. Biederman | c4b8b76 | 2006-12-08 02:39:55 -0800 | [diff] [blame] | 3047 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 3048 | #else /* CONFIG_SYSCTL_SYSCALL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3049 | |
| 3050 | |
Heiko Carstens | 1e7bfb2 | 2009-01-14 14:14:29 +0100 | [diff] [blame] | 3051 | SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | { |
Eric W. Biederman | 0e009be | 2006-11-05 23:52:11 -0800 | [diff] [blame] | 3053 | struct __sysctl_args tmp; |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 3054 | int error; |
Eric W. Biederman | 0e009be | 2006-11-05 23:52:11 -0800 | [diff] [blame] | 3055 | |
Eric W. Biederman | 0e009be | 2006-11-05 23:52:11 -0800 | [diff] [blame] | 3056 | if (copy_from_user(&tmp, args, sizeof(tmp))) |
| 3057 | return -EFAULT; |
Eric W. Biederman | 0e009be | 2006-11-05 23:52:11 -0800 | [diff] [blame] | 3058 | |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 3059 | error = deprecated_sysctl_warning(&tmp); |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 3060 | |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 3061 | /* If no error reading the parameters then just -ENOSYS ... */ |
| 3062 | if (!error) |
| 3063 | error = -ENOSYS; |
| 3064 | |
| 3065 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | } |
| 3067 | |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 3068 | int sysctl_data(struct ctl_table *table, |
Eric W. Biederman | 49a0c45 | 2007-10-18 03:05:23 -0700 | [diff] [blame] | 3069 | void __user *oldval, size_t __user *oldlenp, |
| 3070 | void __user *newval, size_t newlen) |
| 3071 | { |
| 3072 | return -ENOSYS; |
| 3073 | } |
| 3074 | |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 3075 | int sysctl_string(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 3077 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3078 | { |
| 3079 | return -ENOSYS; |
| 3080 | } |
| 3081 | |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 3082 | int sysctl_intvec(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3083 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 3084 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3085 | { |
| 3086 | return -ENOSYS; |
| 3087 | } |
| 3088 | |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 3089 | int sysctl_jiffies(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3090 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 3091 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | { |
| 3093 | return -ENOSYS; |
| 3094 | } |
| 3095 | |
Alexey Dobriyan | f221e72 | 2008-10-15 22:04:23 -0700 | [diff] [blame] | 3096 | int sysctl_ms_jiffies(struct ctl_table *table, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3097 | void __user *oldval, size_t __user *oldlenp, |
Alexey Dobriyan | 1f29bcd | 2006-12-10 02:19:10 -0800 | [diff] [blame] | 3098 | void __user *newval, size_t newlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | { |
| 3100 | return -ENOSYS; |
| 3101 | } |
| 3102 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 3103 | #endif /* CONFIG_SYSCTL_SYSCALL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3104 | |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 3105 | static int deprecated_sysctl_warning(struct __sysctl_args *args) |
| 3106 | { |
| 3107 | static int msg_count; |
| 3108 | int name[CTL_MAXNAME]; |
| 3109 | int i; |
| 3110 | |
Tetsuo Handa | 6fc48af | 2007-11-14 16:58:38 -0800 | [diff] [blame] | 3111 | /* Check args->nlen. */ |
| 3112 | if (args->nlen < 0 || args->nlen > CTL_MAXNAME) |
| 3113 | return -ENOTDIR; |
| 3114 | |
Eric W. Biederman | 7058cb0 | 2007-10-18 03:05:58 -0700 | [diff] [blame] | 3115 | /* Read in the sysctl name for better debug message logging */ |
| 3116 | for (i = 0; i < args->nlen; i++) |
| 3117 | if (get_user(name[i], args->name + i)) |
| 3118 | return -EFAULT; |
| 3119 | |
| 3120 | /* Ignore accesses to kernel.version */ |
| 3121 | if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION)) |
| 3122 | return 0; |
| 3123 | |
| 3124 | if (msg_count < 5) { |
| 3125 | msg_count++; |
| 3126 | printk(KERN_INFO |
| 3127 | "warning: process `%s' used the deprecated sysctl " |
| 3128 | "system call with ", current->comm); |
| 3129 | for (i = 0; i < args->nlen; i++) |
| 3130 | printk("%d.", name[i]); |
| 3131 | printk("\n"); |
| 3132 | } |
| 3133 | return 0; |
| 3134 | } |
| 3135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | /* |
| 3137 | * No sense putting this after each symbol definition, twice, |
| 3138 | * exception granted :-) |
| 3139 | */ |
| 3140 | EXPORT_SYMBOL(proc_dointvec); |
| 3141 | EXPORT_SYMBOL(proc_dointvec_jiffies); |
| 3142 | EXPORT_SYMBOL(proc_dointvec_minmax); |
| 3143 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); |
| 3144 | EXPORT_SYMBOL(proc_dointvec_ms_jiffies); |
| 3145 | EXPORT_SYMBOL(proc_dostring); |
| 3146 | EXPORT_SYMBOL(proc_doulongvec_minmax); |
| 3147 | EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); |
| 3148 | EXPORT_SYMBOL(register_sysctl_table); |
Eric W. Biederman | 29e796f | 2007-11-30 23:50:18 +1100 | [diff] [blame] | 3149 | EXPORT_SYMBOL(register_sysctl_paths); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | EXPORT_SYMBOL(sysctl_intvec); |
| 3151 | EXPORT_SYMBOL(sysctl_jiffies); |
| 3152 | EXPORT_SYMBOL(sysctl_ms_jiffies); |
| 3153 | EXPORT_SYMBOL(sysctl_string); |
Eric W. Biederman | 49a0c45 | 2007-10-18 03:05:23 -0700 | [diff] [blame] | 3154 | EXPORT_SYMBOL(sysctl_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3155 | EXPORT_SYMBOL(unregister_sysctl_table); |