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