sysctl.c 67.9 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>
Linus Torvalds's avatar
Linus Torvalds committed
59 60 61 62

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

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

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

85

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

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

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

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

static int ngroups_max = NGROUPS_MAX;

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

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

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

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

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

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

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

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

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

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

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif

/* The default sysctl tables: */

224
static struct ctl_table root_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
	{
		.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,
	},
250
	{ }
Linus Torvalds's avatar
Linus Torvalds committed
251 252
};

Ingo Molnar's avatar
Ingo Molnar committed
253
#ifdef CONFIG_SCHED_DEBUG
254 255 256 257
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 */
258 259
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
260 261
#endif

262 263 264 265 266
#ifdef CONFIG_COMPACTION
static int min_extfrag_threshold;
static int max_extfrag_threshold = 1000;
#endif

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

968
static struct ctl_table vm_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
969 970 971 972 973
	{
		.procname	= "overcommit_memory",
		.data		= &sysctl_overcommit_memory,
		.maxlen		= sizeof(sysctl_overcommit_memory),
		.mode		= 0644,
974
		.proc_handler	= proc_dointvec,
Linus Torvalds's avatar
Linus Torvalds committed
975
	},
976 977 978 979 980
	{
		.procname	= "panic_on_oom",
		.data		= &sysctl_panic_on_oom,
		.maxlen		= sizeof(sysctl_panic_on_oom),
		.mode		= 0644,
981
		.proc_handler	= proc_dointvec,
982
	},
983 984 985 986 987
	{
		.procname	= "oom_kill_allocating_task",
		.data		= &sysctl_oom_kill_allocating_task,
		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
		.mode		= 0644,
988
		.proc_handler	= proc_dointvec,
989
	},
990 991 992 993 994
	{
		.procname	= "oom_dump_tasks",
		.data		= &sysctl_oom_dump_tasks,
		.maxlen		= sizeof(sysctl_oom_dump_tasks),
		.mode		= 0644,
995