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

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

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

93
#ifdef CONFIG_LOCKUP_DETECTOR
94
95
96
#include <linux/nmi.h>
#endif

Linus Torvalds's avatar
Linus Torvalds committed
97
98
99
#if defined(CONFIG_SYSCTL)

/* External variables not in a header file. */
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
extern int pid_max;
extern int pid_max_min, pid_max_max;
108
extern int percpu_pagelist_fraction;
Arjan van de Ven's avatar
Arjan van de Ven committed
109
extern int latencytop_enabled;
110
extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
111
112
113
#ifndef CONFIG_MMU
extern int sysctl_nr_trim_pages;
#endif
Linus Torvalds's avatar
Linus Torvalds committed
114

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

120
121
static int __maybe_unused neg_one = -1;

122
static int zero;
123
124
static int __maybe_unused one = 1;
static int __maybe_unused two = 2;
125
static int __maybe_unused four = 4;
126
static unsigned long one_ul = 1;
127
static int one_hundred = 100;
128
static int one_thousand = 1000;
129
130
131
#ifdef CONFIG_PRINTK
static int ten_thousand = 10000;
#endif
132
133
134
#ifdef CONFIG_PERF_EVENTS
static int six_hundred_forty_kb = 640 * 1024;
#endif
135

136
137
138
/* 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
139
140
141
142
143
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
static int minolduid;

static int ngroups_max = NGROUPS_MAX;
144
static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds's avatar
Linus Torvalds committed
145

146
147
148
149
150
/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
#ifdef CONFIG_DETECT_HUNG_TASK
static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
#endif

Dave Young's avatar
Dave Young committed
151
152
153
#ifdef CONFIG_INOTIFY_USER
#include <linux/inotify.h>
#endif
154
#ifdef CONFIG_SPARC
Linus Torvalds's avatar
Linus Torvalds committed
155
156
157
158
#endif

#ifdef __hppa__
extern int pwrsw_enabled;
159
160
161
#endif

#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds's avatar
Linus Torvalds committed
162
163
164
extern int unaligned_enabled;
#endif

165
#ifdef CONFIG_IA64
166
extern int unaligned_dump_stack;
167
168
#endif

169
170
171
172
#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
extern int no_unaligned_warning;
#endif

173
#ifdef CONFIG_PROC_SYSCTL
174
175
176
177
178

#define SYSCTL_WRITES_LEGACY	-1
#define SYSCTL_WRITES_WARN	 0
#define SYSCTL_WRITES_STRICT	 1

Kees Cook's avatar
Kees Cook committed
179
static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
180

181
static int proc_do_cad_pid(struct ctl_table *table, int write,
182
		  void __user *buffer, size_t *lenp, loff_t *ppos);
183
static int proc_taint(struct ctl_table *table, int write,
184
			       void __user *buffer, size_t *lenp, loff_t *ppos);
185
#endif
186

187
#ifdef CONFIG_PRINTK
188
static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
189
190
191
				void __user *buffer, size_t *lenp, loff_t *ppos);
#endif

192
193
static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
		void __user *buffer, size_t *lenp, loff_t *ppos);
194
#ifdef CONFIG_COREDUMP
195
196
static int proc_dostring_coredump(struct ctl_table *table, int write,
		void __user *buffer, size_t *lenp, loff_t *ppos);
197
#endif
198

199
#ifdef CONFIG_MAGIC_SYSRQ
200
/* Note: sysrq code uses it's own private copy */
201
static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
202

203
static int sysrq_sysctl_handler(struct ctl_table *table, int write,
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
				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

221
222
223
224
225
226
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[];
227
228
229
#ifdef CONFIG_EPOLL
extern struct ctl_table epoll_table[];
#endif
Linus Torvalds's avatar
Linus Torvalds committed
230
231
232
233
234
235
236

#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif

/* The default sysctl tables: */

237
static struct ctl_table sysctl_base_table[] = {
Linus Torvalds's avatar
Linus Torvalds committed
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
	{
		.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,
	},
263
	{ }
Linus Torvalds's avatar
Linus Torvalds committed
264
265
};

Ingo Molnar's avatar
Ingo Molnar committed
266
#ifdef CONFIG_SCHED_DEBUG
267
268
269
270
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 */
271
#ifdef CONFIG_SMP
272
273
static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
274
275
#endif /* CONFIG_SMP */
#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar's avatar
Ingo Molnar committed
276

277
278
279
280
281
#ifdef CONFIG_COMPACTION
static int min_extfrag_threshold;
static int max_extfrag_threshold = 1000;
#endif

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