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