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