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