kthread: rename probe_kthread_data() to kthread_probe_data()
[linux-2.6-block.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 21#include <linux/module.h>
e2e40f2c 22#include <linux/aio.h>
1da177e4
LT
23#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
5a04cca6 27#include <linux/bitmap.h>
d33ed52d 28#include <linux/signal.h>
455cd5ab 29#include <linux/printk.h>
1da177e4 30#include <linux/proc_fs.h>
72c2d582 31#include <linux/security.h>
1da177e4 32#include <linux/ctype.h>
dfec072e 33#include <linux/kmemcheck.h>
fd4b616b 34#include <linux/kmemleak.h>
62239ac2 35#include <linux/fs.h>
1da177e4
LT
36#include <linux/init.h>
37#include <linux/kernel.h>
0296b228 38#include <linux/kobject.h>
20380731 39#include <linux/net.h>
1da177e4
LT
40#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
3fff4c42 43#include <linux/ratelimit.h>
76ab0f53 44#include <linux/compaction.h>
1da177e4 45#include <linux/hugetlb.h>
1da177e4 46#include <linux/initrd.h>
0b77f5bf 47#include <linux/key.h>
1da177e4
LT
48#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
6e006701 51#include <linux/dnotify.h>
1da177e4 52#include <linux/syscalls.h>
c748e134 53#include <linux/vmstat.h>
c255d844
PM
54#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
10a0a8d4 56#include <linux/reboot.h>
b0fc494f 57#include <linux/ftrace.h>
cdd6c482 58#include <linux/perf_event.h>
b2be84df 59#include <linux/kprobes.h>
b492e95b 60#include <linux/pipe_fs_i.h>
8e4228e1 61#include <linux/oom.h>
17f60a7d 62#include <linux/kmod.h>
73efc039 63#include <linux/capability.h>
40401530 64#include <linux/binfmts.h>
cf4aebc2 65#include <linux/sched/sysctl.h>
7984754b 66#include <linux/kexec.h>
1be7f75d 67#include <linux/bpf.h>
d2921684 68#include <linux/mount.h>
1da177e4
LT
69
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
29cbc78b
AK
73#ifdef CONFIG_X86
74#include <asm/nmi.h>
0741f4d2 75#include <asm/stacktrace.h>
6e7c4025 76#include <asm/io.h>
29cbc78b 77#endif
d550bbd4
DH
78#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
c55b7c3e
DY
81#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
4f0e056f
DY
84#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
2edf5e49
DY
87#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
15485a46
DY
90#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
29cbc78b 93
58687acb 94#ifdef CONFIG_LOCKUP_DETECTOR
504d7cf1
DZ
95#include <linux/nmi.h>
96#endif
97
1da177e4
LT
98#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
d6e71144 101extern int suid_dumpable;
046d662f
AK
102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
1da177e4 104extern char core_pattern[];
a293980c 105extern unsigned int core_pipe_limit;
046d662f 106#endif
1da177e4 107extern int pid_max;
1da177e4 108extern int pid_max_min, pid_max_max;
8ad4b1fb 109extern int percpu_pagelist_fraction;
9745512c 110extern int latencytop_enabled;
9b80a184 111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
dd8632a1
PM
112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
1da177e4 115
c4f3b63f 116/* Constants used for minimum and maximum */
2508ce18 117#ifdef CONFIG_LOCKUP_DETECTOR
c4f3b63f
RT
118static int sixty = 60;
119#endif
120
270750db
AT
121static int __maybe_unused neg_one = -1;
122
c4f3b63f 123static int zero;
cd5f9a4c
LT
124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
5509a5d2 126static int __maybe_unused four = 4;
fc3501d4 127static unsigned long one_ul = 1;
c4f3b63f 128static int one_hundred = 100;
795ae7a0 129static int one_thousand = 1000;
af91322e
DY
130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
c5dfd78e
ACM
133#ifdef CONFIG_PERF_EVENTS
134static int six_hundred_forty_kb = 640 * 1024;
135#endif
c4f3b63f 136
9e4a5bda
AR
137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
1da177e4
LT
140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
143
144static int ngroups_max = NGROUPS_MAX;
73efc039 145static const int cap_last_cap = CAP_LAST_CAP;
1da177e4 146
80df2847
LH
147/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148#ifdef CONFIG_DETECT_HUNG_TASK
149static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150#endif
151
d14f1729
DY
152#ifdef CONFIG_INOTIFY_USER
153#include <linux/inotify.h>
154#endif
72c57ed5 155#ifdef CONFIG_SPARC
1da177e4
LT
156#endif
157
158#ifdef __hppa__
159extern int pwrsw_enabled;
bf14e3b9
VG
160#endif
161
162#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1da177e4
LT
163extern int unaligned_enabled;
164#endif
1da177e4 165
d2b176ed 166#ifdef CONFIG_IA64
88fc241f 167extern int unaligned_dump_stack;
d2b176ed
JS
168#endif
169
b6fca725
VG
170#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171extern int no_unaligned_warning;
172#endif
173
d6f8ff73 174#ifdef CONFIG_PROC_SYSCTL
f4aacea2
KC
175
176#define SYSCTL_WRITES_LEGACY -1
177#define SYSCTL_WRITES_WARN 0
178#define SYSCTL_WRITES_STRICT 1
179
41662f5c 180static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
f4aacea2 181
8d65af78 182static int proc_do_cad_pid(struct ctl_table *table, int write,
9ec52099 183 void __user *buffer, size_t *lenp, loff_t *ppos);
8d65af78 184static int proc_taint(struct ctl_table *table, int write,
34f5a398 185 void __user *buffer, size_t *lenp, loff_t *ppos);
d6f8ff73 186#endif
9ec52099 187
bfdc0b49 188#ifdef CONFIG_PRINTK
620f6e8e 189static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
bfdc0b49
RW
190 void __user *buffer, size_t *lenp, loff_t *ppos);
191#endif
192
54b50199
KC
193static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
194 void __user *buffer, size_t *lenp, loff_t *ppos);
046d662f 195#ifdef CONFIG_COREDUMP
54b50199
KC
196static int proc_dostring_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
046d662f 198#endif
54b50199 199
97f5f0cd 200#ifdef CONFIG_MAGIC_SYSRQ
8c6a98b2 201/* Note: sysrq code uses it's own private copy */
8eaede49 202static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
97f5f0cd 203
6f8fd1d7 204static int sysrq_sysctl_handler(struct ctl_table *table, int write,
97f5f0cd
DT
205 void __user *buffer, size_t *lenp,
206 loff_t *ppos)
207{
208 int error;
209
210 error = proc_dointvec(table, write, buffer, lenp, ppos);
211 if (error)
212 return error;
213
214 if (write)
215 sysrq_toggle_support(__sysrq_enabled);
216
217 return 0;
218}
219
220#endif
221
d8217f07
EB
222static struct ctl_table kern_table[];
223static struct ctl_table vm_table[];
224static struct ctl_table fs_table[];
225static struct ctl_table debug_table[];
226static struct ctl_table dev_table[];
227extern struct ctl_table random_table[];
7ef9964e
DL
228#ifdef CONFIG_EPOLL
229extern struct ctl_table epoll_table[];
230#endif
1da177e4
LT
231
232#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
233int sysctl_legacy_va_layout;
234#endif
235
1da177e4
LT
236/* The default sysctl tables: */
237
de4e83bd 238static struct ctl_table sysctl_base_table[] = {
1da177e4 239 {
1da177e4
LT
240 .procname = "kernel",
241 .mode = 0555,
242 .child = kern_table,
243 },
244 {
1da177e4
LT
245 .procname = "vm",
246 .mode = 0555,
247 .child = vm_table,
248 },
1da177e4 249 {
1da177e4
LT
250 .procname = "fs",
251 .mode = 0555,
252 .child = fs_table,
253 },
254 {
1da177e4
LT
255 .procname = "debug",
256 .mode = 0555,
257 .child = debug_table,
258 },
259 {
1da177e4
LT
260 .procname = "dev",
261 .mode = 0555,
262 .child = dev_table,
263 },
6fce56ec 264 { }
1da177e4
LT
265};
266
77e54a1f 267#ifdef CONFIG_SCHED_DEBUG
73c4efd2
ED
268static int min_sched_granularity_ns = 100000; /* 100 usecs */
269static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
270static int min_wakeup_granularity_ns; /* 0 usecs */
271static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
cbee9f88 272#ifdef CONFIG_SMP
1983a922
CE
273static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
274static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
cbee9f88
PZ
275#endif /* CONFIG_SMP */
276#endif /* CONFIG_SCHED_DEBUG */
77e54a1f 277
5e771905
MG
278#ifdef CONFIG_COMPACTION
279static int min_extfrag_threshold;
280static int max_extfrag_threshold = 1000;
281#endif
282
d8217f07 283static struct ctl_table kern_table[] = {
2bba22c5 284 {
2bba22c5
MG
285 .procname = "sched_child_runs_first",
286 .data = &sysctl_sched_child_runs_first,
287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
6d456111 289 .proc_handler = proc_dointvec,
2bba22c5 290 },
77e54a1f
IM
291#ifdef CONFIG_SCHED_DEBUG
292 {
b2be5e96
PZ
293 .procname = "sched_min_granularity_ns",
294 .data = &sysctl_sched_min_granularity,
77e54a1f
IM
295 .maxlen = sizeof(unsigned int),
296 .mode = 0644,
702a7c76 297 .proc_handler = sched_proc_update_handler,
b2be5e96
PZ
298 .extra1 = &min_sched_granularity_ns,
299 .extra2 = &max_sched_granularity_ns,
77e54a1f 300 },
21805085 301 {
21805085
PZ
302 .procname = "sched_latency_ns",
303 .data = &sysctl_sched_latency,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
702a7c76 306 .proc_handler = sched_proc_update_handler,
21805085
PZ
307 .extra1 = &min_sched_granularity_ns,
308 .extra2 = &max_sched_granularity_ns,
309 },
77e54a1f 310 {
77e54a1f
IM
311 .procname = "sched_wakeup_granularity_ns",
312 .data = &sysctl_sched_wakeup_granularity,
313 .maxlen = sizeof(unsigned int),
314 .mode = 0644,
702a7c76 315 .proc_handler = sched_proc_update_handler,
77e54a1f
IM
316 .extra1 = &min_wakeup_granularity_ns,
317 .extra2 = &max_wakeup_granularity_ns,
318 },
cbee9f88 319#ifdef CONFIG_SMP
1983a922 320 {
1983a922
CE
321 .procname = "sched_tunable_scaling",
322 .data = &sysctl_sched_tunable_scaling,
323 .maxlen = sizeof(enum sched_tunable_scaling),
324 .mode = 0644,
702a7c76 325 .proc_handler = sched_proc_update_handler,
1983a922
CE
326 .extra1 = &min_sched_tunable_scaling,
327 .extra2 = &max_sched_tunable_scaling,
2398f2c6 328 },
da84d961 329 {
d00535db 330 .procname = "sched_migration_cost_ns",
da84d961
IM
331 .data = &sysctl_sched_migration_cost,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
6d456111 334 .proc_handler = proc_dointvec,
da84d961 335 },
b82d9fdd 336 {
b82d9fdd
PZ
337 .procname = "sched_nr_migrate",
338 .data = &sysctl_sched_nr_migrate,
339 .maxlen = sizeof(unsigned int),
fa85ae24 340 .mode = 0644,
6d456111 341 .proc_handler = proc_dointvec,
fa85ae24 342 },
e9e9250b 343 {
d00535db 344 .procname = "sched_time_avg_ms",
e9e9250b
PZ
345 .data = &sysctl_sched_time_avg,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
6d456111 348 .proc_handler = proc_dointvec,
e9e9250b 349 },
a7a4f8a7 350 {
d00535db 351 .procname = "sched_shares_window_ns",
a7a4f8a7
PT
352 .data = &sysctl_sched_shares_window,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
355 .proc_handler = proc_dointvec,
356 },
cb251765
MG
357#ifdef CONFIG_SCHEDSTATS
358 {
359 .procname = "sched_schedstats",
360 .data = NULL,
361 .maxlen = sizeof(unsigned int),
362 .mode = 0644,
363 .proc_handler = sysctl_schedstats,
364 .extra1 = &zero,
365 .extra2 = &one,
366 },
367#endif /* CONFIG_SCHEDSTATS */
cbee9f88
PZ
368#endif /* CONFIG_SMP */
369#ifdef CONFIG_NUMA_BALANCING
4b96a29b
PZ
370 {
371 .procname = "numa_balancing_scan_delay_ms",
372 .data = &sysctl_numa_balancing_scan_delay,
373 .maxlen = sizeof(unsigned int),
374 .mode = 0644,
375 .proc_handler = proc_dointvec,
376 },
cbee9f88
PZ
377 {
378 .procname = "numa_balancing_scan_period_min_ms",
379 .data = &sysctl_numa_balancing_scan_period_min,
380 .maxlen = sizeof(unsigned int),
381 .mode = 0644,
382 .proc_handler = proc_dointvec,
383 },
384 {
385 .procname = "numa_balancing_scan_period_max_ms",
386 .data = &sysctl_numa_balancing_scan_period_max,
387 .maxlen = sizeof(unsigned int),
388 .mode = 0644,
389 .proc_handler = proc_dointvec,
390 },
6e5fb223
PZ
391 {
392 .procname = "numa_balancing_scan_size_mb",
393 .data = &sysctl_numa_balancing_scan_size,
394 .maxlen = sizeof(unsigned int),
395 .mode = 0644,
64192658
KT
396 .proc_handler = proc_dointvec_minmax,
397 .extra1 = &one,
6e5fb223 398 },
54a43d54
AK
399 {
400 .procname = "numa_balancing",
401 .data = NULL, /* filled in by handler */
402 .maxlen = sizeof(unsigned int),
403 .mode = 0644,
404 .proc_handler = sysctl_numa_balancing,
405 .extra1 = &zero,
406 .extra2 = &one,
407 },
cbee9f88
PZ
408#endif /* CONFIG_NUMA_BALANCING */
409#endif /* CONFIG_SCHED_DEBUG */
9f0c1e56 410 {
9f0c1e56
PZ
411 .procname = "sched_rt_period_us",
412 .data = &sysctl_sched_rt_period,
413 .maxlen = sizeof(unsigned int),
414 .mode = 0644,
6d456111 415 .proc_handler = sched_rt_handler,
9f0c1e56
PZ
416 },
417 {
9f0c1e56
PZ
418 .procname = "sched_rt_runtime_us",
419 .data = &sysctl_sched_rt_runtime,
420 .maxlen = sizeof(int),
421 .mode = 0644,
6d456111 422 .proc_handler = sched_rt_handler,
9f0c1e56 423 },
ce0dbbbb
CW
424 {
425 .procname = "sched_rr_timeslice_ms",
426 .data = &sched_rr_timeslice,
427 .maxlen = sizeof(int),
428 .mode = 0644,
429 .proc_handler = sched_rr_handler,
430 },
5091faa4
MG
431#ifdef CONFIG_SCHED_AUTOGROUP
432 {
433 .procname = "sched_autogroup_enabled",
434 .data = &sysctl_sched_autogroup_enabled,
435 .maxlen = sizeof(unsigned int),
436 .mode = 0644,
1747b21f 437 .proc_handler = proc_dointvec_minmax,
5091faa4
MG
438 .extra1 = &zero,
439 .extra2 = &one,
440 },
441#endif
ec12cb7f
PT
442#ifdef CONFIG_CFS_BANDWIDTH
443 {
444 .procname = "sched_cfs_bandwidth_slice_us",
445 .data = &sysctl_sched_cfs_bandwidth_slice,
446 .maxlen = sizeof(unsigned int),
447 .mode = 0644,
448 .proc_handler = proc_dointvec_minmax,
449 .extra1 = &one,
450 },
451#endif
f20786ff
PZ
452#ifdef CONFIG_PROVE_LOCKING
453 {
f20786ff
PZ
454 .procname = "prove_locking",
455 .data = &prove_locking,
456 .maxlen = sizeof(int),
457 .mode = 0644,
6d456111 458 .proc_handler = proc_dointvec,
f20786ff
PZ
459 },
460#endif
461#ifdef CONFIG_LOCK_STAT
462 {
f20786ff
PZ
463 .procname = "lock_stat",
464 .data = &lock_stat,
465 .maxlen = sizeof(int),
466 .mode = 0644,
6d456111 467 .proc_handler = proc_dointvec,
f20786ff 468 },
77e54a1f 469#endif
1da177e4 470 {
1da177e4
LT
471 .procname = "panic",
472 .data = &panic_timeout,
473 .maxlen = sizeof(int),
474 .mode = 0644,
6d456111 475 .proc_handler = proc_dointvec,
1da177e4 476 },
046d662f 477#ifdef CONFIG_COREDUMP
1da177e4 478 {
1da177e4
LT
479 .procname = "core_uses_pid",
480 .data = &core_uses_pid,
481 .maxlen = sizeof(int),
482 .mode = 0644,
6d456111 483 .proc_handler = proc_dointvec,
1da177e4
LT
484 },
485 {
1da177e4
LT
486 .procname = "core_pattern",
487 .data = core_pattern,
71ce92f3 488 .maxlen = CORENAME_MAX_SIZE,
1da177e4 489 .mode = 0644,
54b50199 490 .proc_handler = proc_dostring_coredump,
1da177e4 491 },
a293980c 492 {
a293980c
NH
493 .procname = "core_pipe_limit",
494 .data = &core_pipe_limit,
495 .maxlen = sizeof(unsigned int),
496 .mode = 0644,
6d456111 497 .proc_handler = proc_dointvec,
a293980c 498 },
046d662f 499#endif
34f5a398 500#ifdef CONFIG_PROC_SYSCTL
1da177e4 501 {
1da177e4 502 .procname = "tainted",
25ddbb18 503 .maxlen = sizeof(long),
34f5a398 504 .mode = 0644,
6d456111 505 .proc_handler = proc_taint,
1da177e4 506 },
f4aacea2
KC
507 {
508 .procname = "sysctl_writes_strict",
509 .data = &sysctl_writes_strict,
510 .maxlen = sizeof(int),
511 .mode = 0644,
512 .proc_handler = proc_dointvec_minmax,
513 .extra1 = &neg_one,
514 .extra2 = &one,
515 },
34f5a398 516#endif
9745512c
AV
517#ifdef CONFIG_LATENCYTOP
518 {
519 .procname = "latencytop",
520 .data = &latencytop_enabled,
521 .maxlen = sizeof(int),
522 .mode = 0644,
cb251765 523 .proc_handler = sysctl_latencytop,
9745512c
AV
524 },
525#endif
1da177e4
LT
526#ifdef CONFIG_BLK_DEV_INITRD
527 {
1da177e4
LT
528 .procname = "real-root-dev",
529 .data = &real_root_dev,
530 .maxlen = sizeof(int),
531 .mode = 0644,
6d456111 532 .proc_handler = proc_dointvec,
1da177e4
LT
533 },
534#endif
45807a1d 535 {
45807a1d
IM
536 .procname = "print-fatal-signals",
537 .data = &print_fatal_signals,
538 .maxlen = sizeof(int),
539 .mode = 0644,
6d456111 540 .proc_handler = proc_dointvec,
45807a1d 541 },
72c57ed5 542#ifdef CONFIG_SPARC
1da177e4 543 {
1da177e4
LT
544 .procname = "reboot-cmd",
545 .data = reboot_command,
546 .maxlen = 256,
547 .mode = 0644,
6d456111 548 .proc_handler = proc_dostring,
1da177e4
LT
549 },
550 {
1da177e4
LT
551 .procname = "stop-a",
552 .data = &stop_a_enabled,
553 .maxlen = sizeof (int),
554 .mode = 0644,
6d456111 555 .proc_handler = proc_dointvec,
1da177e4
LT
556 },
557 {
1da177e4
LT
558 .procname = "scons-poweroff",
559 .data = &scons_pwroff,
560 .maxlen = sizeof (int),
561 .mode = 0644,
6d456111 562 .proc_handler = proc_dointvec,
1da177e4
LT
563 },
564#endif
0871420f
DM
565#ifdef CONFIG_SPARC64
566 {
0871420f
DM
567 .procname = "tsb-ratio",
568 .data = &sysctl_tsb_ratio,
569 .maxlen = sizeof (int),
570 .mode = 0644,
6d456111 571 .proc_handler = proc_dointvec,
0871420f
DM
572 },
573#endif
1da177e4
LT
574#ifdef __hppa__
575 {
1da177e4
LT
576 .procname = "soft-power",
577 .data = &pwrsw_enabled,
578 .maxlen = sizeof (int),
579 .mode = 0644,
6d456111 580 .proc_handler = proc_dointvec,
1da177e4 581 },
bf14e3b9
VG
582#endif
583#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1da177e4 584 {
1da177e4
LT
585 .procname = "unaligned-trap",
586 .data = &unaligned_enabled,
587 .maxlen = sizeof (int),
588 .mode = 0644,
6d456111 589 .proc_handler = proc_dointvec,
1da177e4
LT
590 },
591#endif
592 {
1da177e4
LT
593 .procname = "ctrl-alt-del",
594 .data = &C_A_D,
595 .maxlen = sizeof(int),
596 .mode = 0644,
6d456111 597 .proc_handler = proc_dointvec,
1da177e4 598 },
606576ce 599#ifdef CONFIG_FUNCTION_TRACER
b0fc494f 600 {
b0fc494f
SR
601 .procname = "ftrace_enabled",
602 .data = &ftrace_enabled,
603 .maxlen = sizeof(int),
604 .mode = 0644,
6d456111 605 .proc_handler = ftrace_enable_sysctl,
b0fc494f
SR
606 },
607#endif
f38f1d2a
SR
608#ifdef CONFIG_STACK_TRACER
609 {
f38f1d2a
SR
610 .procname = "stack_tracer_enabled",
611 .data = &stack_tracer_enabled,
612 .maxlen = sizeof(int),
613 .mode = 0644,
6d456111 614 .proc_handler = stack_trace_sysctl,
f38f1d2a
SR
615 },
616#endif
944ac425
SR
617#ifdef CONFIG_TRACING
618 {
3299b4dd 619 .procname = "ftrace_dump_on_oops",
944ac425
SR
620 .data = &ftrace_dump_on_oops,
621 .maxlen = sizeof(int),
622 .mode = 0644,
6d456111 623 .proc_handler = proc_dointvec,
944ac425 624 },
de7edd31
SRRH
625 {
626 .procname = "traceoff_on_warning",
627 .data = &__disable_trace_on_warning,
628 .maxlen = sizeof(__disable_trace_on_warning),
629 .mode = 0644,
630 .proc_handler = proc_dointvec,
631 },
0daa2302
SRRH
632 {
633 .procname = "tracepoint_printk",
634 .data = &tracepoint_printk,
635 .maxlen = sizeof(tracepoint_printk),
636 .mode = 0644,
637 .proc_handler = proc_dointvec,
638 },
944ac425 639#endif
2965faa5 640#ifdef CONFIG_KEXEC_CORE
7984754b
KC
641 {
642 .procname = "kexec_load_disabled",
643 .data = &kexec_load_disabled,
644 .maxlen = sizeof(int),
645 .mode = 0644,
646 /* only handle a transition from default "0" to "1" */
647 .proc_handler = proc_dointvec_minmax,
648 .extra1 = &one,
649 .extra2 = &one,
650 },
651#endif
a1ef5adb 652#ifdef CONFIG_MODULES
1da177e4 653 {
1da177e4
LT
654 .procname = "modprobe",
655 .data = &modprobe_path,
656 .maxlen = KMOD_PATH_LEN,
657 .mode = 0644,
6d456111 658 .proc_handler = proc_dostring,
1da177e4 659 },
3d43321b 660 {
3d43321b
KC
661 .procname = "modules_disabled",
662 .data = &modules_disabled,
663 .maxlen = sizeof(int),
664 .mode = 0644,
665 /* only handle a transition from default "0" to "1" */
6d456111 666 .proc_handler = proc_dointvec_minmax,
3d43321b
KC
667 .extra1 = &one,
668 .extra2 = &one,
669 },
1da177e4 670#endif
86d56134 671#ifdef CONFIG_UEVENT_HELPER
1da177e4 672 {
1da177e4 673 .procname = "hotplug",
312c004d
KS
674 .data = &uevent_helper,
675 .maxlen = UEVENT_HELPER_PATH_LEN,
1da177e4 676 .mode = 0644,
6d456111 677 .proc_handler = proc_dostring,
1da177e4 678 },
86d56134 679#endif
1da177e4
LT
680#ifdef CONFIG_CHR_DEV_SG
681 {
1da177e4
LT
682 .procname = "sg-big-buff",
683 .data = &sg_big_buff,
684 .maxlen = sizeof (int),
685 .mode = 0444,
6d456111 686 .proc_handler = proc_dointvec,
1da177e4
LT
687 },
688#endif
689#ifdef CONFIG_BSD_PROCESS_ACCT
690 {
1da177e4
LT
691 .procname = "acct",
692 .data = &acct_parm,
693 .maxlen = 3*sizeof(int),
694 .mode = 0644,
6d456111 695 .proc_handler = proc_dointvec,
1da177e4
LT
696 },
697#endif
1da177e4
LT
698#ifdef CONFIG_MAGIC_SYSRQ
699 {
1da177e4 700 .procname = "sysrq",
5d6f647f 701 .data = &__sysrq_enabled,
1da177e4
LT
702 .maxlen = sizeof (int),
703 .mode = 0644,
97f5f0cd 704 .proc_handler = sysrq_sysctl_handler,
1da177e4
LT
705 },
706#endif
d6f8ff73 707#ifdef CONFIG_PROC_SYSCTL
1da177e4 708 {
1da177e4 709 .procname = "cad_pid",
9ec52099 710 .data = NULL,
1da177e4
LT
711 .maxlen = sizeof (int),
712 .mode = 0600,
6d456111 713 .proc_handler = proc_do_cad_pid,
1da177e4 714 },
d6f8ff73 715#endif
1da177e4 716 {
1da177e4 717 .procname = "threads-max",
16db3d3f 718 .data = NULL,
1da177e4
LT
719 .maxlen = sizeof(int),
720 .mode = 0644,
16db3d3f 721 .proc_handler = sysctl_max_threads,
1da177e4
LT
722 },
723 {
1da177e4
LT
724 .procname = "random",
725 .mode = 0555,
726 .child = random_table,
727 },
17f60a7d
EP
728 {
729 .procname = "usermodehelper",
730 .mode = 0555,
731 .child = usermodehelper_table,
732 },
1da177e4 733 {
1da177e4
LT
734 .procname = "overflowuid",
735 .data = &overflowuid,
736 .maxlen = sizeof(int),
737 .mode = 0644,
6d456111 738 .proc_handler = proc_dointvec_minmax,
1da177e4
LT
739 .extra1 = &minolduid,
740 .extra2 = &maxolduid,
741 },
742 {
1da177e4
LT
743 .procname = "overflowgid",
744 .data = &overflowgid,
745 .maxlen = sizeof(int),
746 .mode = 0644,
6d456111 747 .proc_handler = proc_dointvec_minmax,
1da177e4
LT
748 .extra1 = &minolduid,
749 .extra2 = &maxolduid,
750 },
347a8dc3 751#ifdef CONFIG_S390
1da177e4
LT
752#ifdef CONFIG_MATHEMU
753 {
1da177e4
LT
754 .procname = "ieee_emulation_warnings",
755 .data = &sysctl_ieee_emulation_warnings,
756 .maxlen = sizeof(int),
757 .mode = 0644,
6d456111 758 .proc_handler = proc_dointvec,
1da177e4 759 },
1da177e4
LT
760#endif
761 {
1da177e4 762 .procname = "userprocess_debug",
ab3c68ee 763 .data = &show_unhandled_signals,
1da177e4
LT
764 .maxlen = sizeof(int),
765 .mode = 0644,
6d456111 766 .proc_handler = proc_dointvec,
1da177e4
LT
767 },
768#endif
769 {
1da177e4
LT
770 .procname = "pid_max",
771 .data = &pid_max,
772 .maxlen = sizeof (int),
773 .mode = 0644,
6d456111 774 .proc_handler = proc_dointvec_minmax,
1da177e4
LT
775 .extra1 = &pid_max_min,
776 .extra2 = &pid_max_max,
777 },
778 {
1da177e4
LT
779 .procname = "panic_on_oops",
780 .data = &panic_on_oops,
781 .maxlen = sizeof(int),
782 .mode = 0644,
6d456111 783 .proc_handler = proc_dointvec,
1da177e4 784 },
7ef3d2fd
JP
785#if defined CONFIG_PRINTK
786 {
7ef3d2fd
JP
787 .procname = "printk",
788 .data = &console_loglevel,
789 .maxlen = 4*sizeof(int),
790 .mode = 0644,
6d456111 791 .proc_handler = proc_dointvec,
7ef3d2fd 792 },
1da177e4 793 {
1da177e4 794 .procname = "printk_ratelimit",
717115e1 795 .data = &printk_ratelimit_state.interval,
1da177e4
LT
796 .maxlen = sizeof(int),
797 .mode = 0644,
6d456111 798 .proc_handler = proc_dointvec_jiffies,
1da177e4
LT
799 },
800 {
1da177e4 801 .procname = "printk_ratelimit_burst",
717115e1 802 .data = &printk_ratelimit_state.burst,
1da177e4
LT
803 .maxlen = sizeof(int),
804 .mode = 0644,
6d456111 805 .proc_handler = proc_dointvec,
1da177e4 806 },
af91322e 807 {
af91322e
DY
808 .procname = "printk_delay",
809 .data = &printk_delay_msec,
810 .maxlen = sizeof(int),
811 .mode = 0644,
6d456111 812 .proc_handler = proc_dointvec_minmax,
af91322e
DY
813 .extra1 = &zero,
814 .extra2 = &ten_thousand,
815 },
750afe7b
BP
816 {
817 .procname = "printk_devkmsg",
818 .data = devkmsg_log_str,
819 .maxlen = DEVKMSG_STR_MAX_SIZE,
820 .mode = 0644,
821 .proc_handler = devkmsg_sysctl_set_loglvl,
822 },
eaf06b24
DR
823 {
824 .procname = "dmesg_restrict",
825 .data = &dmesg_restrict,
826 .maxlen = sizeof(int),
827 .mode = 0644,
620f6e8e 828 .proc_handler = proc_dointvec_minmax_sysadmin,
eaf06b24
DR
829 .extra1 = &zero,
830 .extra2 = &one,
831 },
455cd5ab
DR
832 {
833 .procname = "kptr_restrict",
834 .data = &kptr_restrict,
835 .maxlen = sizeof(int),
836 .mode = 0644,
620f6e8e 837 .proc_handler = proc_dointvec_minmax_sysadmin,
455cd5ab
DR
838 .extra1 = &zero,
839 .extra2 = &two,
840 },
df6e61d4 841#endif
1da177e4 842 {
1da177e4
LT
843 .procname = "ngroups_max",
844 .data = &ngroups_max,
845 .maxlen = sizeof (int),
846 .mode = 0444,
6d456111 847 .proc_handler = proc_dointvec,
1da177e4 848 },
73efc039
DB
849 {
850 .procname = "cap_last_cap",
851 .data = (void *)&cap_last_cap,
852 .maxlen = sizeof(int),
853 .mode = 0444,
854 .proc_handler = proc_dointvec,
855 },
58687acb 856#if defined(CONFIG_LOCKUP_DETECTOR)
504d7cf1 857 {
58687acb 858 .procname = "watchdog",
3c00ea82 859 .data = &watchdog_user_enabled,
504d7cf1
DZ
860 .maxlen = sizeof (int),
861 .mode = 0644,
195daf66 862 .proc_handler = proc_watchdog,
586692a5
MSB
863 .extra1 = &zero,
864 .extra2 = &one,
58687acb
DZ
865 },
866 {
867 .procname = "watchdog_thresh",
586692a5 868 .data = &watchdog_thresh,
58687acb
DZ
869 .maxlen = sizeof(int),
870 .mode = 0644,
195daf66 871 .proc_handler = proc_watchdog_thresh,
a6572f84 872 .extra1 = &zero,
58687acb 873 .extra2 = &sixty,
504d7cf1 874 },
195daf66
UO
875 {
876 .procname = "nmi_watchdog",
877 .data = &nmi_watchdog_enabled,
878 .maxlen = sizeof (int),
879 .mode = 0644,
880 .proc_handler = proc_nmi_watchdog,
881 .extra1 = &zero,
882#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
883 .extra2 = &one,
884#else
885 .extra2 = &zero,
886#endif
887 },
888 {
889 .procname = "soft_watchdog",
890 .data = &soft_watchdog_enabled,
891 .maxlen = sizeof (int),
892 .mode = 0644,
893 .proc_handler = proc_soft_watchdog,
894 .extra1 = &zero,
895 .extra2 = &one,
896 },
fe4ba3c3
CM
897 {
898 .procname = "watchdog_cpumask",
899 .data = &watchdog_cpumask_bits,
900 .maxlen = NR_CPUS,
901 .mode = 0644,
902 .proc_handler = proc_watchdog_cpumask,
903 },
2508ce18
DZ
904 {
905 .procname = "softlockup_panic",
906 .data = &softlockup_panic,
907 .maxlen = sizeof(int),
908 .mode = 0644,
909 .proc_handler = proc_dointvec_minmax,
910 .extra1 = &zero,
911 .extra2 = &one,
912 },
ac1f5912
DZ
913#ifdef CONFIG_HARDLOCKUP_DETECTOR
914 {
915 .procname = "hardlockup_panic",
916 .data = &hardlockup_panic,
917 .maxlen = sizeof(int),
918 .mode = 0644,
919 .proc_handler = proc_dointvec_minmax,
920 .extra1 = &zero,
921 .extra2 = &one,
922 },
923#endif
ed235875
AT
924#ifdef CONFIG_SMP
925 {
926 .procname = "softlockup_all_cpu_backtrace",
927 .data = &sysctl_softlockup_all_cpu_backtrace,
928 .maxlen = sizeof(int),
929 .mode = 0644,
930 .proc_handler = proc_dointvec_minmax,
931 .extra1 = &zero,
932 .extra2 = &one,
933 },
55537871
JK
934 {
935 .procname = "hardlockup_all_cpu_backtrace",
936 .data = &sysctl_hardlockup_all_cpu_backtrace,
937 .maxlen = sizeof(int),
938 .mode = 0644,
939 .proc_handler = proc_dointvec_minmax,
940 .extra1 = &zero,
941 .extra2 = &one,
942 },
ed235875 943#endif /* CONFIG_SMP */
5dc30558
DZ
944#endif
945#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
946 {
947 .procname = "unknown_nmi_panic",
948 .data = &unknown_nmi_panic,
949 .maxlen = sizeof (int),
950 .mode = 0644,
951 .proc_handler = proc_dointvec,
952 },
504d7cf1 953#endif
1da177e4 954#if defined(CONFIG_X86)
8da5adda 955 {
8da5adda
DZ
956 .procname = "panic_on_unrecovered_nmi",
957 .data = &panic_on_unrecovered_nmi,
958 .maxlen = sizeof(int),
959 .mode = 0644,
6d456111 960 .proc_handler = proc_dointvec,
8da5adda 961 },
5211a242 962 {
5211a242
KG
963 .procname = "panic_on_io_nmi",
964 .data = &panic_on_io_nmi,
965 .maxlen = sizeof(int),
966 .mode = 0644,
6d456111 967 .proc_handler = proc_dointvec,
5211a242 968 },
55af7796
MH
969#ifdef CONFIG_DEBUG_STACKOVERFLOW
970 {
971 .procname = "panic_on_stackoverflow",
972 .data = &sysctl_panic_on_stackoverflow,
973 .maxlen = sizeof(int),
974 .mode = 0644,
975 .proc_handler = proc_dointvec,
976 },
977#endif
1da177e4 978 {
1da177e4
LT
979 .procname = "bootloader_type",
980 .data = &bootloader_type,
981 .maxlen = sizeof (int),
982 .mode = 0444,
6d456111 983 .proc_handler = proc_dointvec,
1da177e4 984 },
5031296c 985 {
5031296c
PA
986 .procname = "bootloader_version",
987 .data = &bootloader_version,
988 .maxlen = sizeof (int),
989 .mode = 0444,
6d456111 990 .proc_handler = proc_dointvec,
5031296c 991 },
0741f4d2 992 {
0741f4d2
CE
993 .procname = "kstack_depth_to_print",
994 .data = &kstack_depth_to_print,
995 .maxlen = sizeof(int),
996 .mode = 0644,
6d456111 997 .proc_handler = proc_dointvec,
0741f4d2 998 },
6e7c4025 999 {
6e7c4025
IM
1000 .procname = "io_delay_type",
1001 .data = &io_delay_type,
1002 .maxlen = sizeof(int),
1003 .mode = 0644,
6d456111 1004 .proc_handler = proc_dointvec,
6e7c4025 1005 },
1da177e4 1006#endif
7a9166e3 1007#if defined(CONFIG_MMU)
1da177e4 1008 {
1da177e4
LT
1009 .procname = "randomize_va_space",
1010 .data = &randomize_va_space,
1011 .maxlen = sizeof(int),
1012 .mode = 0644,
6d456111 1013 .proc_handler = proc_dointvec,
1da177e4 1014 },
7a9166e3 1015#endif
0152fb37 1016#if defined(CONFIG_S390) && defined(CONFIG_SMP)
951f22d5 1017 {
951f22d5
MS
1018 .procname = "spin_retry",
1019 .data = &spin_retry,
1020 .maxlen = sizeof (int),
1021 .mode = 0644,
6d456111 1022 .proc_handler = proc_dointvec,
951f22d5 1023 },
c255d844 1024#endif
673d5b43 1025#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
c255d844 1026 {
c255d844 1027 .procname = "acpi_video_flags",
77afcf78 1028 .data = &acpi_realmode_flags,
c255d844
PM
1029 .maxlen = sizeof (unsigned long),
1030 .mode = 0644,
6d456111 1031 .proc_handler = proc_doulongvec_minmax,
c255d844 1032 },
d2b176ed 1033#endif
b6fca725 1034#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
d2b176ed 1035 {
d2b176ed
JS
1036 .procname = "ignore-unaligned-usertrap",
1037 .data = &no_unaligned_warning,
1038 .maxlen = sizeof (int),
1039 .mode = 0644,
6d456111 1040 .proc_handler = proc_dointvec,
d2b176ed 1041 },
b6fca725
VG
1042#endif
1043#ifdef CONFIG_IA64
88fc241f 1044 {
88fc241f
DC
1045 .procname = "unaligned-dump-stack",
1046 .data = &unaligned_dump_stack,
1047 .maxlen = sizeof (int),
1048 .mode = 0644,
6d456111 1049 .proc_handler = proc_dointvec,
88fc241f 1050 },
bebfa101 1051#endif
e162b39a
MSB
1052#ifdef CONFIG_DETECT_HUNG_TASK
1053 {
e162b39a
MSB
1054 .procname = "hung_task_panic",
1055 .data = &sysctl_hung_task_panic,
1056 .maxlen = sizeof(int),
1057 .mode = 0644,
6d456111 1058 .proc_handler = proc_dointvec_minmax,
e162b39a
MSB
1059 .extra1 = &zero,
1060 .extra2 = &one,
1061 },
82a1fcb9 1062 {
82a1fcb9
IM
1063 .procname = "hung_task_check_count",
1064 .data = &sysctl_hung_task_check_count,
cd64647f 1065 .maxlen = sizeof(int),
82a1fcb9 1066 .mode = 0644,
cd64647f
LZ
1067 .proc_handler = proc_dointvec_minmax,
1068 .extra1 = &zero,
82a1fcb9
IM
1069 },
1070 {
82a1fcb9
IM
1071 .procname = "hung_task_timeout_secs",
1072 .data = &sysctl_hung_task_timeout_secs,
90739081 1073 .maxlen = sizeof(unsigned long),
82a1fcb9 1074 .mode = 0644,
6d456111 1075 .proc_handler = proc_dohung_task_timeout_secs,
80df2847 1076 .extra2 = &hung_task_timeout_max,
82a1fcb9
IM
1077 },
1078 {
82a1fcb9
IM
1079 .procname = "hung_task_warnings",
1080 .data = &sysctl_hung_task_warnings,
270750db 1081 .maxlen = sizeof(int),
82a1fcb9 1082 .mode = 0644,
270750db
AT
1083 .proc_handler = proc_dointvec_minmax,
1084 .extra1 = &neg_one,
82a1fcb9 1085 },
c4f3b63f 1086#endif
23f78d4a
IM
1087#ifdef CONFIG_RT_MUTEXES
1088 {
23f78d4a
IM
1089 .procname = "max_lock_depth",
1090 .data = &max_lock_depth,
1091 .maxlen = sizeof(int),
1092 .mode = 0644,
6d456111 1093 .proc_handler = proc_dointvec,
23f78d4a 1094 },
5096add8 1095#endif
10a0a8d4 1096 {
10a0a8d4
JF
1097 .procname = "poweroff_cmd",
1098 .data = &poweroff_cmd,
1099 .maxlen = POWEROFF_CMD_PATH_LEN,
1100 .mode = 0644,
6d456111 1101 .proc_handler = proc_dostring,
10a0a8d4 1102 },
0b77f5bf
DH
1103#ifdef CONFIG_KEYS
1104 {
0b77f5bf
DH
1105 .procname = "keys",
1106 .mode = 0555,
1107 .child = key_sysctls,
1108 },
1109#endif
cdd6c482 1110#ifdef CONFIG_PERF_EVENTS
aa4a2218
VW
1111 /*
1112 * User-space scripts rely on the existence of this file
1113 * as a feature check for perf_events being enabled.
1114 *
1115 * So it's an ABI, do not remove!
1116 */
1ccd1549 1117 {
cdd6c482
IM
1118 .procname = "perf_event_paranoid",
1119 .data = &sysctl_perf_event_paranoid,
1120 .maxlen = sizeof(sysctl_perf_event_paranoid),
1ccd1549 1121 .mode = 0644,
6d456111 1122 .proc_handler = proc_dointvec,
1ccd1549 1123 },
c5078f78 1124 {
cdd6c482
IM
1125 .procname = "perf_event_mlock_kb",
1126 .data = &sysctl_perf_event_mlock,
1127 .maxlen = sizeof(sysctl_perf_event_mlock),
c5078f78 1128 .mode = 0644,
6d456111 1129 .proc_handler = proc_dointvec,
c5078f78 1130 },
a78ac325 1131 {
cdd6c482
IM
1132 .procname = "perf_event_max_sample_rate",
1133 .data = &sysctl_perf_event_sample_rate,
1134 .maxlen = sizeof(sysctl_perf_event_sample_rate),
a78ac325 1135 .mode = 0644,
163ec435 1136 .proc_handler = perf_proc_update_handler,
723478c8 1137 .extra1 = &one,
a78ac325 1138 },
14c63f17
DH
1139 {
1140 .procname = "perf_cpu_time_max_percent",
1141 .data = &sysctl_perf_cpu_time_max_percent,
1142 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1143 .mode = 0644,
1144 .proc_handler = perf_cpu_time_max_percent_handler,
1145 .extra1 = &zero,
1146 .extra2 = &one_hundred,
1147 },
c5dfd78e
ACM
1148 {
1149 .procname = "perf_event_max_stack",
a831100a 1150 .data = &sysctl_perf_event_max_stack,
c5dfd78e
ACM
1151 .maxlen = sizeof(sysctl_perf_event_max_stack),
1152 .mode = 0644,
1153 .proc_handler = perf_event_max_stack_handler,
1154 .extra1 = &zero,
1155 .extra2 = &six_hundred_forty_kb,
1156 },
c85b0334
ACM
1157 {
1158 .procname = "perf_event_max_contexts_per_stack",
1159 .data = &sysctl_perf_event_max_contexts_per_stack,
1160 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1161 .mode = 0644,
1162 .proc_handler = perf_event_max_stack_handler,
1163 .extra1 = &zero,
1164 .extra2 = &one_thousand,
1165 },
1ccd1549 1166#endif
dfec072e
VN
1167#ifdef CONFIG_KMEMCHECK
1168 {
dfec072e
VN
1169 .procname = "kmemcheck",
1170 .data = &kmemcheck_enabled,
1171 .maxlen = sizeof(int),
1172 .mode = 0644,
6d456111 1173 .proc_handler = proc_dointvec,
dfec072e 1174 },
cb684b5b 1175#endif
9e3961a0
PB
1176 {
1177 .procname = "panic_on_warn",
1178 .data = &panic_on_warn,
1179 .maxlen = sizeof(int),
1180 .mode = 0644,
1181 .proc_handler = proc_dointvec_minmax,
1182 .extra1 = &zero,
1183 .extra2 = &one,
1184 },
bc7a34b8
TG
1185#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1186 {
1187 .procname = "timer_migration",
1188 .data = &sysctl_timer_migration,
1189 .maxlen = sizeof(unsigned int),
1190 .mode = 0644,
1191 .proc_handler = timer_migration_handler,
1192 },
1be7f75d
AS
1193#endif
1194#ifdef CONFIG_BPF_SYSCALL
1195 {
1196 .procname = "unprivileged_bpf_disabled",
1197 .data = &sysctl_unprivileged_bpf_disabled,
1198 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1199 .mode = 0644,
1200 /* only handle a transition from default "0" to "1" */
1201 .proc_handler = proc_dointvec_minmax,
1202 .extra1 = &one,
1203 .extra2 = &one,
1204 },
088e9d25
DBO
1205#endif
1206#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1207 {
1208 .procname = "panic_on_rcu_stall",
1209 .data = &sysctl_panic_on_rcu_stall,
1210 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1211 .mode = 0644,
1212 .proc_handler = proc_dointvec_minmax,
1213 .extra1 = &zero,
1214 .extra2 = &one,
1215 },
bc7a34b8 1216#endif
6fce56ec 1217 { }
1da177e4
LT
1218};
1219
d8217f07 1220static struct ctl_table vm_table[] = {
1da177e4 1221 {
1da177e4
LT
1222 .procname = "overcommit_memory",
1223 .data = &sysctl_overcommit_memory,
1224 .maxlen = sizeof(sysctl_overcommit_memory),
1225 .mode = 0644,
cb16e95f
PH
1226 .proc_handler = proc_dointvec_minmax,
1227 .extra1 = &zero,
1228 .extra2 = &two,
1da177e4 1229 },
fadd8fbd 1230 {
fadd8fbd
KH
1231 .procname = "panic_on_oom",
1232 .data = &sysctl_panic_on_oom,
1233 .maxlen = sizeof(sysctl_panic_on_oom),
1234 .mode = 0644,
cb16e95f
PH
1235 .proc_handler = proc_dointvec_minmax,
1236 .extra1 = &zero,
1237 .extra2 = &two,
fadd8fbd 1238 },
fe071d7e 1239 {
fe071d7e
DR
1240 .procname = "oom_kill_allocating_task",
1241 .data = &sysctl_oom_kill_allocating_task,
1242 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1243 .mode = 0644,
6d456111 1244 .proc_handler = proc_dointvec,
fe071d7e 1245 },
fef1bdd6 1246 {
fef1bdd6
DR
1247 .procname = "oom_dump_tasks",
1248 .data = &sysctl_oom_dump_tasks,
1249 .maxlen = sizeof(sysctl_oom_dump_tasks),
1250 .mode = 0644,
6d456111 1251 .proc_handler = proc_dointvec,
fef1bdd6 1252 },
1da177e4 1253 {
1da177e4
LT
1254 .procname = "overcommit_ratio",
1255 .data = &sysctl_overcommit_ratio,
1256 .maxlen = sizeof(sysctl_overcommit_ratio),
1257 .mode = 0644,
49f0ce5f
JM
1258 .proc_handler = overcommit_ratio_handler,
1259 },
1260 {
1261 .procname = "overcommit_kbytes",
1262 .data = &sysctl_overcommit_kbytes,
1263 .maxlen = sizeof(sysctl_overcommit_kbytes),
1264 .mode = 0644,
1265 .proc_handler = overcommit_kbytes_handler,
1da177e4
LT
1266 },
1267 {
1da177e4
LT
1268 .procname = "page-cluster",
1269 .data = &page_cluster,
1270 .maxlen = sizeof(int),
1271 .mode = 0644,
cb16e95f
PH
1272 .proc_handler = proc_dointvec_minmax,
1273 .extra1 = &zero,
1da177e4
LT
1274 },
1275 {
1da177e4
LT
1276 .procname = "dirty_background_ratio",
1277 .data = &dirty_background_ratio,
1278 .maxlen = sizeof(dirty_background_ratio),
1279 .mode = 0644,
6d456111 1280 .proc_handler = dirty_background_ratio_handler,
1da177e4
LT
1281 .extra1 = &zero,
1282 .extra2 = &one_hundred,
1283 },
2da02997 1284 {
2da02997
DR
1285 .procname = "dirty_background_bytes",
1286 .data = &dirty_background_bytes,
1287 .maxlen = sizeof(dirty_background_bytes),
1288 .mode = 0644,
6d456111 1289 .proc_handler = dirty_background_bytes_handler,
fc3501d4 1290 .extra1 = &one_ul,
2da02997 1291 },
1da177e4 1292 {
1da177e4
LT
1293 .procname = "dirty_ratio",
1294 .data = &vm_dirty_ratio,
1295 .maxlen = sizeof(vm_dirty_ratio),
1296 .mode = 0644,
6d456111 1297 .proc_handler = dirty_ratio_handler,
1da177e4
LT
1298 .extra1 = &zero,
1299 .extra2 = &one_hundred,
1300 },
2da02997 1301 {
2da02997
DR
1302 .procname = "dirty_bytes",
1303 .data = &vm_dirty_bytes,
1304 .maxlen = sizeof(vm_dirty_bytes),
1305 .mode = 0644,
6d456111 1306 .proc_handler = dirty_bytes_handler,
9e4a5bda 1307 .extra1 = &dirty_bytes_min,
2da02997 1308 },
1da177e4 1309 {
1da177e4 1310 .procname = "dirty_writeback_centisecs",
f6ef9438
BS
1311 .data = &dirty_writeback_interval,
1312 .maxlen = sizeof(dirty_writeback_interval),
1da177e4 1313 .mode = 0644,
6d456111 1314 .proc_handler = dirty_writeback_centisecs_handler,
1da177e4
LT
1315 },
1316 {
1da177e4 1317 .procname = "dirty_expire_centisecs",
f6ef9438
BS
1318 .data = &dirty_expire_interval,
1319 .maxlen = sizeof(dirty_expire_interval),
1da177e4 1320 .mode = 0644,
cb16e95f
PH
1321 .proc_handler = proc_dointvec_minmax,
1322 .extra1 = &zero,
1da177e4 1323 },
1efff914
TT
1324 {
1325 .procname = "dirtytime_expire_seconds",
1326 .data = &dirtytime_expire_interval,
1327 .maxlen = sizeof(dirty_expire_interval),
1328 .mode = 0644,
1329 .proc_handler = dirtytime_interval_handler,
1330 .extra1 = &zero,
1331 },
1da177e4 1332 {
3965c9ae
WL
1333 .procname = "nr_pdflush_threads",
1334 .mode = 0444 /* read-only */,
1335 .proc_handler = pdflush_proc_obsolete,
1da177e4
LT
1336 },
1337 {
1da177e4
LT
1338 .procname = "swappiness",
1339 .data = &vm_swappiness,
1340 .maxlen = sizeof(vm_swappiness),
1341 .mode = 0644,
6d456111 1342 .proc_handler = proc_dointvec_minmax,
1da177e4
LT
1343 .extra1 = &zero,
1344 .extra2 = &one_hundred,
1345 },
1346#ifdef CONFIG_HUGETLB_PAGE
06808b08 1347 {
1da177e4 1348 .procname = "nr_hugepages",
e5ff2159 1349 .data = NULL,
1da177e4
LT
1350 .maxlen = sizeof(unsigned long),
1351 .mode = 0644,
6d456111 1352 .proc_handler = hugetlb_sysctl_handler,
06808b08
LS
1353 },
1354#ifdef CONFIG_NUMA
1355 {
1356 .procname = "nr_hugepages_mempolicy",
1357 .data = NULL,
1358 .maxlen = sizeof(unsigned long),
1359 .mode = 0644,
1360 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
06808b08
LS
1361 },
1362#endif
1da177e4 1363 {
1da177e4
LT
1364 .procname = "hugetlb_shm_group",
1365 .data = &sysctl_hugetlb_shm_group,
1366 .maxlen = sizeof(gid_t),
1367 .mode = 0644,
6d456111 1368 .proc_handler = proc_dointvec,
1da177e4 1369 },
396faf03 1370 {
396faf03
MG
1371 .procname = "hugepages_treat_as_movable",
1372 .data = &hugepages_treat_as_movable,
1373 .maxlen = sizeof(int),
1374 .mode = 0644,
86cdb465 1375 .proc_handler = proc_dointvec,
396faf03 1376 },
d1c3fb1f 1377 {
d1c3fb1f 1378 .procname = "nr_overcommit_hugepages",
e5ff2159
AK
1379 .data = NULL,
1380 .maxlen = sizeof(unsigned long),
d1c3fb1f 1381 .mode = 0644,
6d456111 1382 .proc_handler = hugetlb_overcommit_handler,
d1c3fb1f 1383 },
1da177e4
LT
1384#endif
1385 {
1da177e4
LT
1386 .procname = "lowmem_reserve_ratio",
1387 .data = &sysctl_lowmem_reserve_ratio,
1388 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1389 .mode = 0644,
6d456111 1390 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1da177e4 1391 },
9d0243bc 1392 {
9d0243bc
AM
1393 .procname = "drop_caches",
1394 .data = &sysctl_drop_caches,
1395 .maxlen = sizeof(int),
1396 .mode = 0644,
1397 .proc_handler = drop_caches_sysctl_handler,
cb16e95f 1398 .extra1 = &one,
5509a5d2 1399 .extra2 = &four,
9d0243bc 1400 },
76ab0f53
MG
1401#ifdef CONFIG_COMPACTION
1402 {
1403 .procname = "compact_memory",
1404 .data = &sysctl_compact_memory,
1405 .maxlen = sizeof(int),
1406 .mode = 0200,
1407 .proc_handler = sysctl_compaction_handler,
1408 },
5e771905
MG
1409 {
1410 .procname = "extfrag_threshold",
1411 .data = &sysctl_extfrag_threshold,
1412 .maxlen = sizeof(int),
1413 .mode = 0644,
1414 .proc_handler = sysctl_extfrag_handler,
1415 .extra1 = &min_extfrag_threshold,
1416 .extra2 = &max_extfrag_threshold,
1417 },
5bbe3547
EM
1418 {
1419 .procname = "compact_unevictable_allowed",
1420 .data = &sysctl_compact_unevictable_allowed,
1421 .maxlen = sizeof(int),
1422 .mode = 0644,
1423 .proc_handler = proc_dointvec,
1424 .extra1 = &zero,
1425 .extra2 = &one,
1426 },
5e771905 1427
76ab0f53 1428#endif /* CONFIG_COMPACTION */
1da177e4 1429 {
1da177e4
LT
1430 .procname = "min_free_kbytes",
1431 .data = &min_free_kbytes,
1432 .maxlen = sizeof(min_free_kbytes),
1433 .mode = 0644,
6d456111 1434 .proc_handler = min_free_kbytes_sysctl_handler,
1da177e4
LT
1435 .extra1 = &zero,
1436 },
795ae7a0
JW
1437 {
1438 .procname = "watermark_scale_factor",
1439 .data = &watermark_scale_factor,
1440 .maxlen = sizeof(watermark_scale_factor),
1441 .mode = 0644,
1442 .proc_handler = watermark_scale_factor_sysctl_handler,
1443 .extra1 = &one,
1444 .extra2 = &one_thousand,
1445 },
8ad4b1fb 1446 {
8ad4b1fb
RS
1447 .procname = "percpu_pagelist_fraction",
1448 .data = &percpu_pagelist_fraction,
1449 .maxlen = sizeof(percpu_pagelist_fraction),
1450 .mode = 0644,
6d456111 1451 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
7cd2b0a3 1452 .extra1 = &zero,
8ad4b1fb 1453 },
1da177e4
LT
1454#ifdef CONFIG_MMU
1455 {
1da177e4
LT
1456 .procname = "max_map_count",
1457 .data = &sysctl_max_map_count,
1458 .maxlen = sizeof(sysctl_max_map_count),
1459 .mode = 0644,
3e26120c 1460 .proc_handler = proc_dointvec_minmax,
70da2340 1461 .extra1 = &zero,
1da177e4 1462 },
dd8632a1
PM
1463#else
1464 {
dd8632a1
PM
1465 .procname = "nr_trim_pages",
1466 .data = &sysctl_nr_trim_pages,
1467 .maxlen = sizeof(sysctl_nr_trim_pages),
1468 .mode = 0644,
6d456111 1469 .proc_handler = proc_dointvec_minmax,
dd8632a1
PM
1470 .extra1 = &zero,
1471 },
1da177e4
LT
1472#endif
1473 {
1da177e4
LT
1474 .procname = "laptop_mode",
1475 .data = &laptop_mode,
1476 .maxlen = sizeof(laptop_mode),
1477 .mode = 0644,
6d456111 1478 .proc_handler = proc_dointvec_jiffies,
1da177e4
LT
1479 },
1480 {
1da177e4
LT
1481 .procname = "block_dump",
1482 .data = &block_dump,
1483 .maxlen = sizeof(block_dump),
1484 .mode = 0644,
6d456111 1485 .proc_handler = proc_dointvec,
1da177e4
LT
1486 .extra1 = &zero,
1487 },
1488 {
1da177e4
LT
1489 .procname = "vfs_cache_pressure",
1490 .data = &sysctl_vfs_cache_pressure,
1491 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1492 .mode = 0644,
6d456111 1493 .proc_handler = proc_dointvec,
1da177e4
LT
1494 .extra1 = &zero,
1495 },
1496#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1497 {
1da177e4
LT
1498 .procname = "legacy_va_layout",
1499 .data = &sysctl_legacy_va_layout,
1500 .maxlen = sizeof(sysctl_legacy_va_layout),
1501 .mode = 0644,
6d456111 1502 .proc_handler = proc_dointvec,
1da177e4
LT
1503 .extra1 = &zero,
1504 },
1505#endif
1743660b
CL
1506#ifdef CONFIG_NUMA
1507 {
1743660b 1508 .procname = "zone_reclaim_mode",
a5f5f91d
MG
1509 .data = &node_reclaim_mode,
1510 .maxlen = sizeof(node_reclaim_mode),
1743660b 1511 .mode = 0644,
6d456111 1512 .proc_handler = proc_dointvec,
c84db23c 1513 .extra1 = &zero,
1743660b 1514 },
9614634f 1515 {
9614634f
CL
1516 .procname = "min_unmapped_ratio",
1517 .data = &sysctl_min_unmapped_ratio,
1518 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1519 .mode = 0644,
6d456111 1520 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
9614634f
CL
1521 .extra1 = &zero,
1522 .extra2 = &one_hundred,
1523 },
0ff38490 1524 {
0ff38490
CL
1525 .procname = "min_slab_ratio",
1526 .data = &sysctl_min_slab_ratio,
1527 .maxlen = sizeof(sysctl_min_slab_ratio),
1528 .mode = 0644,
6d456111 1529 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
0ff38490
CL
1530 .extra1 = &zero,
1531 .extra2 = &one_hundred,
1532 },
e6e5494c 1533#endif
77461ab3
CL
1534#ifdef CONFIG_SMP
1535 {
77461ab3
CL
1536 .procname = "stat_interval",
1537 .data = &sysctl_stat_interval,
1538 .maxlen = sizeof(sysctl_stat_interval),
1539 .mode = 0644,
6d456111 1540 .proc_handler = proc_dointvec_jiffies,
77461ab3 1541 },
52b6f46b
HD
1542 {
1543 .procname = "stat_refresh",
1544 .data = NULL,
1545 .maxlen = 0,
1546 .mode = 0600,
1547 .proc_handler = vmstat_refresh,
1548 },
77461ab3 1549#endif
6e141546 1550#ifdef CONFIG_MMU
ed032189 1551 {
ed032189 1552 .procname = "mmap_min_addr",
788084ab
EP
1553 .data = &dac_mmap_min_addr,
1554 .maxlen = sizeof(unsigned long),
ed032189 1555 .mode = 0644,
6d456111 1556 .proc_handler = mmap_min_addr_handler,
ed032189 1557 },
6e141546 1558#endif
f0c0b2b8
KH
1559#ifdef CONFIG_NUMA
1560 {
f0c0b2b8
KH
1561 .procname = "numa_zonelist_order",
1562 .data = &numa_zonelist_order,
1563 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1564 .mode = 0644,
6d456111 1565 .proc_handler = numa_zonelist_order_handler,
f0c0b2b8
KH
1566 },
1567#endif
2b8232ce 1568#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
5c36e657 1569 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
e6e5494c 1570 {
e6e5494c 1571 .procname = "vdso_enabled",
3d7ee969
AL
1572#ifdef CONFIG_X86_32
1573 .data = &vdso32_enabled,
1574 .maxlen = sizeof(vdso32_enabled),
1575#else
e6e5494c
IM
1576 .data = &vdso_enabled,
1577 .maxlen = sizeof(vdso_enabled),
3d7ee969 1578#endif
e6e5494c 1579 .mode = 0644,
6d456111 1580 .proc_handler = proc_dointvec,
e6e5494c
IM
1581 .extra1 = &zero,
1582 },
1da177e4 1583#endif
195cf453
BG
1584#ifdef CONFIG_HIGHMEM
1585 {
195cf453
BG
1586 .procname = "highmem_is_dirtyable",
1587 .data = &vm_highmem_is_dirtyable,
1588 .maxlen = sizeof(vm_highmem_is_dirtyable),
1589 .mode = 0644,
6d456111 1590 .proc_handler = proc_dointvec_minmax,
195cf453
BG
1591 .extra1 = &zero,
1592 .extra2 = &one,
1593 },
1594#endif
6a46079c
AK
1595#ifdef CONFIG_MEMORY_FAILURE
1596 {
6a46079c
AK
1597 .procname = "memory_failure_early_kill",
1598 .data = &sysctl_memory_failure_early_kill,
1599 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1600 .mode = 0644,
6d456111 1601 .proc_handler = proc_dointvec_minmax,
6a46079c
AK
1602 .extra1 = &zero,
1603 .extra2 = &one,
1604 },
1605 {
6a46079c
AK
1606 .procname = "memory_failure_recovery",
1607 .data = &sysctl_memory_failure_recovery,
1608 .maxlen = sizeof(sysctl_memory_failure_recovery),
1609 .mode = 0644,
6d456111 1610 .proc_handler = proc_dointvec_minmax,
6a46079c
AK
1611 .extra1 = &zero,
1612 .extra2 = &one,
1613 },
1614#endif
c9b1d098
AS
1615 {
1616 .procname = "user_reserve_kbytes",
1617 .data = &sysctl_user_reserve_kbytes,
1618 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1619 .mode = 0644,
1620 .proc_handler = proc_doulongvec_minmax,
1621 },
4eeab4f5
AS
1622 {
1623 .procname = "admin_reserve_kbytes",
1624 .data = &sysctl_admin_reserve_kbytes,
1625 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1626 .mode = 0644,
1627 .proc_handler = proc_doulongvec_minmax,
1628 },
d07e2259
DC
1629#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1630 {
1631 .procname = "mmap_rnd_bits",
1632 .data = &mmap_rnd_bits,
1633 .maxlen = sizeof(mmap_rnd_bits),
1634 .mode = 0600,
1635 .proc_handler = proc_dointvec_minmax,
1636 .extra1 = (void *)&mmap_rnd_bits_min,
1637 .extra2 = (void *)&mmap_rnd_bits_max,
1638 },
1639#endif
1640#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1641 {
1642 .procname = "mmap_rnd_compat_bits",
1643 .data = &mmap_rnd_compat_bits,
1644 .maxlen = sizeof(mmap_rnd_compat_bits),
1645 .mode = 0600,
1646 .proc_handler = proc_dointvec_minmax,
1647 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1648 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1649 },
1650#endif
6fce56ec 1651 { }
1da177e4
LT
1652};
1653
d8217f07 1654static struct ctl_table fs_table[] = {
1da177e4 1655 {
1da177e4
LT
1656 .procname = "inode-nr",
1657 .data = &inodes_stat,
3942c07c 1658 .maxlen = 2*sizeof(long),
1da177e4 1659 .mode = 0444,
cffbc8aa 1660 .proc_handler = proc_nr_inodes,
1da177e4
LT
1661 },
1662 {
1da177e4
LT
1663 .procname = "inode-state",
1664 .data = &inodes_stat,
3942c07c 1665 .maxlen = 7*sizeof(long),
1da177e4 1666 .mode = 0444,
cffbc8aa 1667 .proc_handler = proc_nr_inodes,
1da177e4
LT
1668 },
1669 {
1da177e4
LT
1670 .procname = "file-nr",
1671 .data = &files_stat,
518de9b3 1672 .maxlen = sizeof(files_stat),
1da177e4 1673 .mode = 0444,
6d456111 1674 .proc_handler = proc_nr_files,
1da177e4
LT
1675 },
1676 {
1da177e4
LT
1677 .procname = "file-max",
1678 .data = &files_stat.max_files,
518de9b3 1679 .maxlen = sizeof(files_stat.max_files),
1da177e4 1680 .mode = 0644,
518de9b3 1681 .proc_handler = proc_doulongvec_minmax,
1da177e4 1682 },
9cfe015a 1683 {
9cfe015a
ED
1684 .procname = "nr_open",
1685 .data = &sysctl_nr_open,
9b80a184 1686 .maxlen = sizeof(unsigned int),
9cfe015a 1687 .mode = 0644,
6d456111 1688 .proc_handler = proc_dointvec_minmax,
eceea0b3
AV
1689 .extra1 = &sysctl_nr_open_min,
1690 .extra2 = &sysctl_nr_open_max,
9cfe015a 1691 },
1da177e4 1692 {
1da177e4
LT
1693 .procname = "dentry-state",
1694 .data = &dentry_stat,
3942c07c 1695 .maxlen = 6*sizeof(long),
1da177e4 1696 .mode = 0444,
312d3ca8 1697 .proc_handler = proc_nr_dentry,
1da177e4
LT
1698 },
1699 {
1da177e4
LT
1700 .procname = "overflowuid",
1701 .data = &fs_overflowuid,
1702 .maxlen = sizeof(int),
1703 .mode = 0644,
6d456111 1704 .proc_handler = proc_dointvec_minmax,
1da177e4
LT
1705 .extra1 = &minolduid,
1706 .extra2 = &maxolduid,
1707 },
1708 {
1da177e4
LT
1709 .procname = "overflowgid",
1710 .data = &fs_overflowgid,
1711 .maxlen = sizeof(int),
1712 .mode = 0644,
6d456111 1713 .proc_handler = proc_dointvec_minmax,
1da177e4
LT
1714 .extra1 = &minolduid,
1715 .extra2 = &maxolduid,
1716 },
bfcd17a6 1717#ifdef CONFIG_FILE_LOCKING
1da177e4 1718 {
1da177e4
LT
1719 .procname = "leases-enable",
1720 .data = &leases_enable,
1721 .maxlen = sizeof(int),
1722 .mode = 0644,
6d456111 1723 .proc_handler = proc_dointvec,
1da177e4 1724 },
bfcd17a6 1725#endif
1da177e4
LT
1726#ifdef CONFIG_DNOTIFY
1727 {
1da177e4
LT
1728 .procname = "dir-notify-enable",
1729 .data = &dir_notify_enable,
1730 .maxlen = sizeof(int),
1731 .mode = 0644,
6d456111 1732 .proc_handler = proc_dointvec,
1da177e4
LT
1733 },
1734#endif
1735#ifdef CONFIG_MMU
bfcd17a6 1736#ifdef CONFIG_FILE_LOCKING
1da177e4 1737 {
1da177e4
LT
1738 .procname = "lease-break-time",
1739 .data = &lease_break_time,
1740 .maxlen = sizeof(int),
1741 .mode = 0644,
6d456111 1742 .proc_handler = proc_dointvec,
1da177e4 1743 },
bfcd17a6 1744#endif
ebf3f09c 1745#ifdef CONFIG_AIO
1da177e4 1746 {
1da177e4
LT
1747 .procname = "aio-nr",
1748 .data = &aio_nr,
1749 .maxlen = sizeof(aio_nr),
1750 .mode = 0444,
6d456111 1751 .proc_handler = proc_doulongvec_minmax,
1da177e4
LT
1752 },
1753 {
1da177e4
LT
1754 .procname = "aio-max-nr",
1755 .data = &aio_max_nr,
1756 .maxlen = sizeof(aio_max_nr),
1757 .mode = 0644,
6d456111 1758 .proc_handler = proc_doulongvec_minmax,
1da177e4 1759 },
ebf3f09c 1760#endif /* CONFIG_AIO */
2d9048e2 1761#ifdef CONFIG_INOTIFY_USER
0399cb08 1762 {
0399cb08
RL
1763 .procname = "inotify",
1764 .mode = 0555,
1765 .child = inotify_table,
1766 },
1767#endif
7ef9964e
DL
1768#ifdef CONFIG_EPOLL
1769 {
1770 .procname = "epoll",
1771 .mode = 0555,
1772 .child = epoll_table,
1773 },
1774#endif
1da177e4 1775#endif
800179c9
KC
1776 {
1777 .procname = "protected_symlinks",
1778 .data = &sysctl_protected_symlinks,
1779 .maxlen = sizeof(int),
1780 .mode = 0600,
1781 .proc_handler = proc_dointvec_minmax,
1782 .extra1 = &zero,
1783 .extra2 = &one,
1784 },
1785 {
1786 .procname = "protected_hardlinks",
1787 .data = &sysctl_protected_hardlinks,
1788 .maxlen = sizeof(int),
1789 .mode = 0600,
1790 .proc_handler = proc_dointvec_minmax,
1791 .extra1 = &zero,
1792 .extra2 = &one,
1793 },
d6e71144 1794 {
d6e71144
AC
1795 .procname = "suid_dumpable",
1796 .data = &suid_dumpable,
1797 .maxlen = sizeof(int),
1798 .mode = 0644,
54b50199 1799 .proc_handler = proc_dointvec_minmax_coredump,
8e654fba
MW
1800 .extra1 = &zero,
1801 .extra2 = &two,
d6e71144 1802 },
2abc26fc
EB
1803#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1804 {
2abc26fc
EB
1805 .procname = "binfmt_misc",
1806 .mode = 0555,
f9bd6733 1807 .child = sysctl_mount_point,
2abc26fc
EB
1808 },
1809#endif
b492e95b 1810 {
ff9da691
JA
1811 .procname = "pipe-max-size",
1812 .data = &pipe_max_size,
b492e95b
JA
1813 .maxlen = sizeof(int),
1814 .mode = 0644,
ff9da691
JA
1815 .proc_handler = &pipe_proc_fn,
1816 .extra1 = &pipe_min_size,
b492e95b 1817 },
759c0114
WT
1818 {
1819 .procname = "pipe-user-pages-hard",
1820 .data = &pipe_user_pages_hard,
1821 .maxlen = sizeof(pipe_user_pages_hard),
1822 .mode = 0644,
1823 .proc_handler = proc_doulongvec_minmax,
1824 },
1825 {
1826 .procname = "pipe-user-pages-soft",
1827 .data = &pipe_user_pages_soft,
1828 .maxlen = sizeof(pipe_user_pages_soft),
1829 .mode = 0644,
1830 .proc_handler = proc_doulongvec_minmax,
1831 },
d2921684
EB
1832 {
1833 .procname = "mount-max",
1834 .data = &sysctl_mount_max,
1835 .maxlen = sizeof(unsigned int),
1836 .mode = 0644,
1837 .proc_handler = proc_dointvec_minmax,
1838 .extra1 = &one,
1839 },
6fce56ec 1840 { }
1da177e4
LT
1841};
1842
d8217f07 1843static struct ctl_table debug_table[] = {
7ac57a89 1844#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
abd4f750 1845 {
abd4f750
MAS
1846 .procname = "exception-trace",
1847 .data = &show_unhandled_signals,
1848 .maxlen = sizeof(int),
1849 .mode = 0644,
1850 .proc_handler = proc_dointvec
1851 },
b2be84df
MH
1852#endif
1853#if defined(CONFIG_OPTPROBES)
1854 {
1855 .procname = "kprobes-optimization",
1856 .data = &sysctl_kprobes_optimization,
1857 .maxlen = sizeof(int),
1858 .mode = 0644,
1859 .proc_handler = proc_kprobes_optimization_handler,
1860 .extra1 = &zero,
1861 .extra2 = &one,
1862 },
abd4f750 1863#endif
6fce56ec 1864 { }
1da177e4
LT
1865};
1866
d8217f07 1867static struct ctl_table dev_table[] = {
6fce56ec 1868 { }
0eeca283 1869};
1da177e4 1870
de4e83bd 1871int __init sysctl_init(void)
d912b0cc 1872{
fd4b616b
SR
1873 struct ctl_table_header *hdr;
1874
1875 hdr = register_sysctl_table(sysctl_base_table);
1876 kmemleak_not_leak(hdr);
d912b0cc
EB
1877 return 0;
1878}
1879
b89a8171
EB
1880#endif /* CONFIG_SYSCTL */
1881
1da177e4
LT
1882/*
1883 * /proc/sys support
1884 */
1885
b89a8171 1886#ifdef CONFIG_PROC_SYSCTL
1da177e4 1887
f8808300
KC
1888static int _proc_do_string(char *data, int maxlen, int write,
1889 char __user *buffer,
b1ba4ddd 1890 size_t *lenp, loff_t *ppos)
1da177e4
LT
1891{
1892 size_t len;
1893 char __user *p;
1894 char c;
8d060877
ON
1895
1896 if (!data || !maxlen || !*lenp) {
1da177e4
LT
1897 *lenp = 0;
1898 return 0;
1899 }
8d060877 1900
1da177e4 1901 if (write) {
f4aacea2
KC
1902 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1903 /* Only continue writes not past the end of buffer. */
1904 len = strlen(data);
1905 if (len > maxlen - 1)
1906 len = maxlen - 1;
1907
1908 if (*ppos > len)
1909 return 0;
1910 len = *ppos;
1911 } else {
1912 /* Start writing from beginning of buffer. */
1913 len = 0;
1914 }
1915
2ca9bb45 1916 *ppos += *lenp;
1da177e4 1917 p = buffer;
2ca9bb45 1918 while ((p - buffer) < *lenp && len < maxlen - 1) {
1da177e4
LT
1919 if (get_user(c, p++))
1920 return -EFAULT;
1921 if (c == 0 || c == '\n')
1922 break;
2ca9bb45 1923 data[len++] = c;
1da177e4 1924 }
f8808300 1925 data[len] = 0;
1da177e4 1926 } else {
f5dd3d6f
SV
1927 len = strlen(data);
1928 if (len > maxlen)
1929 len = maxlen;
8d060877
ON
1930
1931 if (*ppos > len) {
1932 *lenp = 0;
1933 return 0;
1934 }
1935
1936 data += *ppos;
1937 len -= *ppos;
1938
1da177e4
LT
1939 if (len > *lenp)
1940 len = *lenp;
1941 if (len)
f8808300 1942 if (copy_to_user(buffer, data, len))
1da177e4
LT
1943 return -EFAULT;
1944 if (len < *lenp) {
f8808300 1945 if (put_user('\n', buffer + len))
1da177e4
LT
1946 return -EFAULT;
1947 len++;
1948 }
1949 *lenp = len;
1950 *ppos += len;
1951 }
1952 return 0;
1953}
1954
f4aacea2
KC
1955static void warn_sysctl_write(struct ctl_table *table)
1956{
1957 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1958 "This will not be supported in the future. To silence this\n"
1959 "warning, set kernel.sysctl_writes_strict = -1\n",
1960 current->comm, table->procname);
1961}
1962
f5dd3d6f
SV
1963/**
1964 * proc_dostring - read a string sysctl
1965 * @table: the sysctl table
1966 * @write: %TRUE if this is a write to the sysctl file
f5dd3d6f
SV
1967 * @buffer: the user buffer
1968 * @lenp: the size of the user buffer
1969 * @ppos: file position
1970 *
1971 * Reads/writes a string from/to the user buffer. If the kernel
1972 * buffer provided is not large enough to hold the string, the
1973 * string is truncated. The copied string is %NULL-terminated.
1974 * If the string is being read by the user process, it is copied
1975 * and a newline '\n' is added. It is truncated if the buffer is
1976 * not large enough.
1977 *
1978 * Returns 0 on success.
1979 */
8d65af78 1980int proc_dostring(struct ctl_table *table, int write,
f5dd3d6f
SV
1981 void __user *buffer, size_t *lenp, loff_t *ppos)
1982{
f4aacea2
KC
1983 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1984 warn_sysctl_write(table);
1985
f8808300
KC
1986 return _proc_do_string((char *)(table->data), table->maxlen, write,
1987 (char __user *)buffer, lenp, ppos);
f5dd3d6f
SV
1988}
1989
00b7c339
AW
1990static size_t proc_skip_spaces(char **buf)
1991{
1992 size_t ret;
1993 char *tmp = skip_spaces(*buf);
1994 ret = tmp - *buf;
1995 *buf = tmp;
1996 return ret;
1997}
1998
9f977fb7
OP
1999static void proc_skip_char(char **buf, size_t *size, const char v)
2000{
2001 while (*size) {
2002 if (**buf != v)
2003 break;
2004 (*size)--;
2005 (*buf)++;
2006 }
2007}
2008
00b7c339
AW
2009#define TMPBUFLEN 22
2010/**
0fc377bd 2011 * proc_get_long - reads an ASCII formatted integer from a user buffer
00b7c339 2012 *
0fc377bd
RD
2013 * @buf: a kernel buffer
2014 * @size: size of the kernel buffer
2015 * @val: this is where the number will be stored
2016 * @neg: set to %TRUE if number is negative
2017 * @perm_tr: a vector which contains the allowed trailers
2018 * @perm_tr_len: size of the perm_tr vector
2019 * @tr: pointer to store the trailer character
00b7c339 2020 *
0fc377bd
RD
2021 * In case of success %0 is returned and @buf and @size are updated with
2022 * the amount of bytes read. If @tr is non-NULL and a trailing
2023 * character exists (size is non-zero after returning from this
2024 * function), @tr is updated with the trailing character.
00b7c339
AW
2025 */
2026static int proc_get_long(char **buf, size_t *size,
2027 unsigned long *val, bool *neg,
2028 const char *perm_tr, unsigned perm_tr_len, char *tr)
2029{
2030 int len;
2031 char *p, tmp[TMPBUFLEN];
2032
2033 if (!*size)
2034 return -EINVAL;
2035
2036 len = *size;
2037 if (len > TMPBUFLEN - 1)
2038 len = TMPBUFLEN - 1;
2039
2040 memcpy(tmp, *buf, len);
2041
2042 tmp[len] = 0;
2043 p = tmp;
2044 if (*p == '-' && *size > 1) {
2045 *neg = true;
2046 p++;
2047 } else
2048 *neg = false;
2049 if (!isdigit(*p))
2050 return -EINVAL;
2051
2052 *val = simple_strtoul(p, &p, 0);
2053
2054 len = p - tmp;
2055
2056 /* We don't know if the next char is whitespace thus we may accept
2057 * invalid integers (e.g. 1234...a) or two integers instead of one
2058 * (e.g. 123...1). So lets not allow such large numbers. */
2059 if (len == TMPBUFLEN - 1)
2060 return -EINVAL;
2061
2062 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2063 return -EINVAL;
1da177e4 2064
00b7c339
AW
2065 if (tr && (len < *size))
2066 *tr = *p;
2067
2068 *buf += len;
2069 *size -= len;
2070
2071 return 0;
2072}
2073
2074/**
0fc377bd 2075 * proc_put_long - converts an integer to a decimal ASCII formatted string
00b7c339 2076 *
0fc377bd
RD
2077 * @buf: the user buffer
2078 * @size: the size of the user buffer
2079 * @val: the integer to be converted
2080 * @neg: sign of the number, %TRUE for negative
00b7c339 2081 *
0fc377bd
RD
2082 * In case of success %0 is returned and @buf and @size are updated with
2083 * the amount of bytes written.
00b7c339
AW
2084 */
2085static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2086 bool neg)
2087{
2088 int len;
2089 char tmp[TMPBUFLEN], *p = tmp;
2090
2091 sprintf(p, "%s%lu", neg ? "-" : "", val);
2092 len = strlen(tmp);
2093 if (len > *size)
2094 len = *size;
2095 if (copy_to_user(*buf, tmp, len))
2096 return -EFAULT;
2097 *size -= len;
2098 *buf += len;
2099 return 0;
2100}
2101#undef TMPBUFLEN
2102
2103static int proc_put_char(void __user **buf, size_t *size, char c)
2104{
2105 if (*size) {
2106 char __user **buffer = (char __user **)buf;
2107 if (put_user(c, *buffer))
2108 return -EFAULT;
2109 (*size)--, (*buffer)++;
2110 *buf = *buffer;
2111 }
2112 return 0;
2113}
1da177e4 2114
00b7c339 2115static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
2116 int *valp,
2117 int write, void *data)
2118{
2119 if (write) {
230633d1
HS
2120 if (*negp) {
2121 if (*lvalp > (unsigned long) INT_MAX + 1)
2122 return -EINVAL;
2123 *valp = -*lvalp;
2124 } else {
2125 if (*lvalp > (unsigned long) INT_MAX)
2126 return -EINVAL;
2127 *valp = *lvalp;
2128 }
1da177e4
LT
2129 } else {
2130 int val = *valp;
2131 if (val < 0) {
00b7c339 2132 *negp = true;
9a5bc726 2133 *lvalp = -(unsigned long)val;
1da177e4 2134 } else {
00b7c339 2135 *negp = false;
1da177e4
LT
2136 *lvalp = (unsigned long)val;
2137 }
2138 }
2139 return 0;
2140}
2141
e7d316a0
SAK
2142static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2143 int *valp,
2144 int write, void *data)
2145{
2146 if (write) {
2147 if (*negp)
2148 return -EINVAL;
2149 *valp = *lvalp;
2150 } else {
2151 unsigned int val = *valp;
2152 *lvalp = (unsigned long)val;
2153 }
2154 return 0;
2155}
2156
00b7c339
AW
2157static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2158
d8217f07 2159static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
8d65af78 2160 int write, void __user *buffer,
fcfbd547 2161 size_t *lenp, loff_t *ppos,
00b7c339 2162 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
1da177e4
LT
2163 int write, void *data),
2164 void *data)
2165{
00b7c339 2166 int *i, vleft, first = 1, err = 0;
00b7c339 2167 size_t left;
70f6cbb6 2168 char *kbuf = NULL, *p;
1da177e4 2169
00b7c339 2170 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
1da177e4
LT
2171 *lenp = 0;
2172 return 0;
2173 }
2174
fcfbd547 2175 i = (int *) tbl_data;
1da177e4
LT
2176 vleft = table->maxlen / sizeof(*i);
2177 left = *lenp;
2178
2179 if (!conv)
2180 conv = do_proc_dointvec_conv;
2181
00b7c339 2182 if (write) {
f4aacea2
KC
2183 if (*ppos) {
2184 switch (sysctl_writes_strict) {
2185 case SYSCTL_WRITES_STRICT:
2186 goto out;
2187 case SYSCTL_WRITES_WARN:
2188 warn_sysctl_write(table);
2189 break;
2190 default:
2191 break;
2192 }
2193 }
2194
00b7c339
AW
2195 if (left > PAGE_SIZE - 1)
2196 left = PAGE_SIZE - 1;
70f6cbb6
AV
2197 p = kbuf = memdup_user_nul(buffer, left);
2198 if (IS_ERR(kbuf))
2199 return PTR_ERR(kbuf);
00b7c339
AW
2200 }
2201
1da177e4 2202 for (; left && vleft--; i++, first=0) {
00b7c339
AW
2203 unsigned long lval;
2204 bool neg;
1da177e4 2205
00b7c339 2206 if (write) {
70f6cbb6 2207 left -= proc_skip_spaces(&p);
1da177e4 2208
563b0467
O
2209 if (!left)
2210 break;
70f6cbb6 2211 err = proc_get_long(&p, &left, &lval, &neg,
00b7c339
AW
2212 proc_wspace_sep,
2213 sizeof(proc_wspace_sep), NULL);
2214 if (err)
1da177e4 2215 break;
00b7c339
AW
2216 if (conv(&neg, &lval, i, 1, data)) {
2217 err = -EINVAL;
1da177e4 2218 break;
00b7c339 2219 }
1da177e4 2220 } else {
00b7c339
AW
2221 if (conv(&neg, &lval, i, 0, data)) {
2222 err = -EINVAL;
2223 break;
2224 }
1da177e4 2225 if (!first)
00b7c339
AW
2226 err = proc_put_char(&buffer, &left, '\t');
2227 if (err)
2228 break;
2229 err = proc_put_long(&buffer, &left, lval, neg);
2230 if (err)
1da177e4 2231 break;
1da177e4
LT
2232 }
2233 }
2234
00b7c339
AW
2235 if (!write && !first && left && !err)
2236 err = proc_put_char(&buffer, &left, '\n');
563b0467 2237 if (write && !err && left)
70f6cbb6 2238 left -= proc_skip_spaces(&p);
1da177e4 2239 if (write) {
70f6cbb6 2240 kfree(kbuf);
00b7c339
AW
2241 if (first)
2242 return err ? : -EINVAL;
1da177e4 2243 }
1da177e4 2244 *lenp -= left;
f4aacea2 2245out:
1da177e4 2246 *ppos += *lenp;
00b7c339 2247 return err;
1da177e4
LT
2248}
2249
8d65af78 2250static int do_proc_dointvec(struct ctl_table *table, int write,
fcfbd547 2251 void __user *buffer, size_t *lenp, loff_t *ppos,
00b7c339 2252 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
fcfbd547
KK
2253 int write, void *data),
2254 void *data)
2255{
8d65af78 2256 return __do_proc_dointvec(table->data, table, write,
fcfbd547
KK
2257 buffer, lenp, ppos, conv, data);
2258}
2259
1da177e4
LT
2260/**
2261 * proc_dointvec - read a vector of integers
2262 * @table: the sysctl table
2263 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2264 * @buffer: the user buffer
2265 * @lenp: the size of the user buffer
2266 * @ppos: file position
2267 *
2268 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2269 * values from/to the user buffer, treated as an ASCII string.
2270 *
2271 * Returns 0 on success.
2272 */
8d65af78 2273int proc_dointvec(struct ctl_table *table, int write,
1da177e4
LT
2274 void __user *buffer, size_t *lenp, loff_t *ppos)
2275{
e7d316a0
SAK
2276 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2277}
2278
2279/**
2280 * proc_douintvec - read a vector of unsigned integers
2281 * @table: the sysctl table
2282 * @write: %TRUE if this is a write to the sysctl file
2283 * @buffer: the user buffer
2284 * @lenp: the size of the user buffer
2285 * @ppos: file position
2286 *
2287 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2288 * values from/to the user buffer, treated as an ASCII string.
2289 *
2290 * Returns 0 on success.
2291 */
2292int proc_douintvec(struct ctl_table *table, int write,
2293 void __user *buffer, size_t *lenp, loff_t *ppos)
2294{
2295 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2296 do_proc_douintvec_conv, NULL);
1da177e4
LT
2297}
2298
34f5a398 2299/*
25ddbb18
AK
2300 * Taint values can only be increased
2301 * This means we can safely use a temporary.
34f5a398 2302 */
8d65af78 2303static int proc_taint(struct ctl_table *table, int write,
34f5a398
TT
2304 void __user *buffer, size_t *lenp, loff_t *ppos)
2305{
25ddbb18
AK
2306 struct ctl_table t;
2307 unsigned long tmptaint = get_taint();
2308 int err;
34f5a398 2309
91fcd412 2310 if (write && !capable(CAP_SYS_ADMIN))
34f5a398
TT
2311 return -EPERM;
2312
25ddbb18
AK
2313 t = *table;
2314 t.data = &tmptaint;
8d65af78 2315 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
25ddbb18
AK
2316 if (err < 0)
2317 return err;
2318
2319 if (write) {
2320 /*
2321 * Poor man's atomic or. Not worth adding a primitive
2322 * to everyone's atomic.h for this
2323 */
2324 int i;
2325 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2326 if ((tmptaint >> i) & 1)
373d4d09 2327 add_taint(i, LOCKDEP_STILL_OK);
25ddbb18
AK
2328 }
2329 }
2330
2331 return err;
34f5a398
TT
2332}
2333
bfdc0b49 2334#ifdef CONFIG_PRINTK
620f6e8e 2335static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
bfdc0b49
RW
2336 void __user *buffer, size_t *lenp, loff_t *ppos)
2337{
2338 if (write && !capable(CAP_SYS_ADMIN))
2339 return -EPERM;
2340
2341 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2342}
2343#endif
2344
1da177e4
LT
2345struct do_proc_dointvec_minmax_conv_param {
2346 int *min;
2347 int *max;
2348};
2349
00b7c339
AW
2350static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2351 int *valp,
1da177e4
LT
2352 int write, void *data)
2353{
2354 struct do_proc_dointvec_minmax_conv_param *param = data;
2355 if (write) {
2356 int val = *negp ? -*lvalp : *lvalp;
2357 if ((param->min && *param->min > val) ||
2358 (param->max && *param->max < val))
2359 return -EINVAL;
2360 *valp = val;
2361 } else {
2362 int val = *valp;
2363 if (val < 0) {
00b7c339 2364 *negp = true;
9a5bc726 2365 *lvalp = -(unsigned long)val;
1da177e4 2366 } else {
00b7c339 2367 *negp = false;
1da177e4
LT
2368 *lvalp = (unsigned long)val;
2369 }
2370 }
2371 return 0;
2372}
2373
2374/**
2375 * proc_dointvec_minmax - read a vector of integers with min/max values
2376 * @table: the sysctl table
2377 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2378 * @buffer: the user buffer
2379 * @lenp: the size of the user buffer
2380 * @ppos: file position
2381 *
2382 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2383 * values from/to the user buffer, treated as an ASCII string.
2384 *
2385 * This routine will ensure the values are within the range specified by
2386 * table->extra1 (min) and table->extra2 (max).
2387 *
2388 * Returns 0 on success.
2389 */
8d65af78 2390int proc_dointvec_minmax(struct ctl_table *table, int write,
1da177e4
LT
2391 void __user *buffer, size_t *lenp, loff_t *ppos)
2392{
2393 struct do_proc_dointvec_minmax_conv_param param = {
2394 .min = (int *) table->extra1,
2395 .max = (int *) table->extra2,
2396 };
8d65af78 2397 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1da177e4
LT
2398 do_proc_dointvec_minmax_conv, &param);
2399}
2400
54b50199
KC
2401static void validate_coredump_safety(void)
2402{
046d662f 2403#ifdef CONFIG_COREDUMP
e579d2c2 2404 if (suid_dumpable == SUID_DUMP_ROOT &&
54b50199
KC
2405 core_pattern[0] != '/' && core_pattern[0] != '|') {
2406 printk(KERN_WARNING "Unsafe core_pattern used with "\
2407 "suid_dumpable=2. Pipe handler or fully qualified "\
2408 "core dump path required.\n");
2409 }
046d662f 2410#endif
54b50199
KC
2411}
2412
2413static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2414 void __user *buffer, size_t *lenp, loff_t *ppos)
2415{
2416 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2417 if (!error)
2418 validate_coredump_safety();
2419 return error;
2420}
2421
046d662f 2422#ifdef CONFIG_COREDUMP
54b50199
KC
2423static int proc_dostring_coredump(struct ctl_table *table, int write,
2424 void __user *buffer, size_t *lenp, loff_t *ppos)
2425{
2426 int error = proc_dostring(table, write, buffer, lenp, ppos);
2427 if (!error)
2428 validate_coredump_safety();
2429 return error;
2430}
046d662f 2431#endif
54b50199 2432
d8217f07 2433static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
1da177e4
LT
2434 void __user *buffer,
2435 size_t *lenp, loff_t *ppos,
2436 unsigned long convmul,
2437 unsigned long convdiv)
2438{
00b7c339
AW
2439 unsigned long *i, *min, *max;
2440 int vleft, first = 1, err = 0;
00b7c339 2441 size_t left;
70f6cbb6 2442 char *kbuf = NULL, *p;
00b7c339
AW
2443
2444 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1da177e4
LT
2445 *lenp = 0;
2446 return 0;
2447 }
00b7c339 2448
fcfbd547 2449 i = (unsigned long *) data;
1da177e4
LT
2450 min = (unsigned long *) table->extra1;
2451 max = (unsigned long *) table->extra2;
2452 vleft = table->maxlen / sizeof(unsigned long);
2453 left = *lenp;
00b7c339
AW
2454
2455 if (write) {
f4aacea2
KC
2456 if (*ppos) {
2457 switch (sysctl_writes_strict) {
2458 case SYSCTL_WRITES_STRICT:
2459 goto out;
2460 case SYSCTL_WRITES_WARN:
2461 warn_sysctl_write(table);
2462 break;
2463 default:
2464 break;
2465 }
2466 }
2467
00b7c339
AW
2468 if (left > PAGE_SIZE - 1)
2469 left = PAGE_SIZE - 1;
70f6cbb6
AV
2470 p = kbuf = memdup_user_nul(buffer, left);
2471 if (IS_ERR(kbuf))
2472 return PTR_ERR(kbuf);
00b7c339
AW
2473 }
2474
27b3d80a 2475 for (; left && vleft--; i++, first = 0) {
00b7c339
AW
2476 unsigned long val;
2477
1da177e4 2478 if (write) {
00b7c339
AW
2479 bool neg;
2480
70f6cbb6 2481 left -= proc_skip_spaces(&p);
00b7c339 2482
70f6cbb6 2483 err = proc_get_long(&p, &left, &val, &neg,
00b7c339
AW
2484 proc_wspace_sep,
2485 sizeof(proc_wspace_sep), NULL);
2486 if (err)
1da177e4
LT
2487 break;
2488 if (neg)
1da177e4
LT
2489 continue;
2490 if ((min && val < *min) || (max && val > *max))
2491 continue;
2492 *i = val;
2493 } else {
00b7c339 2494 val = convdiv * (*i) / convmul;
7833819d 2495 if (!first) {
00b7c339 2496 err = proc_put_char(&buffer, &left, '\t');
7833819d
CG
2497 if (err)
2498 break;
2499 }
00b7c339
AW
2500 err = proc_put_long(&buffer, &left, val, false);
2501 if (err)
2502 break;
1da177e4
LT
2503 }
2504 }
2505
00b7c339
AW
2506 if (!write && !first && left && !err)
2507 err = proc_put_char(&buffer, &left, '\n');
2508 if (write && !err)
70f6cbb6 2509 left -= proc_skip_spaces(&p);
1da177e4 2510 if (write) {
70f6cbb6 2511 kfree(kbuf);
00b7c339
AW
2512 if (first)
2513 return err ? : -EINVAL;
1da177e4 2514 }
1da177e4 2515 *lenp -= left;
f4aacea2 2516out:
1da177e4 2517 *ppos += *lenp;
00b7c339 2518 return err;
1da177e4
LT
2519}
2520
d8217f07 2521static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
fcfbd547
KK
2522 void __user *buffer,
2523 size_t *lenp, loff_t *ppos,
2524 unsigned long convmul,
2525 unsigned long convdiv)
2526{
2527 return __do_proc_doulongvec_minmax(table->data, table, write,
8d65af78 2528 buffer, lenp, ppos, convmul, convdiv);
fcfbd547
KK
2529}
2530
1da177e4
LT
2531/**
2532 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2533 * @table: the sysctl table
2534 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2535 * @buffer: the user buffer
2536 * @lenp: the size of the user buffer
2537 * @ppos: file position
2538 *
2539 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2540 * values from/to the user buffer, treated as an ASCII string.
2541 *
2542 * This routine will ensure the values are within the range specified by
2543 * table->extra1 (min) and table->extra2 (max).
2544 *
2545 * Returns 0 on success.
2546 */
8d65af78 2547int proc_doulongvec_minmax(struct ctl_table *table, int write,
1da177e4
LT
2548 void __user *buffer, size_t *lenp, loff_t *ppos)
2549{
8d65af78 2550 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1da177e4
LT
2551}
2552
2553/**
2554 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2555 * @table: the sysctl table
2556 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2557 * @buffer: the user buffer
2558 * @lenp: the size of the user buffer
2559 * @ppos: file position
2560 *
2561 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2562 * values from/to the user buffer, treated as an ASCII string. The values
2563 * are treated as milliseconds, and converted to jiffies when they are stored.
2564 *
2565 * This routine will ensure the values are within the range specified by
2566 * table->extra1 (min) and table->extra2 (max).
2567 *
2568 * Returns 0 on success.
2569 */
d8217f07 2570int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1da177e4
LT
2571 void __user *buffer,
2572 size_t *lenp, loff_t *ppos)
2573{
8d65af78 2574 return do_proc_doulongvec_minmax(table, write, buffer,
1da177e4
LT
2575 lenp, ppos, HZ, 1000l);
2576}
2577
2578
00b7c339 2579static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
2580 int *valp,
2581 int write, void *data)
2582{
2583 if (write) {
cba9f33d
BS
2584 if (*lvalp > LONG_MAX / HZ)
2585 return 1;
1da177e4
LT
2586 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2587 } else {
2588 int val = *valp;
2589 unsigned long lval;
2590 if (val < 0) {
00b7c339 2591 *negp = true;
9a5bc726 2592 lval = -(unsigned long)val;
1da177e4 2593 } else {
00b7c339 2594 *negp = false;
1da177e4
LT
2595 lval = (unsigned long)val;
2596 }
2597 *lvalp = lval / HZ;
2598 }
2599 return 0;
2600}
2601
00b7c339 2602static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
2603 int *valp,
2604 int write, void *data)
2605{
2606 if (write) {
cba9f33d
BS
2607 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2608 return 1;
1da177e4
LT
2609 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2610 } else {
2611 int val = *valp;
2612 unsigned long lval;
2613 if (val < 0) {
00b7c339 2614 *negp = true;
9a5bc726 2615 lval = -(unsigned long)val;
1da177e4 2616 } else {
00b7c339 2617 *negp = false;
1da177e4
LT
2618 lval = (unsigned long)val;
2619 }
2620 *lvalp = jiffies_to_clock_t(lval);
2621 }
2622 return 0;
2623}
2624
00b7c339 2625static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
2626 int *valp,
2627 int write, void *data)
2628{
2629 if (write) {
d738ce8f
FF
2630 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2631
2632 if (jif > INT_MAX)
2633 return 1;
2634 *valp = (int)jif;
1da177e4
LT
2635 } else {
2636 int val = *valp;
2637 unsigned long lval;
2638 if (val < 0) {
00b7c339 2639 *negp = true;
9a5bc726 2640 lval = -(unsigned long)val;
1da177e4 2641 } else {
00b7c339 2642 *negp = false;
1da177e4
LT
2643 lval = (unsigned long)val;
2644 }
2645 *lvalp = jiffies_to_msecs(lval);
2646 }
2647 return 0;
2648}
2649
2650/**
2651 * proc_dointvec_jiffies - read a vector of integers as seconds
2652 * @table: the sysctl table
2653 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2654 * @buffer: the user buffer
2655 * @lenp: the size of the user buffer
2656 * @ppos: file position
2657 *
2658 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2659 * values from/to the user buffer, treated as an ASCII string.
2660 * The values read are assumed to be in seconds, and are converted into
2661 * jiffies.
2662 *
2663 * Returns 0 on success.
2664 */
8d65af78 2665int proc_dointvec_jiffies(struct ctl_table *table, int write,
1da177e4
LT
2666 void __user *buffer, size_t *lenp, loff_t *ppos)
2667{
8d65af78 2668 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1da177e4
LT
2669 do_proc_dointvec_jiffies_conv,NULL);
2670}
2671
2672/**
2673 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2674 * @table: the sysctl table
2675 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2676 * @buffer: the user buffer
2677 * @lenp: the size of the user buffer
1e5d5331 2678 * @ppos: pointer to the file position
1da177e4
LT
2679 *
2680 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2681 * values from/to the user buffer, treated as an ASCII string.
2682 * The values read are assumed to be in 1/USER_HZ seconds, and
2683 * are converted into jiffies.
2684 *
2685 * Returns 0 on success.
2686 */
8d65af78 2687int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1da177e4
LT
2688 void __user *buffer, size_t *lenp, loff_t *ppos)
2689{
8d65af78 2690 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1da177e4
LT
2691 do_proc_dointvec_userhz_jiffies_conv,NULL);
2692}
2693
2694/**
2695 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2696 * @table: the sysctl table
2697 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
2698 * @buffer: the user buffer
2699 * @lenp: the size of the user buffer
67be2dd1
MW
2700 * @ppos: file position
2701 * @ppos: the current position in the file
1da177e4
LT
2702 *
2703 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2704 * values from/to the user buffer, treated as an ASCII string.
2705 * The values read are assumed to be in 1/1000 seconds, and
2706 * are converted into jiffies.
2707 *
2708 * Returns 0 on success.
2709 */
8d65af78 2710int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1da177e4
LT
2711 void __user *buffer, size_t *lenp, loff_t *ppos)
2712{
8d65af78 2713 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1da177e4
LT
2714 do_proc_dointvec_ms_jiffies_conv, NULL);
2715}
2716
8d65af78 2717static int proc_do_cad_pid(struct ctl_table *table, int write,
9ec52099
CLG
2718 void __user *buffer, size_t *lenp, loff_t *ppos)
2719{
2720 struct pid *new_pid;
2721 pid_t tmp;
2722 int r;
2723
6c5f3e7b 2724 tmp = pid_vnr(cad_pid);
9ec52099 2725
8d65af78 2726 r = __do_proc_dointvec(&tmp, table, write, buffer,
9ec52099
CLG
2727 lenp, ppos, NULL, NULL);
2728 if (r || !write)
2729 return r;
2730
2731 new_pid = find_get_pid(tmp);
2732 if (!new_pid)
2733 return -ESRCH;
2734
2735 put_pid(xchg(&cad_pid, new_pid));
2736 return 0;
2737}
2738
9f977fb7
OP
2739/**
2740 * proc_do_large_bitmap - read/write from/to a large bitmap
2741 * @table: the sysctl table
2742 * @write: %TRUE if this is a write to the sysctl file
2743 * @buffer: the user buffer
2744 * @lenp: the size of the user buffer
2745 * @ppos: file position
2746 *
2747 * The bitmap is stored at table->data and the bitmap length (in bits)
2748 * in table->maxlen.
2749 *
2750 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2751 * large bitmaps may be represented in a compact manner. Writing into
2752 * the file will clear the bitmap then update it with the given input.
2753 *
2754 * Returns 0 on success.
2755 */
2756int proc_do_large_bitmap(struct ctl_table *table, int write,
2757 void __user *buffer, size_t *lenp, loff_t *ppos)
2758{
2759 int err = 0;
2760 bool first = 1;
2761 size_t left = *lenp;
2762 unsigned long bitmap_len = table->maxlen;
122ff243 2763 unsigned long *bitmap = *(unsigned long **) table->data;
9f977fb7
OP
2764 unsigned long *tmp_bitmap = NULL;
2765 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2766
122ff243 2767 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
9f977fb7
OP
2768 *lenp = 0;
2769 return 0;
2770 }
2771
2772 if (write) {
70f6cbb6 2773 char *kbuf, *p;
9f977fb7
OP
2774
2775 if (left > PAGE_SIZE - 1)
2776 left = PAGE_SIZE - 1;
2777
70f6cbb6
AV
2778 p = kbuf = memdup_user_nul(buffer, left);
2779 if (IS_ERR(kbuf))
2780 return PTR_ERR(kbuf);
9f977fb7
OP
2781
2782 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2783 GFP_KERNEL);
2784 if (!tmp_bitmap) {
70f6cbb6 2785 kfree(kbuf);
9f977fb7
OP
2786 return -ENOMEM;
2787 }
70f6cbb6 2788 proc_skip_char(&p, &left, '\n');
9f977fb7
OP
2789 while (!err && left) {
2790 unsigned long val_a, val_b;
2791 bool neg;
2792
70f6cbb6 2793 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
9f977fb7
OP
2794 sizeof(tr_a), &c);
2795 if (err)
2796 break;
2797 if (val_a >= bitmap_len || neg) {
2798 err = -EINVAL;
2799 break;
2800 }
2801
2802 val_b = val_a;
2803 if (left) {
70f6cbb6 2804 p++;
9f977fb7
OP
2805 left--;
2806 }
2807
2808 if (c == '-') {
70f6cbb6 2809 err = proc_get_long(&p, &left, &val_b,
9f977fb7
OP
2810 &neg, tr_b, sizeof(tr_b),
2811 &c);
2812 if (err)
2813 break;
2814 if (val_b >= bitmap_len || neg ||
2815 val_a > val_b) {
2816 err = -EINVAL;
2817 break;
2818 }
2819 if (left) {
70f6cbb6 2820 p++;
9f977fb7
OP
2821 left--;
2822 }
2823 }
2824
5a04cca6 2825 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
9f977fb7 2826 first = 0;
70f6cbb6 2827 proc_skip_char(&p, &left, '\n');
9f977fb7 2828 }
70f6cbb6 2829 kfree(kbuf);
9f977fb7
OP
2830 } else {
2831 unsigned long bit_a, bit_b = 0;
2832
2833 while (left) {
2834 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2835 if (bit_a >= bitmap_len)
2836 break;
2837 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2838 bit_a + 1) - 1;
2839
2840 if (!first) {
2841 err = proc_put_char(&buffer, &left, ',');
2842 if (err)
2843 break;
2844 }
2845 err = proc_put_long(&buffer, &left, bit_a, false);
2846 if (err)
2847 break;
2848 if (bit_a != bit_b) {
2849 err = proc_put_char(&buffer, &left, '-');
2850 if (err)
2851 break;
2852 err = proc_put_long(&buffer, &left, bit_b, false);
2853 if (err)
2854 break;
2855 }
2856
2857 first = 0; bit_b++;
2858 }
2859 if (!err)
2860 err = proc_put_char(&buffer, &left, '\n');
2861 }
2862
2863 if (!err) {
2864 if (write) {
2865 if (*ppos)
2866 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2867 else
5a04cca6 2868 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
9f977fb7
OP
2869 }
2870 kfree(tmp_bitmap);
2871 *lenp -= left;
2872 *ppos += *lenp;
2873 return 0;
2874 } else {
2875 kfree(tmp_bitmap);
2876 return err;
2877 }
2878}
2879
55610500 2880#else /* CONFIG_PROC_SYSCTL */
1da177e4 2881
8d65af78 2882int proc_dostring(struct ctl_table *table, int write,
1da177e4
LT
2883 void __user *buffer, size_t *lenp, loff_t *ppos)
2884{
2885 return -ENOSYS;
2886}
2887
8d65af78 2888int proc_dointvec(struct ctl_table *table, int write,
1da177e4 2889 void __user *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
2890{
2891 return -ENOSYS;
2892}
2893
e7d316a0
SAK
2894int proc_douintvec(struct ctl_table *table, int write,
2895 void __user *buffer, size_t *lenp, loff_t *ppos)
2896{
2897 return -ENOSYS;
2898}
2899
8d65af78 2900int proc_dointvec_minmax(struct ctl_table *table, int write,
1da177e4
LT
2901 void __user *buffer, size_t *lenp, loff_t *ppos)
2902{
2903 return -ENOSYS;
2904}
2905
8d65af78 2906int proc_dointvec_jiffies(struct ctl_table *table, int write,
1da177e4
LT
2907 void __user *buffer, size_t *lenp, loff_t *ppos)
2908{
2909 return -ENOSYS;
2910}
2911
8d65af78 2912int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1da177e4
LT
2913 void __user *buffer, size_t *lenp, loff_t *ppos)
2914{
2915 return -ENOSYS;
2916}
2917
8d65af78 2918int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1da177e4
LT
2919 void __user *buffer, size_t *lenp, loff_t *ppos)
2920{
2921 return -ENOSYS;
2922}
2923
8d65af78 2924int proc_doulongvec_minmax(struct ctl_table *table, int write,
1da177e4
LT
2925 void __user *buffer, size_t *lenp, loff_t *ppos)
2926{
2927 return -ENOSYS;
2928}
2929
d8217f07 2930int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1da177e4
LT
2931 void __user *buffer,
2932 size_t *lenp, loff_t *ppos)
2933{
2934 return -ENOSYS;
2935}
2936
2937
55610500 2938#endif /* CONFIG_PROC_SYSCTL */
1da177e4 2939
1da177e4
LT
2940/*
2941 * No sense putting this after each symbol definition, twice,
2942 * exception granted :-)
2943 */
2944EXPORT_SYMBOL(proc_dointvec);
e7d316a0 2945EXPORT_SYMBOL(proc_douintvec);
1da177e4
LT
2946EXPORT_SYMBOL(proc_dointvec_jiffies);
2947EXPORT_SYMBOL(proc_dointvec_minmax);
2948EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2949EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2950EXPORT_SYMBOL(proc_dostring);
2951EXPORT_SYMBOL(proc_doulongvec_minmax);
2952EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);