sysctl.c 60.7 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * sysctl.c: General linux system control interface
 *
 * Begun 24 March 1995, Stephen Tweedie
 * Added /proc support, Dec 1995
 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
 * Dynamic registration fixes, Stephen Tweedie.
 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
 *  Horn.
 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
 *  Wendling.
 * The list_for_each() macro wasn't appropriate for the sysctl loop.
 *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
 */

#include <linux/module.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
27
#include <linux/security.h>
Linus Torvalds's avatar
Linus Torvalds committed
28
#include <linux/ctype.h>
29
#include <linux/kmemcheck.h>
30
#include <linux/fs.h>
Linus Torvalds's avatar
Linus Torvalds committed
31 32
#include <linux/init.h>
#include <linux/kernel.h>
33
#include <linux/kobject.h>
34
#include <linux/net.h>
Linus Torvalds's avatar
Linus Torvalds committed
35 36 37
#include <linux/sysrq.h>
#include <linux/highuid.h>
#include <linux/writeback.h>
38
#include <linux/ratelimit.h>
Linus Torvalds's avatar
Linus Torvalds committed
39 40
#include <linux/hugetlb.h>
#include <linux/initrd.h>
41
#include <linux/key.h>
Linus Torvalds's avatar
Linus Torvalds committed
42 43 44 45
#include <linux/times.h>
#include <linux/limits.h>
#include <linux/dcache.h>
#include <linux/syscalls.h>
Adrian Bunk's avatar
Adrian Bunk committed
46
#include <linux/vmstat.h>
47 48
#include <linux/nfs_fs.h>
#include <linux/acpi.h>
49
#include <linux/reboot.h>
50
#include <linux/ftrace.h>
51
#include <linux/slow-work.h>
52
#include <linux/perf_event.h>
Linus Torvalds's avatar
Linus Torvalds committed
53 54 55 56

#include <asm/uaccess.h>
#include <asm/processor.h>

57 58
#ifdef CONFIG_X86
#include <asm/nmi.h>
59
#include <asm/stacktrace.h>
60
#include <asm/io.h>
61 62
#endif

63

Linus Torvalds's avatar
Linus Torvalds committed
64 65 66 67
#if defined(CONFIG_SYSCTL)

/* External variables not in a header file. */
extern int C_A_D;
Ingo Molnar's avatar
Ingo Molnar committed
68
extern int print_fatal_signals;
Linus Torvalds's avatar
Linus Torvalds committed
69 70
extern int sysctl_overcommit_memory;
extern int sysctl_overcommit_ratio;
71
extern int sysctl_panic_on_oom;
72
extern int sysctl_oom_kill_allocating_task;
73
extern int sysctl_oom_dump_tasks;
Linus Torvalds's avatar
Linus Torvalds committed
74 75
extern int max_threads;
extern int core_uses_pid;
Alan Cox's avatar
Alan Cox committed
76
extern int suid_dumpable;
Linus Torvalds's avatar
Linus Torvalds committed
77
extern char core_pattern[];
78
extern unsigned int core_pipe_limit;
Linus Torvalds's avatar
Linus Torvalds committed
79 80 81
extern int pid_max;
extern int min_free_kbytes;
extern int pid_max_min, pid_max_max;
Andrew Morton's avatar
Andrew Morton committed
82
extern int sysctl_drop_caches;
83
extern int percpu_pagelist_fraction;
84
extern int compat_log;
Arjan van de Ven's avatar
Arjan van de Ven committed
85
extern int latencytop_enabled;
86
extern int sysctl_nr_open_min, sysctl_nr_open_max;
87 88 89
#ifndef CONFIG_MMU
extern int sysctl_nr_trim_pages;
#endif
90 91 92
#ifdef CONFIG_RCU_TORTURE_TEST
extern int rcutorture_runnable;
#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
93
#ifdef CONFIG_BLOCK
94
extern int blk_iopoll_enabled;
95
#endif
Linus Torvalds's avatar
Linus Torvalds committed
96

97
/* Constants used for minimum and  maximum */
98
#ifdef CONFIG_DETECT_SOFTLOCKUP
99
static int sixty = 60;
100
static int neg_one = -1;
101 102 103
#endif

static int zero;
104 105
static int __maybe_unused one = 1;
static int __maybe_unused two = 2;
106
static unsigned long one_ul = 1;
107
static int one_hundred = 100;
108 109 110
#ifdef CONFIG_PRINTK
static int ten_thousand = 10000;
#endif
111

112 113 114
/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;

Linus Torvalds's avatar
Linus Torvalds committed
115 116 117
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
static int minolduid;
118
static int min_percpu_pagelist_fract = 8;
Linus Torvalds's avatar
Linus Torvalds committed
119 120 121

