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