blob: 7ba4b0c16d6a324091e4bcf103dd072d062f086c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070021#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>
Randy.Dunlapc59ede72006-01-11 12:17:46 -080027#include <linux/capability.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/ctype.h>
29#include <linux/utsname.h>
30#include <linux/capability.h>
31#include <linux/smp_lock.h>
32#include <linux/init.h>
33#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010034#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030035#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
39#include <linux/hugetlb.h>
40#include <linux/security.h>
41#include <linux/initrd.h>
42#include <linux/times.h>
43#include <linux/limits.h>
44#include <linux/dcache.h>
45#include <linux/syscalls.h>
Pavel Machekc255d842006-02-20 18:27:58 -080046#include <linux/nfs_fs.h>
47#include <linux/acpi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#include <asm/uaccess.h>
50#include <asm/processor.h>
51
Dipankar Sarma529bf6b2006-03-07 21:55:35 -080052extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
53 void __user *buffer, size_t *lenp, loff_t *ppos);
54
Andi Kleen29cbc782006-09-30 01:47:55 +020055#ifdef CONFIG_X86
56#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010057#include <asm/stacktrace.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020058#endif
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#if defined(CONFIG_SYSCTL)
61
62/* External variables not in a header file. */
63extern int C_A_D;
64extern int sysctl_overcommit_memory;
65extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070066extern int sysctl_panic_on_oom;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070069extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070extern char core_pattern[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070071extern int pid_max;
72extern int min_free_kbytes;
73extern int printk_ratelimit_jiffies;
74extern int printk_ratelimit_burst;
75extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080076extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080077extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020078extern int compat_log;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Linus Torvalds1da177e2005-04-16 15:20:36 -070080/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
81static int maxolduid = 65535;
82static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080083static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85static int ngroups_max = NGROUPS_MAX;
86
87#ifdef CONFIG_KMOD
88extern char modprobe_path[];
89#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#ifdef CONFIG_CHR_DEV_SG
91extern int sg_big_buff;
92#endif
93#ifdef CONFIG_SYSVIPC
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -080094static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
95 void __user *buffer, size_t *lenp, loff_t *ppos);
96static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -070097 void __user *buffer, size_t *lenp, loff_t *ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#endif
99
100#ifdef __sparc__
101extern char reboot_command [];
102extern int stop_a_enabled;
103extern int scons_pwroff;
104#endif
105
106#ifdef __hppa__
107extern int pwrsw_enabled;
108extern int unaligned_enabled;
109#endif
110
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800111#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#ifdef CONFIG_MATHEMU
113extern int sysctl_ieee_emulation_warnings;
114#endif
115extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700116extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#endif
118
119extern int sysctl_hz_timer;
120
121#ifdef CONFIG_BSD_PROCESS_ACCT
122extern int acct_parm[];
123#endif
124
Jes Sorensend2b176e2006-02-28 09:42:23 -0800125#ifdef CONFIG_IA64
126extern int no_unaligned_warning;
127#endif
128
Ingo Molnar23f78d42006-06-27 02:54:53 -0700129#ifdef CONFIG_RT_MUTEXES
130extern int max_lock_depth;
131#endif
132
Eric W. Biedermanb89a8172006-09-27 01:51:04 -0700133#ifdef CONFIG_SYSCTL_SYSCALL
134static int parse_table(int __user *, int, void __user *, size_t __user *,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -0800135 void __user *, size_t, ctl_table *);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -0700136#endif
137
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700138static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 void __user *buffer, size_t *lenp, loff_t *ppos);
140
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800141static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
142 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -0800143 void __user *newval, size_t newlen);
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800144
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800145#ifdef CONFIG_SYSVIPC
146static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
147 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -0800148 void __user *newval, size_t newlen);
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800149#endif
150
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700151#ifdef CONFIG_PROC_SYSCTL
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700152static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
153 void __user *buffer, size_t *lenp, loff_t *ppos);
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800154static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
155 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700156#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158static ctl_table root_table[];
159static struct ctl_table_header root_table_header =
160 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
161
162static ctl_table kern_table[];
163static ctl_table vm_table[];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164static ctl_table fs_table[];
165static ctl_table debug_table[];
166static ctl_table dev_table[];
167extern ctl_table random_table[];
168#ifdef CONFIG_UNIX98_PTYS
169extern ctl_table pty_table[];
170#endif
Amy Griffis2d9048e2006-06-01 13:10:59 -0700171#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -0400172extern ctl_table inotify_table[];
173#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
176int sysctl_legacy_va_layout;
177#endif
178
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800179
Eric W. Biedermancf9f1512006-12-08 02:39:55 -0800180static void *get_uts(ctl_table *table, int write)
181{
182 char *which = table->data;
183#ifdef CONFIG_UTS_NS
184 struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
185 which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
186#endif
187 if (!write)
188 down_read(&uts_sem);
189 else
190 down_write(&uts_sem);
191 return which;
192}
193
194static void put_uts(ctl_table *table, int write, void *which)
195{
196 if (!write)
197 up_read(&uts_sem);
198 else
199 up_write(&uts_sem);
200}
201
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800202#ifdef CONFIG_SYSVIPC
203static void *get_ipc(ctl_table *table, int write)
204{
205 char *which = table->data;
206 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
207 which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
208 return which;
209}
210#else
211#define get_ipc(T,W) ((T)->data)
212#endif
213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214/* /proc declarations: */
215
Eric W. Biedermanb89a8172006-09-27 01:51:04 -0700216#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
219static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
220static int proc_opensys(struct inode *, struct file *);
221
Helge Deller15ad7cd2006-12-06 20:40:36 -0800222const struct file_operations proc_sys_file_operations = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 .open = proc_opensys,
224 .read = proc_readsys,
225 .write = proc_writesys,
226};
227
228extern struct proc_dir_entry *proc_sys_root;
229
Al Viro330d57f2005-11-04 10:18:40 +0000230static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
232#endif
233
234/* The default sysctl tables: */
235
236static ctl_table root_table[] = {
237 {
238 .ctl_name = CTL_KERN,
239 .procname = "kernel",
240 .mode = 0555,
241 .child = kern_table,
242 },
243 {
244 .ctl_name = CTL_VM,
245 .procname = "vm",
246 .mode = 0555,
247 .child = vm_table,
248 },
249#ifdef CONFIG_NET
250 {
251 .ctl_name = CTL_NET,
252 .procname = "net",
253 .mode = 0555,
254 .child = net_table,
255 },
256#endif
257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .ctl_name = CTL_FS,
259 .procname = "fs",
260 .mode = 0555,
261 .child = fs_table,
262 },
263 {
264 .ctl_name = CTL_DEBUG,
265 .procname = "debug",
266 .mode = 0555,
267 .child = debug_table,
268 },
269 {
270 .ctl_name = CTL_DEV,
271 .procname = "dev",
272 .mode = 0555,
273 .child = dev_table,
274 },
Robert Love0eeca282005-07-12 17:06:03 -0400275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 { .ctl_name = 0 }
277};
278
279static ctl_table kern_table[] = {
280 {
281 .ctl_name = KERN_OSTYPE,
282 .procname = "ostype",
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700283 .data = init_uts_ns.name.sysname,
284 .maxlen = sizeof(init_uts_ns.name.sysname),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 .mode = 0444,
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700286 .proc_handler = &proc_do_uts_string,
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800287 .strategy = &sysctl_uts_string,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 },
289 {
290 .ctl_name = KERN_OSRELEASE,
291 .procname = "osrelease",
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700292 .data = init_uts_ns.name.release,
293 .maxlen = sizeof(init_uts_ns.name.release),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 .mode = 0444,
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700295 .proc_handler = &proc_do_uts_string,
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800296 .strategy = &sysctl_uts_string,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 },
298 {
299 .ctl_name = KERN_VERSION,
300 .procname = "version",
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700301 .data = init_uts_ns.name.version,
302 .maxlen = sizeof(init_uts_ns.name.version),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 .mode = 0444,
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700304 .proc_handler = &proc_do_uts_string,
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800305 .strategy = &sysctl_uts_string,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 },
307 {
308 .ctl_name = KERN_NODENAME,
309 .procname = "hostname",
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700310 .data = init_uts_ns.name.nodename,
311 .maxlen = sizeof(init_uts_ns.name.nodename),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 .mode = 0644,
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700313 .proc_handler = &proc_do_uts_string,
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800314 .strategy = &sysctl_uts_string,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 },
316 {
317 .ctl_name = KERN_DOMAINNAME,
318 .procname = "domainname",
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700319 .data = init_uts_ns.name.domainname,
320 .maxlen = sizeof(init_uts_ns.name.domainname),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 .mode = 0644,
Serge E. Hallyn8218c742006-10-02 02:18:15 -0700322 .proc_handler = &proc_do_uts_string,
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -0800323 .strategy = &sysctl_uts_string,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 },
325 {
326 .ctl_name = KERN_PANIC,
327 .procname = "panic",
328 .data = &panic_timeout,
329 .maxlen = sizeof(int),
330 .mode = 0644,
331 .proc_handler = &proc_dointvec,
332 },
333 {
334 .ctl_name = KERN_CORE_USES_PID,
335 .procname = "core_uses_pid",
336 .data = &core_uses_pid,
337 .maxlen = sizeof(int),
338 .mode = 0644,
339 .proc_handler = &proc_dointvec,
340 },
341 {
342 .ctl_name = KERN_CORE_PATTERN,
343 .procname = "core_pattern",
344 .data = core_pattern,
Andi Kleend025c9d2006-09-30 23:29:28 -0700345 .maxlen = 128,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 .mode = 0644,
347 .proc_handler = &proc_dostring,
348 .strategy = &sysctl_string,
349 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800350#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 {
352 .ctl_name = KERN_TAINTED,
353 .procname = "tainted",
354 .data = &tainted,
355 .maxlen = sizeof(int),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800356 .mode = 0644,
357 .proc_handler = &proc_dointvec_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800359#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 {
361 .ctl_name = KERN_CAP_BSET,
362 .procname = "cap-bound",
363 .data = &cap_bset,
364 .maxlen = sizeof(kernel_cap_t),
365 .mode = 0600,
366 .proc_handler = &proc_dointvec_bset,
367 },
368#ifdef CONFIG_BLK_DEV_INITRD
369 {
370 .ctl_name = KERN_REALROOTDEV,
371 .procname = "real-root-dev",
372 .data = &real_root_dev,
373 .maxlen = sizeof(int),
374 .mode = 0644,
375 .proc_handler = &proc_dointvec,
376 },
377#endif
378#ifdef __sparc__
379 {
380 .ctl_name = KERN_SPARC_REBOOT,
381 .procname = "reboot-cmd",
382 .data = reboot_command,
383 .maxlen = 256,
384 .mode = 0644,
385 .proc_handler = &proc_dostring,
386 .strategy = &sysctl_string,
387 },
388 {
389 .ctl_name = KERN_SPARC_STOP_A,
390 .procname = "stop-a",
391 .data = &stop_a_enabled,
392 .maxlen = sizeof (int),
393 .mode = 0644,
394 .proc_handler = &proc_dointvec,
395 },
396 {
397 .ctl_name = KERN_SPARC_SCONS_PWROFF,
398 .procname = "scons-poweroff",
399 .data = &scons_pwroff,
400 .maxlen = sizeof (int),
401 .mode = 0644,
402 .proc_handler = &proc_dointvec,
403 },
404#endif
405#ifdef __hppa__
406 {
407 .ctl_name = KERN_HPPA_PWRSW,
408 .procname = "soft-power",
409 .data = &pwrsw_enabled,
410 .maxlen = sizeof (int),
411 .mode = 0644,
412 .proc_handler = &proc_dointvec,
413 },
414 {
415 .ctl_name = KERN_HPPA_UNALIGNED,
416 .procname = "unaligned-trap",
417 .data = &unaligned_enabled,
418 .maxlen = sizeof (int),
419 .mode = 0644,
420 .proc_handler = &proc_dointvec,
421 },
422#endif
423 {
424 .ctl_name = KERN_CTLALTDEL,
425 .procname = "ctrl-alt-del",
426 .data = &C_A_D,
427 .maxlen = sizeof(int),
428 .mode = 0644,
429 .proc_handler = &proc_dointvec,
430 },
431 {
432 .ctl_name = KERN_PRINTK,
433 .procname = "printk",
434 .data = &console_loglevel,
435 .maxlen = 4*sizeof(int),
436 .mode = 0644,
437 .proc_handler = &proc_dointvec,
438 },
439#ifdef CONFIG_KMOD
440 {
441 .ctl_name = KERN_MODPROBE,
442 .procname = "modprobe",
443 .data = &modprobe_path,
444 .maxlen = KMOD_PATH_LEN,
445 .mode = 0644,
446 .proc_handler = &proc_dostring,
447 .strategy = &sysctl_string,
448 },
449#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700450#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 {
452 .ctl_name = KERN_HOTPLUG,
453 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100454 .data = &uevent_helper,
455 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 .mode = 0644,
457 .proc_handler = &proc_dostring,
458 .strategy = &sysctl_string,
459 },
460#endif
461#ifdef CONFIG_CHR_DEV_SG
462 {
463 .ctl_name = KERN_SG_BIG_BUFF,
464 .procname = "sg-big-buff",
465 .data = &sg_big_buff,
466 .maxlen = sizeof (int),
467 .mode = 0444,
468 .proc_handler = &proc_dointvec,
469 },
470#endif
471#ifdef CONFIG_BSD_PROCESS_ACCT
472 {
473 .ctl_name = KERN_ACCT,
474 .procname = "acct",
475 .data = &acct_parm,
476 .maxlen = 3*sizeof(int),
477 .mode = 0644,
478 .proc_handler = &proc_dointvec,
479 },
480#endif
481#ifdef CONFIG_SYSVIPC
482 {
483 .ctl_name = KERN_SHMMAX,
484 .procname = "shmmax",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800485 .data = &init_ipc_ns.shm_ctlmax,
486 .maxlen = sizeof (init_ipc_ns.shm_ctlmax),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800488 .proc_handler = &proc_ipc_doulongvec_minmax,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800489 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 },
491 {
492 .ctl_name = KERN_SHMALL,
493 .procname = "shmall",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800494 .data = &init_ipc_ns.shm_ctlall,
495 .maxlen = sizeof (init_ipc_ns.shm_ctlall),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800497 .proc_handler = &proc_ipc_doulongvec_minmax,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800498 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 },
500 {
501 .ctl_name = KERN_SHMMNI,
502 .procname = "shmmni",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800503 .data = &init_ipc_ns.shm_ctlmni,
504 .maxlen = sizeof (init_ipc_ns.shm_ctlmni),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800506 .proc_handler = &proc_ipc_dointvec,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800507 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 },
509 {
510 .ctl_name = KERN_MSGMAX,
511 .procname = "msgmax",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800512 .data = &init_ipc_ns.msg_ctlmax,
513 .maxlen = sizeof (init_ipc_ns.msg_ctlmax),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800515 .proc_handler = &proc_ipc_dointvec,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800516 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 },
518 {
519 .ctl_name = KERN_MSGMNI,
520 .procname = "msgmni",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800521 .data = &init_ipc_ns.msg_ctlmni,
522 .maxlen = sizeof (init_ipc_ns.msg_ctlmni),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800524 .proc_handler = &proc_ipc_dointvec,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800525 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 },
527 {
528 .ctl_name = KERN_MSGMNB,
529 .procname = "msgmnb",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800530 .data = &init_ipc_ns.msg_ctlmnb,
531 .maxlen = sizeof (init_ipc_ns.msg_ctlmnb),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800533 .proc_handler = &proc_ipc_dointvec,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800534 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 },
536 {
537 .ctl_name = KERN_SEM,
538 .procname = "sem",
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800539 .data = &init_ipc_ns.sem_ctls,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 .maxlen = 4*sizeof (int),
541 .mode = 0644,
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800542 .proc_handler = &proc_ipc_dointvec,
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800543 .strategy = sysctl_ipc_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 },
545#endif
546#ifdef CONFIG_MAGIC_SYSRQ
547 {
548 .ctl_name = KERN_SYSRQ,
549 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800550 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 .maxlen = sizeof (int),
552 .mode = 0644,
553 .proc_handler = &proc_dointvec,
554 },
555#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700556#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 {
558 .ctl_name = KERN_CADPID,
559 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700560 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 .maxlen = sizeof (int),
562 .mode = 0600,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700563 .proc_handler = &proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700565#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 {
567 .ctl_name = KERN_MAX_THREADS,
568 .procname = "threads-max",
569 .data = &max_threads,
570 .maxlen = sizeof(int),
571 .mode = 0644,
572 .proc_handler = &proc_dointvec,
573 },
574 {
575 .ctl_name = KERN_RANDOM,
576 .procname = "random",
577 .mode = 0555,
578 .child = random_table,
579 },
580#ifdef CONFIG_UNIX98_PTYS
581 {
582 .ctl_name = KERN_PTY,
583 .procname = "pty",
584 .mode = 0555,
585 .child = pty_table,
586 },
587#endif
588 {
589 .ctl_name = KERN_OVERFLOWUID,
590 .procname = "overflowuid",
591 .data = &overflowuid,
592 .maxlen = sizeof(int),
593 .mode = 0644,
594 .proc_handler = &proc_dointvec_minmax,
595 .strategy = &sysctl_intvec,
596 .extra1 = &minolduid,
597 .extra2 = &maxolduid,
598 },
599 {
600 .ctl_name = KERN_OVERFLOWGID,
601 .procname = "overflowgid",
602 .data = &overflowgid,
603 .maxlen = sizeof(int),
604 .mode = 0644,
605 .proc_handler = &proc_dointvec_minmax,
606 .strategy = &sysctl_intvec,
607 .extra1 = &minolduid,
608 .extra2 = &maxolduid,
609 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800610#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611#ifdef CONFIG_MATHEMU
612 {
613 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
614 .procname = "ieee_emulation_warnings",
615 .data = &sysctl_ieee_emulation_warnings,
616 .maxlen = sizeof(int),
617 .mode = 0644,
618 .proc_handler = &proc_dointvec,
619 },
620#endif
621#ifdef CONFIG_NO_IDLE_HZ
622 {
623 .ctl_name = KERN_HZ_TIMER,
624 .procname = "hz_timer",
625 .data = &sysctl_hz_timer,
626 .maxlen = sizeof(int),
627 .mode = 0644,
628 .proc_handler = &proc_dointvec,
629 },
630#endif
631 {
632 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
633 .procname = "userprocess_debug",
634 .data = &sysctl_userprocess_debug,
635 .maxlen = sizeof(int),
636 .mode = 0644,
637 .proc_handler = &proc_dointvec,
638 },
639#endif
640 {
641 .ctl_name = KERN_PIDMAX,
642 .procname = "pid_max",
643 .data = &pid_max,
644 .maxlen = sizeof (int),
645 .mode = 0644,
646 .proc_handler = &proc_dointvec_minmax,
647 .strategy = sysctl_intvec,
648 .extra1 = &pid_max_min,
649 .extra2 = &pid_max_max,
650 },
651 {
652 .ctl_name = KERN_PANIC_ON_OOPS,
653 .procname = "panic_on_oops",
654 .data = &panic_on_oops,
655 .maxlen = sizeof(int),
656 .mode = 0644,
657 .proc_handler = &proc_dointvec,
658 },
659 {
660 .ctl_name = KERN_PRINTK_RATELIMIT,
661 .procname = "printk_ratelimit",
662 .data = &printk_ratelimit_jiffies,
663 .maxlen = sizeof(int),
664 .mode = 0644,
665 .proc_handler = &proc_dointvec_jiffies,
666 .strategy = &sysctl_jiffies,
667 },
668 {
669 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
670 .procname = "printk_ratelimit_burst",
671 .data = &printk_ratelimit_burst,
672 .maxlen = sizeof(int),
673 .mode = 0644,
674 .proc_handler = &proc_dointvec,
675 },
676 {
677 .ctl_name = KERN_NGROUPS_MAX,
678 .procname = "ngroups_max",
679 .data = &ngroups_max,
680 .maxlen = sizeof (int),
681 .mode = 0444,
682 .proc_handler = &proc_dointvec,
683 },
684#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
685 {
686 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
687 .procname = "unknown_nmi_panic",
688 .data = &unknown_nmi_panic,
689 .maxlen = sizeof (int),
690 .mode = 0644,
Don Zickus2fbe7b22006-09-26 10:52:27 +0200691 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
Don Zickus407984f2006-09-26 10:52:27 +0200693 {
694 .ctl_name = KERN_NMI_WATCHDOG,
695 .procname = "nmi_watchdog",
696 .data = &nmi_watchdog_enabled,
697 .maxlen = sizeof (int),
698 .mode = 0644,
699 .proc_handler = &proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 },
701#endif
702#if defined(CONFIG_X86)
703 {
Don Zickus8da5adda2006-09-26 10:52:27 +0200704 .ctl_name = KERN_PANIC_ON_NMI,
705 .procname = "panic_on_unrecovered_nmi",
706 .data = &panic_on_unrecovered_nmi,
707 .maxlen = sizeof(int),
708 .mode = 0644,
709 .proc_handler = &proc_dointvec,
710 },
711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .ctl_name = KERN_BOOTLOADER_TYPE,
713 .procname = "bootloader_type",
714 .data = &bootloader_type,
715 .maxlen = sizeof (int),
716 .mode = 0444,
717 .proc_handler = &proc_dointvec,
718 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100719 {
720 .ctl_name = CTL_UNNUMBERED,
721 .procname = "kstack_depth_to_print",
722 .data = &kstack_depth_to_print,
723 .maxlen = sizeof(int),
724 .mode = 0644,
725 .proc_handler = &proc_dointvec,
726 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800728#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 {
730 .ctl_name = KERN_RANDOMIZE,
731 .procname = "randomize_va_space",
732 .data = &randomize_va_space,
733 .maxlen = sizeof(int),
734 .mode = 0644,
735 .proc_handler = &proc_dointvec,
736 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800737#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800738#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700739 {
740 .ctl_name = KERN_SPIN_RETRY,
741 .procname = "spin_retry",
742 .data = &spin_retry,
743 .maxlen = sizeof (int),
744 .mode = 0644,
745 .proc_handler = &proc_dointvec,
746 },
747#endif
Pavel Machekc255d842006-02-20 18:27:58 -0800748#ifdef CONFIG_ACPI_SLEEP
749 {
750 .ctl_name = KERN_ACPI_VIDEO_FLAGS,
751 .procname = "acpi_video_flags",
752 .data = &acpi_video_flags,
753 .maxlen = sizeof (unsigned long),
754 .mode = 0644,
Stefan Seyfried7f99f062006-03-02 02:54:34 -0800755 .proc_handler = &proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800756 },
757#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800758#ifdef CONFIG_IA64
759 {
760 .ctl_name = KERN_IA64_UNALIGNED,
761 .procname = "ignore-unaligned-usertrap",
762 .data = &no_unaligned_warning,
763 .maxlen = sizeof (int),
764 .mode = 0644,
765 .proc_handler = &proc_dointvec,
766 },
767#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200768#ifdef CONFIG_COMPAT
769 {
770 .ctl_name = KERN_COMPAT_LOG,
771 .procname = "compat-log",
772 .data = &compat_log,
773 .maxlen = sizeof (int),
774 .mode = 0644,
775 .proc_handler = &proc_dointvec,
776 },
777#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700778#ifdef CONFIG_RT_MUTEXES
779 {
780 .ctl_name = KERN_MAX_LOCK_DEPTH,
781 .procname = "max_lock_depth",
782 .data = &max_lock_depth,
783 .maxlen = sizeof(int),
784 .mode = 0644,
785 .proc_handler = &proc_dointvec,
786 },
787#endif
788
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 { .ctl_name = 0 }
790};
791
792/* Constants for minimum and maximum testing in vm_table.
793 We use these as one-element integer vectors. */
794static int zero;
795static int one_hundred = 100;
796
797
798static ctl_table vm_table[] = {
799 {
800 .ctl_name = VM_OVERCOMMIT_MEMORY,
801 .procname = "overcommit_memory",
802 .data = &sysctl_overcommit_memory,
803 .maxlen = sizeof(sysctl_overcommit_memory),
804 .mode = 0644,
805 .proc_handler = &proc_dointvec,
806 },
807 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700808 .ctl_name = VM_PANIC_ON_OOM,
809 .procname = "panic_on_oom",
810 .data = &sysctl_panic_on_oom,
811 .maxlen = sizeof(sysctl_panic_on_oom),
812 .mode = 0644,
813 .proc_handler = &proc_dointvec,
814 },
815 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 .ctl_name = VM_OVERCOMMIT_RATIO,
817 .procname = "overcommit_ratio",
818 .data = &sysctl_overcommit_ratio,
819 .maxlen = sizeof(sysctl_overcommit_ratio),
820 .mode = 0644,
821 .proc_handler = &proc_dointvec,
822 },
823 {
824 .ctl_name = VM_PAGE_CLUSTER,
825 .procname = "page-cluster",
826 .data = &page_cluster,
827 .maxlen = sizeof(int),
828 .mode = 0644,
829 .proc_handler = &proc_dointvec,
830 },
831 {
832 .ctl_name = VM_DIRTY_BACKGROUND,
833 .procname = "dirty_background_ratio",
834 .data = &dirty_background_ratio,
835 .maxlen = sizeof(dirty_background_ratio),
836 .mode = 0644,
837 .proc_handler = &proc_dointvec_minmax,
838 .strategy = &sysctl_intvec,
839 .extra1 = &zero,
840 .extra2 = &one_hundred,
841 },
842 {
843 .ctl_name = VM_DIRTY_RATIO,
844 .procname = "dirty_ratio",
845 .data = &vm_dirty_ratio,
846 .maxlen = sizeof(vm_dirty_ratio),
847 .mode = 0644,
848 .proc_handler = &proc_dointvec_minmax,
849 .strategy = &sysctl_intvec,
850 .extra1 = &zero,
851 .extra2 = &one_hundred,
852 },
853 {
854 .ctl_name = VM_DIRTY_WB_CS,
855 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -0800856 .data = &dirty_writeback_interval,
857 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 .mode = 0644,
859 .proc_handler = &dirty_writeback_centisecs_handler,
860 },
861 {
862 .ctl_name = VM_DIRTY_EXPIRE_CS,
863 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -0800864 .data = &dirty_expire_interval,
865 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 .mode = 0644,
Bart Samwelf6ef9432006-03-24 03:15:48 -0800867 .proc_handler = &proc_dointvec_userhz_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 },
869 {
870 .ctl_name = VM_NR_PDFLUSH_THREADS,
871 .procname = "nr_pdflush_threads",
872 .data = &nr_pdflush_threads,
873 .maxlen = sizeof nr_pdflush_threads,
874 .mode = 0444 /* read-only*/,
875 .proc_handler = &proc_dointvec,
876 },
877 {
878 .ctl_name = VM_SWAPPINESS,
879 .procname = "swappiness",
880 .data = &vm_swappiness,
881 .maxlen = sizeof(vm_swappiness),
882 .mode = 0644,
883 .proc_handler = &proc_dointvec_minmax,
884 .strategy = &sysctl_intvec,
885 .extra1 = &zero,
886 .extra2 = &one_hundred,
887 },
888#ifdef CONFIG_HUGETLB_PAGE
889 {
890 .ctl_name = VM_HUGETLB_PAGES,
891 .procname = "nr_hugepages",
892 .data = &max_huge_pages,
893 .maxlen = sizeof(unsigned long),
894 .mode = 0644,
895 .proc_handler = &hugetlb_sysctl_handler,
896 .extra1 = (void *)&hugetlb_zero,
897 .extra2 = (void *)&hugetlb_infinity,
898 },
899 {
900 .ctl_name = VM_HUGETLB_GROUP,
901 .procname = "hugetlb_shm_group",
902 .data = &sysctl_hugetlb_shm_group,
903 .maxlen = sizeof(gid_t),
904 .mode = 0644,
905 .proc_handler = &proc_dointvec,
906 },
907#endif
908 {
909 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
910 .procname = "lowmem_reserve_ratio",
911 .data = &sysctl_lowmem_reserve_ratio,
912 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
913 .mode = 0644,
914 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
915 .strategy = &sysctl_intvec,
916 },
917 {
Andrew Morton9d0243b2006-01-08 01:00:39 -0800918 .ctl_name = VM_DROP_PAGECACHE,
919 .procname = "drop_caches",
920 .data = &sysctl_drop_caches,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = drop_caches_sysctl_handler,
924 .strategy = &sysctl_intvec,
925 },
926 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 .ctl_name = VM_MIN_FREE_KBYTES,
928 .procname = "min_free_kbytes",
929 .data = &min_free_kbytes,
930 .maxlen = sizeof(min_free_kbytes),
931 .mode = 0644,
932 .proc_handler = &min_free_kbytes_sysctl_handler,
933 .strategy = &sysctl_intvec,
934 .extra1 = &zero,
935 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800936 {
937 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
938 .procname = "percpu_pagelist_fraction",
939 .data = &percpu_pagelist_fraction,
940 .maxlen = sizeof(percpu_pagelist_fraction),
941 .mode = 0644,
942 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
943 .strategy = &sysctl_intvec,
944 .extra1 = &min_percpu_pagelist_fract,
945 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946#ifdef CONFIG_MMU
947 {
948 .ctl_name = VM_MAX_MAP_COUNT,
949 .procname = "max_map_count",
950 .data = &sysctl_max_map_count,
951 .maxlen = sizeof(sysctl_max_map_count),
952 .mode = 0644,
953 .proc_handler = &proc_dointvec
954 },
955#endif
956 {
957 .ctl_name = VM_LAPTOP_MODE,
958 .procname = "laptop_mode",
959 .data = &laptop_mode,
960 .maxlen = sizeof(laptop_mode),
961 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -0800962 .proc_handler = &proc_dointvec_jiffies,
963 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 },
965 {
966 .ctl_name = VM_BLOCK_DUMP,
967 .procname = "block_dump",
968 .data = &block_dump,
969 .maxlen = sizeof(block_dump),
970 .mode = 0644,
971 .proc_handler = &proc_dointvec,
972 .strategy = &sysctl_intvec,
973 .extra1 = &zero,
974 },
975 {
976 .ctl_name = VM_VFS_CACHE_PRESSURE,
977 .procname = "vfs_cache_pressure",
978 .data = &sysctl_vfs_cache_pressure,
979 .maxlen = sizeof(sysctl_vfs_cache_pressure),
980 .mode = 0644,
981 .proc_handler = &proc_dointvec,
982 .strategy = &sysctl_intvec,
983 .extra1 = &zero,
984 },
985#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
986 {
987 .ctl_name = VM_LEGACY_VA_LAYOUT,
988 .procname = "legacy_va_layout",
989 .data = &sysctl_legacy_va_layout,
990 .maxlen = sizeof(sysctl_legacy_va_layout),
991 .mode = 0644,
992 .proc_handler = &proc_dointvec,
993 .strategy = &sysctl_intvec,
994 .extra1 = &zero,
995 },
996#endif
Christoph Lameter17436602006-01-18 17:42:32 -0800997#ifdef CONFIG_NUMA
998 {
999 .ctl_name = VM_ZONE_RECLAIM_MODE,
1000 .procname = "zone_reclaim_mode",
1001 .data = &zone_reclaim_mode,
1002 .maxlen = sizeof(zone_reclaim_mode),
1003 .mode = 0644,
1004 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001005 .strategy = &sysctl_intvec,
1006 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001007 },
Christoph Lameter96146342006-07-03 00:24:13 -07001008 {
1009 .ctl_name = VM_MIN_UNMAPPED,
1010 .procname = "min_unmapped_ratio",
1011 .data = &sysctl_min_unmapped_ratio,
1012 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1013 .mode = 0644,
1014 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1015 .strategy = &sysctl_intvec,
1016 .extra1 = &zero,
1017 .extra2 = &one_hundred,
1018 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001019 {
1020 .ctl_name = VM_MIN_SLAB,
1021 .procname = "min_slab_ratio",
1022 .data = &sysctl_min_slab_ratio,
1023 .maxlen = sizeof(sysctl_min_slab_ratio),
1024 .mode = 0644,
1025 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1026 .strategy = &sysctl_intvec,
1027 .extra1 = &zero,
1028 .extra2 = &one_hundred,
1029 },
Christoph Lameter17436602006-01-18 17:42:32 -08001030#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001031#ifdef CONFIG_X86_32
1032 {
1033 .ctl_name = VM_VDSO_ENABLED,
1034 .procname = "vdso_enabled",
1035 .data = &vdso_enabled,
1036 .maxlen = sizeof(vdso_enabled),
1037 .mode = 0644,
1038 .proc_handler = &proc_dointvec,
1039 .strategy = &sysctl_intvec,
1040 .extra1 = &zero,
1041 },
1042#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 { .ctl_name = 0 }
1044};
1045
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046static ctl_table fs_table[] = {
1047 {
1048 .ctl_name = FS_NRINODE,
1049 .procname = "inode-nr",
1050 .data = &inodes_stat,
1051 .maxlen = 2*sizeof(int),
1052 .mode = 0444,
1053 .proc_handler = &proc_dointvec,
1054 },
1055 {
1056 .ctl_name = FS_STATINODE,
1057 .procname = "inode-state",
1058 .data = &inodes_stat,
1059 .maxlen = 7*sizeof(int),
1060 .mode = 0444,
1061 .proc_handler = &proc_dointvec,
1062 },
1063 {
1064 .ctl_name = FS_NRFILE,
1065 .procname = "file-nr",
1066 .data = &files_stat,
1067 .maxlen = 3*sizeof(int),
1068 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001069 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 },
1071 {
1072 .ctl_name = FS_MAXFILE,
1073 .procname = "file-max",
1074 .data = &files_stat.max_files,
1075 .maxlen = sizeof(int),
1076 .mode = 0644,
1077 .proc_handler = &proc_dointvec,
1078 },
1079 {
1080 .ctl_name = FS_DENTRY,
1081 .procname = "dentry-state",
1082 .data = &dentry_stat,
1083 .maxlen = 6*sizeof(int),
1084 .mode = 0444,
1085 .proc_handler = &proc_dointvec,
1086 },
1087 {
1088 .ctl_name = FS_OVERFLOWUID,
1089 .procname = "overflowuid",
1090 .data = &fs_overflowuid,
1091 .maxlen = sizeof(int),
1092 .mode = 0644,
1093 .proc_handler = &proc_dointvec_minmax,
1094 .strategy = &sysctl_intvec,
1095 .extra1 = &minolduid,
1096 .extra2 = &maxolduid,
1097 },
1098 {
1099 .ctl_name = FS_OVERFLOWGID,
1100 .procname = "overflowgid",
1101 .data = &fs_overflowgid,
1102 .maxlen = sizeof(int),
1103 .mode = 0644,
1104 .proc_handler = &proc_dointvec_minmax,
1105 .strategy = &sysctl_intvec,
1106 .extra1 = &minolduid,
1107 .extra2 = &maxolduid,
1108 },
1109 {
1110 .ctl_name = FS_LEASES,
1111 .procname = "leases-enable",
1112 .data = &leases_enable,
1113 .maxlen = sizeof(int),
1114 .mode = 0644,
1115 .proc_handler = &proc_dointvec,
1116 },
1117#ifdef CONFIG_DNOTIFY
1118 {
1119 .ctl_name = FS_DIR_NOTIFY,
1120 .procname = "dir-notify-enable",
1121 .data = &dir_notify_enable,
1122 .maxlen = sizeof(int),
1123 .mode = 0644,
1124 .proc_handler = &proc_dointvec,
1125 },
1126#endif
1127#ifdef CONFIG_MMU
1128 {
1129 .ctl_name = FS_LEASE_TIME,
1130 .procname = "lease-break-time",
1131 .data = &lease_break_time,
1132 .maxlen = sizeof(int),
1133 .mode = 0644,
1134 .proc_handler = &proc_dointvec,
1135 },
1136 {
1137 .ctl_name = FS_AIO_NR,
1138 .procname = "aio-nr",
1139 .data = &aio_nr,
1140 .maxlen = sizeof(aio_nr),
1141 .mode = 0444,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001142 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 },
1144 {
1145 .ctl_name = FS_AIO_MAX_NR,
1146 .procname = "aio-max-nr",
1147 .data = &aio_max_nr,
1148 .maxlen = sizeof(aio_max_nr),
1149 .mode = 0644,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001150 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 },
Amy Griffis2d9048e2006-06-01 13:10:59 -07001152#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001153 {
1154 .ctl_name = FS_INOTIFY,
1155 .procname = "inotify",
1156 .mode = 0555,
1157 .child = inotify_table,
1158 },
1159#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001161 {
1162 .ctl_name = KERN_SETUID_DUMPABLE,
1163 .procname = "suid_dumpable",
1164 .data = &suid_dumpable,
1165 .maxlen = sizeof(int),
1166 .mode = 0644,
1167 .proc_handler = &proc_dointvec,
1168 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 { .ctl_name = 0 }
1170};
1171
1172static ctl_table debug_table[] = {
1173 { .ctl_name = 0 }
1174};
1175
1176static ctl_table dev_table[] = {
1177 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001178};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179
Al Viro330d57f2005-11-04 10:18:40 +00001180static DEFINE_SPINLOCK(sysctl_lock);
1181
1182/* called under sysctl_lock */
1183static int use_table(struct ctl_table_header *p)
1184{
1185 if (unlikely(p->unregistering))
1186 return 0;
1187 p->used++;
1188 return 1;
1189}
1190
1191/* called under sysctl_lock */
1192static void unuse_table(struct ctl_table_header *p)
1193{
1194 if (!--p->used)
1195 if (unlikely(p->unregistering))
1196 complete(p->unregistering);
1197}
1198
1199/* called under sysctl_lock, will reacquire if has to wait */
1200static void start_unregistering(struct ctl_table_header *p)
1201{
1202 /*
1203 * if p->used is 0, nobody will ever touch that entry again;
1204 * we'll eliminate all paths to it before dropping sysctl_lock
1205 */
1206 if (unlikely(p->used)) {
1207 struct completion wait;
1208 init_completion(&wait);
1209 p->unregistering = &wait;
1210 spin_unlock(&sysctl_lock);
1211 wait_for_completion(&wait);
1212 spin_lock(&sysctl_lock);
1213 }
1214 /*
1215 * do not remove from the list until nobody holds it; walking the
1216 * list in do_sysctl() relies on that.
1217 */
1218 list_del_init(&p->ctl_entry);
1219}
1220
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221void __init sysctl_init(void)
1222{
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001223#ifdef CONFIG_PROC_SYSCTL
Al Viro330d57f2005-11-04 10:18:40 +00001224 register_proc_table(root_table, proc_sys_root, &root_table_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225#endif
1226}
1227
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001228#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1230 void __user *newval, size_t newlen)
1231{
1232 struct list_head *tmp;
Al Viro330d57f2005-11-04 10:18:40 +00001233 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234
1235 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1236 return -ENOTDIR;
1237 if (oldval) {
1238 int old_len;
1239 if (!oldlenp || get_user(old_len, oldlenp))
1240 return -EFAULT;
1241 }
Al Viro330d57f2005-11-04 10:18:40 +00001242 spin_lock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 tmp = &root_table_header.ctl_entry;
1244 do {
1245 struct ctl_table_header *head =
1246 list_entry(tmp, struct ctl_table_header, ctl_entry);
Al Viro330d57f2005-11-04 10:18:40 +00001247
1248 if (!use_table(head))
1249 continue;
1250
1251 spin_unlock(&sysctl_lock);
1252
1253 error = parse_table(name, nlen, oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001254 newval, newlen, head->ctl_table);
Al Viro330d57f2005-11-04 10:18:40 +00001255
1256 spin_lock(&sysctl_lock);
1257 unuse_table(head);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 if (error != -ENOTDIR)
Al Viro330d57f2005-11-04 10:18:40 +00001259 break;
1260 } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
1261 spin_unlock(&sysctl_lock);
1262 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263}
1264
1265asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1266{
1267 struct __sysctl_args tmp;
1268 int error;
1269
1270 if (copy_from_user(&tmp, args, sizeof(tmp)))
1271 return -EFAULT;
1272
1273 lock_kernel();
1274 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1275 tmp.newval, tmp.newlen);
1276 unlock_kernel();
1277 return error;
1278}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001279#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280
1281/*
1282 * ctl_perm does NOT grant the superuser all rights automatically, because
1283 * some sysctl variables are readonly even to root.
1284 */
1285
1286static int test_perm(int mode, int op)
1287{
1288 if (!current->euid)
1289 mode >>= 6;
1290 else if (in_egroup_p(0))
1291 mode >>= 3;
1292 if ((mode & op & 0007) == op)
1293 return 0;
1294 return -EACCES;
1295}
1296
1297static inline int ctl_perm(ctl_table *table, int op)
1298{
1299 int error;
1300 error = security_sysctl(table, op);
1301 if (error)
1302 return error;
1303 return test_perm(table->mode, op);
1304}
1305
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001306#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307static int parse_table(int __user *name, int nlen,
1308 void __user *oldval, size_t __user *oldlenp,
1309 void __user *newval, size_t newlen,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001310 ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311{
1312 int n;
1313repeat:
1314 if (!nlen)
1315 return -ENOTDIR;
1316 if (get_user(n, name))
1317 return -EFAULT;
Eric W. Biedermand99f1602006-11-05 23:52:12 -08001318 for ( ; table->ctl_name || table->procname; table++) {
1319 if (!table->ctl_name)
1320 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1322 int error;
1323 if (table->child) {
1324 if (ctl_perm(table, 001))
1325 return -EPERM;
1326 if (table->strategy) {
1327 error = table->strategy(
1328 table, name, nlen,
1329 oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001330 newval, newlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 if (error)
1332 return error;
1333 }
1334 name++;
1335 nlen--;
1336 table = table->child;
1337 goto repeat;
1338 }
1339 error = do_sysctl_strategy(table, name, nlen,
1340 oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001341 newval, newlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 return error;
1343 }
1344 }
1345 return -ENOTDIR;
1346}
1347
1348/* Perform the actual read/write of a sysctl table entry. */
1349int do_sysctl_strategy (ctl_table *table,
1350 int __user *name, int nlen,
1351 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001352 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353{
1354 int op = 0, rc;
1355 size_t len;
1356
1357 if (oldval)
1358 op |= 004;
1359 if (newval)
1360 op |= 002;
1361 if (ctl_perm(table, op))
1362 return -EPERM;
1363
1364 if (table->strategy) {
1365 rc = table->strategy(table, name, nlen, oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001366 newval, newlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 if (rc < 0)
1368 return rc;
1369 if (rc > 0)
1370 return 0;
1371 }
1372
1373 /* If there is no strategy routine, or if the strategy returns
1374 * zero, proceed with automatic r/w */
1375 if (table->data && table->maxlen) {
1376 if (oldval && oldlenp) {
1377 if (get_user(len, oldlenp))
1378 return -EFAULT;
1379 if (len) {
1380 if (len > table->maxlen)
1381 len = table->maxlen;
1382 if(copy_to_user(oldval, table->data, len))
1383 return -EFAULT;
1384 if(put_user(len, oldlenp))
1385 return -EFAULT;
1386 }
1387 }
1388 if (newval && newlen) {
1389 len = newlen;
1390 if (len > table->maxlen)
1391 len = table->maxlen;
1392 if(copy_from_user(table->data, newval, len))
1393 return -EFAULT;
1394 }
1395 }
1396 return 0;
1397}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001398#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399
1400/**
1401 * register_sysctl_table - register a sysctl hierarchy
1402 * @table: the top-level table structure
1403 * @insert_at_head: whether the entry should be inserted in front or at the end
1404 *
1405 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1406 * array. An entry with a ctl_name of 0 terminates the table.
1407 *
1408 * The members of the &ctl_table structure are used as follows:
1409 *
1410 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1411 * must be unique within that level of sysctl
1412 *
1413 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1414 * enter a sysctl file
1415 *
1416 * data - a pointer to data for use by proc_handler
1417 *
1418 * maxlen - the maximum size in bytes of the data
1419 *
1420 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1421 *
1422 * child - a pointer to the child sysctl table if this entry is a directory, or
1423 * %NULL.
1424 *
1425 * proc_handler - the text handler routine (described below)
1426 *
1427 * strategy - the strategy routine (described below)
1428 *
1429 * de - for internal use by the sysctl routines
1430 *
1431 * extra1, extra2 - extra pointers usable by the proc handler routines
1432 *
1433 * Leaf nodes in the sysctl tree will be represented by a single file
1434 * under /proc; non-leaf nodes will be represented by directories.
1435 *
1436 * sysctl(2) can automatically manage read and write requests through
1437 * the sysctl table. The data and maxlen fields of the ctl_table
1438 * struct enable minimal validation of the values being written to be
1439 * performed, and the mode field allows minimal authentication.
1440 *
1441 * More sophisticated management can be enabled by the provision of a
1442 * strategy routine with the table entry. This will be called before
1443 * any automatic read or write of the data is performed.
1444 *
1445 * The strategy routine may return
1446 *
1447 * < 0 - Error occurred (error is passed to user process)
1448 *
1449 * 0 - OK - proceed with automatic read or write.
1450 *
1451 * > 0 - OK - read or write has been done by the strategy routine, so
1452 * return immediately.
1453 *
1454 * There must be a proc_handler routine for any terminal nodes
1455 * mirrored under /proc/sys (non-terminals are handled by a built-in
1456 * directory handler). Several default handlers are available to
1457 * cover common cases -
1458 *
1459 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1460 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1461 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1462 *
1463 * It is the handler's job to read the input buffer from user memory
1464 * and process it. The handler should return 0 on success.
1465 *
1466 * This routine returns %NULL on a failure to register, and a pointer
1467 * to the table header on success.
1468 */
1469struct ctl_table_header *register_sysctl_table(ctl_table * table,
1470 int insert_at_head)
1471{
1472 struct ctl_table_header *tmp;
1473 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1474 if (!tmp)
1475 return NULL;
1476 tmp->ctl_table = table;
1477 INIT_LIST_HEAD(&tmp->ctl_entry);
Al Viro330d57f2005-11-04 10:18:40 +00001478 tmp->used = 0;
1479 tmp->unregistering = NULL;
1480 spin_lock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 if (insert_at_head)
1482 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1483 else
1484 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
Al Viro330d57f2005-11-04 10:18:40 +00001485 spin_unlock(&sysctl_lock);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001486#ifdef CONFIG_PROC_SYSCTL
Al Viro330d57f2005-11-04 10:18:40 +00001487 register_proc_table(table, proc_sys_root, tmp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488#endif
1489 return tmp;
1490}
1491
1492/**
1493 * unregister_sysctl_table - unregister a sysctl table hierarchy
1494 * @header: the header returned from register_sysctl_table
1495 *
1496 * Unregisters the sysctl table and all children. proc entries may not
1497 * actually be removed until they are no longer used by anyone.
1498 */
1499void unregister_sysctl_table(struct ctl_table_header * header)
1500{
Al Viro330d57f2005-11-04 10:18:40 +00001501 might_sleep();
1502 spin_lock(&sysctl_lock);
1503 start_unregistering(header);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001504#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 unregister_proc_table(header->ctl_table, proc_sys_root);
1506#endif
Al Viro330d57f2005-11-04 10:18:40 +00001507 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 kfree(header);
1509}
1510
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001511#else /* !CONFIG_SYSCTL */
1512struct ctl_table_header * register_sysctl_table(ctl_table * table,
1513 int insert_at_head)
1514{
1515 return NULL;
1516}
1517
1518void unregister_sysctl_table(struct ctl_table_header * table)
1519{
1520}
1521
1522#endif /* CONFIG_SYSCTL */
1523
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524/*
1525 * /proc/sys support
1526 */
1527
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001528#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529
1530/* Scan the sysctl entries in table and add them all into /proc */
Al Viro330d57f2005-11-04 10:18:40 +00001531static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532{
1533 struct proc_dir_entry *de;
1534 int len;
1535 mode_t mode;
1536
Eric W. Biedermand99f1602006-11-05 23:52:12 -08001537 for (; table->ctl_name || table->procname; table++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 /* Can't do anything without a proc name. */
1539 if (!table->procname)
1540 continue;
1541 /* Maybe we can't do anything with it... */
1542 if (!table->proc_handler && !table->child) {
1543 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1544 table->procname);
1545 continue;
1546 }
1547
1548 len = strlen(table->procname);
1549 mode = table->mode;
1550
1551 de = NULL;
1552 if (table->proc_handler)
1553 mode |= S_IFREG;
1554 else {
1555 mode |= S_IFDIR;
1556 for (de = root->subdir; de; de = de->next) {
1557 if (proc_match(len, table->procname, de))
1558 break;
1559 }
1560 /* If the subdir exists already, de is non-NULL */
1561 }
1562
1563 if (!de) {
1564 de = create_proc_entry(table->procname, mode, root);
1565 if (!de)
1566 continue;
Al Viro330d57f2005-11-04 10:18:40 +00001567 de->set = set;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 de->data = (void *) table;
1569 if (table->proc_handler)
1570 de->proc_fops = &proc_sys_file_operations;
1571 }
1572 table->de = de;
1573 if (de->mode & S_IFDIR)
Al Viro330d57f2005-11-04 10:18:40 +00001574 register_proc_table(table->child, de, set);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 }
1576}
1577
1578/*
1579 * Unregister a /proc sysctl table and any subdirectories.
1580 */
1581static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1582{
1583 struct proc_dir_entry *de;
Eric W. Biedermand99f1602006-11-05 23:52:12 -08001584 for (; table->ctl_name || table->procname; table++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585 if (!(de = table->de))
1586 continue;
1587 if (de->mode & S_IFDIR) {
1588 if (!table->child) {
1589 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1590 continue;
1591 }
1592 unregister_proc_table(table->child, de);
1593
1594 /* Don't unregister directories which still have entries.. */
1595 if (de->subdir)
1596 continue;
1597 }
1598
Al Viro330d57f2005-11-04 10:18:40 +00001599 /*
1600 * In any case, mark the entry as goner; we'll keep it
1601 * around if it's busy, but we'll know to do nothing with
1602 * its fields. We are under sysctl_lock here.
1603 */
1604 de->data = NULL;
1605
Linus Torvalds1da177e2005-04-16 15:20:36 -07001606 /* Don't unregister proc entries that are still being used.. */
1607 if (atomic_read(&de->count))
1608 continue;
1609
1610 table->de = NULL;
1611 remove_proc_entry(table->procname, root);
1612 }
1613}
1614
1615static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1616 size_t count, loff_t *ppos)
1617{
1618 int op;
Josef "Jeff" Sipekf3a43f32006-12-08 02:36:43 -08001619 struct proc_dir_entry *de = PDE(file->f_path.dentry->d_inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620 struct ctl_table *table;
1621 size_t res;
Al Viro330d57f2005-11-04 10:18:40 +00001622 ssize_t error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623
Al Viro330d57f2005-11-04 10:18:40 +00001624 spin_lock(&sysctl_lock);
1625 if (de && de->data && use_table(de->set)) {
1626 /*
1627 * at that point we know that sysctl was not unregistered
1628 * and won't be until we finish
1629 */
1630 spin_unlock(&sysctl_lock);
1631 table = (struct ctl_table *) de->data;
1632 if (!table || !table->proc_handler)
1633 goto out;
1634 error = -EPERM;
1635 op = (write ? 002 : 004);
1636 if (ctl_perm(table, op))
1637 goto out;
1638
1639 /* careful: calling conventions are nasty here */
1640 res = count;
1641 error = (*table->proc_handler)(table, write, file,
1642 buf, &res, ppos);
1643 if (!error)
1644 error = res;
1645 out:
1646 spin_lock(&sysctl_lock);
1647 unuse_table(de->set);
1648 }
1649 spin_unlock(&sysctl_lock);
1650 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001651}
1652
1653static int proc_opensys(struct inode *inode, struct file *file)
1654{
1655 if (file->f_mode & FMODE_WRITE) {
1656 /*
1657 * sysctl entries that are not writable,
1658 * are _NOT_ writable, capabilities or not.
1659 */
1660 if (!(inode->i_mode & S_IWUSR))
1661 return -EPERM;
1662 }
1663
1664 return 0;
1665}
1666
1667static ssize_t proc_readsys(struct file * file, char __user * buf,
1668 size_t count, loff_t *ppos)
1669{
1670 return do_rw_proc(0, file, buf, count, ppos);
1671}
1672
1673static ssize_t proc_writesys(struct file * file, const char __user * buf,
1674 size_t count, loff_t *ppos)
1675{
1676 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1677}
1678
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001679static int _proc_do_string(void* data, int maxlen, int write,
1680 struct file *filp, void __user *buffer,
1681 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001682{
1683 size_t len;
1684 char __user *p;
1685 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001686
1687 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001688 *lenp = 0;
1689 return 0;
1690 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001691
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001692 if (write) {
1693 len = 0;
1694 p = buffer;
1695 while (len < *lenp) {
1696 if (get_user(c, p++))
1697 return -EFAULT;
1698 if (c == 0 || c == '\n')
1699 break;
1700 len++;
1701 }
1702 if (len >= maxlen)
1703 len = maxlen-1;
1704 if(copy_from_user(data, buffer, len))
1705 return -EFAULT;
1706 ((char *) data)[len] = 0;
1707 *ppos += *lenp;
1708 } else {
1709 len = strlen(data);
1710 if (len > maxlen)
1711 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001712
1713 if (*ppos > len) {
1714 *lenp = 0;
1715 return 0;
1716 }
1717
1718 data += *ppos;
1719 len -= *ppos;
1720
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001721 if (len > *lenp)
1722 len = *lenp;
1723 if (len)
1724 if(copy_to_user(buffer, data, len))
1725 return -EFAULT;
1726 if (len < *lenp) {
1727 if(put_user('\n', ((char __user *) buffer) + len))
1728 return -EFAULT;
1729 len++;
1730 }
1731 *lenp = len;
1732 *ppos += len;
1733 }
1734 return 0;
1735}
1736
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737/**
1738 * proc_dostring - read a string sysctl
1739 * @table: the sysctl table
1740 * @write: %TRUE if this is a write to the sysctl file
1741 * @filp: the file structure
1742 * @buffer: the user buffer
1743 * @lenp: the size of the user buffer
1744 * @ppos: file position
1745 *
1746 * Reads/writes a string from/to the user buffer. If the kernel
1747 * buffer provided is not large enough to hold the string, the
1748 * string is truncated. The copied string is %NULL-terminated.
1749 * If the string is being read by the user process, it is copied
1750 * and a newline '\n' is added. It is truncated if the buffer is
1751 * not large enough.
1752 *
1753 * Returns 0 on success.
1754 */
1755int proc_dostring(ctl_table *table, int write, struct file *filp,
1756 void __user *buffer, size_t *lenp, loff_t *ppos)
1757{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001758 return _proc_do_string(table->data, table->maxlen, write, filp,
1759 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760}
1761
1762/*
1763 * Special case of dostring for the UTS structure. This has locks
1764 * to observe. Should this be in kernel/sys.c ????
1765 */
Eric W. Biedermancf9f1512006-12-08 02:39:55 -08001766
Serge E. Hallyn8218c742006-10-02 02:18:15 -07001767static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 void __user *buffer, size_t *lenp, loff_t *ppos)
1769{
1770 int r;
Eric W. Biedermancf9f1512006-12-08 02:39:55 -08001771 void *which;
1772 which = get_uts(table, write);
1773 r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
1774 put_uts(table, write, which);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775 return r;
1776}
1777
1778static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1779 int *valp,
1780 int write, void *data)
1781{
1782 if (write) {
1783 *valp = *negp ? -*lvalp : *lvalp;
1784 } else {
1785 int val = *valp;
1786 if (val < 0) {
1787 *negp = -1;
1788 *lvalp = (unsigned long)-val;
1789 } else {
1790 *negp = 0;
1791 *lvalp = (unsigned long)val;
1792 }
1793 }
1794 return 0;
1795}
1796
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001797static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
1798 int write, struct file *filp, void __user *buffer,
1799 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1801 int write, void *data),
1802 void *data)
1803{
1804#define TMPBUFLEN 21
1805 int *i, vleft, first=1, neg, val;
1806 unsigned long lval;
1807 size_t left, len;
1808
1809 char buf[TMPBUFLEN], *p;
1810 char __user *s = buffer;
1811
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001812 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 (*ppos && !write)) {
1814 *lenp = 0;
1815 return 0;
1816 }
1817
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001818 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 vleft = table->maxlen / sizeof(*i);
1820 left = *lenp;
1821
1822 if (!conv)
1823 conv = do_proc_dointvec_conv;
1824
1825 for (; left && vleft--; i++, first=0) {
1826 if (write) {
1827 while (left) {
1828 char c;
1829 if (get_user(c, s))
1830 return -EFAULT;
1831 if (!isspace(c))
1832 break;
1833 left--;
1834 s++;
1835 }
1836 if (!left)
1837 break;
1838 neg = 0;
1839 len = left;
1840 if (len > sizeof(buf) - 1)
1841 len = sizeof(buf) - 1;
1842 if (copy_from_user(buf, s, len))
1843 return -EFAULT;
1844 buf[len] = 0;
1845 p = buf;
1846 if (*p == '-' && left > 1) {
1847 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08001848 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 }
1850 if (*p < '0' || *p > '9')
1851 break;
1852
1853 lval = simple_strtoul(p, &p, 0);
1854
1855 len = p-buf;
1856 if ((len < left) && *p && !isspace(*p))
1857 break;
1858 if (neg)
1859 val = -val;
1860 s += len;
1861 left -= len;
1862
1863 if (conv(&neg, &lval, i, 1, data))
1864 break;
1865 } else {
1866 p = buf;
1867 if (!first)
1868 *p++ = '\t';
1869
1870 if (conv(&neg, &lval, i, 0, data))
1871 break;
1872
1873 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1874 len = strlen(buf);
1875 if (len > left)
1876 len = left;
1877 if(copy_to_user(s, buf, len))
1878 return -EFAULT;
1879 left -= len;
1880 s += len;
1881 }
1882 }
1883
1884 if (!write && !first && left) {
1885 if(put_user('\n', s))
1886 return -EFAULT;
1887 left--, s++;
1888 }
1889 if (write) {
1890 while (left) {
1891 char c;
1892 if (get_user(c, s++))
1893 return -EFAULT;
1894 if (!isspace(c))
1895 break;
1896 left--;
1897 }
1898 }
1899 if (write && first)
1900 return -EINVAL;
1901 *lenp -= left;
1902 *ppos += *lenp;
1903 return 0;
1904#undef TMPBUFLEN
1905}
1906
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001907static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1908 void __user *buffer, size_t *lenp, loff_t *ppos,
1909 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1910 int write, void *data),
1911 void *data)
1912{
1913 return __do_proc_dointvec(table->data, table, write, filp,
1914 buffer, lenp, ppos, conv, data);
1915}
1916
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917/**
1918 * proc_dointvec - read a vector of integers
1919 * @table: the sysctl table
1920 * @write: %TRUE if this is a write to the sysctl file
1921 * @filp: the file structure
1922 * @buffer: the user buffer
1923 * @lenp: the size of the user buffer
1924 * @ppos: file position
1925 *
1926 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1927 * values from/to the user buffer, treated as an ASCII string.
1928 *
1929 * Returns 0 on success.
1930 */
1931int proc_dointvec(ctl_table *table, int write, struct file *filp,
1932 void __user *buffer, size_t *lenp, loff_t *ppos)
1933{
1934 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1935 NULL,NULL);
1936}
1937
1938#define OP_SET 0
1939#define OP_AND 1
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001940#define OP_OR 2
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941
1942static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1943 int *valp,
1944 int write, void *data)
1945{
1946 int op = *(int *)data;
1947 if (write) {
1948 int val = *negp ? -*lvalp : *lvalp;
1949 switch(op) {
1950 case OP_SET: *valp = val; break;
1951 case OP_AND: *valp &= val; break;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001952 case OP_OR: *valp |= val; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953 }
1954 } else {
1955 int val = *valp;
1956 if (val < 0) {
1957 *negp = -1;
1958 *lvalp = (unsigned long)-val;
1959 } else {
1960 *negp = 0;
1961 *lvalp = (unsigned long)val;
1962 }
1963 }
1964 return 0;
1965}
1966
1967/*
1968 * init may raise the set.
1969 */
1970
1971int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1972 void __user *buffer, size_t *lenp, loff_t *ppos)
1973{
1974 int op;
1975
Eric Paris6ff1b442007-02-10 01:43:19 -08001976 if (write && !capable(CAP_SYS_MODULE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 return -EPERM;
1978 }
1979
Sukadev Bhattiproluf400e192006-09-29 02:00:07 -07001980 op = is_init(current) ? OP_SET : OP_AND;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1982 do_proc_dointvec_bset_conv,&op);
1983}
1984
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001985/*
1986 * Taint values can only be increased
1987 */
1988static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp,
1989 void __user *buffer, size_t *lenp, loff_t *ppos)
1990{
1991 int op;
1992
1993 if (!capable(CAP_SYS_ADMIN))
1994 return -EPERM;
1995
1996 op = OP_OR;
1997 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1998 do_proc_dointvec_bset_conv,&op);
1999}
2000
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001struct do_proc_dointvec_minmax_conv_param {
2002 int *min;
2003 int *max;
2004};
2005
2006static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2007 int *valp,
2008 int write, void *data)
2009{
2010 struct do_proc_dointvec_minmax_conv_param *param = data;
2011 if (write) {
2012 int val = *negp ? -*lvalp : *lvalp;
2013 if ((param->min && *param->min > val) ||
2014 (param->max && *param->max < val))
2015 return -EINVAL;
2016 *valp = val;
2017 } else {
2018 int val = *valp;
2019 if (val < 0) {
2020 *negp = -1;
2021 *lvalp = (unsigned long)-val;
2022 } else {
2023 *negp = 0;
2024 *lvalp = (unsigned long)val;
2025 }
2026 }
2027 return 0;
2028}
2029
2030/**
2031 * proc_dointvec_minmax - read a vector of integers with min/max values
2032 * @table: the sysctl table
2033 * @write: %TRUE if this is a write to the sysctl file
2034 * @filp: the file structure
2035 * @buffer: the user buffer
2036 * @lenp: the size of the user buffer
2037 * @ppos: file position
2038 *
2039 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2040 * values from/to the user buffer, treated as an ASCII string.
2041 *
2042 * This routine will ensure the values are within the range specified by
2043 * table->extra1 (min) and table->extra2 (max).
2044 *
2045 * Returns 0 on success.
2046 */
2047int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2048 void __user *buffer, size_t *lenp, loff_t *ppos)
2049{
2050 struct do_proc_dointvec_minmax_conv_param param = {
2051 .min = (int *) table->extra1,
2052 .max = (int *) table->extra2,
2053 };
2054 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2055 do_proc_dointvec_minmax_conv, &param);
2056}
2057
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002058static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 struct file *filp,
2060 void __user *buffer,
2061 size_t *lenp, loff_t *ppos,
2062 unsigned long convmul,
2063 unsigned long convdiv)
2064{
2065#define TMPBUFLEN 21
2066 unsigned long *i, *min, *max, val;
2067 int vleft, first=1, neg;
2068 size_t len, left;
2069 char buf[TMPBUFLEN], *p;
2070 char __user *s = buffer;
2071
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002072 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 (*ppos && !write)) {
2074 *lenp = 0;
2075 return 0;
2076 }
2077
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002078 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 min = (unsigned long *) table->extra1;
2080 max = (unsigned long *) table->extra2;
2081 vleft = table->maxlen / sizeof(unsigned long);
2082 left = *lenp;
2083
2084 for (; left && vleft--; i++, min++, max++, first=0) {
2085 if (write) {
2086 while (left) {
2087 char c;
2088 if (get_user(c, s))
2089 return -EFAULT;
2090 if (!isspace(c))
2091 break;
2092 left--;
2093 s++;
2094 }
2095 if (!left)
2096 break;
2097 neg = 0;
2098 len = left;
2099 if (len > TMPBUFLEN-1)
2100 len = TMPBUFLEN-1;
2101 if (copy_from_user(buf, s, len))
2102 return -EFAULT;
2103 buf[len] = 0;
2104 p = buf;
2105 if (*p == '-' && left > 1) {
2106 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002107 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 }
2109 if (*p < '0' || *p > '9')
2110 break;
2111 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2112 len = p-buf;
2113 if ((len < left) && *p && !isspace(*p))
2114 break;
2115 if (neg)
2116 val = -val;
2117 s += len;
2118 left -= len;
2119
2120 if(neg)
2121 continue;
2122 if ((min && val < *min) || (max && val > *max))
2123 continue;
2124 *i = val;
2125 } else {
2126 p = buf;
2127 if (!first)
2128 *p++ = '\t';
2129 sprintf(p, "%lu", convdiv * (*i) / convmul);
2130 len = strlen(buf);
2131 if (len > left)
2132 len = left;
2133 if(copy_to_user(s, buf, len))
2134 return -EFAULT;
2135 left -= len;
2136 s += len;
2137 }
2138 }
2139
2140 if (!write && !first && left) {
2141 if(put_user('\n', s))
2142 return -EFAULT;
2143 left--, s++;
2144 }
2145 if (write) {
2146 while (left) {
2147 char c;
2148 if (get_user(c, s++))
2149 return -EFAULT;
2150 if (!isspace(c))
2151 break;
2152 left--;
2153 }
2154 }
2155 if (write && first)
2156 return -EINVAL;
2157 *lenp -= left;
2158 *ppos += *lenp;
2159 return 0;
2160#undef TMPBUFLEN
2161}
2162
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002163static int do_proc_doulongvec_minmax(ctl_table *table, int write,
2164 struct file *filp,
2165 void __user *buffer,
2166 size_t *lenp, loff_t *ppos,
2167 unsigned long convmul,
2168 unsigned long convdiv)
2169{
2170 return __do_proc_doulongvec_minmax(table->data, table, write,
2171 filp, buffer, lenp, ppos, convmul, convdiv);
2172}
2173
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174/**
2175 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2176 * @table: the sysctl table
2177 * @write: %TRUE if this is a write to the sysctl file
2178 * @filp: the file structure
2179 * @buffer: the user buffer
2180 * @lenp: the size of the user buffer
2181 * @ppos: file position
2182 *
2183 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2184 * values from/to the user buffer, treated as an ASCII string.
2185 *
2186 * This routine will ensure the values are within the range specified by
2187 * table->extra1 (min) and table->extra2 (max).
2188 *
2189 * Returns 0 on success.
2190 */
2191int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2192 void __user *buffer, size_t *lenp, loff_t *ppos)
2193{
2194 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2195}
2196
2197/**
2198 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2199 * @table: the sysctl table
2200 * @write: %TRUE if this is a write to the sysctl file
2201 * @filp: the file structure
2202 * @buffer: the user buffer
2203 * @lenp: the size of the user buffer
2204 * @ppos: file position
2205 *
2206 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2207 * values from/to the user buffer, treated as an ASCII string. The values
2208 * are treated as milliseconds, and converted to jiffies when they are stored.
2209 *
2210 * This routine will ensure the values are within the range specified by
2211 * table->extra1 (min) and table->extra2 (max).
2212 *
2213 * Returns 0 on success.
2214 */
2215int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2216 struct file *filp,
2217 void __user *buffer,
2218 size_t *lenp, loff_t *ppos)
2219{
2220 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2221 lenp, ppos, HZ, 1000l);
2222}
2223
2224
2225static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2226 int *valp,
2227 int write, void *data)
2228{
2229 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002230 if (*lvalp > LONG_MAX / HZ)
2231 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2233 } else {
2234 int val = *valp;
2235 unsigned long lval;
2236 if (val < 0) {
2237 *negp = -1;
2238 lval = (unsigned long)-val;
2239 } else {
2240 *negp = 0;
2241 lval = (unsigned long)val;
2242 }
2243 *lvalp = lval / HZ;
2244 }
2245 return 0;
2246}
2247
2248static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2249 int *valp,
2250 int write, void *data)
2251{
2252 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002253 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2254 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2256 } else {
2257 int val = *valp;
2258 unsigned long lval;
2259 if (val < 0) {
2260 *negp = -1;
2261 lval = (unsigned long)-val;
2262 } else {
2263 *negp = 0;
2264 lval = (unsigned long)val;
2265 }
2266 *lvalp = jiffies_to_clock_t(lval);
2267 }
2268 return 0;
2269}
2270
2271static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2272 int *valp,
2273 int write, void *data)
2274{
2275 if (write) {
2276 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2277 } else {
2278 int val = *valp;
2279 unsigned long lval;
2280 if (val < 0) {
2281 *negp = -1;
2282 lval = (unsigned long)-val;
2283 } else {
2284 *negp = 0;
2285 lval = (unsigned long)val;
2286 }
2287 *lvalp = jiffies_to_msecs(lval);
2288 }
2289 return 0;
2290}
2291
2292/**
2293 * proc_dointvec_jiffies - read a vector of integers as seconds
2294 * @table: the sysctl table
2295 * @write: %TRUE if this is a write to the sysctl file
2296 * @filp: the file structure
2297 * @buffer: the user buffer
2298 * @lenp: the size of the user buffer
2299 * @ppos: file position
2300 *
2301 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2302 * values from/to the user buffer, treated as an ASCII string.
2303 * The values read are assumed to be in seconds, and are converted into
2304 * jiffies.
2305 *
2306 * Returns 0 on success.
2307 */
2308int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2309 void __user *buffer, size_t *lenp, loff_t *ppos)
2310{
2311 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2312 do_proc_dointvec_jiffies_conv,NULL);
2313}
2314
2315/**
2316 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2317 * @table: the sysctl table
2318 * @write: %TRUE if this is a write to the sysctl file
2319 * @filp: the file structure
2320 * @buffer: the user buffer
2321 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002322 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002323 *
2324 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2325 * values from/to the user buffer, treated as an ASCII string.
2326 * The values read are assumed to be in 1/USER_HZ seconds, and
2327 * are converted into jiffies.
2328 *
2329 * Returns 0 on success.
2330 */
2331int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2332 void __user *buffer, size_t *lenp, loff_t *ppos)
2333{
2334 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2335 do_proc_dointvec_userhz_jiffies_conv,NULL);
2336}
2337
2338/**
2339 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2340 * @table: the sysctl table
2341 * @write: %TRUE if this is a write to the sysctl file
2342 * @filp: the file structure
2343 * @buffer: the user buffer
2344 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002345 * @ppos: file position
2346 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 *
2348 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2349 * values from/to the user buffer, treated as an ASCII string.
2350 * The values read are assumed to be in 1/1000 seconds, and
2351 * are converted into jiffies.
2352 *
2353 * Returns 0 on success.
2354 */
2355int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2356 void __user *buffer, size_t *lenp, loff_t *ppos)
2357{
2358 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2359 do_proc_dointvec_ms_jiffies_conv, NULL);
2360}
2361
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002362#ifdef CONFIG_SYSVIPC
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -08002363static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
2364 void __user *buffer, size_t *lenp, loff_t *ppos)
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002365{
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -08002366 void *which;
2367 which = get_ipc(table, write);
2368 return __do_proc_dointvec(which, table, write, filp, buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002369 lenp, ppos, NULL, NULL);
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -08002370}
2371
2372static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
2373 struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
2374{
2375 void *which;
2376 which = get_ipc(table, write);
2377 return __do_proc_doulongvec_minmax(which, table, write, filp, buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002378 lenp, ppos, 1l, 1l);
2379}
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -08002380
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002381#endif
2382
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002383static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
2384 void __user *buffer, size_t *lenp, loff_t *ppos)
2385{
2386 struct pid *new_pid;
2387 pid_t tmp;
2388 int r;
2389
2390 tmp = pid_nr(cad_pid);
2391
2392 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2393 lenp, ppos, NULL, NULL);
2394 if (r || !write)
2395 return r;
2396
2397 new_pid = find_get_pid(tmp);
2398 if (!new_pid)
2399 return -ESRCH;
2400
2401 put_pid(xchg(&cad_pid, new_pid));
2402 return 0;
2403}
2404
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405#else /* CONFIG_PROC_FS */
2406
2407int proc_dostring(ctl_table *table, int write, struct file *filp,
2408 void __user *buffer, size_t *lenp, loff_t *ppos)
2409{
2410 return -ENOSYS;
2411}
2412
Serge E. Hallyn8218c742006-10-02 02:18:15 -07002413static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
2414 void __user *buffer, size_t *lenp, loff_t *ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415{
2416 return -ENOSYS;
2417}
2418
Serge E. Hallyn8218c742006-10-02 02:18:15 -07002419#ifdef CONFIG_SYSVIPC
2420static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
2421 void __user *buffer, size_t *lenp, loff_t *ppos)
2422{
2423 return -ENOSYS;
2424}
Randy Dunlapd53ef072006-12-10 02:18:36 -08002425static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
2426 void __user *buffer, size_t *lenp, loff_t *ppos)
2427{
2428 return -ENOSYS;
2429}
2430static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
2431 struct file *filp, void __user *buffer,
2432 size_t *lenp, loff_t *ppos)
2433{
2434 return -ENOSYS;
2435}
Serge E. Hallyn8218c742006-10-02 02:18:15 -07002436#endif
2437
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438int proc_dointvec(ctl_table *table, int write, struct file *filp,
2439 void __user *buffer, size_t *lenp, loff_t *ppos)
2440{
2441 return -ENOSYS;
2442}
2443
2444int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2445 void __user *buffer, size_t *lenp, loff_t *ppos)
2446{
2447 return -ENOSYS;
2448}
2449
2450int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2451 void __user *buffer, size_t *lenp, loff_t *ppos)
2452{
2453 return -ENOSYS;
2454}
2455
2456int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2457 void __user *buffer, size_t *lenp, loff_t *ppos)
2458{
2459 return -ENOSYS;
2460}
2461
2462int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2463 void __user *buffer, size_t *lenp, loff_t *ppos)
2464{
2465 return -ENOSYS;
2466}
2467
2468int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2469 void __user *buffer, size_t *lenp, loff_t *ppos)
2470{
2471 return -ENOSYS;
2472}
2473
2474int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2475 void __user *buffer, size_t *lenp, loff_t *ppos)
2476{
2477 return -ENOSYS;
2478}
2479
2480int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2481 struct file *filp,
2482 void __user *buffer,
2483 size_t *lenp, loff_t *ppos)
2484{
2485 return -ENOSYS;
2486}
2487
2488
2489#endif /* CONFIG_PROC_FS */
2490
2491
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002492#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493/*
2494 * General sysctl support routines
2495 */
2496
2497/* The generic string strategy routine: */
2498int sysctl_string(ctl_table *table, int __user *name, int nlen,
2499 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002500 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502 if (!table->data || !table->maxlen)
2503 return -ENOTDIR;
2504
2505 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002506 size_t bufsize;
2507 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002509 if (bufsize) {
2510 size_t len = strlen(table->data), copied;
2511
2512 /* This shouldn't trigger for a well-formed sysctl */
2513 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002515
2516 /* Copy up to a max of bufsize-1 bytes of the string */
2517 copied = (len >= bufsize) ? bufsize - 1 : len;
2518
2519 if (copy_to_user(oldval, table->data, copied) ||
2520 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002522 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523 return -EFAULT;
2524 }
2525 }
2526 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002527 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 if (len > table->maxlen)
2529 len = table->maxlen;
2530 if(copy_from_user(table->data, newval, len))
2531 return -EFAULT;
2532 if (len == table->maxlen)
2533 len--;
2534 ((char *) table->data)[len] = 0;
2535 }
Yi Yang82c9df82005-12-30 16:37:10 +08002536 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537}
2538
2539/*
2540 * This function makes sure that all of the integers in the vector
2541 * are between the minimum and maximum values given in the arrays
2542 * table->extra1 and table->extra2, respectively.
2543 */
2544int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2545 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002546 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547{
2548
2549 if (newval && newlen) {
2550 int __user *vec = (int __user *) newval;
2551 int *min = (int *) table->extra1;
2552 int *max = (int *) table->extra2;
2553 size_t length;
2554 int i;
2555
2556 if (newlen % sizeof(int) != 0)
2557 return -EINVAL;
2558
2559 if (!table->extra1 && !table->extra2)
2560 return 0;
2561
2562 if (newlen > table->maxlen)
2563 newlen = table->maxlen;
2564 length = newlen / sizeof(int);
2565
2566 for (i = 0; i < length; i++) {
2567 int value;
2568 if (get_user(value, vec + i))
2569 return -EFAULT;
2570 if (min && value < min[i])
2571 return -EINVAL;
2572 if (max && value > max[i])
2573 return -EINVAL;
2574 }
2575 }
2576 return 0;
2577}
2578
2579/* Strategy function to convert jiffies to seconds */
2580int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2581 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002582 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002584 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002586
2587 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002589 if (olen) {
2590 int val;
2591
2592 if (olen < sizeof(int))
2593 return -EINVAL;
2594
2595 val = *(int *)(table->data) / HZ;
2596 if (put_user(val, (int __user *)oldval))
2597 return -EFAULT;
2598 if (put_user(sizeof(int), oldlenp))
2599 return -EFAULT;
2600 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 }
2602 if (newval && newlen) {
2603 int new;
2604 if (newlen != sizeof(int))
2605 return -EINVAL;
2606 if (get_user(new, (int __user *)newval))
2607 return -EFAULT;
2608 *(int *)(table->data) = new*HZ;
2609 }
2610 return 1;
2611}
2612
2613/* Strategy function to convert jiffies to seconds */
2614int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2615 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002616 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002618 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002620
2621 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002623 if (olen) {
2624 int val;
2625
2626 if (olen < sizeof(int))
2627 return -EINVAL;
2628
2629 val = jiffies_to_msecs(*(int *)(table->data));
2630 if (put_user(val, (int __user *)oldval))
2631 return -EFAULT;
2632 if (put_user(sizeof(int), oldlenp))
2633 return -EFAULT;
2634 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 }
2636 if (newval && newlen) {
2637 int new;
2638 if (newlen != sizeof(int))
2639 return -EINVAL;
2640 if (get_user(new, (int __user *)newval))
2641 return -EFAULT;
2642 *(int *)(table->data) = msecs_to_jiffies(new);
2643 }
2644 return 1;
2645}
2646
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002647
2648/* The generic string strategy routine: */
2649static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2650 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002651 void __user *newval, size_t newlen)
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002652{
2653 struct ctl_table uts_table;
2654 int r, write;
2655 write = newval && newlen;
2656 memcpy(&uts_table, table, sizeof(uts_table));
2657 uts_table.data = get_uts(table, write);
2658 r = sysctl_string(&uts_table, name, nlen,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002659 oldval, oldlenp, newval, newlen);
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002660 put_uts(table, write, uts_table.data);
2661 return r;
2662}
2663
Eric W. Biederman6b49a252006-12-08 02:39:57 -08002664#ifdef CONFIG_SYSVIPC
2665/* The generic sysctl ipc data routine. */
2666static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2667 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002668 void __user *newval, size_t newlen)
Eric W. Biederman6b49a252006-12-08 02:39:57 -08002669{
2670 size_t len;
2671 void *data;
2672
2673 /* Get out of I don't have a variable */
2674 if (!table->data || !table->maxlen)
2675 return -ENOTDIR;
2676
2677 data = get_ipc(table, 1);
2678 if (!data)
2679 return -ENOTDIR;
2680
2681 if (oldval && oldlenp) {
2682 if (get_user(len, oldlenp))
2683 return -EFAULT;
2684 if (len) {
2685 if (len > table->maxlen)
2686 len = table->maxlen;
2687 if (copy_to_user(oldval, data, len))
2688 return -EFAULT;
2689 if (put_user(len, oldlenp))
2690 return -EFAULT;
2691 }
2692 }
2693
2694 if (newval && newlen) {
2695 if (newlen > table->maxlen)
2696 newlen = table->maxlen;
2697
2698 if (copy_from_user(data, newval, newlen))
2699 return -EFAULT;
2700 }
2701 return 1;
2702}
2703#endif
2704
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002705#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706
2707
2708asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2709{
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002710 static int msg_count;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002711 struct __sysctl_args tmp;
2712 int name[CTL_MAXNAME];
2713 int i;
2714
2715 /* Read in the sysctl name for better debug message logging */
2716 if (copy_from_user(&tmp, args, sizeof(tmp)))
2717 return -EFAULT;
2718 if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
2719 return -ENOTDIR;
2720 for (i = 0; i < tmp.nlen; i++)
2721 if (get_user(name[i], tmp.name + i))
2722 return -EFAULT;
2723
2724 /* Ignore accesses to kernel.version */
2725 if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2726 goto out;
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002727
2728 if (msg_count < 5) {
2729 msg_count++;
2730 printk(KERN_INFO
2731 "warning: process `%s' used the removed sysctl "
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002732 "system call with ", current->comm);
2733 for (i = 0; i < tmp.nlen; i++)
2734 printk("%d.", name[i]);
2735 printk("\n");
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002736 }
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002737out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 return -ENOSYS;
2739}
2740
2741int sysctl_string(ctl_table *table, int __user *name, int nlen,
2742 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002743 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744{
2745 return -ENOSYS;
2746}
2747
2748int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2749 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002750 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751{
2752 return -ENOSYS;
2753}
2754
2755int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2756 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002757 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758{
2759 return -ENOSYS;
2760}
2761
2762int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2763 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002764 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002765{
2766 return -ENOSYS;
2767}
2768
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002769static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2770 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002771 void __user *newval, size_t newlen)
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002772{
2773 return -ENOSYS;
2774}
Andrew Mortoncb799b82007-02-10 01:45:51 -08002775#ifdef CONFIG_SYSVIPC
Eric W. Biederman6b49a252006-12-08 02:39:57 -08002776static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2777 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002778 void __user *newval, size_t newlen)
Eric W. Biederman6b49a252006-12-08 02:39:57 -08002779{
2780 return -ENOSYS;
2781}
Andrew Mortoncb799b82007-02-10 01:45:51 -08002782#endif
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002783#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002784
2785/*
2786 * No sense putting this after each symbol definition, twice,
2787 * exception granted :-)
2788 */
2789EXPORT_SYMBOL(proc_dointvec);
2790EXPORT_SYMBOL(proc_dointvec_jiffies);
2791EXPORT_SYMBOL(proc_dointvec_minmax);
2792EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2793EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2794EXPORT_SYMBOL(proc_dostring);
2795EXPORT_SYMBOL(proc_doulongvec_minmax);
2796EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2797EXPORT_SYMBOL(register_sysctl_table);
2798EXPORT_SYMBOL(sysctl_intvec);
2799EXPORT_SYMBOL(sysctl_jiffies);
2800EXPORT_SYMBOL(sysctl_ms_jiffies);
2801EXPORT_SYMBOL(sysctl_string);
2802EXPORT_SYMBOL(unregister_sysctl_table);