static int ngroups_max = NGROUPS_MAX;

122
#ifdef CONFIG_MODULES
Linus Torvalds's avatar
Linus Torvalds committed
123
extern char modprobe_path[];
124
extern int modules_disabled;
Linus Torvalds's avatar
Linus Torvalds committed
125 126 127 128 129
#endif
#ifdef CONFIG_CHR_DEV_SG
extern int sg_big_buff;
#endif

130
#ifdef CONFIG_SPARC
131
#include <asm/system.h>
Linus Torvalds's avatar
Linus Torvalds committed
132 133
#endif

134 135 136 137
#ifdef CONFIG_SPARC64
extern int sysctl_tsb_ratio;
#endif

Linus Torvalds's avatar
Linus Torvalds committed
138 139 140 141 142
#ifdef __hppa__
extern int pwrsw_enabled;
extern int unaligned_enabled;
#endif

143
#ifdef CONFIG_S390
Linus Torvalds's avatar
Linus Torvalds committed
144 145 146 147
#ifdef CONFIG_MATHEMU
extern int sysctl_ieee_emulation_warnings;
#endif
extern int sysctl_userprocess_debug;
148
extern int spin_retry;
Linus Torvalds's avatar
Linus Torvalds committed
149 150 151 152 153 154
#endif

#ifdef CONFIG_BSD_PROCESS_ACCT
extern int acct_parm[];
#endif

155 156
#ifdef CONFIG_IA64
extern int no_unaligned_warning;
157
extern int unaligned_dump_stack;
158 159
#endif

160 161
extern struct ratelimit_state printk_ratelimit_state;

Ingo Molnar's avatar
Ingo Molnar committed
162 163 164 165
#ifdef CONFIG_RT_MUTEXES
extern int max_lock_depth;
#endif

166
#ifdef CONFIG_PROC_SYSCTL
167
static int proc_do_cad_pid(struct ctl_table *table, int write,
168
		  void __user *buffer, size_t *lenp, loff_t *ppos);
169
static int proc_taint(struct ctl_table *table, int write,
170
			       void __user *buffer, size_t *lenp, loff_t *ppos);
171
#endif
172

173
static struct ctl_table root_table[];
174 175
static struct ctl_table_root sysctl_table_root;
static struct ctl_table_header root_table_header = {
176
	.count = 1,
177
	.ctl_table = root_table,
178
	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
179
	.root = &sysctl_table_root,
180
	.set = &sysctl_table_root.default_set,
181 182 183
};
static struct ctl_table_root sysctl_table_root = {
	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
184
	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
185
};
Linus Torvalds's avatar
Linus Torvalds committed
186

187 188 189 190 191 192
static struct ctl_table kern_table[];
static struct ctl_table vm_table[];
static struct ctl_table fs_table[];
static struct ctl_table debug_table[];
static struct ctl_table dev_table[];
extern struct ctl_table random_table[];
193
#ifdef CONFIG_INOTIFY_USER
194
extern struct ctl_table inotify_table[];
Robert Love's avatar
Robert Love committed
195
#endif
196 197 198
#ifdef CONFIG_EPOLL
extern struct ctl_table epoll_table[];
#endif
Linus Torvalds's avatar
Linus Torvalds committed
199 200 201 202 203

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif

Peter Zijlstra's avatar
Peter Zijlstra committed
204 205
extern int prove_locking;
extern int lock_stat;
206

Linus Torvalds's avatar
Linus Torvalds committed
207 208
/* The default sysctl tables: */

209
static struct ctl_table root_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
	{
		.procname	= "kernel",
		.mode		= 0555,
		.child		= kern_table,
	},
	{
		.procname	= "vm",
		.mode		= 0555,
		.child		= vm_table,
	},
	{
		.procname	= "fs",
		.mode		= 0555,
		.child		= fs_table,
	},
	{
		.procname	= "debug",
		.mode		= 0555,
		.child		= debug_table,
	},
	{
		.procname	= "dev",
		.mode		= 0555,
		.child		= dev_table,
	},
235 236 237 238
/*
 * NOTE: do not add new entries to this table unless you have read
 * Documentation/sysctl/ctl_unnumbered.txt
 */
239
	{ }
Linus Torvalds's avatar
Linus Torvalds committed
240 241
};

Ingo Molnar's avatar
Ingo Molnar committed
242
#ifdef CONFIG_SCHED_DEBUG
243 244 245 246
static int min_sched_granularity_ns = 100000;		/* 100 usecs */
static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
static int min_wakeup_granularity_ns;			/* 0 usecs */
static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
Ingo Molnar's avatar
Ingo Molnar committed
247 248
#endif

