dynamic_debug: add an option to enable dynamic debug for modules only
[linux-block.git] / kernel / sysctl.c
CommitLineData
457c8996 1// SPDX-License-Identifier: GPL-2.0-only
1da177e4
LT
2/*
3 * sysctl.c: General linux system control interface
4 *
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Horn.
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * Wendling.
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
20 */
21
1da177e4 22#include <linux/module.h>
e2e40f2c 23#include <linux/aio.h>
1da177e4
LT
24#include <linux/mm.h>
25#include <linux/swap.h>
26#include <linux/slab.h>
27#include <linux/sysctl.h>
5a04cca6 28#include <linux/bitmap.h>
d33ed52d 29#include <linux/signal.h>
455cd5ab 30#include <linux/printk.h>
1da177e4 31#include <linux/proc_fs.h>
72c2d582 32#include <linux/security.h>
1da177e4 33#include <linux/ctype.h>
fd4b616b 34#include <linux/kmemleak.h>
62239ac2 35#include <linux/fs.h>
1da177e4
LT
36#include <linux/init.h>
37#include <linux/kernel.h>
0296b228 38#include <linux/kobject.h>
20380731 39#include <linux/net.h>
1da177e4
LT
40#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
3fff4c42 43#include <linux/ratelimit.h>
76ab0f53 44#include <linux/compaction.h>
1da177e4 45#include <linux/hugetlb.h>
1da177e4 46#include <linux/initrd.h>
0b77f5bf 47#include <linux/key.h>
1da177e4
LT
48#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
6e006701 51#include <linux/dnotify.h>
1da177e4 52#include <linux/syscalls.h>
c748e134 53#include <linux/vmstat.h>
c255d844
PM
54#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
10a0a8d4 56#include <linux/reboot.h>
b0fc494f 57#include <linux/ftrace.h>
cdd6c482 58#include <linux/perf_event.h>
b2be84df 59#include <linux/kprobes.h>
b492e95b 60#include <linux/pipe_fs_i.h>
8e4228e1 61#include <linux/oom.h>
17f60a7d 62#include <linux/kmod.h>
73efc039 63#include <linux/capability.h>
40401530 64#include <linux/binfmts.h>
cf4aebc2 65#include <linux/sched/sysctl.h>
f7ccbae4 66#include <linux/sched/coredump.h>
7984754b 67#include <linux/kexec.h>
1be7f75d 68#include <linux/bpf.h>
d2921684 69#include <linux/mount.h>
cefdca0a 70#include <linux/userfaultfd_k.h>
2374c09b
CH
71#include <linux/coredump.h>
72#include <linux/latencytop.h>
73#include <linux/pid.h>
1da177e4 74
7f2923c4
CB
75#include "../lib/kstrtox.h"
76
7c0f6ba6 77#include <linux/uaccess.h>
1da177e4
LT
78#include <asm/processor.h>
79
29cbc78b
AK
80#ifdef CONFIG_X86
81#include <asm/nmi.h>
0741f4d2 82#include <asm/stacktrace.h>
6e7c4025 83#include <asm/io.h>
29cbc78b 84#endif
d550bbd4
DH
85#ifdef CONFIG_SPARC
86#include <asm/setup.h>
87#endif
c55b7c3e
DY
88#ifdef CONFIG_BSD_PROCESS_ACCT
89#include <linux/acct.h>
90#endif
4f0e056f
DY
91#ifdef CONFIG_RT_MUTEXES
92#include <linux/rtmutex.h>
93#endif
2edf5e49
DY
94#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
95#include <linux/lockdep.h>
96#endif
15485a46
DY
97#ifdef CONFIG_CHR_DEV_SG
98#include <scsi/sg.h>
99#endif
964c9dff
AP
100#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101#include <linux/stackleak.h>
102#endif
58687acb 103#ifdef CONFIG_LOCKUP_DETECTOR
504d7cf1
DZ
104#include <linux/nmi.h>
105#endif
106
1da177e4
LT
107#if defined(CONFIG_SYSCTL)
108
c4f3b63f 109/* Constants used for minimum and maximum */
2508ce18 110#ifdef CONFIG_LOCKUP_DETECTOR
c4f3b63f
RT
111static int sixty = 60;
112#endif
113
270750db 114static int __maybe_unused neg_one = -1;
cd5f9a4c 115static int __maybe_unused two = 2;
5509a5d2 116static int __maybe_unused four = 4;
9002b214 117static unsigned long zero_ul;
fc3501d4 118static unsigned long one_ul = 1;
32a5ad9c 119static unsigned long long_max = LONG_MAX;
c4f3b63f 120static int one_hundred = 100;
c843966c 121static int two_hundred = 200;
795ae7a0 122static int one_thousand = 1000;
af91322e
DY
123#ifdef CONFIG_PRINTK
124static int ten_thousand = 10000;
125#endif
c5dfd78e
ACM
126#ifdef CONFIG_PERF_EVENTS
127static int six_hundred_forty_kb = 640 * 1024;
128#endif
c4f3b63f 129
9e4a5bda
AR
130/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
131static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
132
1da177e4
LT
133/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
134static int maxolduid = 65535;
135static int minolduid;
136
137static int ngroups_max = NGROUPS_MAX;
73efc039 138static const int cap_last_cap = CAP_LAST_CAP;
1da177e4 139
a2e51445
DV
140/*
141 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
142 * and hung_task_check_interval_secs
143 */
80df2847
LH
144#ifdef CONFIG_DETECT_HUNG_TASK
145static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
146#endif
147
d14f1729
DY
148#ifdef CONFIG_INOTIFY_USER
149#include <linux/inotify.h>
150#endif
b6fca725 151
d6f8ff73 152#ifdef CONFIG_PROC_SYSCTL
f4aacea2 153
a19ac337
LR
154/**
155 * enum sysctl_writes_mode - supported sysctl write modes
156 *
157 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
65f50f25
WH
158 * to be written, and multiple writes on the same sysctl file descriptor
159 * will rewrite the sysctl value, regardless of file position. No warning
160 * is issued when the initial position is not 0.
a19ac337 161 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
65f50f25 162 * not 0.
a19ac337 163 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
65f50f25
WH
164 * file position 0 and the value must be fully contained in the buffer
165 * sent to the write syscall. If dealing with strings respect the file
166 * position, but restrict this to the max length of the buffer, anything
167 * passed the max length will be ignored. Multiple writes will append
168 * to the buffer.
a19ac337
LR
169 *
170 * These write modes control how current file position affects the behavior of
171 * updating sysctl values through the proc interface on each write.
172 */
173enum sysctl_writes_mode {
174 SYSCTL_WRITES_LEGACY = -1,
175 SYSCTL_WRITES_WARN = 0,
176 SYSCTL_WRITES_STRICT = 1,
177};
f4aacea2 178
a19ac337 179static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
f461d2dc 180#endif /* CONFIG_PROC_SYSCTL */
ceb18132 181
67f3977f
AG
182#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
183 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
1da177e4
LT
184int sysctl_legacy_va_layout;
185#endif
186
77e54a1f 187#ifdef CONFIG_SCHED_DEBUG
73c4efd2
ED
188static int min_sched_granularity_ns = 100000; /* 100 usecs */
189static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
190static int min_wakeup_granularity_ns; /* 0 usecs */
191static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
cbee9f88 192#ifdef CONFIG_SMP
1983a922
CE
193static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
194static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
cbee9f88
PZ
195#endif /* CONFIG_SMP */
196#endif /* CONFIG_SCHED_DEBUG */
77e54a1f 197
5e771905
MG
198#ifdef CONFIG_COMPACTION
199static int min_extfrag_threshold;
200static int max_extfrag_threshold = 1000;
201#endif
202
f461d2dc
CH
203#endif /* CONFIG_SYSCTL */
204
5447e8e0 205#if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
d46edd67
SL
206static int bpf_stats_handler(struct ctl_table *table, int write,
207 void __user *buffer, size_t *lenp,
208 loff_t *ppos)
209{
210 struct static_key *key = (struct static_key *)table->data;
211 static int saved_val;
212 int val, ret;
213 struct ctl_table tmp = {
214 .data = &val,
215 .maxlen = sizeof(val),
216 .mode = table->mode,
217 .extra1 = SYSCTL_ZERO,
218 .extra2 = SYSCTL_ONE,
219 };
220
221 if (write && !capable(CAP_SYS_ADMIN))
222 return -EPERM;
223
224 mutex_lock(&bpf_stats_enabled_mutex);
225 val = saved_val;
226 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
227 if (write && !ret && val != saved_val) {
228 if (val)
229 static_key_slow_inc(key);
230 else
231 static_key_slow_dec(key);
232 saved_val = val;
233 }
234 mutex_unlock(&bpf_stats_enabled_mutex);
235 return ret;
236}
046d662f 237#endif
d46edd67 238
f461d2dc
CH
239/*
240 * /proc/sys support
241 */
242
b89a8171 243#ifdef CONFIG_PROC_SYSCTL
1da177e4 244
f8808300 245static int _proc_do_string(char *data, int maxlen, int write,
32927393 246 char *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
247{
248 size_t len;
32927393 249 char c, *p;
8d060877
ON
250
251 if (!data || !maxlen || !*lenp) {
1da177e4
LT
252 *lenp = 0;
253 return 0;
254 }
8d060877 255
1da177e4 256 if (write) {
f4aacea2
KC
257 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
258 /* Only continue writes not past the end of buffer. */
259 len = strlen(data);
260 if (len > maxlen - 1)
261 len = maxlen - 1;
262
263 if (*ppos > len)
264 return 0;
265 len = *ppos;
266 } else {
267 /* Start writing from beginning of buffer. */
268 len = 0;
269 }
270
2ca9bb45 271 *ppos += *lenp;
1da177e4 272 p = buffer;
2ca9bb45 273 while ((p - buffer) < *lenp && len < maxlen - 1) {
32927393 274 c = *(p++);
1da177e4
LT
275 if (c == 0 || c == '\n')
276 break;
2ca9bb45 277 data[len++] = c;
1da177e4 278 }
f8808300 279 data[len] = 0;
1da177e4 280 } else {
f5dd3d6f
SV
281 len = strlen(data);
282 if (len > maxlen)
283 len = maxlen;
8d060877
ON
284
285 if (*ppos > len) {
286 *lenp = 0;
287 return 0;
288 }
289
290 data += *ppos;
291 len -= *ppos;
292
1da177e4
LT
293 if (len > *lenp)
294 len = *lenp;
295 if (len)
32927393 296 memcpy(buffer, data, len);
1da177e4 297 if (len < *lenp) {
32927393 298 buffer[len] = '\n';
1da177e4
LT
299 len++;
300 }
301 *lenp = len;
302 *ppos += len;
303 }
304 return 0;
305}
306
f4aacea2
KC
307static void warn_sysctl_write(struct ctl_table *table)
308{
309 pr_warn_once("%s wrote to %s when file position was not 0!\n"
310 "This will not be supported in the future. To silence this\n"
311 "warning, set kernel.sysctl_writes_strict = -1\n",
312 current->comm, table->procname);
313}
314
d383d484 315/**
5f733e8a 316 * proc_first_pos_non_zero_ignore - check if first position is allowed
d383d484
LR
317 * @ppos: file position
318 * @table: the sysctl table
319 *
320 * Returns true if the first position is non-zero and the sysctl_writes_strict
321 * mode indicates this is not allowed for numeric input types. String proc
5f733e8a 322 * handlers can ignore the return value.
d383d484
LR
323 */
324static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
325 struct ctl_table *table)
326{
327 if (!*ppos)
328 return false;
329
330 switch (sysctl_writes_strict) {
331 case SYSCTL_WRITES_STRICT:
332 return true;
333 case SYSCTL_WRITES_WARN:
334 warn_sysctl_write(table);
335 return false;
336 default:
337 return false;
338 }
339}
340
f5dd3d6f
SV
341/**
342 * proc_dostring - read a string sysctl
343 * @table: the sysctl table
344 * @write: %TRUE if this is a write to the sysctl file
f5dd3d6f
SV
345 * @buffer: the user buffer
346 * @lenp: the size of the user buffer
347 * @ppos: file position
348 *
349 * Reads/writes a string from/to the user buffer. If the kernel
350 * buffer provided is not large enough to hold the string, the
351 * string is truncated. The copied string is %NULL-terminated.
352 * If the string is being read by the user process, it is copied
353 * and a newline '\n' is added. It is truncated if the buffer is
354 * not large enough.
355 *
356 * Returns 0 on success.
357 */
8d65af78 358int proc_dostring(struct ctl_table *table, int write,
32927393 359 void *buffer, size_t *lenp, loff_t *ppos)
f5dd3d6f 360{
d383d484
LR
361 if (write)
362 proc_first_pos_non_zero_ignore(ppos, table);
f4aacea2 363
32927393
CH
364 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
365 ppos);
f5dd3d6f
SV
366}
367
00b7c339
AW
368static size_t proc_skip_spaces(char **buf)
369{
370 size_t ret;
371 char *tmp = skip_spaces(*buf);
372 ret = tmp - *buf;
373 *buf = tmp;
374 return ret;
375}
376
9f977fb7
OP
377static void proc_skip_char(char **buf, size_t *size, const char v)
378{
379 while (*size) {
380 if (**buf != v)
381 break;
382 (*size)--;
383 (*buf)++;
384 }
385}
386
7f2923c4
CB
387/**
388 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
389 * fail on overflow
390 *
391 * @cp: kernel buffer containing the string to parse
392 * @endp: pointer to store the trailing characters
393 * @base: the base to use
394 * @res: where the parsed integer will be stored
395 *
396 * In case of success 0 is returned and @res will contain the parsed integer,
397 * @endp will hold any trailing characters.
398 * This function will fail the parse on overflow. If there wasn't an overflow
399 * the function will defer the decision what characters count as invalid to the
400 * caller.
401 */
402static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
403 unsigned long *res)
404{
405 unsigned long long result;
406 unsigned int rv;
407
408 cp = _parse_integer_fixup_radix(cp, &base);
409 rv = _parse_integer(cp, base, &result);
410 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
411 return -ERANGE;
412
413 cp += rv;
414
415 if (endp)
416 *endp = (char *)cp;
417
418 *res = (unsigned long)result;
419 return 0;
420}
421
00b7c339
AW
422#define TMPBUFLEN 22
423/**
0fc377bd 424 * proc_get_long - reads an ASCII formatted integer from a user buffer
00b7c339 425 *
0fc377bd
RD
426 * @buf: a kernel buffer
427 * @size: size of the kernel buffer
428 * @val: this is where the number will be stored
429 * @neg: set to %TRUE if number is negative
430 * @perm_tr: a vector which contains the allowed trailers
431 * @perm_tr_len: size of the perm_tr vector
432 * @tr: pointer to store the trailer character
00b7c339 433 *
0fc377bd
RD
434 * In case of success %0 is returned and @buf and @size are updated with
435 * the amount of bytes read. If @tr is non-NULL and a trailing
436 * character exists (size is non-zero after returning from this
437 * function), @tr is updated with the trailing character.
00b7c339
AW
438 */
439static int proc_get_long(char **buf, size_t *size,
440 unsigned long *val, bool *neg,
441 const char *perm_tr, unsigned perm_tr_len, char *tr)
442{
443 int len;
444 char *p, tmp[TMPBUFLEN];
445
446 if (!*size)
447 return -EINVAL;
448
449 len = *size;
450 if (len > TMPBUFLEN - 1)
451 len = TMPBUFLEN - 1;
452
453 memcpy(tmp, *buf, len);
454
455 tmp[len] = 0;
456 p = tmp;
457 if (*p == '-' && *size > 1) {
458 *neg = true;
459 p++;
460 } else
461 *neg = false;
462 if (!isdigit(*p))
463 return -EINVAL;
464
7f2923c4
CB
465 if (strtoul_lenient(p, &p, 0, val))
466 return -EINVAL;
00b7c339
AW
467
468 len = p - tmp;
469
470 /* We don't know if the next char is whitespace thus we may accept
471 * invalid integers (e.g. 1234...a) or two integers instead of one
472 * (e.g. 123...1). So lets not allow such large numbers. */
473 if (len == TMPBUFLEN - 1)
474 return -EINVAL;
475
476 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
477 return -EINVAL;
1da177e4 478
00b7c339
AW
479 if (tr && (len < *size))
480 *tr = *p;
481
482 *buf += len;
483 *size -= len;
484
485 return 0;
486}
487
488/**
0fc377bd 489 * proc_put_long - converts an integer to a decimal ASCII formatted string
00b7c339 490 *
0fc377bd
RD
491 * @buf: the user buffer
492 * @size: the size of the user buffer
493 * @val: the integer to be converted
494 * @neg: sign of the number, %TRUE for negative
00b7c339 495 *
32927393
CH
496 * In case of success @buf and @size are updated with the amount of bytes
497 * written.
00b7c339 498 */
32927393 499static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
00b7c339
AW
500{
501 int len;
502 char tmp[TMPBUFLEN], *p = tmp;
503
504 sprintf(p, "%s%lu", neg ? "-" : "", val);
505 len = strlen(tmp);
506 if (len > *size)
507 len = *size;
32927393 508 memcpy(*buf, tmp, len);
00b7c339
AW
509 *size -= len;
510 *buf += len;
00b7c339
AW
511}
512#undef TMPBUFLEN
513
32927393 514static void proc_put_char(void **buf, size_t *size, char c)
00b7c339
AW
515{
516 if (*size) {
32927393
CH
517 char **buffer = (char **)buf;
518 **buffer = c;
519
520 (*size)--;
521 (*buffer)++;
00b7c339
AW
522 *buf = *buffer;
523 }
00b7c339 524}
1da177e4 525
00b7c339 526static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
527 int *valp,
528 int write, void *data)
529{
530 if (write) {
230633d1
HS
531 if (*negp) {
532 if (*lvalp > (unsigned long) INT_MAX + 1)
533 return -EINVAL;
534 *valp = -*lvalp;
535 } else {
536 if (*lvalp > (unsigned long) INT_MAX)
537 return -EINVAL;
538 *valp = *lvalp;
539 }
1da177e4
LT
540 } else {
541 int val = *valp;
542 if (val < 0) {
00b7c339 543 *negp = true;
9a5bc726 544 *lvalp = -(unsigned long)val;
1da177e4 545 } else {
00b7c339 546 *negp = false;
1da177e4
LT
547 *lvalp = (unsigned long)val;
548 }
549 }
550 return 0;
551}
552
4f2fec00
LR
553static int do_proc_douintvec_conv(unsigned long *lvalp,
554 unsigned int *valp,
555 int write, void *data)
e7d316a0
SAK
556{
557 if (write) {
425fffd8
LZ
558 if (*lvalp > UINT_MAX)
559 return -EINVAL;
e7d316a0
SAK
560 *valp = *lvalp;
561 } else {
562 unsigned int val = *valp;
563 *lvalp = (unsigned long)val;
564 }
565 return 0;
566}
567
00b7c339
AW
568static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
569
d8217f07 570static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
32927393 571 int write, void *buffer,
fcfbd547 572 size_t *lenp, loff_t *ppos,
00b7c339 573 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
1da177e4
LT
574 int write, void *data),
575 void *data)
576{
00b7c339 577 int *i, vleft, first = 1, err = 0;
00b7c339 578 size_t left;
32927393 579 char *p;
1da177e4 580
00b7c339 581 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
1da177e4
LT
582 *lenp = 0;
583 return 0;
584 }
585
fcfbd547 586 i = (int *) tbl_data;
1da177e4
LT
587 vleft = table->maxlen / sizeof(*i);
588 left = *lenp;
589
590 if (!conv)
591 conv = do_proc_dointvec_conv;
592
00b7c339 593 if (write) {
d383d484
LR
594 if (proc_first_pos_non_zero_ignore(ppos, table))
595 goto out;
f4aacea2 596
00b7c339
AW
597 if (left > PAGE_SIZE - 1)
598 left = PAGE_SIZE - 1;
32927393 599 p = buffer;
00b7c339
AW
600 }
601
1da177e4 602 for (; left && vleft--; i++, first=0) {
00b7c339
AW
603 unsigned long lval;
604 bool neg;
1da177e4 605
00b7c339 606 if (write) {
70f6cbb6 607 left -= proc_skip_spaces(&p);
1da177e4 608
563b0467
O
609 if (!left)
610 break;
70f6cbb6 611 err = proc_get_long(&p, &left, &lval, &neg,
00b7c339
AW
612 proc_wspace_sep,
613 sizeof(proc_wspace_sep), NULL);
614 if (err)
1da177e4 615 break;
00b7c339
AW
616 if (conv(&neg, &lval, i, 1, data)) {
617 err = -EINVAL;
1da177e4 618 break;
00b7c339 619 }
1da177e4 620 } else {
00b7c339
AW
621 if (conv(&neg, &lval, i, 0, data)) {
622 err = -EINVAL;
623 break;
624 }
1da177e4 625 if (!first)
32927393
CH
626 proc_put_char(&buffer, &left, '\t');
627 proc_put_long(&buffer, &left, lval, neg);
1da177e4
LT
628 }
629 }
630
00b7c339 631 if (!write && !first && left && !err)
32927393 632 proc_put_char(&buffer, &left, '\n');
563b0467 633 if (write && !err && left)
70f6cbb6 634 left -= proc_skip_spaces(&p);
32927393
CH
635 if (write && first)
636 return err ? : -EINVAL;
1da177e4 637 *lenp -= left;
f4aacea2 638out:
1da177e4 639 *ppos += *lenp;
00b7c339 640 return err;
1da177e4
LT
641}
642
8d65af78 643static int do_proc_dointvec(struct ctl_table *table, int write,
32927393 644 void *buffer, size_t *lenp, loff_t *ppos,
00b7c339 645 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
fcfbd547
KK
646 int write, void *data),
647 void *data)
648{
8d65af78 649 return __do_proc_dointvec(table->data, table, write,
fcfbd547
KK
650 buffer, lenp, ppos, conv, data);
651}
652
4f2fec00
LR
653static int do_proc_douintvec_w(unsigned int *tbl_data,
654 struct ctl_table *table,
32927393 655 void *buffer,
4f2fec00
LR
656 size_t *lenp, loff_t *ppos,
657 int (*conv)(unsigned long *lvalp,
658 unsigned int *valp,
659 int write, void *data),
660 void *data)
661{
662 unsigned long lval;
663 int err = 0;
664 size_t left;
665 bool neg;
32927393 666 char *p = buffer;
4f2fec00
LR
667
668 left = *lenp;
669
670 if (proc_first_pos_non_zero_ignore(ppos, table))
671 goto bail_early;
672
673 if (left > PAGE_SIZE - 1)
674 left = PAGE_SIZE - 1;
675
4f2fec00
LR
676 left -= proc_skip_spaces(&p);
677 if (!left) {
678 err = -EINVAL;
679 goto out_free;
680 }
681
682 err = proc_get_long(&p, &left, &lval, &neg,
683 proc_wspace_sep,
684 sizeof(proc_wspace_sep), NULL);
685 if (err || neg) {
686 err = -EINVAL;
687 goto out_free;
688 }
689
690 if (conv(&lval, tbl_data, 1, data)) {
691 err = -EINVAL;
692 goto out_free;
693 }
694
695 if (!err && left)
696 left -= proc_skip_spaces(&p);
697
698out_free:
4f2fec00
LR
699 if (err)
700 return -EINVAL;
701
702 return 0;
703
704 /* This is in keeping with old __do_proc_dointvec() */
705bail_early:
706 *ppos += *lenp;
707 return err;
708}
709
32927393 710static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
4f2fec00
LR
711 size_t *lenp, loff_t *ppos,
712 int (*conv)(unsigned long *lvalp,
713 unsigned int *valp,
714 int write, void *data),
715 void *data)
716{
717 unsigned long lval;
718 int err = 0;
719 size_t left;
720
721 left = *lenp;
722
723 if (conv(&lval, tbl_data, 0, data)) {
724 err = -EINVAL;
725 goto out;
726 }
727
32927393
CH
728 proc_put_long(&buffer, &left, lval, false);
729 if (!left)
4f2fec00
LR
730 goto out;
731
32927393 732 proc_put_char(&buffer, &left, '\n');
4f2fec00
LR
733
734out:
735 *lenp -= left;
736 *ppos += *lenp;
737
738 return err;
739}
740
741static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
32927393 742 int write, void *buffer,
4f2fec00
LR
743 size_t *lenp, loff_t *ppos,
744 int (*conv)(unsigned long *lvalp,
745 unsigned int *valp,
746 int write, void *data),
747 void *data)
748{
749 unsigned int *i, vleft;
750
751 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
752 *lenp = 0;
753 return 0;
754 }
755
756 i = (unsigned int *) tbl_data;
757 vleft = table->maxlen / sizeof(*i);
758
759 /*
760 * Arrays are not supported, keep this simple. *Do not* add
761 * support for them.
762 */
763 if (vleft != 1) {
764 *lenp = 0;
765 return -EINVAL;
766 }
767
768 if (!conv)
769 conv = do_proc_douintvec_conv;
770
771 if (write)
772 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
773 conv, data);
774 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
775}
776
777static int do_proc_douintvec(struct ctl_table *table, int write,
32927393 778 void *buffer, size_t *lenp, loff_t *ppos,
4f2fec00
LR
779 int (*conv)(unsigned long *lvalp,
780 unsigned int *valp,
781 int write, void *data),
782 void *data)
783{
784 return __do_proc_douintvec(table->data, table, write,
785 buffer, lenp, ppos, conv, data);
786}
787
1da177e4
LT
788/**
789 * proc_dointvec - read a vector of integers
790 * @table: the sysctl table
791 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
792 * @buffer: the user buffer
793 * @lenp: the size of the user buffer
794 * @ppos: file position
795 *
796 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
797 * values from/to the user buffer, treated as an ASCII string.
798 *
799 * Returns 0 on success.
800 */
32927393
CH
801int proc_dointvec(struct ctl_table *table, int write, void *buffer,
802 size_t *lenp, loff_t *ppos)
1da177e4 803{
e7d316a0
SAK
804 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
805}
806
6923aa0d
SAS
807#ifdef CONFIG_COMPACTION
808static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
32927393 809 int write, void *buffer, size_t *lenp, loff_t *ppos)
6923aa0d
SAS
810{
811 int ret, old;
812
813 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
814 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
815
816 old = *(int *)table->data;
817 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
818 if (ret)
819 return ret;
820 if (old != *(int *)table->data)
821 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
822 table->procname, current->comm,
823 task_pid_nr(current));
824 return ret;
825}
826#endif
827
e7d316a0
SAK
828/**
829 * proc_douintvec - read a vector of unsigned integers
830 * @table: the sysctl table
831 * @write: %TRUE if this is a write to the sysctl file
832 * @buffer: the user buffer
833 * @lenp: the size of the user buffer
834 * @ppos: file position
835 *
836 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
837 * values from/to the user buffer, treated as an ASCII string.
838 *
839 * Returns 0 on success.
840 */
32927393
CH
841int proc_douintvec(struct ctl_table *table, int write, void *buffer,
842 size_t *lenp, loff_t *ppos)
e7d316a0 843{
4f2fec00
LR
844 return do_proc_douintvec(table, write, buffer, lenp, ppos,
845 do_proc_douintvec_conv, NULL);
1da177e4
LT
846}
847
34f5a398 848/*
25ddbb18
AK
849 * Taint values can only be increased
850 * This means we can safely use a temporary.
34f5a398 851 */
8d65af78 852static int proc_taint(struct ctl_table *table, int write,
32927393 853 void *buffer, size_t *lenp, loff_t *ppos)
34f5a398 854{
25ddbb18
AK
855 struct ctl_table t;
856 unsigned long tmptaint = get_taint();
857 int err;
34f5a398 858
91fcd412 859 if (write && !capable(CAP_SYS_ADMIN))
34f5a398
TT
860 return -EPERM;
861
25ddbb18
AK
862 t = *table;
863 t.data = &tmptaint;
8d65af78 864 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
25ddbb18
AK
865 if (err < 0)
866 return err;
867
868 if (write) {
869 /*
870 * Poor man's atomic or. Not worth adding a primitive
871 * to everyone's atomic.h for this
872 */
873 int i;
874 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
875 if ((tmptaint >> i) & 1)
373d4d09 876 add_taint(i, LOCKDEP_STILL_OK);
25ddbb18
AK
877 }
878 }
879
880 return err;
34f5a398
TT
881}
882
bfdc0b49 883#ifdef CONFIG_PRINTK
620f6e8e 884static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
32927393 885 void *buffer, size_t *lenp, loff_t *ppos)
bfdc0b49
RW
886{
887 if (write && !capable(CAP_SYS_ADMIN))
888 return -EPERM;
889
890 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
891}
892#endif
893
24704f36
WL
894/**
895 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
896 * @min: pointer to minimum allowable value
897 * @max: pointer to maximum allowable value
898 *
899 * The do_proc_dointvec_minmax_conv_param structure provides the
900 * minimum and maximum values for doing range checking for those sysctl
901 * parameters that use the proc_dointvec_minmax() handler.
902 */
1da177e4
LT
903struct do_proc_dointvec_minmax_conv_param {
904 int *min;
905 int *max;
906};
907
00b7c339
AW
908static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
909 int *valp,
1da177e4
LT
910 int write, void *data)
911{
2bc4fc60 912 int tmp, ret;
1da177e4 913 struct do_proc_dointvec_minmax_conv_param *param = data;
2bc4fc60
ZW
914 /*
915 * If writing, first do so via a temporary local int so we can
916 * bounds-check it before touching *valp.
917 */
918 int *ip = write ? &tmp : valp;
919
920 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
921 if (ret)
922 return ret;
923
1da177e4 924 if (write) {
2bc4fc60
ZW
925 if ((param->min && *param->min > tmp) ||
926 (param->max && *param->max < tmp))
1da177e4 927 return -EINVAL;
2bc4fc60 928 *valp = tmp;
1da177e4 929 }
2bc4fc60 930
1da177e4
LT
931 return 0;
932}
933
934/**
935 * proc_dointvec_minmax - read a vector of integers with min/max values
936 * @table: the sysctl table
937 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
938 * @buffer: the user buffer
939 * @lenp: the size of the user buffer
940 * @ppos: file position
941 *
942 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
943 * values from/to the user buffer, treated as an ASCII string.
944 *
945 * This routine will ensure the values are within the range specified by
946 * table->extra1 (min) and table->extra2 (max).
947 *
24704f36 948 * Returns 0 on success or -EINVAL on write when the range check fails.
1da177e4 949 */
8d65af78 950int proc_dointvec_minmax(struct ctl_table *table, int write,
32927393 951 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
952{
953 struct do_proc_dointvec_minmax_conv_param param = {
954 .min = (int *) table->extra1,
955 .max = (int *) table->extra2,
956 };
8d65af78 957 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1da177e4
LT
958 do_proc_dointvec_minmax_conv, &param);
959}
960
24704f36
WL
961/**
962 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
963 * @min: pointer to minimum allowable value
964 * @max: pointer to maximum allowable value
965 *
966 * The do_proc_douintvec_minmax_conv_param structure provides the
967 * minimum and maximum values for doing range checking for those sysctl
968 * parameters that use the proc_douintvec_minmax() handler.
969 */
61d9b56a
LR
970struct do_proc_douintvec_minmax_conv_param {
971 unsigned int *min;
972 unsigned int *max;
973};
974
975static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
976 unsigned int *valp,
977 int write, void *data)
978{
2bc4fc60
ZW
979 int ret;
980 unsigned int tmp;
61d9b56a 981 struct do_proc_douintvec_minmax_conv_param *param = data;
2bc4fc60
ZW
982 /* write via temporary local uint for bounds-checking */
983 unsigned int *up = write ? &tmp : valp;
61d9b56a 984
2bc4fc60
ZW
985 ret = do_proc_douintvec_conv(lvalp, up, write, data);
986 if (ret)
987 return ret;
fb910c42 988
2bc4fc60
ZW
989 if (write) {
990 if ((param->min && *param->min > tmp) ||
991 (param->max && *param->max < tmp))
61d9b56a
LR
992 return -ERANGE;
993
2bc4fc60 994 *valp = tmp;
61d9b56a
LR
995 }
996
997 return 0;
998}
999
1000/**
1001 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1002 * @table: the sysctl table
1003 * @write: %TRUE if this is a write to the sysctl file
1004 * @buffer: the user buffer
1005 * @lenp: the size of the user buffer
1006 * @ppos: file position
1007 *
1008 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1009 * values from/to the user buffer, treated as an ASCII string. Negative
1010 * strings are not allowed.
1011 *
1012 * This routine will ensure the values are within the range specified by
1013 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1014 * check for UINT_MAX to avoid having to support wrap around uses from
1015 * userspace.
1016 *
24704f36 1017 * Returns 0 on success or -ERANGE on write when the range check fails.
61d9b56a
LR
1018 */
1019int proc_douintvec_minmax(struct ctl_table *table, int write,
32927393 1020 void *buffer, size_t *lenp, loff_t *ppos)
61d9b56a
LR
1021{
1022 struct do_proc_douintvec_minmax_conv_param param = {
1023 .min = (unsigned int *) table->extra1,
1024 .max = (unsigned int *) table->extra2,
1025 };
1026 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1027 do_proc_douintvec_minmax_conv, &param);
1028}
1029
7a8d1819
JL
1030static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1031 unsigned int *valp,
1032 int write, void *data)
1033{
7a8d1819 1034 if (write) {
fb910c42 1035 unsigned int val;
7a8d1819 1036
fb910c42 1037 val = round_pipe_size(*lvalp);
7a8d1819
JL
1038 if (val == 0)
1039 return -EINVAL;
1040
7a8d1819
JL
1041 *valp = val;
1042 } else {
1043 unsigned int val = *valp;
1044 *lvalp = (unsigned long) val;
1045 }
1046
1047 return 0;
1048}
1049
319e0a21 1050static int proc_dopipe_max_size(struct ctl_table *table, int write,
32927393 1051 void *buffer, size_t *lenp, loff_t *ppos)
7a8d1819 1052{
7a8d1819 1053 return do_proc_douintvec(table, write, buffer, lenp, ppos,
4c2e4bef 1054 do_proc_dopipe_max_size_conv, NULL);
7a8d1819
JL
1055}
1056
54b50199
KC
1057static void validate_coredump_safety(void)
1058{
046d662f 1059#ifdef CONFIG_COREDUMP
e579d2c2 1060 if (suid_dumpable == SUID_DUMP_ROOT &&
54b50199 1061 core_pattern[0] != '/' && core_pattern[0] != '|') {
760c6a91
AD
1062 printk(KERN_WARNING
1063"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1064"Pipe handler or fully qualified core dump path required.\n"
1065"Set kernel.core_pattern before fs.suid_dumpable.\n"
1066 );
54b50199 1067 }
046d662f 1068#endif
54b50199
KC
1069}
1070
1071static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
32927393 1072 void *buffer, size_t *lenp, loff_t *ppos)
54b50199
KC
1073{
1074 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1075 if (!error)
1076 validate_coredump_safety();
1077 return error;
1078}
1079
046d662f 1080#ifdef CONFIG_COREDUMP
54b50199 1081static int proc_dostring_coredump(struct ctl_table *table, int write,
32927393 1082 void *buffer, size_t *lenp, loff_t *ppos)
54b50199
KC
1083{
1084 int error = proc_dostring(table, write, buffer, lenp, ppos);
1085 if (!error)
1086 validate_coredump_safety();
1087 return error;
1088}
046d662f 1089#endif
54b50199 1090
eaee4172
DS
1091#ifdef CONFIG_MAGIC_SYSRQ
1092static int sysrq_sysctl_handler(struct ctl_table *table, int write,
32927393 1093 void *buffer, size_t *lenp, loff_t *ppos)
eaee4172
DS
1094{
1095 int tmp, ret;
1096
1097 tmp = sysrq_mask();
1098
1099 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1100 lenp, ppos, NULL, NULL);
1101 if (ret || !write)
1102 return ret;
1103
1104 if (write)
1105 sysrq_toggle_support(tmp);
1106
1107 return 0;
1108}
1109#endif
1110
32927393
CH
1111static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1112 int write, void *buffer, size_t *lenp, loff_t *ppos,
1113 unsigned long convmul, unsigned long convdiv)
1da177e4 1114{
00b7c339
AW
1115 unsigned long *i, *min, *max;
1116 int vleft, first = 1, err = 0;
00b7c339 1117 size_t left;
32927393 1118 char *p;
00b7c339
AW
1119
1120 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1da177e4
LT
1121 *lenp = 0;
1122 return 0;
1123 }
00b7c339 1124
fcfbd547 1125 i = (unsigned long *) data;
1da177e4
LT
1126 min = (unsigned long *) table->extra1;
1127 max = (unsigned long *) table->extra2;
1128 vleft = table->maxlen / sizeof(unsigned long);
1129 left = *lenp;
00b7c339
AW
1130
1131 if (write) {
d383d484
LR
1132 if (proc_first_pos_non_zero_ignore(ppos, table))
1133 goto out;
f4aacea2 1134
00b7c339
AW
1135 if (left > PAGE_SIZE - 1)
1136 left = PAGE_SIZE - 1;
32927393 1137 p = buffer;
00b7c339
AW
1138 }
1139
27b3d80a 1140 for (; left && vleft--; i++, first = 0) {
00b7c339
AW
1141 unsigned long val;
1142
1da177e4 1143 if (write) {
00b7c339
AW
1144 bool neg;
1145
70f6cbb6 1146 left -= proc_skip_spaces(&p);
09be1784
CL
1147 if (!left)
1148 break;
00b7c339 1149
70f6cbb6 1150 err = proc_get_long(&p, &left, &val, &neg,
00b7c339
AW
1151 proc_wspace_sep,
1152 sizeof(proc_wspace_sep), NULL);
1153 if (err)
1da177e4
LT
1154 break;
1155 if (neg)
1da177e4 1156 continue;
ff9f8a7c 1157 val = convmul * val / convdiv;
e260ad01
CB
1158 if ((min && val < *min) || (max && val > *max)) {
1159 err = -EINVAL;
1160 break;
1161 }
1da177e4
LT
1162 *i = val;
1163 } else {
00b7c339 1164 val = convdiv * (*i) / convmul;
32927393
CH
1165 if (!first)
1166 proc_put_char(&buffer, &left, '\t');
1167 proc_put_long(&buffer, &left, val, false);
1da177e4
LT
1168 }
1169 }
1170
00b7c339 1171 if (!write && !first && left && !err)
32927393 1172 proc_put_char(&buffer, &left, '\n');
00b7c339 1173 if (write && !err)
70f6cbb6 1174 left -= proc_skip_spaces(&p);
32927393
CH
1175 if (write && first)
1176 return err ? : -EINVAL;
1da177e4 1177 *lenp -= left;
f4aacea2 1178out:
1da177e4 1179 *ppos += *lenp;
00b7c339 1180 return err;
1da177e4
LT
1181}
1182
d8217f07 1183static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
32927393
CH
1184 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1185 unsigned long convdiv)
fcfbd547
KK
1186{
1187 return __do_proc_doulongvec_minmax(table->data, table, write,
8d65af78 1188 buffer, lenp, ppos, convmul, convdiv);
fcfbd547
KK
1189}
1190
1da177e4
LT
1191/**
1192 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1193 * @table: the sysctl table
1194 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
1195 * @buffer: the user buffer
1196 * @lenp: the size of the user buffer
1197 * @ppos: file position
1198 *
1199 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1200 * values from/to the user buffer, treated as an ASCII string.
1201 *
1202 * This routine will ensure the values are within the range specified by
1203 * table->extra1 (min) and table->extra2 (max).
1204 *
1205 * Returns 0 on success.
1206 */
8d65af78 1207int proc_doulongvec_minmax(struct ctl_table *table, int write,
32927393 1208 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4 1209{
8d65af78 1210 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1da177e4
LT
1211}
1212
1213/**
1214 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1215 * @table: the sysctl table
1216 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
1217 * @buffer: the user buffer
1218 * @lenp: the size of the user buffer
1219 * @ppos: file position
1220 *
1221 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1222 * values from/to the user buffer, treated as an ASCII string. The values
1223 * are treated as milliseconds, and converted to jiffies when they are stored.
1224 *
1225 * This routine will ensure the values are within the range specified by
1226 * table->extra1 (min) and table->extra2 (max).
1227 *
1228 * Returns 0 on success.
1229 */
d8217f07 1230int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
32927393 1231 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4 1232{
8d65af78 1233 return do_proc_doulongvec_minmax(table, write, buffer,
1da177e4
LT
1234 lenp, ppos, HZ, 1000l);
1235}
1236
1237
00b7c339 1238static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
1239 int *valp,
1240 int write, void *data)
1241{
1242 if (write) {
63259457 1243 if (*lvalp > INT_MAX / HZ)
cba9f33d 1244 return 1;
1da177e4
LT
1245 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1246 } else {
1247 int val = *valp;
1248 unsigned long lval;
1249 if (val < 0) {
00b7c339 1250 *negp = true;
9a5bc726 1251 lval = -(unsigned long)val;
1da177e4 1252 } else {
00b7c339 1253 *negp = false;
1da177e4
LT
1254 lval = (unsigned long)val;
1255 }
1256 *lvalp = lval / HZ;
1257 }
1258 return 0;
1259}
1260
00b7c339 1261static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
1262 int *valp,
1263 int write, void *data)
1264{
1265 if (write) {
cba9f33d
BS
1266 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1267 return 1;
1da177e4
LT
1268 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1269 } else {
1270 int val = *valp;
1271 unsigned long lval;
1272 if (val < 0) {
00b7c339 1273 *negp = true;
9a5bc726 1274 lval = -(unsigned long)val;
1da177e4 1275 } else {
00b7c339 1276 *negp = false;
1da177e4
LT
1277 lval = (unsigned long)val;
1278 }
1279 *lvalp = jiffies_to_clock_t(lval);
1280 }
1281 return 0;
1282}
1283
00b7c339 1284static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1da177e4
LT
1285 int *valp,
1286 int write, void *data)
1287{
1288 if (write) {
d738ce8f
FF
1289 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1290
1291 if (jif > INT_MAX)
1292 return 1;
1293 *valp = (int)jif;
1da177e4
LT
1294 } else {
1295 int val = *valp;
1296 unsigned long lval;
1297 if (val < 0) {
00b7c339 1298 *negp = true;
9a5bc726 1299 lval = -(unsigned long)val;
1da177e4 1300 } else {
00b7c339 1301 *negp = false;
1da177e4
LT
1302 lval = (unsigned long)val;
1303 }
1304 *lvalp = jiffies_to_msecs(lval);
1305 }
1306 return 0;
1307}
1308
1309/**
1310 * proc_dointvec_jiffies - read a vector of integers as seconds
1311 * @table: the sysctl table
1312 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
1313 * @buffer: the user buffer
1314 * @lenp: the size of the user buffer
1315 * @ppos: file position
1316 *
1317 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1318 * values from/to the user buffer, treated as an ASCII string.
1319 * The values read are assumed to be in seconds, and are converted into
1320 * jiffies.
1321 *
1322 * Returns 0 on success.
1323 */
8d65af78 1324int proc_dointvec_jiffies(struct ctl_table *table, int write,
32927393 1325 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4 1326{
8d65af78 1327 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1da177e4
LT
1328 do_proc_dointvec_jiffies_conv,NULL);
1329}
1330
1331/**
1332 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1333 * @table: the sysctl table
1334 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
1335 * @buffer: the user buffer
1336 * @lenp: the size of the user buffer
1e5d5331 1337 * @ppos: pointer to the file position
1da177e4
LT
1338 *
1339 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1340 * values from/to the user buffer, treated as an ASCII string.
1341 * The values read are assumed to be in 1/USER_HZ seconds, and
1342 * are converted into jiffies.
1343 *
1344 * Returns 0 on success.
1345 */
8d65af78 1346int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
32927393 1347 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4 1348{
8d65af78 1349 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1da177e4
LT
1350 do_proc_dointvec_userhz_jiffies_conv,NULL);
1351}
1352
1353/**
1354 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1355 * @table: the sysctl table
1356 * @write: %TRUE if this is a write to the sysctl file
1da177e4
LT
1357 * @buffer: the user buffer
1358 * @lenp: the size of the user buffer
67be2dd1
MW
1359 * @ppos: file position
1360 * @ppos: the current position in the file
1da177e4
LT
1361 *
1362 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1363 * values from/to the user buffer, treated as an ASCII string.
1364 * The values read are assumed to be in 1/1000 seconds, and
1365 * are converted into jiffies.
1366 *
1367 * Returns 0 on success.
1368 */
32927393
CH
1369int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1370 size_t *lenp, loff_t *ppos)
1da177e4 1371{
8d65af78 1372 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1da177e4
LT
1373 do_proc_dointvec_ms_jiffies_conv, NULL);
1374}
1375
32927393
CH
1376static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1377 size_t *lenp, loff_t *ppos)
9ec52099
CLG
1378{
1379 struct pid *new_pid;
1380 pid_t tmp;
1381 int r;
1382
6c5f3e7b 1383 tmp = pid_vnr(cad_pid);
9ec52099 1384
8d65af78 1385 r = __do_proc_dointvec(&tmp, table, write, buffer,
9ec52099
CLG
1386 lenp, ppos, NULL, NULL);
1387 if (r || !write)
1388 return r;
1389
1390 new_pid = find_get_pid(tmp);
1391 if (!new_pid)
1392 return -ESRCH;
1393
1394 put_pid(xchg(&cad_pid, new_pid));
1395 return 0;
1396}
1397
9f977fb7
OP
1398/**
1399 * proc_do_large_bitmap - read/write from/to a large bitmap
1400 * @table: the sysctl table
1401 * @write: %TRUE if this is a write to the sysctl file
1402 * @buffer: the user buffer
1403 * @lenp: the size of the user buffer
1404 * @ppos: file position
1405 *
1406 * The bitmap is stored at table->data and the bitmap length (in bits)
1407 * in table->maxlen.
1408 *
1409 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1410 * large bitmaps may be represented in a compact manner. Writing into
1411 * the file will clear the bitmap then update it with the given input.
1412 *
1413 * Returns 0 on success.
1414 */
1415int proc_do_large_bitmap(struct ctl_table *table, int write,
32927393 1416 void *buffer, size_t *lenp, loff_t *ppos)
9f977fb7
OP
1417{
1418 int err = 0;
1419 bool first = 1;
1420 size_t left = *lenp;
1421 unsigned long bitmap_len = table->maxlen;
122ff243 1422 unsigned long *bitmap = *(unsigned long **) table->data;
9f977fb7
OP
1423 unsigned long *tmp_bitmap = NULL;
1424 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1425
122ff243 1426 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
9f977fb7
OP
1427 *lenp = 0;
1428 return 0;
1429 }
1430
1431 if (write) {
32927393 1432 char *p = buffer;
3116ad38 1433 size_t skipped = 0;
9f977fb7 1434
3116ad38 1435 if (left > PAGE_SIZE - 1) {
9f977fb7 1436 left = PAGE_SIZE - 1;
3116ad38
ES
1437 /* How much of the buffer we'll skip this pass */
1438 skipped = *lenp - left;
1439 }
9f977fb7 1440
475dae38 1441 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
32927393 1442 if (!tmp_bitmap)
9f977fb7 1443 return -ENOMEM;
70f6cbb6 1444 proc_skip_char(&p, &left, '\n');
9f977fb7
OP
1445 while (!err && left) {
1446 unsigned long val_a, val_b;
1447 bool neg;
3116ad38 1448 size_t saved_left;
9f977fb7 1449
3116ad38
ES
1450 /* In case we stop parsing mid-number, we can reset */
1451 saved_left = left;
70f6cbb6 1452 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
9f977fb7 1453 sizeof(tr_a), &c);
3116ad38
ES
1454 /*
1455 * If we consumed the entirety of a truncated buffer or
1456 * only one char is left (may be a "-"), then stop here,
1457 * reset, & come back for more.
1458 */
1459 if ((left <= 1) && skipped) {
1460 left = saved_left;
1461 break;
1462 }
1463
9f977fb7
OP
1464 if (err)
1465 break;
1466 if (val_a >= bitmap_len || neg) {
1467 err = -EINVAL;
1468 break;
1469 }
1470
1471 val_b = val_a;
1472 if (left) {
70f6cbb6 1473 p++;
9f977fb7
OP
1474 left--;
1475 }
1476
1477 if (c == '-') {
70f6cbb6 1478 err = proc_get_long(&p, &left, &val_b,
9f977fb7
OP
1479 &neg, tr_b, sizeof(tr_b),
1480 &c);
3116ad38
ES
1481 /*
1482 * If we consumed all of a truncated buffer or
1483 * then stop here, reset, & come back for more.
1484 */
1485 if (!left && skipped) {
1486 left = saved_left;
1487 break;
1488 }
1489
9f977fb7
OP
1490 if (err)
1491 break;
1492 if (val_b >= bitmap_len || neg ||
1493 val_a > val_b) {
1494 err = -EINVAL;
1495 break;
1496 }
1497 if (left) {
70f6cbb6 1498 p++;
9f977fb7
OP
1499 left--;
1500 }
1501 }
1502
5a04cca6 1503 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
9f977fb7 1504 first = 0;
70f6cbb6 1505 proc_skip_char(&p, &left, '\n');
9f977fb7 1506 }
3116ad38 1507 left += skipped;
9f977fb7
OP
1508 } else {
1509 unsigned long bit_a, bit_b = 0;
1510
1511 while (left) {
1512 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1513 if (bit_a >= bitmap_len)
1514 break;
1515 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1516 bit_a + 1) - 1;
1517
32927393
CH
1518 if (!first)
1519 proc_put_char(&buffer, &left, ',');
1520 proc_put_long(&buffer, &left, bit_a, false);
9f977fb7 1521 if (bit_a != bit_b) {
32927393
CH
1522 proc_put_char(&buffer, &left, '-');
1523 proc_put_long(&buffer, &left, bit_b, false);
9f977fb7
OP
1524 }
1525
1526 first = 0; bit_b++;
1527 }
32927393 1528 proc_put_char(&buffer, &left, '\n');
9f977fb7
OP
1529 }
1530
1531 if (!err) {
1532 if (write) {
1533 if (*ppos)
1534 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1535 else
5a04cca6 1536 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
9f977fb7 1537 }
9f977fb7
OP
1538 *lenp -= left;
1539 *ppos += *lenp;
9f977fb7 1540 }
f9eb2fdd 1541
475dae38 1542 bitmap_free(tmp_bitmap);
f9eb2fdd 1543 return err;
9f977fb7
OP
1544}
1545
55610500 1546#else /* CONFIG_PROC_SYSCTL */
1da177e4 1547
8d65af78 1548int proc_dostring(struct ctl_table *table, int write,
32927393 1549 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
1550{
1551 return -ENOSYS;
1552}
1553
f461d2dc 1554int proc_dointvec(struct ctl_table *table, int write,
32927393 1555 void *buffer, size_t *lenp, loff_t *ppos)
f461d2dc
CH
1556{
1557 return -ENOSYS;
1558}
1559
1560int proc_douintvec(struct ctl_table *table, int write,
32927393 1561 void *buffer, size_t *lenp, loff_t *ppos)
f461d2dc
CH
1562{
1563 return -ENOSYS;
1564}
1565
1566int proc_dointvec_minmax(struct ctl_table *table, int write,
32927393 1567 void *buffer, size_t *lenp, loff_t *ppos)
f461d2dc
CH
1568{
1569 return -ENOSYS;
1570}
1571
1572int proc_douintvec_minmax(struct ctl_table *table, int write,
32927393 1573 void *buffer, size_t *lenp, loff_t *ppos)
f461d2dc
CH
1574{
1575 return -ENOSYS;
9f977fb7
OP
1576}
1577
f461d2dc 1578int proc_dointvec_jiffies(struct ctl_table *table, int write,
32927393 1579 void *buffer, size_t *lenp, loff_t *ppos)
f461d2dc
CH
1580{
1581 return -ENOSYS;
1582}
1da177e4 1583
f461d2dc 1584int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
32927393 1585 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
1586{
1587 return -ENOSYS;
1588}
1589
f461d2dc 1590int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
32927393 1591 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
1592{
1593 return -ENOSYS;
1594}
1595
f461d2dc 1596int proc_doulongvec_minmax(struct ctl_table *table, int write,
32927393 1597 void *buffer, size_t *lenp, loff_t *ppos)
e7d316a0
SAK
1598{
1599 return -ENOSYS;
1600}
1601
f461d2dc 1602int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
32927393 1603 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4 1604{
32927393 1605 return -ENOSYS;
1da177e4
LT
1606}
1607
f461d2dc 1608int proc_do_large_bitmap(struct ctl_table *table, int write,
32927393 1609 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
1610{
1611 return -ENOSYS;
1612}
1613
f461d2dc
CH
1614#endif /* CONFIG_PROC_SYSCTL */
1615
1616#if defined(CONFIG_SYSCTL)
1617int proc_do_static_key(struct ctl_table *table, int write,
32927393 1618 void *buffer, size_t *lenp, loff_t *ppos)
1da177e4 1619{
f461d2dc
CH
1620 struct static_key *key = (struct static_key *)table->data;
1621 static DEFINE_MUTEX(static_key_mutex);
1622 int val, ret;
1623 struct ctl_table tmp = {
1624 .data = &val,
1625 .maxlen = sizeof(val),
1626 .mode = table->mode,
1627 .extra1 = SYSCTL_ZERO,
1628 .extra2 = SYSCTL_ONE,
1629 };
1630
1631 if (write && !capable(CAP_SYS_ADMIN))
1632 return -EPERM;
1633
1634 mutex_lock(&static_key_mutex);
1635 val = static_key_enabled(key);
1636 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1637 if (write && !ret) {
1638 if (val)
1639 static_key_enable(key);
1640 else
1641 static_key_disable(key);
1642 }
1643 mutex_unlock(&static_key_mutex);
1644 return ret;
1da177e4
LT
1645}
1646
f461d2dc
CH
1647static struct ctl_table kern_table[] = {
1648 {
1649 .procname = "sched_child_runs_first",
1650 .data = &sysctl_sched_child_runs_first,
1651 .maxlen = sizeof(unsigned int),
1652 .mode = 0644,
1653 .proc_handler = proc_dointvec,
1654 },
1655#ifdef CONFIG_SCHED_DEBUG
1656 {
1657 .procname = "sched_min_granularity_ns",
1658 .data = &sysctl_sched_min_granularity,
1659 .maxlen = sizeof(unsigned int),
1660 .mode = 0644,
1661 .proc_handler = sched_proc_update_handler,
1662 .extra1 = &min_sched_granularity_ns,
1663 .extra2 = &max_sched_granularity_ns,
1664 },
1665 {
1666 .procname = "sched_latency_ns",
1667 .data = &sysctl_sched_latency,
1668 .maxlen = sizeof(unsigned int),
1669 .mode = 0644,
1670 .proc_handler = sched_proc_update_handler,
1671 .extra1 = &min_sched_granularity_ns,
1672 .extra2 = &max_sched_granularity_ns,
1673 },
1674 {
1675 .procname = "sched_wakeup_granularity_ns",
1676 .data = &sysctl_sched_wakeup_granularity,
1677 .maxlen = sizeof(unsigned int),
1678 .mode = 0644,
1679 .proc_handler = sched_proc_update_handler,
1680 .extra1 = &min_wakeup_granularity_ns,
1681 .extra2 = &max_wakeup_granularity_ns,
1682 },
1683#ifdef CONFIG_SMP
1684 {
1685 .procname = "sched_tunable_scaling",
1686 .data = &sysctl_sched_tunable_scaling,
1687 .maxlen = sizeof(enum sched_tunable_scaling),
1688 .mode = 0644,
1689 .proc_handler = sched_proc_update_handler,
1690 .extra1 = &min_sched_tunable_scaling,
1691 .extra2 = &max_sched_tunable_scaling,
1692 },
1693 {
1694 .procname = "sched_migration_cost_ns",
1695 .data = &sysctl_sched_migration_cost,
1696 .maxlen = sizeof(unsigned int),
1697 .mode = 0644,
1698 .proc_handler = proc_dointvec,
1699 },
1700 {
1701 .procname = "sched_nr_migrate",
1702 .data = &sysctl_sched_nr_migrate,
1703 .maxlen = sizeof(unsigned int),
1704 .mode = 0644,
1705 .proc_handler = proc_dointvec,
1706 },
1707#ifdef CONFIG_SCHEDSTATS
1708 {
1709 .procname = "sched_schedstats",
1710 .data = NULL,
1711 .maxlen = sizeof(unsigned int),
1712 .mode = 0644,
1713 .proc_handler = sysctl_schedstats,
1714 .extra1 = SYSCTL_ZERO,
1715 .extra2 = SYSCTL_ONE,
1716 },
1717#endif /* CONFIG_SCHEDSTATS */
1718#endif /* CONFIG_SMP */
1719#ifdef CONFIG_NUMA_BALANCING
1720 {
1721 .procname = "numa_balancing_scan_delay_ms",
1722 .data = &sysctl_numa_balancing_scan_delay,
1723 .maxlen = sizeof(unsigned int),
1724 .mode = 0644,
1725 .proc_handler = proc_dointvec,
1726 },
1727 {
1728 .procname = "numa_balancing_scan_period_min_ms",
1729 .data = &sysctl_numa_balancing_scan_period_min,
1730 .maxlen = sizeof(unsigned int),
1731 .mode = 0644,
1732 .proc_handler = proc_dointvec,
1733 },
1734 {
1735 .procname = "numa_balancing_scan_period_max_ms",
1736 .data = &sysctl_numa_balancing_scan_period_max,
1737 .maxlen = sizeof(unsigned int),
1738 .mode = 0644,
1739 .proc_handler = proc_dointvec,
1740 },
1741 {
1742 .procname = "numa_balancing_scan_size_mb",
1743 .data = &sysctl_numa_balancing_scan_size,
1744 .maxlen = sizeof(unsigned int),
1745 .mode = 0644,
1746 .proc_handler = proc_dointvec_minmax,
1747 .extra1 = SYSCTL_ONE,
1748 },
1749 {
1750 .procname = "numa_balancing",
1751 .data = NULL, /* filled in by handler */
1752 .maxlen = sizeof(unsigned int),
1753 .mode = 0644,
1754 .proc_handler = sysctl_numa_balancing,
1755 .extra1 = SYSCTL_ZERO,
1756 .extra2 = SYSCTL_ONE,
1757 },
1758#endif /* CONFIG_NUMA_BALANCING */
1759#endif /* CONFIG_SCHED_DEBUG */
1760 {
1761 .procname = "sched_rt_period_us",
1762 .data = &sysctl_sched_rt_period,
1763 .maxlen = sizeof(unsigned int),
1764 .mode = 0644,
1765 .proc_handler = sched_rt_handler,
1766 },
1767 {
1768 .procname = "sched_rt_runtime_us",
1769 .data = &sysctl_sched_rt_runtime,
1770 .maxlen = sizeof(int),
1771 .mode = 0644,
1772 .proc_handler = sched_rt_handler,
1773 },
1774 {
1775 .procname = "sched_rr_timeslice_ms",
1776 .data = &sysctl_sched_rr_timeslice,
1777 .maxlen = sizeof(int),
1778 .mode = 0644,
1779 .proc_handler = sched_rr_handler,
1780 },
1781#ifdef CONFIG_UCLAMP_TASK
1782 {
1783 .procname = "sched_util_clamp_min",
1784 .data = &sysctl_sched_uclamp_util_min,
1785 .maxlen = sizeof(unsigned int),
1786 .mode = 0644,
1787 .proc_handler = sysctl_sched_uclamp_handler,
1788 },
1789 {
1790 .procname = "sched_util_clamp_max",
1791 .data = &sysctl_sched_uclamp_util_max,
1792 .maxlen = sizeof(unsigned int),
1793 .mode = 0644,
1794 .proc_handler = sysctl_sched_uclamp_handler,
1795 },
1796#endif
1797#ifdef CONFIG_SCHED_AUTOGROUP
1798 {
1799 .procname = "sched_autogroup_enabled",
1800 .data = &sysctl_sched_autogroup_enabled,
1801 .maxlen = sizeof(unsigned int),
1802 .mode = 0644,
1803 .proc_handler = proc_dointvec_minmax,
1804 .extra1 = SYSCTL_ZERO,
1805 .extra2 = SYSCTL_ONE,
1806 },
1807#endif
1808#ifdef CONFIG_CFS_BANDWIDTH
1809 {
1810 .procname = "sched_cfs_bandwidth_slice_us",
1811 .data = &sysctl_sched_cfs_bandwidth_slice,
1812 .maxlen = sizeof(unsigned int),
1813 .mode = 0644,
1814 .proc_handler = proc_dointvec_minmax,
1815 .extra1 = SYSCTL_ONE,
1816 },
1817#endif
1818#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1819 {
1820 .procname = "sched_energy_aware",
1821 .data = &sysctl_sched_energy_aware,
1822 .maxlen = sizeof(unsigned int),
1823 .mode = 0644,
1824 .proc_handler = sched_energy_aware_handler,
1825 .extra1 = SYSCTL_ZERO,
1826 .extra2 = SYSCTL_ONE,
1827 },
1828#endif
1829#ifdef CONFIG_PROVE_LOCKING
1830 {
1831 .procname = "prove_locking",
1832 .data = &prove_locking,
1833 .maxlen = sizeof(int),
1834 .mode = 0644,
1835 .proc_handler = proc_dointvec,
1836 },
1837#endif
1838#ifdef CONFIG_LOCK_STAT
1839 {
1840 .procname = "lock_stat",
1841 .data = &lock_stat,
1842 .maxlen = sizeof(int),
1843 .mode = 0644,
1844 .proc_handler = proc_dointvec,
1845 },
1846#endif
1847 {
1848 .procname = "panic",
1849 .data = &panic_timeout,
1850 .maxlen = sizeof(int),
1851 .mode = 0644,
1852 .proc_handler = proc_dointvec,
1853 },
1854#ifdef CONFIG_COREDUMP
1855 {
1856 .procname = "core_uses_pid",
1857 .data = &core_uses_pid,
1858 .maxlen = sizeof(int),
1859 .mode = 0644,
1860 .proc_handler = proc_dointvec,
1861 },
1862 {
1863 .procname = "core_pattern",
1864 .data = core_pattern,
1865 .maxlen = CORENAME_MAX_SIZE,
1866 .mode = 0644,
1867 .proc_handler = proc_dostring_coredump,
1868 },
1869 {
1870 .procname = "core_pipe_limit",
1871 .data = &core_pipe_limit,
1872 .maxlen = sizeof(unsigned int),
1873 .mode = 0644,
1874 .proc_handler = proc_dointvec,
1875 },
1876#endif
1877#ifdef CONFIG_PROC_SYSCTL
1878 {
1879 .procname = "tainted",
1880 .maxlen = sizeof(long),
1881 .mode = 0644,
1882 .proc_handler = proc_taint,
1883 },
1884 {
1885 .procname = "sysctl_writes_strict",
1886 .data = &sysctl_writes_strict,
1887 .maxlen = sizeof(int),
1888 .mode = 0644,
1889 .proc_handler = proc_dointvec_minmax,
1890 .extra1 = &neg_one,
1891 .extra2 = SYSCTL_ONE,
1892 },
1893#endif
1894#ifdef CONFIG_LATENCYTOP
1895 {
1896 .procname = "latencytop",
1897 .data = &latencytop_enabled,
1898 .maxlen = sizeof(int),
1899 .mode = 0644,
1900 .proc_handler = sysctl_latencytop,
1901 },
1902#endif
1903#ifdef CONFIG_BLK_DEV_INITRD
1904 {
1905 .procname = "real-root-dev",
1906 .data = &real_root_dev,
1907 .maxlen = sizeof(int),
1908 .mode = 0644,
1909 .proc_handler = proc_dointvec,
1910 },
1911#endif
1912 {
1913 .procname = "print-fatal-signals",
1914 .data = &print_fatal_signals,
1915 .maxlen = sizeof(int),
1916 .mode = 0644,
1917 .proc_handler = proc_dointvec,
1918 },
1919#ifdef CONFIG_SPARC
1920 {
1921 .procname = "reboot-cmd",
1922 .data = reboot_command,
1923 .maxlen = 256,
1924 .mode = 0644,
1925 .proc_handler = proc_dostring,
1926 },
1927 {
1928 .procname = "stop-a",
1929 .data = &stop_a_enabled,
1930 .maxlen = sizeof (int),
1931 .mode = 0644,
1932 .proc_handler = proc_dointvec,
1933 },
1934 {
1935 .procname = "scons-poweroff",
1936 .data = &scons_pwroff,
1937 .maxlen = sizeof (int),
1938 .mode = 0644,
1939 .proc_handler = proc_dointvec,
1940 },
1941#endif
1942#ifdef CONFIG_SPARC64
1943 {
1944 .procname = "tsb-ratio",
1945 .data = &sysctl_tsb_ratio,
1946 .maxlen = sizeof (int),
1947 .mode = 0644,
1948 .proc_handler = proc_dointvec,
1949 },
1950#endif
1951#ifdef CONFIG_PARISC
1952 {
1953 .procname = "soft-power",
1954 .data = &pwrsw_enabled,
1955 .maxlen = sizeof (int),
1956 .mode = 0644,
1957 .proc_handler = proc_dointvec,
1958 },
1959#endif
1960#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1961 {
1962 .procname = "unaligned-trap",
1963 .data = &unaligned_enabled,
1964 .maxlen = sizeof (int),
1965 .mode = 0644,
1966 .proc_handler = proc_dointvec,
1967 },
1968#endif
1969 {
1970 .procname = "ctrl-alt-del",
1971 .data = &C_A_D,
1972 .maxlen = sizeof(int),
1973 .mode = 0644,
1974 .proc_handler = proc_dointvec,
1975 },
1976#ifdef CONFIG_FUNCTION_TRACER
1977 {
1978 .procname = "ftrace_enabled",
1979 .data = &ftrace_enabled,
1980 .maxlen = sizeof(int),
1981 .mode = 0644,
1982 .proc_handler = ftrace_enable_sysctl,
1983 },
1984#endif
1985#ifdef CONFIG_STACK_TRACER
1986 {
1987 .procname = "stack_tracer_enabled",
1988 .data = &stack_tracer_enabled,
1989 .maxlen = sizeof(int),
1990 .mode = 0644,
1991 .proc_handler = stack_trace_sysctl,
1992 },
1993#endif
1994#ifdef CONFIG_TRACING
1995 {
1996 .procname = "ftrace_dump_on_oops",
1997 .data = &ftrace_dump_on_oops,
1998 .maxlen = sizeof(int),
1999 .mode = 0644,
2000 .proc_handler = proc_dointvec,
2001 },
2002 {
2003 .procname = "traceoff_on_warning",
2004 .data = &__disable_trace_on_warning,
2005 .maxlen = sizeof(__disable_trace_on_warning),
2006 .mode = 0644,
2007 .proc_handler = proc_dointvec,
2008 },
2009 {
2010 .procname = "tracepoint_printk",
2011 .data = &tracepoint_printk,
2012 .maxlen = sizeof(tracepoint_printk),
2013 .mode = 0644,
2014 .proc_handler = tracepoint_printk_sysctl,
2015 },
2016#endif
2017#ifdef CONFIG_KEXEC_CORE
2018 {
2019 .procname = "kexec_load_disabled",
2020 .data = &kexec_load_disabled,
2021 .maxlen = sizeof(int),
2022 .mode = 0644,
2023 /* only handle a transition from default "0" to "1" */
2024 .proc_handler = proc_dointvec_minmax,
2025 .extra1 = SYSCTL_ONE,
2026 .extra2 = SYSCTL_ONE,
2027 },
2028#endif
2029#ifdef CONFIG_MODULES
2030 {
2031 .procname = "modprobe",
2032 .data = &modprobe_path,
2033 .maxlen = KMOD_PATH_LEN,
2034 .mode = 0644,
2035 .proc_handler = proc_dostring,
2036 },
2037 {
2038 .procname = "modules_disabled",
2039 .data = &modules_disabled,
2040 .maxlen = sizeof(int),
2041 .mode = 0644,
2042 /* only handle a transition from default "0" to "1" */
2043 .proc_handler = proc_dointvec_minmax,
2044 .extra1 = SYSCTL_ONE,
2045 .extra2 = SYSCTL_ONE,
2046 },
2047#endif
2048#ifdef CONFIG_UEVENT_HELPER
2049 {
2050 .procname = "hotplug",
2051 .data = &uevent_helper,
2052 .maxlen = UEVENT_HELPER_PATH_LEN,
2053 .mode = 0644,
2054 .proc_handler = proc_dostring,
2055 },
2056#endif
2057#ifdef CONFIG_CHR_DEV_SG
2058 {
2059 .procname = "sg-big-buff",
2060 .data = &sg_big_buff,
2061 .maxlen = sizeof (int),
2062 .mode = 0444,
2063 .proc_handler = proc_dointvec,
2064 },
2065#endif
2066#ifdef CONFIG_BSD_PROCESS_ACCT
2067 {
2068 .procname = "acct",
2069 .data = &acct_parm,
2070 .maxlen = 3*sizeof(int),
2071 .mode = 0644,
2072 .proc_handler = proc_dointvec,
2073 },
2074#endif
2075#ifdef CONFIG_MAGIC_SYSRQ
2076 {
2077 .procname = "sysrq",
2078 .data = NULL,
2079 .maxlen = sizeof (int),
2080 .mode = 0644,
2081 .proc_handler = sysrq_sysctl_handler,
2082 },
2083#endif
2084#ifdef CONFIG_PROC_SYSCTL
2085 {
2086 .procname = "cad_pid",
2087 .data = NULL,
2088 .maxlen = sizeof (int),
2089 .mode = 0600,
2090 .proc_handler = proc_do_cad_pid,
2091 },
2092#endif
2093 {
2094 .procname = "threads-max",
2095 .data = NULL,
2096 .maxlen = sizeof(int),
2097 .mode = 0644,
2098 .proc_handler = sysctl_max_threads,
2099 },
2100 {
2101 .procname = "random",
2102 .mode = 0555,
2103 .child = random_table,
2104 },
2105 {
2106 .procname = "usermodehelper",
2107 .mode = 0555,
2108 .child = usermodehelper_table,
2109 },
2110#ifdef CONFIG_FW_LOADER_USER_HELPER
2111 {
2112 .procname = "firmware_config",
2113 .mode = 0555,
2114 .child = firmware_config_table,
2115 },
2116#endif
2117 {
2118 .procname = "overflowuid",
2119 .data = &overflowuid,
2120 .maxlen = sizeof(int),
2121 .mode = 0644,
2122 .proc_handler = proc_dointvec_minmax,
2123 .extra1 = &minolduid,
2124 .extra2 = &maxolduid,
2125 },
2126 {
2127 .procname = "overflowgid",
2128 .data = &overflowgid,
2129 .maxlen = sizeof(int),
2130 .mode = 0644,
2131 .proc_handler = proc_dointvec_minmax,
2132 .extra1 = &minolduid,
2133 .extra2 = &maxolduid,
2134 },
2135#ifdef CONFIG_S390
2136 {
2137 .procname = "userprocess_debug",
2138 .data = &show_unhandled_signals,
2139 .maxlen = sizeof(int),
2140 .mode = 0644,
2141 .proc_handler = proc_dointvec,
2142 },
2143#endif
2144 {
2145 .procname = "pid_max",
2146 .data = &pid_max,
2147 .maxlen = sizeof (int),
2148 .mode = 0644,
2149 .proc_handler = proc_dointvec_minmax,
2150 .extra1 = &pid_max_min,
2151 .extra2 = &pid_max_max,
2152 },
2153 {
2154 .procname = "panic_on_oops",
2155 .data = &panic_on_oops,
2156 .maxlen = sizeof(int),
2157 .mode = 0644,
2158 .proc_handler = proc_dointvec,
2159 },
2160 {
2161 .procname = "panic_print",
2162 .data = &panic_print,
2163 .maxlen = sizeof(unsigned long),
2164 .mode = 0644,
2165 .proc_handler = proc_doulongvec_minmax,
2166 },
2167#if defined CONFIG_PRINTK
2168 {
2169 .procname = "printk",
2170 .data = &console_loglevel,
2171 .maxlen = 4*sizeof(int),
2172 .mode = 0644,
2173 .proc_handler = proc_dointvec,
2174 },
2175 {
2176 .procname = "printk_ratelimit",
2177 .data = &printk_ratelimit_state.interval,
2178 .maxlen = sizeof(int),
2179 .mode = 0644,
2180 .proc_handler = proc_dointvec_jiffies,
2181 },
2182 {
2183 .procname = "printk_ratelimit_burst",
2184 .data = &printk_ratelimit_state.burst,
2185 .maxlen = sizeof(int),
2186 .mode = 0644,
2187 .proc_handler = proc_dointvec,
2188 },
2189 {
2190 .procname = "printk_delay",
2191 .data = &printk_delay_msec,
2192 .maxlen = sizeof(int),
2193 .mode = 0644,
2194 .proc_handler = proc_dointvec_minmax,
2195 .extra1 = SYSCTL_ZERO,
2196 .extra2 = &ten_thousand,
2197 },
2198 {
2199 .procname = "printk_devkmsg",
2200 .data = devkmsg_log_str,
2201 .maxlen = DEVKMSG_STR_MAX_SIZE,
2202 .mode = 0644,
2203 .proc_handler = devkmsg_sysctl_set_loglvl,
2204 },
2205 {
2206 .procname = "dmesg_restrict",
2207 .data = &dmesg_restrict,
2208 .maxlen = sizeof(int),
2209 .mode = 0644,
2210 .proc_handler = proc_dointvec_minmax_sysadmin,
2211 .extra1 = SYSCTL_ZERO,
2212 .extra2 = SYSCTL_ONE,
2213 },
2214 {
2215 .procname = "kptr_restrict",
2216 .data = &kptr_restrict,
2217 .maxlen = sizeof(int),
2218 .mode = 0644,
2219 .proc_handler = proc_dointvec_minmax_sysadmin,
2220 .extra1 = SYSCTL_ZERO,
2221 .extra2 = &two,
2222 },
2223#endif
2224 {
2225 .procname = "ngroups_max",
2226 .data = &ngroups_max,
2227 .maxlen = sizeof (int),
2228 .mode = 0444,
2229 .proc_handler = proc_dointvec,
2230 },
2231 {
2232 .procname = "cap_last_cap",
2233 .data = (void *)&cap_last_cap,
2234 .maxlen = sizeof(int),
2235 .mode = 0444,
2236 .proc_handler = proc_dointvec,
2237 },
2238#if defined(CONFIG_LOCKUP_DETECTOR)
2239 {
2240 .procname = "watchdog",
2241 .data = &watchdog_user_enabled,
2242 .maxlen = sizeof(int),
2243 .mode = 0644,
2244 .proc_handler = proc_watchdog,
2245 .extra1 = SYSCTL_ZERO,
2246 .extra2 = SYSCTL_ONE,
2247 },
2248 {
2249 .procname = "watchdog_thresh",
2250 .data = &watchdog_thresh,
2251 .maxlen = sizeof(int),
2252 .mode = 0644,
2253 .proc_handler = proc_watchdog_thresh,
2254 .extra1 = SYSCTL_ZERO,
2255 .extra2 = &sixty,
2256 },
2257 {
2258 .procname = "nmi_watchdog",
2259 .data = &nmi_watchdog_user_enabled,
2260 .maxlen = sizeof(int),
2261 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2262 .proc_handler = proc_nmi_watchdog,
2263 .extra1 = SYSCTL_ZERO,
2264 .extra2 = SYSCTL_ONE,
2265 },
2266 {
2267 .procname = "watchdog_cpumask",
2268 .data = &watchdog_cpumask_bits,
2269 .maxlen = NR_CPUS,
2270 .mode = 0644,
2271 .proc_handler = proc_watchdog_cpumask,
2272 },
2273#ifdef CONFIG_SOFTLOCKUP_DETECTOR
2274 {
2275 .procname = "soft_watchdog",
2276 .data = &soft_watchdog_user_enabled,
2277 .maxlen = sizeof(int),
2278 .mode = 0644,
2279 .proc_handler = proc_soft_watchdog,
2280 .extra1 = SYSCTL_ZERO,
2281 .extra2 = SYSCTL_ONE,
2282 },
2283 {
2284 .procname = "softlockup_panic",
2285 .data = &softlockup_panic,
2286 .maxlen = sizeof(int),
2287 .mode = 0644,
2288 .proc_handler = proc_dointvec_minmax,
2289 .extra1 = SYSCTL_ZERO,
2290 .extra2 = SYSCTL_ONE,
2291 },
2292#ifdef CONFIG_SMP
2293 {
2294 .procname = "softlockup_all_cpu_backtrace",
2295 .data = &sysctl_softlockup_all_cpu_backtrace,
2296 .maxlen = sizeof(int),
2297 .mode = 0644,
2298 .proc_handler = proc_dointvec_minmax,
2299 .extra1 = SYSCTL_ZERO,
2300 .extra2 = SYSCTL_ONE,
2301 },
2302#endif /* CONFIG_SMP */
2303#endif
2304#ifdef CONFIG_HARDLOCKUP_DETECTOR
2305 {
2306 .procname = "hardlockup_panic",
2307 .data = &hardlockup_panic,
2308 .maxlen = sizeof(int),
2309 .mode = 0644,
2310 .proc_handler = proc_dointvec_minmax,
2311 .extra1 = SYSCTL_ZERO,
2312 .extra2 = SYSCTL_ONE,
2313 },
2314#ifdef CONFIG_SMP
2315 {
2316 .procname = "hardlockup_all_cpu_backtrace",
2317 .data = &sysctl_hardlockup_all_cpu_backtrace,
2318 .maxlen = sizeof(int),
2319 .mode = 0644,
2320 .proc_handler = proc_dointvec_minmax,
2321 .extra1 = SYSCTL_ZERO,
2322 .extra2 = SYSCTL_ONE,
2323 },
2324#endif /* CONFIG_SMP */
2325#endif
2326#endif
2327
2328#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2329 {
2330 .procname = "unknown_nmi_panic",
2331 .data = &unknown_nmi_panic,
2332 .maxlen = sizeof (int),
2333 .mode = 0644,
2334 .proc_handler = proc_dointvec,
2335 },
2336#endif
61d9b56a 2337
cb8e59cc
LT
2338#if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2339 defined(CONFIG_DEBUG_STACKOVERFLOW)
f461d2dc 2340 {
cb8e59cc
LT
2341 .procname = "panic_on_stackoverflow",
2342 .data = &sysctl_panic_on_stackoverflow,
f461d2dc
CH
2343 .maxlen = sizeof(int),
2344 .mode = 0644,
2345 .proc_handler = proc_dointvec,
2346 },
cb8e59cc
LT
2347#endif
2348#if defined(CONFIG_X86)
f461d2dc 2349 {
cb8e59cc
LT
2350 .procname = "panic_on_unrecovered_nmi",
2351 .data = &panic_on_unrecovered_nmi,
f461d2dc
CH
2352 .maxlen = sizeof(int),
2353 .mode = 0644,
2354 .proc_handler = proc_dointvec,
2355 },
f461d2dc 2356 {
cb8e59cc
LT
2357 .procname = "panic_on_io_nmi",
2358 .data = &panic_on_io_nmi,
f461d2dc
CH
2359 .maxlen = sizeof(int),
2360 .mode = 0644,
2361 .proc_handler = proc_dointvec,
2362 },
f461d2dc
CH
2363 {
2364 .procname = "bootloader_type",
2365 .data = &bootloader_type,
2366 .maxlen = sizeof (int),
2367 .mode = 0444,
2368 .proc_handler = proc_dointvec,
2369 },
2370 {
2371 .procname = "bootloader_version",
2372 .data = &bootloader_version,
2373 .maxlen = sizeof (int),
2374 .mode = 0444,
2375 .proc_handler = proc_dointvec,
2376 },
2377 {
2378 .procname = "io_delay_type",
2379 .data = &io_delay_type,
2380 .maxlen = sizeof(int),
2381 .mode = 0644,
2382 .proc_handler = proc_dointvec,
2383 },
2384#endif
2385#if defined(CONFIG_MMU)
2386 {
2387 .procname = "randomize_va_space",
2388 .data = &randomize_va_space,
2389 .maxlen = sizeof(int),
2390 .mode = 0644,
2391 .proc_handler = proc_dointvec,
2392 },
2393#endif
2394#if defined(CONFIG_S390) && defined(CONFIG_SMP)
2395 {
2396 .procname = "spin_retry",
2397 .data = &spin_retry,
2398 .maxlen = sizeof (int),
2399 .mode = 0644,
2400 .proc_handler = proc_dointvec,
2401 },
2402#endif
2403#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2404 {
2405 .procname = "acpi_video_flags",
2406 .data = &acpi_realmode_flags,
2407 .maxlen = sizeof (unsigned long),
2408 .mode = 0644,
2409 .proc_handler = proc_doulongvec_minmax,
2410 },
2411#endif
2412#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2413 {
2414 .procname = "ignore-unaligned-usertrap",
2415 .data = &no_unaligned_warning,
2416 .maxlen = sizeof (int),
2417 .mode = 0644,
2418 .proc_handler = proc_dointvec,
2419 },
2420#endif
2421#ifdef CONFIG_IA64
2422 {
2423 .procname = "unaligned-dump-stack",
2424 .data = &unaligned_dump_stack,
2425 .maxlen = sizeof (int),
2426 .mode = 0644,
2427 .proc_handler = proc_dointvec,
2428 },
2429#endif
2430#ifdef CONFIG_DETECT_HUNG_TASK
2431 {
2432 .procname = "hung_task_panic",
2433 .data = &sysctl_hung_task_panic,
2434 .maxlen = sizeof(int),
2435 .mode = 0644,
2436 .proc_handler = proc_dointvec_minmax,
2437 .extra1 = SYSCTL_ZERO,
2438 .extra2 = SYSCTL_ONE,
2439 },
2440 {
2441 .procname = "hung_task_check_count",
2442 .data = &sysctl_hung_task_check_count,
2443 .maxlen = sizeof(int),
2444 .mode = 0644,
2445 .proc_handler = proc_dointvec_minmax,
2446 .extra1 = SYSCTL_ZERO,
2447 },
2448 {
2449 .procname = "hung_task_timeout_secs",
2450 .data = &sysctl_hung_task_timeout_secs,
2451 .maxlen = sizeof(unsigned long),
2452 .mode = 0644,
2453 .proc_handler = proc_dohung_task_timeout_secs,
2454 .extra2 = &hung_task_timeout_max,
2455 },
2456 {
2457 .procname = "hung_task_check_interval_secs",
2458 .data = &sysctl_hung_task_check_interval_secs,
2459 .maxlen = sizeof(unsigned long),
2460 .mode = 0644,
2461 .proc_handler = proc_dohung_task_timeout_secs,
2462 .extra2 = &hung_task_timeout_max,
2463 },
2464 {
2465 .procname = "hung_task_warnings",
2466 .data = &sysctl_hung_task_warnings,
2467 .maxlen = sizeof(int),
2468 .mode = 0644,
2469 .proc_handler = proc_dointvec_minmax,
2470 .extra1 = &neg_one,
2471 },
2472#endif
2473#ifdef CONFIG_RT_MUTEXES
2474 {
2475 .procname = "max_lock_depth",
2476 .data = &max_lock_depth,
2477 .maxlen = sizeof(int),
2478 .mode = 0644,
2479 .proc_handler = proc_dointvec,
2480 },
2481#endif
2482 {
2483 .procname = "poweroff_cmd",
2484 .data = &poweroff_cmd,
2485 .maxlen = POWEROFF_CMD_PATH_LEN,
2486 .mode = 0644,
2487 .proc_handler = proc_dostring,
2488 },
2489#ifdef CONFIG_KEYS
2490 {
2491 .procname = "keys",
2492 .mode = 0555,
2493 .child = key_sysctls,
2494 },
2495#endif
2496#ifdef CONFIG_PERF_EVENTS
2497 /*
2498 * User-space scripts rely on the existence of this file
2499 * as a feature check for perf_events being enabled.
2500 *
2501 * So it's an ABI, do not remove!
2502 */
2503 {
2504 .procname = "perf_event_paranoid",
2505 .data = &sysctl_perf_event_paranoid,
2506 .maxlen = sizeof(sysctl_perf_event_paranoid),
2507 .mode = 0644,
2508 .proc_handler = proc_dointvec,
2509 },
2510 {
2511 .procname = "perf_event_mlock_kb",
2512 .data = &sysctl_perf_event_mlock,
2513 .maxlen = sizeof(sysctl_perf_event_mlock),
2514 .mode = 0644,
2515 .proc_handler = proc_dointvec,
2516 },
2517 {
2518 .procname = "perf_event_max_sample_rate",
2519 .data = &sysctl_perf_event_sample_rate,
2520 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2521 .mode = 0644,
2522 .proc_handler = perf_proc_update_handler,
2523 .extra1 = SYSCTL_ONE,
2524 },
2525 {
2526 .procname = "perf_cpu_time_max_percent",
2527 .data = &sysctl_perf_cpu_time_max_percent,
2528 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2529 .mode = 0644,
2530 .proc_handler = perf_cpu_time_max_percent_handler,
2531 .extra1 = SYSCTL_ZERO,
2532 .extra2 = &one_hundred,
2533 },
2534 {
2535 .procname = "perf_event_max_stack",
2536 .data = &sysctl_perf_event_max_stack,
2537 .maxlen = sizeof(sysctl_perf_event_max_stack),
2538 .mode = 0644,
2539 .proc_handler = perf_event_max_stack_handler,
2540 .extra1 = SYSCTL_ZERO,
2541 .extra2 = &six_hundred_forty_kb,
2542 },
2543 {
2544 .procname = "perf_event_max_contexts_per_stack",
2545 .data = &sysctl_perf_event_max_contexts_per_stack,
2546 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2547 .mode = 0644,
2548 .proc_handler = perf_event_max_stack_handler,
2549 .extra1 = SYSCTL_ZERO,
2550 .extra2 = &one_thousand,
2551 },
2552#endif
2553 {
2554 .procname = "panic_on_warn",
2555 .data = &panic_on_warn,
2556 .maxlen = sizeof(int),
2557 .mode = 0644,
2558 .proc_handler = proc_dointvec_minmax,
2559 .extra1 = SYSCTL_ZERO,
2560 .extra2 = SYSCTL_ONE,
2561 },
2562#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2563 {
2564 .procname = "timer_migration",
2565 .data = &sysctl_timer_migration,
2566 .maxlen = sizeof(unsigned int),
2567 .mode = 0644,
2568 .proc_handler = timer_migration_handler,
2569 .extra1 = SYSCTL_ZERO,
2570 .extra2 = SYSCTL_ONE,
2571 },
2572#endif
2573#ifdef CONFIG_BPF_SYSCALL
2574 {
2575 .procname = "unprivileged_bpf_disabled",
2576 .data = &sysctl_unprivileged_bpf_disabled,
2577 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2578 .mode = 0644,
2579 /* only handle a transition from default "0" to "1" */
2580 .proc_handler = proc_dointvec_minmax,
2581 .extra1 = SYSCTL_ONE,
2582 .extra2 = SYSCTL_ONE,
2583 },
2584 {
2585 .procname = "bpf_stats_enabled",
2586 .data = &bpf_stats_enabled_key.key,
2587 .maxlen = sizeof(bpf_stats_enabled_key),
2588 .mode = 0644,
d46edd67 2589 .proc_handler = bpf_stats_handler,
f461d2dc
CH
2590 },
2591#endif
2592#if defined(CONFIG_TREE_RCU)
2593 {
2594 .procname = "panic_on_rcu_stall",
2595 .data = &sysctl_panic_on_rcu_stall,
2596 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2597 .mode = 0644,
2598 .proc_handler = proc_dointvec_minmax,
2599 .extra1 = SYSCTL_ZERO,
2600 .extra2 = SYSCTL_ONE,
2601 },
2602#endif
2603#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2604 {
2605 .procname = "stack_erasing",
2606 .data = NULL,
2607 .maxlen = sizeof(int),
2608 .mode = 0600,
2609 .proc_handler = stack_erasing_sysctl,
2610 .extra1 = SYSCTL_ZERO,
2611 .extra2 = SYSCTL_ONE,
2612 },
2613#endif
2614 { }
2615};
1da177e4 2616
f461d2dc
CH
2617static struct ctl_table vm_table[] = {
2618 {
2619 .procname = "overcommit_memory",
2620 .data = &sysctl_overcommit_memory,
2621 .maxlen = sizeof(sysctl_overcommit_memory),
2622 .mode = 0644,
2623 .proc_handler = proc_dointvec_minmax,
2624 .extra1 = SYSCTL_ZERO,
2625 .extra2 = &two,
2626 },
2627 {
2628 .procname = "panic_on_oom",
2629 .data = &sysctl_panic_on_oom,
2630 .maxlen = sizeof(sysctl_panic_on_oom),
2631 .mode = 0644,
2632 .proc_handler = proc_dointvec_minmax,
2633 .extra1 = SYSCTL_ZERO,
2634 .extra2 = &two,
2635 },
2636 {
2637 .procname = "oom_kill_allocating_task",
2638 .data = &sysctl_oom_kill_allocating_task,
2639 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2640 .mode = 0644,
2641 .proc_handler = proc_dointvec,
2642 },
2643 {
2644 .procname = "oom_dump_tasks",
2645 .data = &sysctl_oom_dump_tasks,
2646 .maxlen = sizeof(sysctl_oom_dump_tasks),
2647 .mode = 0644,
2648 .proc_handler = proc_dointvec,
2649 },
2650 {
2651 .procname = "overcommit_ratio",
2652 .data = &sysctl_overcommit_ratio,
2653 .maxlen = sizeof(sysctl_overcommit_ratio),
2654 .mode = 0644,
2655 .proc_handler = overcommit_ratio_handler,
2656 },
2657 {
2658 .procname = "overcommit_kbytes",
2659 .data = &sysctl_overcommit_kbytes,
2660 .maxlen = sizeof(sysctl_overcommit_kbytes),
2661 .mode = 0644,
2662 .proc_handler = overcommit_kbytes_handler,
2663 },
2664 {
2665 .procname = "page-cluster",
2666 .data = &page_cluster,
2667 .maxlen = sizeof(int),
2668 .mode = 0644,
2669 .proc_handler = proc_dointvec_minmax,
2670 .extra1 = SYSCTL_ZERO,
2671 },
2672 {
2673 .procname = "dirty_background_ratio",
2674 .data = &dirty_background_ratio,
2675 .maxlen = sizeof(dirty_background_ratio),
2676 .mode = 0644,
2677 .proc_handler = dirty_background_ratio_handler,
2678 .extra1 = SYSCTL_ZERO,
2679 .extra2 = &one_hundred,
2680 },
2681 {
2682 .procname = "dirty_background_bytes",
2683 .data = &dirty_background_bytes,
2684 .maxlen = sizeof(dirty_background_bytes),
2685 .mode = 0644,
2686 .proc_handler = dirty_background_bytes_handler,
2687 .extra1 = &one_ul,
2688 },
2689 {
2690 .procname = "dirty_ratio",
2691 .data = &vm_dirty_ratio,
2692 .maxlen = sizeof(vm_dirty_ratio),
2693 .mode = 0644,
2694 .proc_handler = dirty_ratio_handler,
2695 .extra1 = SYSCTL_ZERO,
2696 .extra2 = &one_hundred,
2697 },
2698 {
2699 .procname = "dirty_bytes",
2700 .data = &vm_dirty_bytes,
2701 .maxlen = sizeof(vm_dirty_bytes),
2702 .mode = 0644,
2703 .proc_handler = dirty_bytes_handler,
2704 .extra1 = &dirty_bytes_min,
2705 },
2706 {
2707 .procname = "dirty_writeback_centisecs",
2708 .data = &dirty_writeback_interval,
2709 .maxlen = sizeof(dirty_writeback_interval),
2710 .mode = 0644,
2711 .proc_handler = dirty_writeback_centisecs_handler,
2712 },
2713 {
2714 .procname = "dirty_expire_centisecs",
2715 .data = &dirty_expire_interval,
2716 .maxlen = sizeof(dirty_expire_interval),
2717 .mode = 0644,
2718 .proc_handler = proc_dointvec_minmax,
2719 .extra1 = SYSCTL_ZERO,
2720 },
2721 {
2722 .procname = "dirtytime_expire_seconds",
2723 .data = &dirtytime_expire_interval,
2724 .maxlen = sizeof(dirtytime_expire_interval),
2725 .mode = 0644,
2726 .proc_handler = dirtytime_interval_handler,
2727 .extra1 = SYSCTL_ZERO,
2728 },
2729 {
2730 .procname = "swappiness",
2731 .data = &vm_swappiness,
2732 .maxlen = sizeof(vm_swappiness),
2733 .mode = 0644,
2734 .proc_handler = proc_dointvec_minmax,
2735 .extra1 = SYSCTL_ZERO,
ee01c4d7 2736 .extra2 = &two_hundred,
f461d2dc
CH
2737 },
2738#ifdef CONFIG_HUGETLB_PAGE
2739 {
2740 .procname = "nr_hugepages",
2741 .data = NULL,
2742 .maxlen = sizeof(unsigned long),
2743 .mode = 0644,
2744 .proc_handler = hugetlb_sysctl_handler,
2745 },
2746#ifdef CONFIG_NUMA
2747 {
2748 .procname = "nr_hugepages_mempolicy",
2749 .data = NULL,
2750 .maxlen = sizeof(unsigned long),
2751 .mode = 0644,
2752 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2753 },
2754 {
2755 .procname = "numa_stat",
2756 .data = &sysctl_vm_numa_stat,
2757 .maxlen = sizeof(int),
2758 .mode = 0644,
2759 .proc_handler = sysctl_vm_numa_stat_handler,
2760 .extra1 = SYSCTL_ZERO,
2761 .extra2 = SYSCTL_ONE,
2762 },
2763#endif
2764 {
2765 .procname = "hugetlb_shm_group",
2766 .data = &sysctl_hugetlb_shm_group,
2767 .maxlen = sizeof(gid_t),
2768 .mode = 0644,
2769 .proc_handler = proc_dointvec,
2770 },
2771 {
2772 .procname = "nr_overcommit_hugepages",
2773 .data = NULL,
2774 .maxlen = sizeof(unsigned long),
2775 .mode = 0644,
2776 .proc_handler = hugetlb_overcommit_handler,
2777 },
2778#endif
2779 {
2780 .procname = "lowmem_reserve_ratio",
2781 .data = &sysctl_lowmem_reserve_ratio,
2782 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2783 .mode = 0644,
2784 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2785 },
2786 {
2787 .procname = "drop_caches",
2788 .data = &sysctl_drop_caches,
2789 .maxlen = sizeof(int),
2790 .mode = 0200,
2791 .proc_handler = drop_caches_sysctl_handler,
2792 .extra1 = SYSCTL_ONE,
2793 .extra2 = &four,
2794 },
2795#ifdef CONFIG_COMPACTION
2796 {
2797 .procname = "compact_memory",
2798 .data = &sysctl_compact_memory,
2799 .maxlen = sizeof(int),
2800 .mode = 0200,
2801 .proc_handler = sysctl_compaction_handler,
2802 },
2803 {
2804 .procname = "extfrag_threshold",
2805 .data = &sysctl_extfrag_threshold,
2806 .maxlen = sizeof(int),
2807 .mode = 0644,
2808 .proc_handler = proc_dointvec_minmax,
2809 .extra1 = &min_extfrag_threshold,
2810 .extra2 = &max_extfrag_threshold,
2811 },
2812 {
2813 .procname = "compact_unevictable_allowed",
2814 .data = &sysctl_compact_unevictable_allowed,
2815 .maxlen = sizeof(int),
2816 .mode = 0644,
2817 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2818 .extra1 = SYSCTL_ZERO,
2819 .extra2 = SYSCTL_ONE,
2820 },
1da177e4 2821
f461d2dc
CH
2822#endif /* CONFIG_COMPACTION */
2823 {
2824 .procname = "min_free_kbytes",
2825 .data = &min_free_kbytes,
2826 .maxlen = sizeof(min_free_kbytes),
2827 .mode = 0644,
2828 .proc_handler = min_free_kbytes_sysctl_handler,
2829 .extra1 = SYSCTL_ZERO,
2830 },
2831 {
2832 .procname = "watermark_boost_factor",
2833 .data = &watermark_boost_factor,
2834 .maxlen = sizeof(watermark_boost_factor),
2835 .mode = 0644,
2836 .proc_handler = proc_dointvec_minmax,
2837 .extra1 = SYSCTL_ZERO,
2838 },
2839 {
2840 .procname = "watermark_scale_factor",
2841 .data = &watermark_scale_factor,
2842 .maxlen = sizeof(watermark_scale_factor),
2843 .mode = 0644,
2844 .proc_handler = watermark_scale_factor_sysctl_handler,
2845 .extra1 = SYSCTL_ONE,
2846 .extra2 = &one_thousand,
2847 },
2848 {
2849 .procname = "percpu_pagelist_fraction",
2850 .data = &percpu_pagelist_fraction,
2851 .maxlen = sizeof(percpu_pagelist_fraction),
2852 .mode = 0644,
2853 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2854 .extra1 = SYSCTL_ZERO,
2855 },
2856#ifdef CONFIG_MMU
2857 {
2858 .procname = "max_map_count",
2859 .data = &sysctl_max_map_count,
2860 .maxlen = sizeof(sysctl_max_map_count),
2861 .mode = 0644,
2862 .proc_handler = proc_dointvec_minmax,
2863 .extra1 = SYSCTL_ZERO,
2864 },
2865#else
2866 {
2867 .procname = "nr_trim_pages",
2868 .data = &sysctl_nr_trim_pages,
2869 .maxlen = sizeof(sysctl_nr_trim_pages),
2870 .mode = 0644,
2871 .proc_handler = proc_dointvec_minmax,
2872 .extra1 = SYSCTL_ZERO,
2873 },
2874#endif
2875 {
2876 .procname = "laptop_mode",
2877 .data = &laptop_mode,
2878 .maxlen = sizeof(laptop_mode),
2879 .mode = 0644,
2880 .proc_handler = proc_dointvec_jiffies,
2881 },
2882 {
2883 .procname = "block_dump",
2884 .data = &block_dump,
2885 .maxlen = sizeof(block_dump),
2886 .mode = 0644,
2887 .proc_handler = proc_dointvec,
2888 .extra1 = SYSCTL_ZERO,
2889 },
2890 {
2891 .procname = "vfs_cache_pressure",
2892 .data = &sysctl_vfs_cache_pressure,
2893 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2894 .mode = 0644,
2895 .proc_handler = proc_dointvec,
2896 .extra1 = SYSCTL_ZERO,
2897 },
2898#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2899 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2900 {
2901 .procname = "legacy_va_layout",
2902 .data = &sysctl_legacy_va_layout,
2903 .maxlen = sizeof(sysctl_legacy_va_layout),
2904 .mode = 0644,
2905 .proc_handler = proc_dointvec,
2906 .extra1 = SYSCTL_ZERO,
2907 },
2908#endif
2909#ifdef CONFIG_NUMA
2910 {
2911 .procname = "zone_reclaim_mode",
2912 .data = &node_reclaim_mode,
2913 .maxlen = sizeof(node_reclaim_mode),
2914 .mode = 0644,
2915 .proc_handler = proc_dointvec,
2916 .extra1 = SYSCTL_ZERO,
2917 },
2918 {
2919 .procname = "min_unmapped_ratio",
2920 .data = &sysctl_min_unmapped_ratio,
2921 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2922 .mode = 0644,
2923 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2924 .extra1 = SYSCTL_ZERO,
2925 .extra2 = &one_hundred,
2926 },
2927 {
2928 .procname = "min_slab_ratio",
2929 .data = &sysctl_min_slab_ratio,
2930 .maxlen = sizeof(sysctl_min_slab_ratio),
2931 .mode = 0644,
2932 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2933 .extra1 = SYSCTL_ZERO,
2934 .extra2 = &one_hundred,
2935 },
2936#endif
2937#ifdef CONFIG_SMP
2938 {
2939 .procname = "stat_interval",
2940 .data = &sysctl_stat_interval,
2941 .maxlen = sizeof(sysctl_stat_interval),
2942 .mode = 0644,
2943 .proc_handler = proc_dointvec_jiffies,
2944 },
2945 {
2946 .procname = "stat_refresh",
2947 .data = NULL,
2948 .maxlen = 0,
2949 .mode = 0600,
2950 .proc_handler = vmstat_refresh,
2951 },
2952#endif
2953#ifdef CONFIG_MMU
2954 {
2955 .procname = "mmap_min_addr",
2956 .data = &dac_mmap_min_addr,
2957 .maxlen = sizeof(unsigned long),
2958 .mode = 0644,
2959 .proc_handler = mmap_min_addr_handler,
2960 },
2961#endif
2962#ifdef CONFIG_NUMA
2963 {
2964 .procname = "numa_zonelist_order",
2965 .data = &numa_zonelist_order,
2966 .maxlen = NUMA_ZONELIST_ORDER_LEN,
2967 .mode = 0644,
2968 .proc_handler = numa_zonelist_order_handler,
2969 },
2970#endif
2971#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
2972 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
2973 {
2974 .procname = "vdso_enabled",
2975#ifdef CONFIG_X86_32
2976 .data = &vdso32_enabled,
2977 .maxlen = sizeof(vdso32_enabled),
2978#else
2979 .data = &vdso_enabled,
2980 .maxlen = sizeof(vdso_enabled),
2981#endif
2982 .mode = 0644,
2983 .proc_handler = proc_dointvec,
2984 .extra1 = SYSCTL_ZERO,
2985 },
2986#endif
2987#ifdef CONFIG_HIGHMEM
2988 {
2989 .procname = "highmem_is_dirtyable",
2990 .data = &vm_highmem_is_dirtyable,
2991 .maxlen = sizeof(vm_highmem_is_dirtyable),
2992 .mode = 0644,
2993 .proc_handler = proc_dointvec_minmax,
2994 .extra1 = SYSCTL_ZERO,
2995 .extra2 = SYSCTL_ONE,
2996 },
2997#endif
2998#ifdef CONFIG_MEMORY_FAILURE
2999 {
3000 .procname = "memory_failure_early_kill",
3001 .data = &sysctl_memory_failure_early_kill,
3002 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3003 .mode = 0644,
3004 .proc_handler = proc_dointvec_minmax,
3005 .extra1 = SYSCTL_ZERO,
3006 .extra2 = SYSCTL_ONE,
3007 },
3008 {
3009 .procname = "memory_failure_recovery",
3010 .data = &sysctl_memory_failure_recovery,
3011 .maxlen = sizeof(sysctl_memory_failure_recovery),
3012 .mode = 0644,
3013 .proc_handler = proc_dointvec_minmax,
3014 .extra1 = SYSCTL_ZERO,
3015 .extra2 = SYSCTL_ONE,
3016 },
3017#endif
3018 {
3019 .procname = "user_reserve_kbytes",
3020 .data = &sysctl_user_reserve_kbytes,
3021 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3022 .mode = 0644,
3023 .proc_handler = proc_doulongvec_minmax,
3024 },
3025 {
3026 .procname = "admin_reserve_kbytes",
3027 .data = &sysctl_admin_reserve_kbytes,
3028 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3029 .mode = 0644,
3030 .proc_handler = proc_doulongvec_minmax,
3031 },
3032#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3033 {
3034 .procname = "mmap_rnd_bits",
3035 .data = &mmap_rnd_bits,
3036 .maxlen = sizeof(mmap_rnd_bits),
3037 .mode = 0600,
3038 .proc_handler = proc_dointvec_minmax,
3039 .extra1 = (void *)&mmap_rnd_bits_min,
3040 .extra2 = (void *)&mmap_rnd_bits_max,
3041 },
3042#endif
3043#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3044 {
3045 .procname = "mmap_rnd_compat_bits",
3046 .data = &mmap_rnd_compat_bits,
3047 .maxlen = sizeof(mmap_rnd_compat_bits),
3048 .mode = 0600,
3049 .proc_handler = proc_dointvec_minmax,
3050 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3051 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3052 },
3053#endif
3054#ifdef CONFIG_USERFAULTFD
3055 {
3056 .procname = "unprivileged_userfaultfd",
3057 .data = &sysctl_unprivileged_userfaultfd,
3058 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3059 .mode = 0644,
3060 .proc_handler = proc_dointvec_minmax,
3061 .extra1 = SYSCTL_ZERO,
3062 .extra2 = SYSCTL_ONE,
3063 },
3064#endif
3065 { }
3066};
1da177e4 3067
f461d2dc
CH
3068static struct ctl_table fs_table[] = {
3069 {
3070 .procname = "inode-nr",
3071 .data = &inodes_stat,
3072 .maxlen = 2*sizeof(long),
3073 .mode = 0444,
3074 .proc_handler = proc_nr_inodes,
3075 },
3076 {
3077 .procname = "inode-state",
3078 .data = &inodes_stat,
3079 .maxlen = 7*sizeof(long),
3080 .mode = 0444,
3081 .proc_handler = proc_nr_inodes,
3082 },
3083 {
3084 .procname = "file-nr",
3085 .data = &files_stat,
3086 .maxlen = sizeof(files_stat),
3087 .mode = 0444,
3088 .proc_handler = proc_nr_files,
3089 },
3090 {
3091 .procname = "file-max",
3092 .data = &files_stat.max_files,
3093 .maxlen = sizeof(files_stat.max_files),
3094 .mode = 0644,
3095 .proc_handler = proc_doulongvec_minmax,
3096 .extra1 = &zero_ul,
3097 .extra2 = &long_max,
3098 },
3099 {
3100 .procname = "nr_open",
3101 .data = &sysctl_nr_open,
3102 .maxlen = sizeof(unsigned int),
3103 .mode = 0644,
3104 .proc_handler = proc_dointvec_minmax,
3105 .extra1 = &sysctl_nr_open_min,
3106 .extra2 = &sysctl_nr_open_max,
3107 },
3108 {
3109 .procname = "dentry-state",
3110 .data = &dentry_stat,
3111 .maxlen = 6*sizeof(long),
3112 .mode = 0444,
3113 .proc_handler = proc_nr_dentry,
3114 },
3115 {
3116 .procname = "overflowuid",
3117 .data = &fs_overflowuid,
3118 .maxlen = sizeof(int),
3119 .mode = 0644,
3120 .proc_handler = proc_dointvec_minmax,
3121 .extra1 = &minolduid,
3122 .extra2 = &maxolduid,
3123 },
3124 {
3125 .procname = "overflowgid",
3126 .data = &fs_overflowgid,
3127 .maxlen = sizeof(int),
3128 .mode = 0644,
3129 .proc_handler = proc_dointvec_minmax,
3130 .extra1 = &minolduid,
3131 .extra2 = &maxolduid,
3132 },
3133#ifdef CONFIG_FILE_LOCKING
3134 {
3135 .procname = "leases-enable",
3136 .data = &leases_enable,
3137 .maxlen = sizeof(int),
3138 .mode = 0644,
3139 .proc_handler = proc_dointvec,
3140 },
3141#endif
3142#ifdef CONFIG_DNOTIFY
3143 {
3144 .procname = "dir-notify-enable",
3145 .data = &dir_notify_enable,
3146 .maxlen = sizeof(int),
3147 .mode = 0644,
3148 .proc_handler = proc_dointvec,
3149 },
3150#endif
3151#ifdef CONFIG_MMU
3152#ifdef CONFIG_FILE_LOCKING
3153 {
3154 .procname = "lease-break-time",
3155 .data = &lease_break_time,
3156 .maxlen = sizeof(int),
3157 .mode = 0644,
3158 .proc_handler = proc_dointvec,
3159 },
3160#endif
3161#ifdef CONFIG_AIO
3162 {
3163 .procname = "aio-nr",
3164 .data = &aio_nr,
3165 .maxlen = sizeof(aio_nr),
3166 .mode = 0444,
3167 .proc_handler = proc_doulongvec_minmax,
3168 },
3169 {
3170 .procname = "aio-max-nr",
3171 .data = &aio_max_nr,
3172 .maxlen = sizeof(aio_max_nr),
3173 .mode = 0644,
3174 .proc_handler = proc_doulongvec_minmax,
3175 },
3176#endif /* CONFIG_AIO */
3177#ifdef CONFIG_INOTIFY_USER
3178 {
3179 .procname = "inotify",
3180 .mode = 0555,
3181 .child = inotify_table,
3182 },
3183#endif
3184#ifdef CONFIG_EPOLL
3185 {
3186 .procname = "epoll",
3187 .mode = 0555,
3188 .child = epoll_table,
3189 },
3190#endif
3191#endif
3192 {
3193 .procname = "protected_symlinks",
3194 .data = &sysctl_protected_symlinks,
3195 .maxlen = sizeof(int),
3196 .mode = 0600,
3197 .proc_handler = proc_dointvec_minmax,
3198 .extra1 = SYSCTL_ZERO,
3199 .extra2 = SYSCTL_ONE,
3200 },
3201 {
3202 .procname = "protected_hardlinks",
3203 .data = &sysctl_protected_hardlinks,
3204 .maxlen = sizeof(int),
3205 .mode = 0600,
3206 .proc_handler = proc_dointvec_minmax,
3207 .extra1 = SYSCTL_ZERO,
3208 .extra2 = SYSCTL_ONE,
3209 },
3210 {
3211 .procname = "protected_fifos",
3212 .data = &sysctl_protected_fifos,
3213 .maxlen = sizeof(int),
3214 .mode = 0600,
3215 .proc_handler = proc_dointvec_minmax,
3216 .extra1 = SYSCTL_ZERO,
3217 .extra2 = &two,
3218 },
3219 {
3220 .procname = "protected_regular",
3221 .data = &sysctl_protected_regular,
3222 .maxlen = sizeof(int),
3223 .mode = 0600,
3224 .proc_handler = proc_dointvec_minmax,
3225 .extra1 = SYSCTL_ZERO,
3226 .extra2 = &two,
3227 },
3228 {
3229 .procname = "suid_dumpable",
3230 .data = &suid_dumpable,
3231 .maxlen = sizeof(int),
3232 .mode = 0644,
3233 .proc_handler = proc_dointvec_minmax_coredump,
3234 .extra1 = SYSCTL_ZERO,
3235 .extra2 = &two,
3236 },
3237#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3238 {
3239 .procname = "binfmt_misc",
3240 .mode = 0555,
3241 .child = sysctl_mount_point,
3242 },
3243#endif
3244 {
3245 .procname = "pipe-max-size",
3246 .data = &pipe_max_size,
3247 .maxlen = sizeof(pipe_max_size),
3248 .mode = 0644,
3249 .proc_handler = proc_dopipe_max_size,
3250 },
3251 {
3252 .procname = "pipe-user-pages-hard",
3253 .data = &pipe_user_pages_hard,
3254 .maxlen = sizeof(pipe_user_pages_hard),
3255 .mode = 0644,
3256 .proc_handler = proc_doulongvec_minmax,
3257 },
3258 {
3259 .procname = "pipe-user-pages-soft",
3260 .data = &pipe_user_pages_soft,
3261 .maxlen = sizeof(pipe_user_pages_soft),
3262 .mode = 0644,
3263 .proc_handler = proc_doulongvec_minmax,
3264 },
3265 {
3266 .procname = "mount-max",
3267 .data = &sysctl_mount_max,
3268 .maxlen = sizeof(unsigned int),
3269 .mode = 0644,
3270 .proc_handler = proc_dointvec_minmax,
3271 .extra1 = SYSCTL_ONE,
3272 },
3273 { }
3274};
1da177e4 3275
f461d2dc
CH
3276static struct ctl_table debug_table[] = {
3277#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3278 {
3279 .procname = "exception-trace",
3280 .data = &show_unhandled_signals,
3281 .maxlen = sizeof(int),
3282 .mode = 0644,
3283 .proc_handler = proc_dointvec
3284 },
3285#endif
3286#if defined(CONFIG_OPTPROBES)
3287 {
3288 .procname = "kprobes-optimization",
3289 .data = &sysctl_kprobes_optimization,
3290 .maxlen = sizeof(int),
3291 .mode = 0644,
3292 .proc_handler = proc_kprobes_optimization_handler,
3293 .extra1 = SYSCTL_ZERO,
3294 .extra2 = SYSCTL_ONE,
3295 },
3296#endif
3297 { }
3298};
1da177e4 3299
f461d2dc
CH
3300static struct ctl_table dev_table[] = {
3301 { }
3302};
1da177e4 3303
f461d2dc
CH
3304static struct ctl_table sysctl_base_table[] = {
3305 {
3306 .procname = "kernel",
3307 .mode = 0555,
3308 .child = kern_table,
3309 },
3310 {
3311 .procname = "vm",
3312 .mode = 0555,
3313 .child = vm_table,
3314 },
3315 {
3316 .procname = "fs",
3317 .mode = 0555,
3318 .child = fs_table,
3319 },
3320 {
3321 .procname = "debug",
3322 .mode = 0555,
3323 .child = debug_table,
3324 },
3325 {
3326 .procname = "dev",
3327 .mode = 0555,
3328 .child = dev_table,
3329 },
3330 { }
3331};
1da177e4 3332
f461d2dc 3333int __init sysctl_init(void)
492ecee8 3334{
f461d2dc 3335 struct ctl_table_header *hdr;
492ecee8 3336
f461d2dc
CH
3337 hdr = register_sysctl_table(sysctl_base_table);
3338 kmemleak_not_leak(hdr);
3339 return 0;
492ecee8 3340}
f461d2dc 3341#endif /* CONFIG_SYSCTL */
1da177e4
LT
3342/*
3343 * No sense putting this after each symbol definition, twice,
3344 * exception granted :-)
3345 */
3346EXPORT_SYMBOL(proc_dointvec);
e7d316a0 3347EXPORT_SYMBOL(proc_douintvec);
1da177e4
LT
3348EXPORT_SYMBOL(proc_dointvec_jiffies);
3349EXPORT_SYMBOL(proc_dointvec_minmax);
61d9b56a 3350EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
1da177e4
LT
3351EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3352EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3353EXPORT_SYMBOL(proc_dostring);
3354EXPORT_SYMBOL(proc_doulongvec_minmax);
3355EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
0bc19985 3356EXPORT_SYMBOL(proc_do_large_bitmap);