sysctl.c 68.1 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
/*
 * 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>
Dave Young's avatar
Dave Young committed
26
#include <linux/signal.h>
Linus Torvalds's avatar
Linus Torvalds committed
27
#include <linux/proc_fs.h>
28
#include <linux/security.h>
Linus Torvalds's avatar
Linus Torvalds committed
29
#include <linux/ctype.h>
30
#include <linux/kmemcheck.h>
31
#include <linux/fs.h>
Linus Torvalds's avatar
Linus Torvalds committed
32 33
#include <linux/init.h>
#include <linux/kernel.h>
34
#include <linux/kobject.h>
35
#include <linux/net.h>
Linus Torvalds's avatar
Linus Torvalds committed
36 37 38
#include <linux/sysrq.h>
#include <linux/highuid.h>
#include <linux/writeback.h>
39
#include <linux/ratelimit.h>
40
#include <linux/compaction.h>
Linus Torvalds's avatar
Linus Torvalds committed
41 42
#include <linux/hugetlb.h>
#include <linux/initrd.h>
43
#include <linux/key.h>
Linus Torvalds's avatar
Linus Torvalds committed
44 45 46
#include <linux/times.h>
#include <linux/limits.h>
#include <linux/dcache.h>
47
#include <linux/dnotify.h>
Linus Torvalds's avatar
Linus Torvalds committed
48
#include <linux/syscalls.h>
Adrian Bunk's avatar
Adrian Bunk committed
49
#include <linux/vmstat.h>
50 51
#include <linux/nfs_fs.h>
#include <linux/acpi.h>
52
#include <linux/reboot.h>
53
#include <linux/ftrace.h>
54
#include <linux/perf_event.h>
55
#include <linux/kprobes.h>
56
#include <linux/pipe_fs_i.h>
57
#include <linux/oom.h>
Linus Torvalds's avatar
Linus Torvalds committed
58 59 60 61

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

62 63
#ifdef CONFIG_X86
#include <asm/nmi.h>
64
#include <asm/stacktrace.h>
65
#include <asm/io.h>
66
#endif
Dave Young's avatar
Dave Young committed
67 68 69
#ifdef CONFIG_BSD_PROCESS_ACCT
#include <linux/acct.h>
#endif
Dave Young's avatar
Dave Young committed
70 71 72
#ifdef CONFIG_RT_MUTEXES
#include <linux/rtmutex.h>
#endif
Dave Young's avatar
Dave Young committed
73 74 75
#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
#include <linux/lockdep.h>
#endif
Dave Young's avatar
Dave Young committed
76 77 78
#ifdef CONFIG_CHR_DEV_SG
#include <scsi/sg.h>
#endif
79

80
#ifdef CONFIG_LOCKUP_DETECTOR
81 82 83
#include <linux/nmi.h>
#endif

84

Linus Torvalds's avatar
Linus Torvalds committed
85 86 87 88 89 90 91
#if defined(CONFIG_SYSCTL)

/* External variables not in a header file. */
extern int sysctl_overcommit_memory;
extern int sysctl_overcommit_ratio;
extern int max_threads;
extern int core_uses_pid;
Alan Cox's avatar
Alan Cox committed
92
extern int suid_dumpable;
Linus Torvalds's avatar
Linus Torvalds committed
93
extern char core_pattern[];
94
extern unsigned int core_pipe_limit;
Linus Torvalds's avatar
Linus Torvalds committed
95 96 97
extern int pid_max;
extern int min_free_kbytes;
extern int pid_max_min, pid_max_max;
Andrew Morton's avatar
Andrew Morton committed
98
extern int sysctl_drop_caches;
99
extern int percpu_pagelist_fraction;
100
extern int compat_log;
Arjan van de Ven's avatar
Arjan van de Ven committed
101
extern int latencytop_enabled;
102
extern int sysctl_nr_open_min, sysctl_nr_open_max;
103 104 105
#ifndef CONFIG_MMU
extern int sysctl_nr_trim_pages;
#endif
106
#ifdef CONFIG_BLOCK
107
extern int blk_iopoll_enabled;
108
#endif
Linus Torvalds's avatar
Linus Torvalds committed
109

110
/* Constants used for minimum and  maximum */
111
#ifdef CONFIG_LOCKUP_DETECTOR
112
static int sixty = 60;
113
static int neg_one = -1;
114 115 116
#endif

