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