249
static struct ctl_table kern_table[] = {
250 251 252 253 254
	{
		.procname	= "sched_child_runs_first",
		.data		= &sysctl_sched_child_runs_first,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
255
		.proc_handler	= proc_dointvec,
256
	},
Ingo Molnar's avatar
Ingo Molnar committed
257 258
#ifdef CONFIG_SCHED_DEBUG
	{
259 260
		.procname	= "sched_min_granularity_ns",
		.data		= &sysctl_sched_min_granularity,
Ingo Molnar's avatar
Ingo Molnar committed
261 262
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
263
		.proc_handler	= sched_nr_latency_handler,
264 265
		.extra1		= &min_sched_granularity_ns,
		.extra2		= &max_sched_granularity_ns,
Ingo Molnar's avatar
Ingo Molnar committed
266
	},
267 268 269 270 271
	{
		.procname	= "sched_latency_ns",
		.data		= &sysctl_sched_latency,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
272
		.proc_handler	= sched_nr_latency_handler,
273 274 275
		.extra1		= &min_sched_granularity_ns,
		.extra2		= &max_sched_granularity_ns,
	},
Ingo Molnar's avatar
Ingo Molnar committed
276 277 278 279 280
	{
		.procname	= "sched_wakeup_granularity_ns",
		.data		= &sysctl_sched_wakeup_granularity,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
281
		.proc_handler	= proc_dointvec_minmax,
Ingo Molnar's avatar
Ingo Molnar committed
282 283 284
		.extra1		= &min_wakeup_granularity_ns,
		.extra2		= &max_wakeup_granularity_ns,
	},
285 286 287 288 289
	{
		.procname	= "sched_shares_ratelimit",
		.data		= &sysctl_sched_shares_ratelimit,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
290
		.proc_handler	= proc_dointvec,
291
	},
292 293 294 295 296
	{
		.procname	= "sched_shares_thresh",
		.data		= &sysctl_sched_shares_thresh,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
297
		.proc_handler	= proc_dointvec_minmax,
298 299
		.extra1		= &zero,
	},
300 301 302 303 304
	{
		.procname	= "sched_features",
		.data		= &sysctl_sched_features,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
305
		.proc_handler	= proc_dointvec,
306
	},
307 308 309 310 311
	{
		.procname	= "sched_migration_cost",
		.data		= &sysctl_sched_migration_cost,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
312
		.proc_handler	= proc_dointvec,
313
	},
314 315 316 317
	{
		.procname	= "sched_nr_migrate",
		.data		= &sysctl_sched_nr_migrate,
		.maxlen		= sizeof(unsigned int),
Peter Zijlstra's avatar
Peter Zijlstra committed
318
		.mode		= 0644,
319
		.proc_handler	= proc_dointvec,
Peter Zijlstra's avatar
Peter Zijlstra committed
320
	},
321 322 323 324 325
	{
		.procname	= "sched_time_avg",
		.data		= &sysctl_sched_time_avg,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
326
		.proc_handler	= proc_dointvec,
327
	},
328 329 330 331 332
	{
		.procname	= "timer_migration",
		.data		= &sysctl_timer_migration,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
333
		.proc_handler	= proc_dointvec_minmax,
334 335
		.extra1		= &zero,
		.extra2		= &one,
Peter Zijlstra's avatar
Peter Zijlstra committed
336
	},
337
#endif
Peter Zijlstra's avatar
Peter Zijlstra committed
338 339 340 341 342
	{
		.procname	= "sched_rt_period_us",
		.data		= &sysctl_sched_rt_period,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
343
		.proc_handler	= sched_rt_handler,
Peter Zijlstra's avatar
Peter Zijlstra committed
344 345 346 347 348 349
	},
	{
		.procname	= "sched_rt_runtime_us",
		.data		= &sysctl_sched_rt_runtime,
		.maxlen		= sizeof(int),
		.mode		= 0644,
350
		.proc_handler	= sched_rt_handler,
Peter Zijlstra's avatar
Peter Zijlstra committed
351
	},
352 353 354 355 356
	{
		.procname	= "sched_compat_yield",
		.data		= &sysctl_sched_compat_yield,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
357
		.proc_handler	= proc_dointvec,
358
	},
Peter Zijlstra's avatar
Peter Zijlstra committed
359 360 361 362 363 364
#ifdef CONFIG_PROVE_LOCKING
	{
		.procname	= "prove_locking",
		.data		= &prove_locking,
		.maxlen		= sizeof(int),
		.mode		= 0644,
365
		.proc_handler	= proc_dointvec,
Peter Zijlstra's avatar
Peter Zijlstra committed
366 367 368 369 370 371 372 373
	},
#endif
#ifdef CONFIG_LOCK_STAT
	{
		.procname	= "lock_stat",
		.data		= &lock_stat,
		.maxlen		= sizeof(int),
		.mode		= 0644,
374
		.proc_handler	= proc_dointvec,
Peter Zijlstra's avatar
Peter Zijlstra committed
375
	},
Ingo Molnar's avatar
Ingo Molnar committed
376
#endif
Linus Torvalds's avatar
Linus Torvalds committed
377 378 379 380 381
	{
		.procname	= "panic",
		.data		= &panic_timeout,
		.maxlen		= sizeof(int),
		.mode		= 0644,
382
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
383 384 385 386 387 388
	},
	{
		.procname	= "core_uses_pid",
		.data		= &core_uses_pid,
		.maxlen		= sizeof(int),
		.mode		= 0644,
389
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
390 391 392 393
	},
	{
		.procname	= "core_pattern",
		.data		= core_pattern,
394
		.maxlen		= CORENAME_MAX_SIZE,
Linus Torvalds's avatar
Linus Torvalds committed
395
		.mode		= 0644,
396
		.proc_handler	= proc_dostring,
Linus Torvalds's avatar
Linus Torvalds committed
397
	},
398 399 400 401 402
	{
		.procname	= "core_pipe_limit",
		.data		= &core_pipe_limit,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
403
		.proc_handler	= proc_dointvec,
404
	},
405
#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds's avatar
Linus Torvalds committed
406 407
	{
		.procname	= "tainted",
Andi Kleen's avatar
Andi Kleen committed
408
		.maxlen 	= sizeof(long),
409
		.mode		= 0644,
410
		.proc_handler	= proc_taint,
Linus Torvalds's avatar
Linus Torvalds committed
411
	},
412
#endif
Arjan van de Ven's avatar
Arjan van de Ven committed
413 414 415 416 417 418
#ifdef CONFIG_LATENCYTOP
	{
		.procname	= "latencytop",
		.data		= &latencytop_enabled,
		.maxlen		= sizeof(int),
		.mode		= 0644,
419
		.proc_handler	= proc_dointvec,
Arjan van de Ven's avatar
Arjan van de Ven committed
420 421
	},
#endif
Linus Torvalds's avatar
Linus Torvalds committed
422 423 424 425 426 427
#ifdef CONFIG_BLK_DEV_INITRD
	{
		.procname	= "real-root-dev",
		.data		= &real_root_dev,
		.maxlen		= sizeof(int),
		.mode		= 0644,
428
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
429 430
	},
#endif
Ingo Molnar's avatar
Ingo Molnar committed
431 432 433 434 435
	{
		.procname	= "print-fatal-signals",
		.data		= &print_fatal_signals,
		.maxlen		= sizeof(int),
		.mode		= 0644,
436
		.proc_handler	= proc_dointvec,
Ingo Molnar's avatar
Ingo Molnar committed
437
	},
438
#ifdef CONFIG_SPARC
Linus Torvalds's avatar
Linus Torvalds committed
439 440 441 442 443
	{
		.procname	= "reboot-cmd",
		.data		= reboot_command,
		.maxlen		= 256,
		.mode		= 0644,
444
		.proc_handler	= proc_dostring,
Linus Torvalds's avatar
Linus Torvalds committed
445 446 447 448 449 450
	},
	{
		.procname	= "stop-a",
		.data		= &stop_a_enabled,
		.maxlen		= sizeof (int),
		.mode		= 0644,
451
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
452 453 454 455 456 457
	},
	{
		.procname	= "scons-poweroff",
		.data		= &scons_pwroff,
		.maxlen		= sizeof (int),
		.mode		= 0644,
458
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
459 460
	},
#endif
461 462 463 464 465 466
#ifdef CONFIG_SPARC64
	{
		.procname	= "tsb-ratio",
		.data		= &sysctl_tsb_ratio,
		.maxlen		= sizeof (int),
		.mode		= 0644,
467
		.proc_handler	= proc_dointvec,
468 469
	},
#endif
Linus Torvalds's avatar
Linus Torvalds committed
470 471 472 473 474 475
#ifdef __hppa__
	{
		.procname	= "soft-power",
		.data		= &pwrsw_enabled,
		.maxlen		= sizeof (int),
	 	.mode		= 0644,
476
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
477 478 479 480 481 482
	},
	{
		.procname	= "unaligned-trap",
		.data		= &unaligned_enabled,
		.maxlen		= sizeof (int),
		.mode		= 0644,
483
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
484 485 486 487 488 489 490
	},
#endif
	{
		.procname	= "ctrl-alt-del",
		.data		= &C_A_D,
		.maxlen		= sizeof(int),
		.mode		= 0644,
491
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
492
	},
493
#ifdef CONFIG_FUNCTION_TRACER
494 495 496 497 498
	{
		.procname	= "ftrace_enabled",
		.data		= &ftrace_enabled,
		.maxlen		= sizeof(int),
		.mode		= 0644,
499
		.proc_handler	= ftrace_enable_sysctl,
500 501
	},
#endif
502 503 504 505 506 507
#ifdef CONFIG_STACK_TRACER
	{
		.procname	= "stack_tracer_enabled",
		.data		= &stack_tracer_enabled,
		.maxlen		= sizeof(int),
		.mode		= 0644,
508
		.proc_handler	= stack_trace_sysctl,
509 510
	},
#endif
511 512
#ifdef CONFIG_TRACING
	{
Peter Zijlstra's avatar
Peter Zijlstra committed
513
		.procname	= "ftrace_dump_on_oops",
514 515 516
		.data		= &ftrace_dump_on_oops,
		.maxlen		= sizeof(int),
		.mode		= 0644,
517
		.proc_handler	= proc_dointvec,
518 519
	},
#endif
520
#ifdef CONFIG_MODULES
Linus Torvalds's avatar
Linus Torvalds committed
521 522 523 524 525
	{
		.procname	= "modprobe",
		.data		= &modprobe_path,
		.maxlen		= KMOD_PATH_LEN,
		.mode		= 0644,
526
		.proc_handler	= proc_dostring,
Linus Torvalds's avatar
Linus Torvalds committed
527
	},
528 529 530 531 532 533
	{
		.procname	= "modules_disabled",
		.data		= &modules_disabled,
		.maxlen		= sizeof(int),
		.mode		= 0644,
		/* only handle a transition from default "0" to "1" */
534
		.proc_handler	= proc_dointvec_minmax,
535 536 537
		.extra1		= &one,
		.extra2		= &one,
	},
Linus Torvalds's avatar
Linus Torvalds committed
538
#endif
Andrew Morton's avatar
Andrew Morton committed
539
#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds's avatar
Linus Torvalds committed
540 541
	{
		.procname	= "hotplug",
542 543
		.data		= &uevent_helper,
		.maxlen		= UEVENT_HELPER_PATH_LEN,
Linus Torvalds's avatar
Linus Torvalds committed
544
		.mode		= 0644,
545
		.proc_handler	= proc_dostring,
Linus Torvalds's avatar
Linus Torvalds committed
546 547 548 549 550 551 552 553
	},
#endif
#ifdef CONFIG_CHR_DEV_SG
	{
		.procname	= "sg-big-buff",
		.data		= &sg_big_buff,
		.maxlen		= sizeof (int),
		.mode		= 0444,
554
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
555 556 557 558 559 560 561 562
	},
#endif
#ifdef CONFIG_BSD_PROCESS_ACCT
	{
		.procname	= "acct",
		.data		= &acct_parm,
		.maxlen		= 3*sizeof(int),
		.mode		= 0644,
563
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
564 565 566 567 568
	},
#endif
#ifdef CONFIG_MAGIC_SYSRQ
	{
		.procname	= "sysrq",
569
		.data		= &__sysrq_enabled,
Linus Torvalds's avatar
Linus Torvalds committed
570 571
		.maxlen		= sizeof (int),
		.mode		= 0644,
572
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
573 574
	},
#endif
575
#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds's avatar
Linus Torvalds committed
576 577
	{
		.procname	= "cad_pid",
578
		.data		= NULL,
Linus Torvalds's avatar
Linus Torvalds committed
579 580
		.maxlen		= sizeof (int),
		.mode		= 0600,
581
		.proc_handler	= proc_do_cad_pid,
Linus Torvalds's avatar
Linus Torvalds committed
582
	},
583
#endif
Linus Torvalds's avatar
Linus Torvalds committed
584 585 586 587 588
	{
		.procname	= "threads-max",
		.data		= &max_threads,
		.maxlen		= sizeof(int),
		.mode		= 0644,
589
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
590 591 592 593 594 595 596 597 598 599 600
	},
	{
		.procname	= "random",
		.mode		= 0555,
		.child		= random_table,
	},
	{
		.procname	= "overflowuid",
		.data		= &overflowuid,
		.maxlen		= sizeof(int),
		.mode		= 0644,
601
		.proc_handler	= proc_dointvec_minmax,
Linus Torvalds's avatar
Linus Torvalds committed
602 603 604 605 606 607 608 609
		.extra1		= &minolduid,
		.extra2		= &maxolduid,
	},
	{
		.procname	= "overflowgid",
		.data		= &overflowgid,
		.maxlen		= sizeof(int),
		.mode		= 0644,
610
		.proc_handler	= proc_dointvec_minmax,
Linus Torvalds's avatar
Linus Torvalds committed
611 612 613
		.extra1		= &minolduid,
		.extra2		= &maxolduid,
	},
614
#ifdef CONFIG_S390
Linus Torvalds's avatar
Linus Torvalds committed
615 616 617 618 619 620
#ifdef CONFIG_MATHEMU
	{
		.procname	= "ieee_emulation_warnings",
		.data		= &sysctl_ieee_emulation_warnings,
		.maxlen		= sizeof(int),
		.mode		= 0644,
621
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
622 623 624 625 626 627 628
	},
#endif
	{
		.procname	= "userprocess_debug",
		.data		= &sysctl_userprocess_debug,
		.maxlen		= sizeof(int),
		.mode		= 0644,
629
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
630 631 632 633 634 635 636
	},
#endif
	{
		.procname	= "pid_max",
		.data		= &pid_max,
		.maxlen		= sizeof (int),
		.mode		= 0644,
637
		.proc_handler	= proc_dointvec_minmax,
Linus Torvalds's avatar
Linus Torvalds committed
638 639 640 641 642 643 644 645
		.extra1		= &pid_max_min,
		.extra2		= &pid_max_max,
	},
	{
		.procname	= "panic_on_oops",
		.data		= &panic_on_oops,
		.maxlen		= sizeof(int),
		.mode		= 0644,
646
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
647
	},
648 649 650 651 652 653
#if defined CONFIG_PRINTK
	{
		.procname	= "printk",
		.data		= &console_loglevel,
		.maxlen		= 4*sizeof(int),
		.mode		= 0644,
654
		.proc_handler	= proc_dointvec,
655
	},
Linus Torvalds's avatar
Linus Torvalds committed
656 657
	{
		.procname	= "printk_ratelimit",
Dave Young's avatar
Dave Young committed
658
		.data		= &printk_ratelimit_state.interval,
Linus Torvalds's avatar
Linus Torvalds committed
659 660
		.maxlen		= sizeof(int),
		.mode		= 0644,
661
		.proc_handler	= proc_dointvec_jiffies,
Linus Torvalds's avatar
Linus Torvalds committed
662 663 664
	},
	{
		.procname	= "printk_ratelimit_burst",
Dave Young's avatar
Dave Young committed
665
		.data		= &printk_ratelimit_state.burst,
Linus Torvalds's avatar
Linus Torvalds committed
666 667
		.maxlen		= sizeof(int),
		.mode		= 0644,
668
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
669
	},
670 671 672 673 674
	{
		.procname	= "printk_delay",
		.data		= &printk_delay_msec,
		.maxlen		= sizeof(int),
		.mode		= 0644,
675
		.proc_handler	= proc_dointvec_minmax,
676 677 678
		.extra1		= &zero,
		.extra2		= &ten_thousand,
	},
679
#endif
Linus Torvalds's avatar
Linus Torvalds committed
680 681 682 683 684
	{
		.procname	= "ngroups_max",
		.data		= &ngroups_max,
		.maxlen		= sizeof (int),
		.mode		= 0444,
685
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
686 687 688 689 690 691 692
	},
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
	{
		.procname       = "unknown_nmi_panic",
		.data           = &unknown_nmi_panic,
		.maxlen         = sizeof (int),
		.mode           = 0644,
693
		.proc_handler   = proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
694
	},
695 696 697 698 699
	{
		.procname       = "nmi_watchdog",
		.data           = &nmi_watchdog_enabled,
		.maxlen         = sizeof (int),
		.mode           = 0644,
700
		.proc_handler   = proc_nmi_enabled,
Linus Torvalds's avatar
Linus Torvalds committed
701 702 703
	},
#endif
#if defined(CONFIG_X86)
704 705 706 707 708
	{
		.procname	= "panic_on_unrecovered_nmi",
		.data		= &panic_on_unrecovered_nmi,
		.maxlen		= sizeof(int),
		.mode		= 0644,
709
		.proc_handler	= proc_dointvec,
710
	},
711 712 713 714 715
	{
		.procname	= "panic_on_io_nmi",
		.data		= &panic_on_io_nmi,
		.maxlen		= sizeof(int),
		.mode		= 0644,
716
		.proc_handler	= proc_dointvec,
717
	},
Linus Torvalds's avatar
Linus Torvalds committed
718 719 720 721 722
	{
		.procname	= "bootloader_type",
		.data		= &bootloader_type,
		.maxlen		= sizeof (int),
		.mode		= 0444,
723
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
724
	},
725 726 727 728 729
	{
		.procname	= "bootloader_version",
		.data		= &bootloader_version,
		.maxlen		= sizeof (int),
		.mode		= 0444,
730
		.proc_handler	= proc_dointvec,
731
	},
732 733 734 735 736
	{
		.procname	= "kstack_depth_to_print",
		.data		= &kstack_depth_to_print,
		.maxlen		= sizeof(int),
		.mode		= 0644,
737
		.proc_handler	= proc_dointvec,
738
	},
739 740 741 742 743
	{
		.procname	= "io_delay_type",
		.data		= &io_delay_type,
		.maxlen		= sizeof(int),
		.mode		= 0644,
744
		.proc_handler	= proc_dointvec,
745
	},
Linus Torvalds's avatar
Linus Torvalds committed
746
#endif
747
#if defined(CONFIG_MMU)
Linus Torvalds's avatar
Linus Torvalds committed
748 749 750 751 752
	{
		.procname	= "randomize_va_space",
		.data		= &randomize_va_space,
		.maxlen		= sizeof(int),
		.mode		= 0644,
753
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
754
	},
755
#endif
756
#if defined(CONFIG_S390) && defined(CONFIG_SMP)
757 758 759 760 761
	{
		.procname	= "spin_retry",
		.data		= &spin_retry,
		.maxlen		= sizeof (int),
		.mode		= 0644,
762
		.proc_handler	= proc_dointvec,
763
	},
764
#endif
Len Brown's avatar
Len Brown committed
765
#if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
766 767
	{
		.procname	= "acpi_video_flags",
768
		.data		= &acpi_realmode_flags,
769 770
		.maxlen		= sizeof (unsigned long),
		.mode		= 0644,
771
		.proc_handler	= proc_doulongvec_minmax,
772
	},
773 774 775 776 777 778 779
#endif
#ifdef CONFIG_IA64
	{
		.procname	= "ignore-unaligned-usertrap",
		.data		= &no_unaligned_warning,
		.maxlen		= sizeof (int),
	 	.mode		= 0644,
780
		.proc_handler	= proc_dointvec,
781
	},
782 783 784 785 786
	{
		.procname	= "unaligned-dump-stack",
		.data		= &unaligned_dump_stack,
		.maxlen		= sizeof (int),
		.mode		= 0644,
787
		.proc_handler	= proc_dointvec,
788
	},
789
#endif
790
#ifdef CONFIG_DETECT_SOFTLOCKUP
791 792 793 794 795
	{
		.procname	= "softlockup_panic",
		.data		= &softlockup_panic,
		.maxlen		= sizeof(int),
		.mode		= 0644,
796
		.proc_handler	= proc_dointvec_minmax,
797 798 799
		.extra1		= &zero,
		.extra2		= &one,
	},
800 801 802
	{
		.procname	= "softlockup_thresh",
		.data		= &softlockup_thresh,
803
		.maxlen		= sizeof(int),
804
		.mode		= 0644,
805
		.proc_handler	= proc_dosoftlockup_thresh,
806
		.extra1		= &neg_one,
807 808
		.extra2		= &sixty,
	},
809 810 811 812 813 814 815
#endif
#ifdef CONFIG_DETECT_HUNG_TASK
	{
		.procname	= "hung_task_panic",
		.data		= &sysctl_hung_task_panic,
		.maxlen		= sizeof(int),
		.mode		= 0644,
816
		.proc_handler	= proc_dointvec_minmax,
817 818 819
		.extra1		= &zero,
		.extra2		= &one,
	},
820 821 822
	{
		.procname	= "hung_task_check_count",
		.data		= &sysctl_hung_task_check_count,
Ingo Molnar's avatar
Ingo Molnar committed
823
		.maxlen		= sizeof(unsigned long),
824
		.mode		= 0644,
825
		.proc_handler	= proc_doulongvec_minmax,
826 827 828 829
	},
	{
		.procname	= "hung_task_timeout_secs",
		.data		= &sysctl_hung_task_timeout_secs,
Ingo Molnar's avatar
Ingo Molnar committed
830
		.maxlen		= sizeof(unsigned long),
831
		.mode		= 0644,
832
		.proc_handler	= proc_dohung_task_timeout_secs,
833 834 835 836
	},
	{
		.procname	= "hung_task_warnings",
		.data		= &sysctl_hung_task_warnings,
Ingo Molnar's avatar
Ingo Molnar committed
837
		.maxlen		= sizeof(unsigned long),
838
		.mode		= 0644,
839
		.proc_handler	= proc_doulongvec_minmax,
840
	},
841
#endif
842 843 844 845 846 847
#ifdef CONFIG_COMPAT
	{
		.procname	= "compat-log",
		.data		= &compat_log,
		.maxlen		= sizeof (int),
	 	.mode		= 0644,
848
		.proc_handler	= proc_dointvec,
849
	},
850
#endif
Ingo Molnar's avatar
Ingo Molnar committed
851 852 853 854 855 856
#ifdef CONFIG_RT_MUTEXES
	{
		.procname	= "max_lock_depth",
		.data		= &max_lock_depth,
		.maxlen		= sizeof(int),
		.mode		= 0644,
857
		.proc_handler	= proc_dointvec,
Ingo Molnar's avatar
Ingo Molnar committed
858
	},
Kees Cook's avatar
Kees Cook committed
859
#endif
860 861 862 863 864
	{
		.procname	= "poweroff_cmd",
		.data		= &poweroff_cmd,
		.maxlen		= POWEROFF_CMD_PATH_LEN,
		.mode		= 0644,
865
		.proc_handler	= proc_dostring,
866
	},
867 868 869 870 871 872 873
#ifdef CONFIG_KEYS
	{
		.procname	= "keys",
		.mode		= 0555,
		.child		= key_sysctls,
	},
#endif
874 875 876 877 878 879
#ifdef CONFIG_RCU_TORTURE_TEST
	{
		.procname       = "rcutorture_runnable",
		.data           = &rcutorture_runnable,
		.maxlen         = sizeof(int),
		.mode           = 0644,
880
		.proc_handler	= proc_dointvec,
881 882
	},
#endif
883 884 885 886 887 888 889
#ifdef CONFIG_SLOW_WORK
	{
		.procname	= "slow-work",
		.mode		= 0555,
		.child		= slow_work_sysctls,
	},
#endif
890
#ifdef CONFIG_PERF_EVENTS
891
	{
892 893 894
		.procname	= "perf_event_paranoid",
		.data		= &sysctl_perf_event_paranoid,
		.maxlen		= sizeof(sysctl_perf_event_paranoid),
895
		.mode		= 0644,
896
		.proc_handler	= proc_dointvec,
897
	},
898
	{
899 900 901
		.procname	= "perf_event_mlock_kb",
		.data		= &sysctl_perf_event_mlock,
		.maxlen		= sizeof(sysctl_perf_event_mlock),
902
		.mode		= 0644,
903
		.proc_handler	= proc_dointvec,
904
	},
905
	{
906 907 908
		.procname	= "perf_event_max_sample_rate",
		.data		= &sysctl_perf_event_sample_rate,
		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
909
		.mode		= 0644,
910
		.proc_handler	= proc_dointvec,
911
	},
912
#endif
913 914 915 916 917 918
#ifdef CONFIG_KMEMCHECK
	{
		.procname	= "kmemcheck",
		.data		= &kmemcheck_enabled,
		.maxlen		= sizeof(int),
		.mode		= 0644,
919
		.proc_handler	= proc_dointvec,
920 921
	},
#endif
922
#ifdef CONFIG_BLOCK
923 924 925 926 927
	{
		.procname	= "blk_iopoll",
		.data		= &blk_iopoll_enabled,
		.maxlen		= sizeof(int),
		.mode		= 0644,
928
		.proc_handler	= proc_dointvec,
929
	},
930
#endif
931 932 933 934
/*
 * NOTE: do not add new entries to this table unless you have read
 * Documentation/sysctl/ctl_unnumbered.txt
 */
935
	{ }
Linus Torvalds's avatar
Linus Torvalds committed
936 937
};

938
static struct ctl_table vm_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
939 940 941 942 943
	{
		.procname	= "overcommit_memory",
		.data		= &sysctl_overcommit_memory,
		.maxlen		= sizeof(sysctl_overcommit_memory),
		.mode		= 0644,
944
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
945
	},
946 947 948 949 950
	{
		.procname	= "panic_on_oom",
		.data		= &sysctl_panic_on_oom,
		.maxlen		= sizeof(sysctl_panic_on_oom),
		.mode		= 0644,
951
		.proc_handler	= proc_dointvec,
952
	},
953 954 955 956 957
	{
		.procname	= "oom_kill_allocating_task",
		.data		= &sysctl_oom_kill_allocating_task,
		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
		.mode		= 0644,
958
		.proc_handler	= proc_dointvec,
959
	},
960 961 962 963 964
	{
		.procname	= "oom_dump_tasks",
		.data		= &sysctl_oom_dump_tasks,
		.maxlen		= sizeof(sysctl_oom_dump_tasks),
		.mode		= 0644,
965
		.proc_handler	= proc_dointvec,