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

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

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

84
#ifdef CONFIG_LOCKUP_DETECTOR
85 86 87
#include <linux/nmi.h>
#endif

88

Linus Torvalds's avatar
Linus Torvalds committed
89 90 91 92 93 94 95
#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
96
extern int suid_dumpable;
Linus Torvalds's avatar
Linus Torvalds committed
97
extern char core_pattern[];
98
extern unsigned int core_pipe_limit;
Linus Torvalds's avatar
Linus Torvalds committed
99 100 101
extern int pid_max;
extern int min_free_kbytes;
extern int pid_max_min, pid_max_max;
Andrew Morton's avatar
Andrew Morton committed
102
extern int sysctl_drop_caches;
103
extern int percpu_pagelist_fraction;
104
extern int compat_log;
Arjan van de Ven's avatar
Arjan van de Ven committed
105
extern int latencytop_enabled;
106
extern int sysctl_nr_open_min, sysctl_nr_open_max;
107 108 109
#ifndef CONFIG_MMU
extern int sysctl_nr_trim_pages;
#endif
110
#ifdef CONFIG_BLOCK
111
extern int blk_iopoll_enabled;
112
#endif
Linus Torvalds's avatar
Linus Torvalds committed
113

114
/* Constants used for minimum and  maximum */
115
#ifdef CONFIG_LOCKUP_DETECTOR
116
static int sixty = 60;
117
static int neg_one = -1;
118 119 120
#endif

static int zero;
121 122
static int __maybe_unused one = 1;
static int __maybe_unused two = 2;
123
static int __maybe_unused three = 3;
124
static unsigned long one_ul = 1;
125
static int one_hundred = 100;
126 127 128
#ifdef CONFIG_PRINTK
static int ten_thousand = 10000;
#endif
129

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

static int ngroups_max = NGROUPS_MAX;
139
static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds's avatar
Linus Torvalds committed
140

Dave Young's avatar
Dave Young committed
141 142 143
#ifdef CONFIG_INOTIFY_USER
#include <linux/inotify.h>
#endif
144
#ifdef CONFIG_SPARC
145
#include <asm/system.h>
Linus Torvalds's avatar
Linus Torvalds committed
146 147
#endif

148 149 150 151
#ifdef CONFIG_SPARC64
extern int sysctl_tsb_ratio;
#endif

Linus Torvalds's avatar
Linus Torvalds committed
152 153 154 155 156
#ifdef __hppa__
extern int pwrsw_enabled;
extern int unaligned_enabled;
#endif

157 158
#ifdef CONFIG_IA64
extern int no_unaligned_warning;
159
extern int unaligned_dump_stack;
160 161
#endif

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

169 170 171 172 173
#ifdef CONFIG_PRINTK
static int proc_dmesg_restrict(struct ctl_table *table, int write,
				void __user *buffer, size_t *lenp, loff_t *ppos);
#endif

174
#ifdef CONFIG_MAGIC_SYSRQ
175 176
/* Note: sysrq code uses it's own private copy */
static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195

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

196 197 198 199 200 201
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[];
202 203 204
#ifdef CONFIG_EPOLL
extern struct ctl_table epoll_table[];
#endif
Linus Torvalds's avatar
Linus Torvalds committed
205 206 207 208 209 210 211

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif

/* The default sysctl tables: */

212
static struct ctl_table sysctl_base_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
	{
		.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,
	},
238
	{ }
Linus Torvalds's avatar
Linus Torvalds committed
239 240
};

Ingo Molnar's avatar
Ingo Molnar committed
241
#ifdef CONFIG_SCHED_DEBUG
242 243 244 245
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 */
246 247
static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar's avatar
Ingo Molnar committed
248 249
#endif

250 251 252 253 254
#ifdef CONFIG_COMPACTION
static int min_extfrag_threshold;
static int max_extfrag_threshold = 1000;
#endif

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

997
static struct ctl_table vm_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed