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

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

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

89
#ifdef CONFIG_LOCKUP_DETECTOR
90 91 92
#include <linux/nmi.h>
#endif

93

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

121
/* Constants used for minimum and  maximum */
122
#ifdef CONFIG_LOCKUP_DETECTOR
123
static int sixty = 60;
124
static int neg_one = -1;
125 126 127
#endif

static int zero;
128 129
static int __maybe_unused one = 1;
static int __maybe_unused two = 2;
130
static int __maybe_unused three = 3;
131
static unsigned long one_ul = 1;
132
static int one_hundred = 100;
133 134 135
#ifdef CONFIG_PRINTK
static int ten_thousand = 10000;
#endif
136

137 138 139
/* 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
140 141 142
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
static int minolduid;
143
static int min_percpu_pagelist_fract = 8;
Linus Torvalds's avatar
Linus Torvalds committed
144 145

static int ngroups_max = NGROUPS_MAX;
146
static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds's avatar
Linus Torvalds committed
147

Dave Young's avatar
Dave Young committed
148 149 150
#ifdef CONFIG_INOTIFY_USER
#include <linux/inotify.h>
#endif
151
#ifdef CONFIG_SPARC
Linus Torvalds's avatar
Linus Torvalds committed
152 153
#endif

154 155 156 157
#ifdef CONFIG_SPARC64
extern int sysctl_tsb_ratio;
#endif

Linus Torvalds's avatar
Linus Torvalds committed
158 159 160 161 162
#ifdef __hppa__
extern int pwrsw_enabled;
extern int unaligned_enabled;
#endif

163 164
#ifdef CONFIG_IA64
extern int no_unaligned_warning;
165
extern int unaligned_dump_stack;
166 167
#endif

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

175
#ifdef CONFIG_PRINTK
176
static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
177 178 179
				void __user *buffer, size_t *lenp, loff_t *ppos);
#endif

180 181
static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
		void __user *buffer, size_t *lenp, loff_t *ppos);
182
#ifdef CONFIG_COREDUMP
183 184
static int proc_dostring_coredump(struct ctl_table *table, int write,
		void __user *buffer, size_t *lenp, loff_t *ppos);
185
#endif
186

187
#ifdef CONFIG_MAGIC_SYSRQ
188 189
/* Note: sysrq code uses it's own private copy */
static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208

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

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

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif

/* The default sysctl tables: */

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

Ingo Molnar's avatar
Ingo Molnar committed
254
#ifdef CONFIG_SCHED_DEBUG
255 256 257 258
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 */
259
#ifdef CONFIG_SMP
260 261
static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
262 263
#endif /* CONFIG_SMP */
#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar's avatar
Ingo Molnar committed
264

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

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