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