static int zero;
117 118
static int __maybe_unused one = 1;
static int __maybe_unused two = 2;
119
static unsigned long one_ul = 1;
120
static int one_hundred = 100;
121 122 123
#ifdef CONFIG_PRINTK
static int ten_thousand = 10000;
#endif
124

125 126 127
/* 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
128 129 130
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
static int minolduid;
131
static int min_percpu_pagelist_fract = 8;
Linus Torvalds's avatar
Linus Torvalds committed
132 133 134

static int ngroups_max = NGROUPS_MAX;

Dave Young's avatar
Dave Young committed
135 136 137
#ifdef CONFIG_INOTIFY_USER
#include <linux/inotify.h>
#endif
138
#ifdef CONFIG_SPARC
139
#include <asm/system.h>
Linus Torvalds's avatar
Linus Torvalds committed
140 141
#endif

142 143 144 145
#ifdef CONFIG_SPARC64
extern int sysctl_tsb_ratio;
#endif

Linus Torvalds's avatar
Linus Torvalds committed
146 147 148 149 150
#ifdef __hppa__
extern int pwrsw_enabled;
extern int unaligned_enabled;
#endif

151
#ifdef CONFIG_S390
Linus Torvalds's avatar
Linus Torvalds committed
152 153 154 155
#ifdef CONFIG_MATHEMU
extern int sysctl_ieee_emulation_warnings;
#endif
extern int sysctl_userprocess_debug;
156
extern int spin_retry;
Linus Torvalds's avatar
Linus Torvalds committed
157 158
#endif

159 160
#ifdef CONFIG_IA64
extern int no_unaligned_warning;
161
extern int unaligned_dump_stack;
162 163
#endif

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

171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
#ifdef CONFIG_MAGIC_SYSRQ
static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */

static int sysrq_sysctl_handler(ctl_table *table, int write,
				void __user *buffer, size_t *lenp,
				loff_t *ppos)
{
	int error;

	error = proc_dointvec(table, write, buffer, lenp, ppos);
	if (error)
		return error;

	if (write)
		sysrq_toggle_support(__sysrq_enabled);

	return 0;
}

#endif

192
static struct ctl_table root_table[];
193 194
static struct ctl_table_root sysctl_table_root;
static struct ctl_table_header root_table_header = {
195
	.count = 1,
196
	.ctl_table = root_table,
197
	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
198
	.root = &sysctl_table_root,
199
	.set = &sysctl_table_root.default_set,
200 201 202
};
static struct ctl_table_root sysctl_table_root = {
	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
203
	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
204
};
Linus Torvalds's avatar
Linus Torvalds committed
205

206 207 208 209 210 211
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[];
212 213 214
#ifdef CONFIG_EPOLL
extern struct ctl_table epoll_table[];
#endif
Linus Torvalds's avatar
Linus Torvalds committed
215 216 217 218 219 220 221

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif

/* The default sysctl tables: */

222
static struct ctl_table root_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
	{
		.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,
	},
248 249 250 251
/*
 * NOTE: do not add new entries to this table unless you have read
 * Documentation/sysctl/ctl_unnumbered.txt
 */
252
	{ }
Linus Torvalds's avatar
Linus Torvalds committed
253 254
};

Ingo Molnar's avatar
Ingo Molnar committed
255
#ifdef CONFIG_SCHED_DEBUG
256 257 258 259
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 */
260 261
static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
262 263
static int min_sched_shares_ratelimit = 100000; /* 100 usec */
static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar's avatar
Ingo Molnar committed
264 265
#endif

266 267 268 269 270
#ifdef CONFIG_COMPACTION
static int min_extfrag_threshold;
static int max_extfrag_threshold = 1000;
#endif

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

957
static struct ctl_table vm_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
958 959 960 961 962
	{
		.procname	= "overcommit_memory",
		.data		= &sysctl_overcommit_memory,
		.maxlen		= sizeof(sysctl_overcommit_memory),
		.mode		= 0644,
963
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
964
	},
965 966 967 968 969
	{
		.procname	= "panic_on_oom",
		.data		= &sysctl_panic_on_oom,
		.maxlen		= sizeof(sysctl_panic_on_oom),
		.mode		= 0644,
970
		.proc_handler	= proc_dointvec,
971
	},
972 973 974 975 976
	{
		.procname	= "oom_kill_allocating_task",
		.data		= &sysctl_oom_kill_allocating_task,
		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
		.mode		= 0644,
977
		.proc_handler	= proc_dointvec,
978
	},