1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
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
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
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
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/sched/coredump.h>
67 #include <linux/kexec.h>
68 #include <linux/bpf.h>
69 #include <linux/mount.h>
70 #include <linux/userfaultfd_k.h>
71 #include <linux/coredump.h>
72 #include <linux/latencytop.h>
73 #include <linux/pid.h>
75 #include "../lib/kstrtox.h"
77 #include <linux/uaccess.h>
78 #include <asm/processor.h>
82 #include <asm/stacktrace.h>
86 #include <asm/setup.h>
88 #ifdef CONFIG_BSD_PROCESS_ACCT
89 #include <linux/acct.h>
91 #ifdef CONFIG_RT_MUTEXES
92 #include <linux/rtmutex.h>
94 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
95 #include <linux/lockdep.h>
97 #ifdef CONFIG_CHR_DEV_SG
100 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101 #include <linux/stackleak.h>
103 #ifdef CONFIG_LOCKUP_DETECTOR
104 #include <linux/nmi.h>
107 #if defined(CONFIG_SYSCTL)
109 /* Constants used for minimum and maximum */
110 #ifdef CONFIG_LOCKUP_DETECTOR
111 static int sixty = 60;
114 static int __maybe_unused neg_one = -1;
115 static int __maybe_unused two = 2;
116 static int __maybe_unused four = 4;
117 static unsigned long zero_ul;
118 static unsigned long one_ul = 1;
119 static unsigned long long_max = LONG_MAX;
120 static int one_hundred = 100;
121 static int two_hundred = 200;
122 static int one_thousand = 1000;
124 static int ten_thousand = 10000;
126 #ifdef CONFIG_PERF_EVENTS
127 static int six_hundred_forty_kb = 640 * 1024;
130 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
131 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
133 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
134 static int maxolduid = 65535;
135 static int minolduid;
137 static int ngroups_max = NGROUPS_MAX;
138 static const int cap_last_cap = CAP_LAST_CAP;
141 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
142 * and hung_task_check_interval_secs
144 #ifdef CONFIG_DETECT_HUNG_TASK
145 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
148 #ifdef CONFIG_INOTIFY_USER
149 #include <linux/inotify.h>
151 #ifdef CONFIG_FANOTIFY
152 #include <linux/fanotify.h>
155 #ifdef CONFIG_PROC_SYSCTL
158 * enum sysctl_writes_mode - supported sysctl write modes
160 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
161 * to be written, and multiple writes on the same sysctl file descriptor
162 * will rewrite the sysctl value, regardless of file position. No warning
163 * is issued when the initial position is not 0.
164 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
166 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
167 * file position 0 and the value must be fully contained in the buffer
168 * sent to the write syscall. If dealing with strings respect the file
169 * position, but restrict this to the max length of the buffer, anything
170 * passed the max length will be ignored. Multiple writes will append
173 * These write modes control how current file position affects the behavior of
174 * updating sysctl values through the proc interface on each write.
176 enum sysctl_writes_mode {
177 SYSCTL_WRITES_LEGACY = -1,
178 SYSCTL_WRITES_WARN = 0,
179 SYSCTL_WRITES_STRICT = 1,
182 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
183 #endif /* CONFIG_PROC_SYSCTL */
185 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
186 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
187 int sysctl_legacy_va_layout;
190 #ifdef CONFIG_COMPACTION
191 static int min_extfrag_threshold;
192 static int max_extfrag_threshold = 1000;
195 #endif /* CONFIG_SYSCTL */
197 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
198 static int bpf_stats_handler(struct ctl_table *table, int write,
199 void *buffer, size_t *lenp, loff_t *ppos)
201 struct static_key *key = (struct static_key *)table->data;
202 static int saved_val;
204 struct ctl_table tmp = {
206 .maxlen = sizeof(val),
208 .extra1 = SYSCTL_ZERO,
209 .extra2 = SYSCTL_ONE,
212 if (write && !capable(CAP_SYS_ADMIN))
215 mutex_lock(&bpf_stats_enabled_mutex);
217 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
218 if (write && !ret && val != saved_val) {
220 static_key_slow_inc(key);
222 static_key_slow_dec(key);
225 mutex_unlock(&bpf_stats_enabled_mutex);
234 #ifdef CONFIG_PROC_SYSCTL
236 static int _proc_do_string(char *data, int maxlen, int write,
237 char *buffer, size_t *lenp, loff_t *ppos)
242 if (!data || !maxlen || !*lenp) {
248 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
249 /* Only continue writes not past the end of buffer. */
251 if (len > maxlen - 1)
258 /* Start writing from beginning of buffer. */
264 while ((p - buffer) < *lenp && len < maxlen - 1) {
266 if (c == 0 || c == '\n')
287 memcpy(buffer, data, len);
298 static void warn_sysctl_write(struct ctl_table *table)
300 pr_warn_once("%s wrote to %s when file position was not 0!\n"
301 "This will not be supported in the future. To silence this\n"
302 "warning, set kernel.sysctl_writes_strict = -1\n",
303 current->comm, table->procname);
307 * proc_first_pos_non_zero_ignore - check if first position is allowed
308 * @ppos: file position
309 * @table: the sysctl table
311 * Returns true if the first position is non-zero and the sysctl_writes_strict
312 * mode indicates this is not allowed for numeric input types. String proc
313 * handlers can ignore the return value.
315 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
316 struct ctl_table *table)
321 switch (sysctl_writes_strict) {
322 case SYSCTL_WRITES_STRICT:
324 case SYSCTL_WRITES_WARN:
325 warn_sysctl_write(table);
333 * proc_dostring - read a string sysctl
334 * @table: the sysctl table
335 * @write: %TRUE if this is a write to the sysctl file
336 * @buffer: the user buffer
337 * @lenp: the size of the user buffer
338 * @ppos: file position
340 * Reads/writes a string from/to the user buffer. If the kernel
341 * buffer provided is not large enough to hold the string, the
342 * string is truncated. The copied string is %NULL-terminated.
343 * If the string is being read by the user process, it is copied
344 * and a newline '\n' is added. It is truncated if the buffer is
347 * Returns 0 on success.
349 int proc_dostring(struct ctl_table *table, int write,
350 void *buffer, size_t *lenp, loff_t *ppos)
353 proc_first_pos_non_zero_ignore(ppos, table);
355 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
359 static size_t proc_skip_spaces(char **buf)
362 char *tmp = skip_spaces(*buf);
368 static void proc_skip_char(char **buf, size_t *size, const char v)
379 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
382 * @cp: kernel buffer containing the string to parse
383 * @endp: pointer to store the trailing characters
384 * @base: the base to use
385 * @res: where the parsed integer will be stored
387 * In case of success 0 is returned and @res will contain the parsed integer,
388 * @endp will hold any trailing characters.
389 * This function will fail the parse on overflow. If there wasn't an overflow
390 * the function will defer the decision what characters count as invalid to the
393 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
396 unsigned long long result;
399 cp = _parse_integer_fixup_radix(cp, &base);
400 rv = _parse_integer(cp, base, &result);
401 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
409 *res = (unsigned long)result;
415 * proc_get_long - reads an ASCII formatted integer from a user buffer
417 * @buf: a kernel buffer
418 * @size: size of the kernel buffer
419 * @val: this is where the number will be stored
420 * @neg: set to %TRUE if number is negative
421 * @perm_tr: a vector which contains the allowed trailers
422 * @perm_tr_len: size of the perm_tr vector
423 * @tr: pointer to store the trailer character
425 * In case of success %0 is returned and @buf and @size are updated with
426 * the amount of bytes read. If @tr is non-NULL and a trailing
427 * character exists (size is non-zero after returning from this
428 * function), @tr is updated with the trailing character.
430 static int proc_get_long(char **buf, size_t *size,
431 unsigned long *val, bool *neg,
432 const char *perm_tr, unsigned perm_tr_len, char *tr)
435 char *p, tmp[TMPBUFLEN];
441 if (len > TMPBUFLEN - 1)
444 memcpy(tmp, *buf, len);
448 if (*p == '-' && *size > 1) {
456 if (strtoul_lenient(p, &p, 0, val))
461 /* We don't know if the next char is whitespace thus we may accept
462 * invalid integers (e.g. 1234...a) or two integers instead of one
463 * (e.g. 123...1). So lets not allow such large numbers. */
464 if (len == TMPBUFLEN - 1)
467 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
470 if (tr && (len < *size))
480 * proc_put_long - converts an integer to a decimal ASCII formatted string
482 * @buf: the user buffer
483 * @size: the size of the user buffer
484 * @val: the integer to be converted
485 * @neg: sign of the number, %TRUE for negative
487 * In case of success @buf and @size are updated with the amount of bytes
490 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
493 char tmp[TMPBUFLEN], *p = tmp;
495 sprintf(p, "%s%lu", neg ? "-" : "", val);
499 memcpy(*buf, tmp, len);
505 static void proc_put_char(void **buf, size_t *size, char c)
508 char **buffer = (char **)buf;
517 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
519 int write, void *data)
523 if (*lvalp > (unsigned long) INT_MAX + 1)
527 if (*lvalp > (unsigned long) INT_MAX)
535 *lvalp = -(unsigned long)val;
538 *lvalp = (unsigned long)val;
544 static int do_proc_douintvec_conv(unsigned long *lvalp,
546 int write, void *data)
549 if (*lvalp > UINT_MAX)
553 unsigned int val = *valp;
554 *lvalp = (unsigned long)val;
559 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
561 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
562 int write, void *buffer,
563 size_t *lenp, loff_t *ppos,
564 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
565 int write, void *data),
568 int *i, vleft, first = 1, err = 0;
572 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
577 i = (int *) tbl_data;
578 vleft = table->maxlen / sizeof(*i);
582 conv = do_proc_dointvec_conv;
585 if (proc_first_pos_non_zero_ignore(ppos, table))
588 if (left > PAGE_SIZE - 1)
589 left = PAGE_SIZE - 1;
593 for (; left && vleft--; i++, first=0) {
598 left -= proc_skip_spaces(&p);
602 err = proc_get_long(&p, &left, &lval, &neg,
604 sizeof(proc_wspace_sep), NULL);
607 if (conv(&neg, &lval, i, 1, data)) {
612 if (conv(&neg, &lval, i, 0, data)) {
617 proc_put_char(&buffer, &left, '\t');
618 proc_put_long(&buffer, &left, lval, neg);
622 if (!write && !first && left && !err)
623 proc_put_char(&buffer, &left, '\n');
624 if (write && !err && left)
625 left -= proc_skip_spaces(&p);
627 return err ? : -EINVAL;
634 static int do_proc_dointvec(struct ctl_table *table, int write,
635 void *buffer, size_t *lenp, loff_t *ppos,
636 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
637 int write, void *data),
640 return __do_proc_dointvec(table->data, table, write,
641 buffer, lenp, ppos, conv, data);
644 static int do_proc_douintvec_w(unsigned int *tbl_data,
645 struct ctl_table *table,
647 size_t *lenp, loff_t *ppos,
648 int (*conv)(unsigned long *lvalp,
650 int write, void *data),
661 if (proc_first_pos_non_zero_ignore(ppos, table))
664 if (left > PAGE_SIZE - 1)
665 left = PAGE_SIZE - 1;
667 left -= proc_skip_spaces(&p);
673 err = proc_get_long(&p, &left, &lval, &neg,
675 sizeof(proc_wspace_sep), NULL);
681 if (conv(&lval, tbl_data, 1, data)) {
687 left -= proc_skip_spaces(&p);
695 /* This is in keeping with old __do_proc_dointvec() */
701 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
702 size_t *lenp, loff_t *ppos,
703 int (*conv)(unsigned long *lvalp,
705 int write, void *data),
714 if (conv(&lval, tbl_data, 0, data)) {
719 proc_put_long(&buffer, &left, lval, false);
723 proc_put_char(&buffer, &left, '\n');
732 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
733 int write, void *buffer,
734 size_t *lenp, loff_t *ppos,
735 int (*conv)(unsigned long *lvalp,
737 int write, void *data),
740 unsigned int *i, vleft;
742 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
747 i = (unsigned int *) tbl_data;
748 vleft = table->maxlen / sizeof(*i);
751 * Arrays are not supported, keep this simple. *Do not* add
760 conv = do_proc_douintvec_conv;
763 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
765 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
768 static int do_proc_douintvec(struct ctl_table *table, int write,
769 void *buffer, size_t *lenp, loff_t *ppos,
770 int (*conv)(unsigned long *lvalp,
772 int write, void *data),
775 return __do_proc_douintvec(table->data, table, write,
776 buffer, lenp, ppos, conv, data);
780 * proc_dointvec - read a vector of integers
781 * @table: the sysctl table
782 * @write: %TRUE if this is a write to the sysctl file
783 * @buffer: the user buffer
784 * @lenp: the size of the user buffer
785 * @ppos: file position
787 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
788 * values from/to the user buffer, treated as an ASCII string.
790 * Returns 0 on success.
792 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
793 size_t *lenp, loff_t *ppos)
795 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
798 #ifdef CONFIG_COMPACTION
799 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
800 int write, void *buffer, size_t *lenp, loff_t *ppos)
804 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
805 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
807 old = *(int *)table->data;
808 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
811 if (old != *(int *)table->data)
812 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
813 table->procname, current->comm,
814 task_pid_nr(current));
820 * proc_douintvec - read a vector of unsigned integers
821 * @table: the sysctl table
822 * @write: %TRUE if this is a write to the sysctl file
823 * @buffer: the user buffer
824 * @lenp: the size of the user buffer
825 * @ppos: file position
827 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
828 * values from/to the user buffer, treated as an ASCII string.
830 * Returns 0 on success.
832 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
833 size_t *lenp, loff_t *ppos)
835 return do_proc_douintvec(table, write, buffer, lenp, ppos,
836 do_proc_douintvec_conv, NULL);
840 * Taint values can only be increased
841 * This means we can safely use a temporary.
843 static int proc_taint(struct ctl_table *table, int write,
844 void *buffer, size_t *lenp, loff_t *ppos)
847 unsigned long tmptaint = get_taint();
850 if (write && !capable(CAP_SYS_ADMIN))
855 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
863 * If we are relying on panic_on_taint not producing
864 * false positives due to userspace input, bail out
865 * before setting the requested taint flags.
867 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
871 * Poor man's atomic or. Not worth adding a primitive
872 * to everyone's atomic.h for this
874 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
875 if ((1UL << i) & tmptaint)
876 add_taint(i, LOCKDEP_STILL_OK);
883 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
884 void *buffer, size_t *lenp, loff_t *ppos)
886 if (write && !capable(CAP_SYS_ADMIN))
889 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
894 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
895 * @min: pointer to minimum allowable value
896 * @max: pointer to maximum allowable value
898 * The do_proc_dointvec_minmax_conv_param structure provides the
899 * minimum and maximum values for doing range checking for those sysctl
900 * parameters that use the proc_dointvec_minmax() handler.
902 struct do_proc_dointvec_minmax_conv_param {
907 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
909 int write, void *data)
912 struct do_proc_dointvec_minmax_conv_param *param = data;
914 * If writing, first do so via a temporary local int so we can
915 * bounds-check it before touching *valp.
917 int *ip = write ? &tmp : valp;
919 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
924 if ((param->min && *param->min > tmp) ||
925 (param->max && *param->max < tmp))
934 * proc_dointvec_minmax - read a vector of integers with min/max values
935 * @table: the sysctl table
936 * @write: %TRUE if this is a write to the sysctl file
937 * @buffer: the user buffer
938 * @lenp: the size of the user buffer
939 * @ppos: file position
941 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
942 * values from/to the user buffer, treated as an ASCII string.
944 * This routine will ensure the values are within the range specified by
945 * table->extra1 (min) and table->extra2 (max).
947 * Returns 0 on success or -EINVAL on write when the range check fails.
949 int proc_dointvec_minmax(struct ctl_table *table, int write,
950 void *buffer, size_t *lenp, loff_t *ppos)
952 struct do_proc_dointvec_minmax_conv_param param = {
953 .min = (int *) table->extra1,
954 .max = (int *) table->extra2,
956 return do_proc_dointvec(table, write, buffer, lenp, ppos,
957 do_proc_dointvec_minmax_conv, ¶m);
961 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
962 * @min: pointer to minimum allowable value
963 * @max: pointer to maximum allowable value
965 * The do_proc_douintvec_minmax_conv_param structure provides the
966 * minimum and maximum values for doing range checking for those sysctl
967 * parameters that use the proc_douintvec_minmax() handler.
969 struct do_proc_douintvec_minmax_conv_param {
974 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
976 int write, void *data)
980 struct do_proc_douintvec_minmax_conv_param *param = data;
981 /* write via temporary local uint for bounds-checking */
982 unsigned int *up = write ? &tmp : valp;
984 ret = do_proc_douintvec_conv(lvalp, up, write, data);
989 if ((param->min && *param->min > tmp) ||
990 (param->max && *param->max < tmp))
1000 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1001 * @table: the sysctl table
1002 * @write: %TRUE if this is a write to the sysctl file
1003 * @buffer: the user buffer
1004 * @lenp: the size of the user buffer
1005 * @ppos: file position
1007 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1008 * values from/to the user buffer, treated as an ASCII string. Negative
1009 * strings are not allowed.
1011 * This routine will ensure the values are within the range specified by
1012 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1013 * check for UINT_MAX to avoid having to support wrap around uses from
1016 * Returns 0 on success or -ERANGE on write when the range check fails.
1018 int proc_douintvec_minmax(struct ctl_table *table, int write,
1019 void *buffer, size_t *lenp, loff_t *ppos)
1021 struct do_proc_douintvec_minmax_conv_param param = {
1022 .min = (unsigned int *) table->extra1,
1023 .max = (unsigned int *) table->extra2,
1025 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1026 do_proc_douintvec_minmax_conv, ¶m);
1030 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1031 * @table: the sysctl table
1032 * @write: %TRUE if this is a write to the sysctl file
1033 * @buffer: the user buffer
1034 * @lenp: the size of the user buffer
1035 * @ppos: file position
1037 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1038 * values from/to the user buffer, treated as an ASCII string. Negative
1039 * strings are not allowed.
1041 * This routine will ensure the values are within the range specified by
1042 * table->extra1 (min) and table->extra2 (max).
1044 * Returns 0 on success or an error on write when the range check fails.
1046 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1047 void *buffer, size_t *lenp, loff_t *ppos)
1049 struct ctl_table tmp;
1050 unsigned int min = 0, max = 255U, val;
1051 u8 *data = table->data;
1052 struct do_proc_douintvec_minmax_conv_param param = {
1058 /* Do not support arrays yet. */
1059 if (table->maxlen != sizeof(u8))
1062 if (table->extra1) {
1063 min = *(unsigned int *) table->extra1;
1067 if (table->extra2) {
1068 max = *(unsigned int *) table->extra2;
1075 tmp.maxlen = sizeof(val);
1078 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1079 do_proc_douintvec_minmax_conv, ¶m);
1086 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1088 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1090 int write, void *data)
1095 val = round_pipe_size(*lvalp);
1101 unsigned int val = *valp;
1102 *lvalp = (unsigned long) val;
1108 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1109 void *buffer, size_t *lenp, loff_t *ppos)
1111 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1112 do_proc_dopipe_max_size_conv, NULL);
1115 static void validate_coredump_safety(void)
1117 #ifdef CONFIG_COREDUMP
1118 if (suid_dumpable == SUID_DUMP_ROOT &&
1119 core_pattern[0] != '/' && core_pattern[0] != '|') {
1121 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1122 "Pipe handler or fully qualified core dump path required.\n"
1123 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1129 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1130 void *buffer, size_t *lenp, loff_t *ppos)
1132 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1134 validate_coredump_safety();
1138 #ifdef CONFIG_COREDUMP
1139 static int proc_dostring_coredump(struct ctl_table *table, int write,
1140 void *buffer, size_t *lenp, loff_t *ppos)
1142 int error = proc_dostring(table, write, buffer, lenp, ppos);
1144 validate_coredump_safety();
1149 #ifdef CONFIG_MAGIC_SYSRQ
1150 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1151 void *buffer, size_t *lenp, loff_t *ppos)
1157 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1158 lenp, ppos, NULL, NULL);
1163 sysrq_toggle_support(tmp);
1169 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1170 int write, void *buffer, size_t *lenp, loff_t *ppos,
1171 unsigned long convmul, unsigned long convdiv)
1173 unsigned long *i, *min, *max;
1174 int vleft, first = 1, err = 0;
1178 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1183 i = (unsigned long *) data;
1184 min = (unsigned long *) table->extra1;
1185 max = (unsigned long *) table->extra2;
1186 vleft = table->maxlen / sizeof(unsigned long);
1190 if (proc_first_pos_non_zero_ignore(ppos, table))
1193 if (left > PAGE_SIZE - 1)
1194 left = PAGE_SIZE - 1;
1198 for (; left && vleft--; i++, first = 0) {
1204 left -= proc_skip_spaces(&p);
1208 err = proc_get_long(&p, &left, &val, &neg,
1210 sizeof(proc_wspace_sep), NULL);
1215 val = convmul * val / convdiv;
1216 if ((min && val < *min) || (max && val > *max)) {
1222 val = convdiv * (*i) / convmul;
1224 proc_put_char(&buffer, &left, '\t');
1225 proc_put_long(&buffer, &left, val, false);
1229 if (!write && !first && left && !err)
1230 proc_put_char(&buffer, &left, '\n');
1232 left -= proc_skip_spaces(&p);
1234 return err ? : -EINVAL;
1241 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1242 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1243 unsigned long convdiv)
1245 return __do_proc_doulongvec_minmax(table->data, table, write,
1246 buffer, lenp, ppos, convmul, convdiv);
1250 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1251 * @table: the sysctl table
1252 * @write: %TRUE if this is a write to the sysctl file
1253 * @buffer: the user buffer
1254 * @lenp: the size of the user buffer
1255 * @ppos: file position
1257 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1258 * values from/to the user buffer, treated as an ASCII string.
1260 * This routine will ensure the values are within the range specified by
1261 * table->extra1 (min) and table->extra2 (max).
1263 * Returns 0 on success.
1265 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1266 void *buffer, size_t *lenp, loff_t *ppos)
1268 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1272 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1273 * @table: the sysctl table
1274 * @write: %TRUE if this is a write to the sysctl file
1275 * @buffer: the user buffer
1276 * @lenp: the size of the user buffer
1277 * @ppos: file position
1279 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1280 * values from/to the user buffer, treated as an ASCII string. The values
1281 * are treated as milliseconds, and converted to jiffies when they are stored.
1283 * This routine will ensure the values are within the range specified by
1284 * table->extra1 (min) and table->extra2 (max).
1286 * Returns 0 on success.
1288 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1289 void *buffer, size_t *lenp, loff_t *ppos)
1291 return do_proc_doulongvec_minmax(table, write, buffer,
1292 lenp, ppos, HZ, 1000l);
1296 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1298 int write, void *data)
1301 if (*lvalp > INT_MAX / HZ)
1303 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1309 lval = -(unsigned long)val;
1312 lval = (unsigned long)val;
1319 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1321 int write, void *data)
1324 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1326 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1332 lval = -(unsigned long)val;
1335 lval = (unsigned long)val;
1337 *lvalp = jiffies_to_clock_t(lval);
1342 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1344 int write, void *data)
1347 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1357 lval = -(unsigned long)val;
1360 lval = (unsigned long)val;
1362 *lvalp = jiffies_to_msecs(lval);
1368 * proc_dointvec_jiffies - read a vector of integers as seconds
1369 * @table: the sysctl table
1370 * @write: %TRUE if this is a write to the sysctl file
1371 * @buffer: the user buffer
1372 * @lenp: the size of the user buffer
1373 * @ppos: file position
1375 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1376 * values from/to the user buffer, treated as an ASCII string.
1377 * The values read are assumed to be in seconds, and are converted into
1380 * Returns 0 on success.
1382 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1383 void *buffer, size_t *lenp, loff_t *ppos)
1385 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1386 do_proc_dointvec_jiffies_conv,NULL);
1390 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1391 * @table: the sysctl table
1392 * @write: %TRUE if this is a write to the sysctl file
1393 * @buffer: the user buffer
1394 * @lenp: the size of the user buffer
1395 * @ppos: pointer to the file position
1397 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1398 * values from/to the user buffer, treated as an ASCII string.
1399 * The values read are assumed to be in 1/USER_HZ seconds, and
1400 * are converted into jiffies.
1402 * Returns 0 on success.
1404 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1405 void *buffer, size_t *lenp, loff_t *ppos)
1407 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1408 do_proc_dointvec_userhz_jiffies_conv,NULL);
1412 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1413 * @table: the sysctl table
1414 * @write: %TRUE if this is a write to the sysctl file
1415 * @buffer: the user buffer
1416 * @lenp: the size of the user buffer
1417 * @ppos: file position
1418 * @ppos: the current position in the file
1420 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1421 * values from/to the user buffer, treated as an ASCII string.
1422 * The values read are assumed to be in 1/1000 seconds, and
1423 * are converted into jiffies.
1425 * Returns 0 on success.
1427 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1428 size_t *lenp, loff_t *ppos)
1430 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1431 do_proc_dointvec_ms_jiffies_conv, NULL);
1434 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1435 size_t *lenp, loff_t *ppos)
1437 struct pid *new_pid;
1441 tmp = pid_vnr(cad_pid);
1443 r = __do_proc_dointvec(&tmp, table, write, buffer,
1444 lenp, ppos, NULL, NULL);
1448 new_pid = find_get_pid(tmp);
1452 put_pid(xchg(&cad_pid, new_pid));
1457 * proc_do_large_bitmap - read/write from/to a large bitmap
1458 * @table: the sysctl table
1459 * @write: %TRUE if this is a write to the sysctl file
1460 * @buffer: the user buffer
1461 * @lenp: the size of the user buffer
1462 * @ppos: file position
1464 * The bitmap is stored at table->data and the bitmap length (in bits)
1467 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1468 * large bitmaps may be represented in a compact manner. Writing into
1469 * the file will clear the bitmap then update it with the given input.
1471 * Returns 0 on success.
1473 int proc_do_large_bitmap(struct ctl_table *table, int write,
1474 void *buffer, size_t *lenp, loff_t *ppos)
1478 size_t left = *lenp;
1479 unsigned long bitmap_len = table->maxlen;
1480 unsigned long *bitmap = *(unsigned long **) table->data;
1481 unsigned long *tmp_bitmap = NULL;
1482 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1484 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1493 if (left > PAGE_SIZE - 1) {
1494 left = PAGE_SIZE - 1;
1495 /* How much of the buffer we'll skip this pass */
1496 skipped = *lenp - left;
1499 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1502 proc_skip_char(&p, &left, '\n');
1503 while (!err && left) {
1504 unsigned long val_a, val_b;
1508 /* In case we stop parsing mid-number, we can reset */
1510 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1513 * If we consumed the entirety of a truncated buffer or
1514 * only one char is left (may be a "-"), then stop here,
1515 * reset, & come back for more.
1517 if ((left <= 1) && skipped) {
1524 if (val_a >= bitmap_len || neg) {
1536 err = proc_get_long(&p, &left, &val_b,
1537 &neg, tr_b, sizeof(tr_b),
1540 * If we consumed all of a truncated buffer or
1541 * then stop here, reset, & come back for more.
1543 if (!left && skipped) {
1550 if (val_b >= bitmap_len || neg ||
1561 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1563 proc_skip_char(&p, &left, '\n');
1567 unsigned long bit_a, bit_b = 0;
1570 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1571 if (bit_a >= bitmap_len)
1573 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1577 proc_put_char(&buffer, &left, ',');
1578 proc_put_long(&buffer, &left, bit_a, false);
1579 if (bit_a != bit_b) {
1580 proc_put_char(&buffer, &left, '-');
1581 proc_put_long(&buffer, &left, bit_b, false);
1586 proc_put_char(&buffer, &left, '\n');
1592 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1594 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1600 bitmap_free(tmp_bitmap);
1604 #else /* CONFIG_PROC_SYSCTL */
1606 int proc_dostring(struct ctl_table *table, int write,
1607 void *buffer, size_t *lenp, loff_t *ppos)
1612 int proc_dointvec(struct ctl_table *table, int write,
1613 void *buffer, size_t *lenp, loff_t *ppos)
1618 int proc_douintvec(struct ctl_table *table, int write,
1619 void *buffer, size_t *lenp, loff_t *ppos)
1624 int proc_dointvec_minmax(struct ctl_table *table, int write,
1625 void *buffer, size_t *lenp, loff_t *ppos)
1630 int proc_douintvec_minmax(struct ctl_table *table, int write,
1631 void *buffer, size_t *lenp, loff_t *ppos)
1636 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1637 void *buffer, size_t *lenp, loff_t *ppos)
1642 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1643 void *buffer, size_t *lenp, loff_t *ppos)
1648 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1649 void *buffer, size_t *lenp, loff_t *ppos)
1654 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1655 void *buffer, size_t *lenp, loff_t *ppos)
1660 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1661 void *buffer, size_t *lenp, loff_t *ppos)
1666 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1667 void *buffer, size_t *lenp, loff_t *ppos)
1672 int proc_do_large_bitmap(struct ctl_table *table, int write,
1673 void *buffer, size_t *lenp, loff_t *ppos)
1678 #endif /* CONFIG_PROC_SYSCTL */
1680 #if defined(CONFIG_SYSCTL)
1681 int proc_do_static_key(struct ctl_table *table, int write,
1682 void *buffer, size_t *lenp, loff_t *ppos)
1684 struct static_key *key = (struct static_key *)table->data;
1685 static DEFINE_MUTEX(static_key_mutex);
1687 struct ctl_table tmp = {
1689 .maxlen = sizeof(val),
1690 .mode = table->mode,
1691 .extra1 = SYSCTL_ZERO,
1692 .extra2 = SYSCTL_ONE,
1695 if (write && !capable(CAP_SYS_ADMIN))
1698 mutex_lock(&static_key_mutex);
1699 val = static_key_enabled(key);
1700 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1701 if (write && !ret) {
1703 static_key_enable(key);
1705 static_key_disable(key);
1707 mutex_unlock(&static_key_mutex);
1711 static struct ctl_table kern_table[] = {
1713 .procname = "sched_child_runs_first",
1714 .data = &sysctl_sched_child_runs_first,
1715 .maxlen = sizeof(unsigned int),
1717 .proc_handler = proc_dointvec,
1719 #ifdef CONFIG_SCHEDSTATS
1721 .procname = "sched_schedstats",
1723 .maxlen = sizeof(unsigned int),
1725 .proc_handler = sysctl_schedstats,
1726 .extra1 = SYSCTL_ZERO,
1727 .extra2 = SYSCTL_ONE,
1729 #endif /* CONFIG_SCHEDSTATS */
1730 #ifdef CONFIG_NUMA_BALANCING
1732 .procname = "numa_balancing",
1733 .data = NULL, /* filled in by handler */
1734 .maxlen = sizeof(unsigned int),
1736 .proc_handler = sysctl_numa_balancing,
1737 .extra1 = SYSCTL_ZERO,
1738 .extra2 = SYSCTL_ONE,
1740 #endif /* CONFIG_NUMA_BALANCING */
1742 .procname = "sched_rt_period_us",
1743 .data = &sysctl_sched_rt_period,
1744 .maxlen = sizeof(unsigned int),
1746 .proc_handler = sched_rt_handler,
1749 .procname = "sched_rt_runtime_us",
1750 .data = &sysctl_sched_rt_runtime,
1751 .maxlen = sizeof(int),
1753 .proc_handler = sched_rt_handler,
1756 .procname = "sched_deadline_period_max_us",
1757 .data = &sysctl_sched_dl_period_max,
1758 .maxlen = sizeof(unsigned int),
1760 .proc_handler = proc_dointvec,
1763 .procname = "sched_deadline_period_min_us",
1764 .data = &sysctl_sched_dl_period_min,
1765 .maxlen = sizeof(unsigned int),
1767 .proc_handler = proc_dointvec,
1770 .procname = "sched_rr_timeslice_ms",
1771 .data = &sysctl_sched_rr_timeslice,
1772 .maxlen = sizeof(int),
1774 .proc_handler = sched_rr_handler,
1776 #ifdef CONFIG_UCLAMP_TASK
1778 .procname = "sched_util_clamp_min",
1779 .data = &sysctl_sched_uclamp_util_min,
1780 .maxlen = sizeof(unsigned int),
1782 .proc_handler = sysctl_sched_uclamp_handler,
1785 .procname = "sched_util_clamp_max",
1786 .data = &sysctl_sched_uclamp_util_max,
1787 .maxlen = sizeof(unsigned int),
1789 .proc_handler = sysctl_sched_uclamp_handler,
1792 .procname = "sched_util_clamp_min_rt_default",
1793 .data = &sysctl_sched_uclamp_util_min_rt_default,
1794 .maxlen = sizeof(unsigned int),
1796 .proc_handler = sysctl_sched_uclamp_handler,
1799 #ifdef CONFIG_SCHED_AUTOGROUP
1801 .procname = "sched_autogroup_enabled",
1802 .data = &sysctl_sched_autogroup_enabled,
1803 .maxlen = sizeof(unsigned int),
1805 .proc_handler = proc_dointvec_minmax,
1806 .extra1 = SYSCTL_ZERO,
1807 .extra2 = SYSCTL_ONE,
1810 #ifdef CONFIG_CFS_BANDWIDTH
1812 .procname = "sched_cfs_bandwidth_slice_us",
1813 .data = &sysctl_sched_cfs_bandwidth_slice,
1814 .maxlen = sizeof(unsigned int),
1816 .proc_handler = proc_dointvec_minmax,
1817 .extra1 = SYSCTL_ONE,
1820 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1822 .procname = "sched_energy_aware",
1823 .data = &sysctl_sched_energy_aware,
1824 .maxlen = sizeof(unsigned int),
1826 .proc_handler = sched_energy_aware_handler,
1827 .extra1 = SYSCTL_ZERO,
1828 .extra2 = SYSCTL_ONE,
1831 #ifdef CONFIG_PROVE_LOCKING
1833 .procname = "prove_locking",
1834 .data = &prove_locking,
1835 .maxlen = sizeof(int),
1837 .proc_handler = proc_dointvec,
1840 #ifdef CONFIG_LOCK_STAT
1842 .procname = "lock_stat",
1844 .maxlen = sizeof(int),
1846 .proc_handler = proc_dointvec,
1850 .procname = "panic",
1851 .data = &panic_timeout,
1852 .maxlen = sizeof(int),
1854 .proc_handler = proc_dointvec,
1856 #ifdef CONFIG_COREDUMP
1858 .procname = "core_uses_pid",
1859 .data = &core_uses_pid,
1860 .maxlen = sizeof(int),
1862 .proc_handler = proc_dointvec,
1865 .procname = "core_pattern",
1866 .data = core_pattern,
1867 .maxlen = CORENAME_MAX_SIZE,
1869 .proc_handler = proc_dostring_coredump,
1872 .procname = "core_pipe_limit",
1873 .data = &core_pipe_limit,
1874 .maxlen = sizeof(unsigned int),
1876 .proc_handler = proc_dointvec,
1879 #ifdef CONFIG_PROC_SYSCTL
1881 .procname = "tainted",
1882 .maxlen = sizeof(long),
1884 .proc_handler = proc_taint,
1887 .procname = "sysctl_writes_strict",
1888 .data = &sysctl_writes_strict,
1889 .maxlen = sizeof(int),
1891 .proc_handler = proc_dointvec_minmax,
1893 .extra2 = SYSCTL_ONE,
1896 #ifdef CONFIG_LATENCYTOP
1898 .procname = "latencytop",
1899 .data = &latencytop_enabled,
1900 .maxlen = sizeof(int),
1902 .proc_handler = sysctl_latencytop,
1905 #ifdef CONFIG_BLK_DEV_INITRD
1907 .procname = "real-root-dev",
1908 .data = &real_root_dev,
1909 .maxlen = sizeof(int),
1911 .proc_handler = proc_dointvec,
1915 .procname = "print-fatal-signals",
1916 .data = &print_fatal_signals,
1917 .maxlen = sizeof(int),
1919 .proc_handler = proc_dointvec,
1923 .procname = "reboot-cmd",
1924 .data = reboot_command,
1927 .proc_handler = proc_dostring,
1930 .procname = "stop-a",
1931 .data = &stop_a_enabled,
1932 .maxlen = sizeof (int),
1934 .proc_handler = proc_dointvec,
1937 .procname = "scons-poweroff",
1938 .data = &scons_pwroff,
1939 .maxlen = sizeof (int),
1941 .proc_handler = proc_dointvec,
1944 #ifdef CONFIG_SPARC64
1946 .procname = "tsb-ratio",
1947 .data = &sysctl_tsb_ratio,
1948 .maxlen = sizeof (int),
1950 .proc_handler = proc_dointvec,
1953 #ifdef CONFIG_PARISC
1955 .procname = "soft-power",
1956 .data = &pwrsw_enabled,
1957 .maxlen = sizeof (int),
1959 .proc_handler = proc_dointvec,
1962 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1964 .procname = "unaligned-trap",
1965 .data = &unaligned_enabled,
1966 .maxlen = sizeof (int),
1968 .proc_handler = proc_dointvec,
1972 .procname = "ctrl-alt-del",
1974 .maxlen = sizeof(int),
1976 .proc_handler = proc_dointvec,
1978 #ifdef CONFIG_FUNCTION_TRACER
1980 .procname = "ftrace_enabled",
1981 .data = &ftrace_enabled,
1982 .maxlen = sizeof(int),
1984 .proc_handler = ftrace_enable_sysctl,
1987 #ifdef CONFIG_STACK_TRACER
1989 .procname = "stack_tracer_enabled",
1990 .data = &stack_tracer_enabled,
1991 .maxlen = sizeof(int),
1993 .proc_handler = stack_trace_sysctl,
1996 #ifdef CONFIG_TRACING
1998 .procname = "ftrace_dump_on_oops",
1999 .data = &ftrace_dump_on_oops,
2000 .maxlen = sizeof(int),
2002 .proc_handler = proc_dointvec,
2005 .procname = "traceoff_on_warning",
2006 .data = &__disable_trace_on_warning,
2007 .maxlen = sizeof(__disable_trace_on_warning),
2009 .proc_handler = proc_dointvec,
2012 .procname = "tracepoint_printk",
2013 .data = &tracepoint_printk,
2014 .maxlen = sizeof(tracepoint_printk),
2016 .proc_handler = tracepoint_printk_sysctl,
2019 #ifdef CONFIG_KEXEC_CORE
2021 .procname = "kexec_load_disabled",
2022 .data = &kexec_load_disabled,
2023 .maxlen = sizeof(int),
2025 /* only handle a transition from default "0" to "1" */
2026 .proc_handler = proc_dointvec_minmax,
2027 .extra1 = SYSCTL_ONE,
2028 .extra2 = SYSCTL_ONE,
2031 #ifdef CONFIG_MODULES
2033 .procname = "modprobe",
2034 .data = &modprobe_path,
2035 .maxlen = KMOD_PATH_LEN,
2037 .proc_handler = proc_dostring,
2040 .procname = "modules_disabled",
2041 .data = &modules_disabled,
2042 .maxlen = sizeof(int),
2044 /* only handle a transition from default "0" to "1" */
2045 .proc_handler = proc_dointvec_minmax,
2046 .extra1 = SYSCTL_ONE,
2047 .extra2 = SYSCTL_ONE,
2050 #ifdef CONFIG_UEVENT_HELPER
2052 .procname = "hotplug",
2053 .data = &uevent_helper,
2054 .maxlen = UEVENT_HELPER_PATH_LEN,
2056 .proc_handler = proc_dostring,
2059 #ifdef CONFIG_CHR_DEV_SG
2061 .procname = "sg-big-buff",
2062 .data = &sg_big_buff,
2063 .maxlen = sizeof (int),
2065 .proc_handler = proc_dointvec,
2068 #ifdef CONFIG_BSD_PROCESS_ACCT
2072 .maxlen = 3*sizeof(int),
2074 .proc_handler = proc_dointvec,
2077 #ifdef CONFIG_MAGIC_SYSRQ
2079 .procname = "sysrq",
2081 .maxlen = sizeof (int),
2083 .proc_handler = sysrq_sysctl_handler,
2086 #ifdef CONFIG_PROC_SYSCTL
2088 .procname = "cad_pid",
2090 .maxlen = sizeof (int),
2092 .proc_handler = proc_do_cad_pid,
2096 .procname = "threads-max",
2098 .maxlen = sizeof(int),
2100 .proc_handler = sysctl_max_threads,
2103 .procname = "random",
2105 .child = random_table,
2108 .procname = "usermodehelper",
2110 .child = usermodehelper_table,
2112 #ifdef CONFIG_FW_LOADER_USER_HELPER
2114 .procname = "firmware_config",
2116 .child = firmware_config_table,
2120 .procname = "overflowuid",
2121 .data = &overflowuid,
2122 .maxlen = sizeof(int),
2124 .proc_handler = proc_dointvec_minmax,
2125 .extra1 = &minolduid,
2126 .extra2 = &maxolduid,
2129 .procname = "overflowgid",
2130 .data = &overflowgid,
2131 .maxlen = sizeof(int),
2133 .proc_handler = proc_dointvec_minmax,
2134 .extra1 = &minolduid,
2135 .extra2 = &maxolduid,
2139 .procname = "userprocess_debug",
2140 .data = &show_unhandled_signals,
2141 .maxlen = sizeof(int),
2143 .proc_handler = proc_dointvec,
2148 .procname = "oops_all_cpu_backtrace",
2149 .data = &sysctl_oops_all_cpu_backtrace,
2150 .maxlen = sizeof(int),
2152 .proc_handler = proc_dointvec_minmax,
2153 .extra1 = SYSCTL_ZERO,
2154 .extra2 = SYSCTL_ONE,
2156 #endif /* CONFIG_SMP */
2158 .procname = "pid_max",
2160 .maxlen = sizeof (int),
2162 .proc_handler = proc_dointvec_minmax,
2163 .extra1 = &pid_max_min,
2164 .extra2 = &pid_max_max,
2167 .procname = "panic_on_oops",
2168 .data = &panic_on_oops,
2169 .maxlen = sizeof(int),
2171 .proc_handler = proc_dointvec,
2174 .procname = "panic_print",
2175 .data = &panic_print,
2176 .maxlen = sizeof(unsigned long),
2178 .proc_handler = proc_doulongvec_minmax,
2180 #if defined CONFIG_PRINTK
2182 .procname = "printk",
2183 .data = &console_loglevel,
2184 .maxlen = 4*sizeof(int),
2186 .proc_handler = proc_dointvec,
2189 .procname = "printk_ratelimit",
2190 .data = &printk_ratelimit_state.interval,
2191 .maxlen = sizeof(int),
2193 .proc_handler = proc_dointvec_jiffies,
2196 .procname = "printk_ratelimit_burst",
2197 .data = &printk_ratelimit_state.burst,
2198 .maxlen = sizeof(int),
2200 .proc_handler = proc_dointvec,
2203 .procname = "printk_delay",
2204 .data = &printk_delay_msec,
2205 .maxlen = sizeof(int),
2207 .proc_handler = proc_dointvec_minmax,
2208 .extra1 = SYSCTL_ZERO,
2209 .extra2 = &ten_thousand,
2212 .procname = "printk_devkmsg",
2213 .data = devkmsg_log_str,
2214 .maxlen = DEVKMSG_STR_MAX_SIZE,
2216 .proc_handler = devkmsg_sysctl_set_loglvl,
2219 .procname = "dmesg_restrict",
2220 .data = &dmesg_restrict,
2221 .maxlen = sizeof(int),
2223 .proc_handler = proc_dointvec_minmax_sysadmin,
2224 .extra1 = SYSCTL_ZERO,
2225 .extra2 = SYSCTL_ONE,
2228 .procname = "kptr_restrict",
2229 .data = &kptr_restrict,
2230 .maxlen = sizeof(int),
2232 .proc_handler = proc_dointvec_minmax_sysadmin,
2233 .extra1 = SYSCTL_ZERO,
2238 .procname = "ngroups_max",
2239 .data = &ngroups_max,
2240 .maxlen = sizeof (int),
2242 .proc_handler = proc_dointvec,
2245 .procname = "cap_last_cap",
2246 .data = (void *)&cap_last_cap,
2247 .maxlen = sizeof(int),
2249 .proc_handler = proc_dointvec,
2251 #if defined(CONFIG_LOCKUP_DETECTOR)
2253 .procname = "watchdog",
2254 .data = &watchdog_user_enabled,
2255 .maxlen = sizeof(int),
2257 .proc_handler = proc_watchdog,
2258 .extra1 = SYSCTL_ZERO,
2259 .extra2 = SYSCTL_ONE,
2262 .procname = "watchdog_thresh",
2263 .data = &watchdog_thresh,
2264 .maxlen = sizeof(int),
2266 .proc_handler = proc_watchdog_thresh,
2267 .extra1 = SYSCTL_ZERO,
2271 .procname = "nmi_watchdog",
2272 .data = &nmi_watchdog_user_enabled,
2273 .maxlen = sizeof(int),
2274 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2275 .proc_handler = proc_nmi_watchdog,
2276 .extra1 = SYSCTL_ZERO,
2277 .extra2 = SYSCTL_ONE,
2280 .procname = "watchdog_cpumask",
2281 .data = &watchdog_cpumask_bits,
2284 .proc_handler = proc_watchdog_cpumask,
2286 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2288 .procname = "soft_watchdog",
2289 .data = &soft_watchdog_user_enabled,
2290 .maxlen = sizeof(int),
2292 .proc_handler = proc_soft_watchdog,
2293 .extra1 = SYSCTL_ZERO,
2294 .extra2 = SYSCTL_ONE,
2297 .procname = "softlockup_panic",
2298 .data = &softlockup_panic,
2299 .maxlen = sizeof(int),
2301 .proc_handler = proc_dointvec_minmax,
2302 .extra1 = SYSCTL_ZERO,
2303 .extra2 = SYSCTL_ONE,
2307 .procname = "softlockup_all_cpu_backtrace",
2308 .data = &sysctl_softlockup_all_cpu_backtrace,
2309 .maxlen = sizeof(int),
2311 .proc_handler = proc_dointvec_minmax,
2312 .extra1 = SYSCTL_ZERO,
2313 .extra2 = SYSCTL_ONE,
2315 #endif /* CONFIG_SMP */
2317 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2319 .procname = "hardlockup_panic",
2320 .data = &hardlockup_panic,
2321 .maxlen = sizeof(int),
2323 .proc_handler = proc_dointvec_minmax,
2324 .extra1 = SYSCTL_ZERO,
2325 .extra2 = SYSCTL_ONE,
2329 .procname = "hardlockup_all_cpu_backtrace",
2330 .data = &sysctl_hardlockup_all_cpu_backtrace,
2331 .maxlen = sizeof(int),
2333 .proc_handler = proc_dointvec_minmax,
2334 .extra1 = SYSCTL_ZERO,
2335 .extra2 = SYSCTL_ONE,
2337 #endif /* CONFIG_SMP */
2341 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2343 .procname = "unknown_nmi_panic",
2344 .data = &unknown_nmi_panic,
2345 .maxlen = sizeof (int),
2347 .proc_handler = proc_dointvec,
2351 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2352 defined(CONFIG_DEBUG_STACKOVERFLOW)
2354 .procname = "panic_on_stackoverflow",
2355 .data = &sysctl_panic_on_stackoverflow,
2356 .maxlen = sizeof(int),
2358 .proc_handler = proc_dointvec,
2361 #if defined(CONFIG_X86)
2363 .procname = "panic_on_unrecovered_nmi",
2364 .data = &panic_on_unrecovered_nmi,
2365 .maxlen = sizeof(int),
2367 .proc_handler = proc_dointvec,
2370 .procname = "panic_on_io_nmi",
2371 .data = &panic_on_io_nmi,
2372 .maxlen = sizeof(int),
2374 .proc_handler = proc_dointvec,
2377 .procname = "bootloader_type",
2378 .data = &bootloader_type,
2379 .maxlen = sizeof (int),
2381 .proc_handler = proc_dointvec,
2384 .procname = "bootloader_version",
2385 .data = &bootloader_version,
2386 .maxlen = sizeof (int),
2388 .proc_handler = proc_dointvec,
2391 .procname = "io_delay_type",
2392 .data = &io_delay_type,
2393 .maxlen = sizeof(int),
2395 .proc_handler = proc_dointvec,
2398 #if defined(CONFIG_MMU)
2400 .procname = "randomize_va_space",
2401 .data = &randomize_va_space,
2402 .maxlen = sizeof(int),
2404 .proc_handler = proc_dointvec,
2407 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2409 .procname = "spin_retry",
2410 .data = &spin_retry,
2411 .maxlen = sizeof (int),
2413 .proc_handler = proc_dointvec,
2416 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2418 .procname = "acpi_video_flags",
2419 .data = &acpi_realmode_flags,
2420 .maxlen = sizeof (unsigned long),
2422 .proc_handler = proc_doulongvec_minmax,
2425 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2427 .procname = "ignore-unaligned-usertrap",
2428 .data = &no_unaligned_warning,
2429 .maxlen = sizeof (int),
2431 .proc_handler = proc_dointvec,
2436 .procname = "unaligned-dump-stack",
2437 .data = &unaligned_dump_stack,
2438 .maxlen = sizeof (int),
2440 .proc_handler = proc_dointvec,
2443 #ifdef CONFIG_DETECT_HUNG_TASK
2446 .procname = "hung_task_all_cpu_backtrace",
2447 .data = &sysctl_hung_task_all_cpu_backtrace,
2448 .maxlen = sizeof(int),
2450 .proc_handler = proc_dointvec_minmax,
2451 .extra1 = SYSCTL_ZERO,
2452 .extra2 = SYSCTL_ONE,
2454 #endif /* CONFIG_SMP */
2456 .procname = "hung_task_panic",
2457 .data = &sysctl_hung_task_panic,
2458 .maxlen = sizeof(int),
2460 .proc_handler = proc_dointvec_minmax,
2461 .extra1 = SYSCTL_ZERO,
2462 .extra2 = SYSCTL_ONE,
2465 .procname = "hung_task_check_count",
2466 .data = &sysctl_hung_task_check_count,
2467 .maxlen = sizeof(int),
2469 .proc_handler = proc_dointvec_minmax,
2470 .extra1 = SYSCTL_ZERO,
2473 .procname = "hung_task_timeout_secs",
2474 .data = &sysctl_hung_task_timeout_secs,
2475 .maxlen = sizeof(unsigned long),
2477 .proc_handler = proc_dohung_task_timeout_secs,
2478 .extra2 = &hung_task_timeout_max,
2481 .procname = "hung_task_check_interval_secs",
2482 .data = &sysctl_hung_task_check_interval_secs,
2483 .maxlen = sizeof(unsigned long),
2485 .proc_handler = proc_dohung_task_timeout_secs,
2486 .extra2 = &hung_task_timeout_max,
2489 .procname = "hung_task_warnings",
2490 .data = &sysctl_hung_task_warnings,
2491 .maxlen = sizeof(int),
2493 .proc_handler = proc_dointvec_minmax,
2497 #ifdef CONFIG_RT_MUTEXES
2499 .procname = "max_lock_depth",
2500 .data = &max_lock_depth,
2501 .maxlen = sizeof(int),
2503 .proc_handler = proc_dointvec,
2507 .procname = "poweroff_cmd",
2508 .data = &poweroff_cmd,
2509 .maxlen = POWEROFF_CMD_PATH_LEN,
2511 .proc_handler = proc_dostring,
2517 .child = key_sysctls,
2520 #ifdef CONFIG_PERF_EVENTS
2522 * User-space scripts rely on the existence of this file
2523 * as a feature check for perf_events being enabled.
2525 * So it's an ABI, do not remove!
2528 .procname = "perf_event_paranoid",
2529 .data = &sysctl_perf_event_paranoid,
2530 .maxlen = sizeof(sysctl_perf_event_paranoid),
2532 .proc_handler = proc_dointvec,
2535 .procname = "perf_event_mlock_kb",
2536 .data = &sysctl_perf_event_mlock,
2537 .maxlen = sizeof(sysctl_perf_event_mlock),
2539 .proc_handler = proc_dointvec,
2542 .procname = "perf_event_max_sample_rate",
2543 .data = &sysctl_perf_event_sample_rate,
2544 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2546 .proc_handler = perf_proc_update_handler,
2547 .extra1 = SYSCTL_ONE,
2550 .procname = "perf_cpu_time_max_percent",
2551 .data = &sysctl_perf_cpu_time_max_percent,
2552 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2554 .proc_handler = perf_cpu_time_max_percent_handler,
2555 .extra1 = SYSCTL_ZERO,
2556 .extra2 = &one_hundred,
2559 .procname = "perf_event_max_stack",
2560 .data = &sysctl_perf_event_max_stack,
2561 .maxlen = sizeof(sysctl_perf_event_max_stack),
2563 .proc_handler = perf_event_max_stack_handler,
2564 .extra1 = SYSCTL_ZERO,
2565 .extra2 = &six_hundred_forty_kb,
2568 .procname = "perf_event_max_contexts_per_stack",
2569 .data = &sysctl_perf_event_max_contexts_per_stack,
2570 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2572 .proc_handler = perf_event_max_stack_handler,
2573 .extra1 = SYSCTL_ZERO,
2574 .extra2 = &one_thousand,
2578 .procname = "panic_on_warn",
2579 .data = &panic_on_warn,
2580 .maxlen = sizeof(int),
2582 .proc_handler = proc_dointvec_minmax,
2583 .extra1 = SYSCTL_ZERO,
2584 .extra2 = SYSCTL_ONE,
2586 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2588 .procname = "timer_migration",
2589 .data = &sysctl_timer_migration,
2590 .maxlen = sizeof(unsigned int),
2592 .proc_handler = timer_migration_handler,
2593 .extra1 = SYSCTL_ZERO,
2594 .extra2 = SYSCTL_ONE,
2597 #ifdef CONFIG_BPF_SYSCALL
2599 .procname = "unprivileged_bpf_disabled",
2600 .data = &sysctl_unprivileged_bpf_disabled,
2601 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2603 /* only handle a transition from default "0" to "1" */
2604 .proc_handler = proc_dointvec_minmax,
2605 .extra1 = SYSCTL_ONE,
2606 .extra2 = SYSCTL_ONE,
2609 .procname = "bpf_stats_enabled",
2610 .data = &bpf_stats_enabled_key.key,
2611 .maxlen = sizeof(bpf_stats_enabled_key),
2613 .proc_handler = bpf_stats_handler,
2616 #if defined(CONFIG_TREE_RCU)
2618 .procname = "panic_on_rcu_stall",
2619 .data = &sysctl_panic_on_rcu_stall,
2620 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2622 .proc_handler = proc_dointvec_minmax,
2623 .extra1 = SYSCTL_ZERO,
2624 .extra2 = SYSCTL_ONE,
2627 #if defined(CONFIG_TREE_RCU)
2629 .procname = "max_rcu_stall_to_panic",
2630 .data = &sysctl_max_rcu_stall_to_panic,
2631 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2633 .proc_handler = proc_dointvec_minmax,
2634 .extra1 = SYSCTL_ONE,
2635 .extra2 = SYSCTL_INT_MAX,
2638 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2640 .procname = "stack_erasing",
2642 .maxlen = sizeof(int),
2644 .proc_handler = stack_erasing_sysctl,
2645 .extra1 = SYSCTL_ZERO,
2646 .extra2 = SYSCTL_ONE,
2652 static struct ctl_table vm_table[] = {
2654 .procname = "overcommit_memory",
2655 .data = &sysctl_overcommit_memory,
2656 .maxlen = sizeof(sysctl_overcommit_memory),
2658 .proc_handler = overcommit_policy_handler,
2659 .extra1 = SYSCTL_ZERO,
2663 .procname = "panic_on_oom",
2664 .data = &sysctl_panic_on_oom,
2665 .maxlen = sizeof(sysctl_panic_on_oom),
2667 .proc_handler = proc_dointvec_minmax,
2668 .extra1 = SYSCTL_ZERO,
2672 .procname = "oom_kill_allocating_task",
2673 .data = &sysctl_oom_kill_allocating_task,
2674 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2676 .proc_handler = proc_dointvec,
2679 .procname = "oom_dump_tasks",
2680 .data = &sysctl_oom_dump_tasks,
2681 .maxlen = sizeof(sysctl_oom_dump_tasks),
2683 .proc_handler = proc_dointvec,
2686 .procname = "overcommit_ratio",
2687 .data = &sysctl_overcommit_ratio,
2688 .maxlen = sizeof(sysctl_overcommit_ratio),
2690 .proc_handler = overcommit_ratio_handler,
2693 .procname = "overcommit_kbytes",
2694 .data = &sysctl_overcommit_kbytes,
2695 .maxlen = sizeof(sysctl_overcommit_kbytes),
2697 .proc_handler = overcommit_kbytes_handler,
2700 .procname = "page-cluster",
2701 .data = &page_cluster,
2702 .maxlen = sizeof(int),
2704 .proc_handler = proc_dointvec_minmax,
2705 .extra1 = SYSCTL_ZERO,
2708 .procname = "dirty_background_ratio",
2709 .data = &dirty_background_ratio,
2710 .maxlen = sizeof(dirty_background_ratio),
2712 .proc_handler = dirty_background_ratio_handler,
2713 .extra1 = SYSCTL_ZERO,
2714 .extra2 = &one_hundred,
2717 .procname = "dirty_background_bytes",
2718 .data = &dirty_background_bytes,
2719 .maxlen = sizeof(dirty_background_bytes),
2721 .proc_handler = dirty_background_bytes_handler,
2725 .procname = "dirty_ratio",
2726 .data = &vm_dirty_ratio,
2727 .maxlen = sizeof(vm_dirty_ratio),
2729 .proc_handler = dirty_ratio_handler,
2730 .extra1 = SYSCTL_ZERO,
2731 .extra2 = &one_hundred,
2734 .procname = "dirty_bytes",
2735 .data = &vm_dirty_bytes,
2736 .maxlen = sizeof(vm_dirty_bytes),
2738 .proc_handler = dirty_bytes_handler,
2739 .extra1 = &dirty_bytes_min,
2742 .procname = "dirty_writeback_centisecs",
2743 .data = &dirty_writeback_interval,
2744 .maxlen = sizeof(dirty_writeback_interval),
2746 .proc_handler = dirty_writeback_centisecs_handler,
2749 .procname = "dirty_expire_centisecs",
2750 .data = &dirty_expire_interval,
2751 .maxlen = sizeof(dirty_expire_interval),
2753 .proc_handler = proc_dointvec_minmax,
2754 .extra1 = SYSCTL_ZERO,
2757 .procname = "dirtytime_expire_seconds",
2758 .data = &dirtytime_expire_interval,
2759 .maxlen = sizeof(dirtytime_expire_interval),
2761 .proc_handler = dirtytime_interval_handler,
2762 .extra1 = SYSCTL_ZERO,
2765 .procname = "swappiness",
2766 .data = &vm_swappiness,
2767 .maxlen = sizeof(vm_swappiness),
2769 .proc_handler = proc_dointvec_minmax,
2770 .extra1 = SYSCTL_ZERO,
2771 .extra2 = &two_hundred,
2773 #ifdef CONFIG_HUGETLB_PAGE
2775 .procname = "nr_hugepages",
2777 .maxlen = sizeof(unsigned long),
2779 .proc_handler = hugetlb_sysctl_handler,
2783 .procname = "nr_hugepages_mempolicy",
2785 .maxlen = sizeof(unsigned long),
2787 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2790 .procname = "numa_stat",
2791 .data = &sysctl_vm_numa_stat,
2792 .maxlen = sizeof(int),
2794 .proc_handler = sysctl_vm_numa_stat_handler,
2795 .extra1 = SYSCTL_ZERO,
2796 .extra2 = SYSCTL_ONE,
2800 .procname = "hugetlb_shm_group",
2801 .data = &sysctl_hugetlb_shm_group,
2802 .maxlen = sizeof(gid_t),
2804 .proc_handler = proc_dointvec,
2807 .procname = "nr_overcommit_hugepages",
2809 .maxlen = sizeof(unsigned long),
2811 .proc_handler = hugetlb_overcommit_handler,
2815 .procname = "lowmem_reserve_ratio",
2816 .data = &sysctl_lowmem_reserve_ratio,
2817 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2819 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2822 .procname = "drop_caches",
2823 .data = &sysctl_drop_caches,
2824 .maxlen = sizeof(int),
2826 .proc_handler = drop_caches_sysctl_handler,
2827 .extra1 = SYSCTL_ONE,
2830 #ifdef CONFIG_COMPACTION
2832 .procname = "compact_memory",
2834 .maxlen = sizeof(int),
2836 .proc_handler = sysctl_compaction_handler,
2839 .procname = "compaction_proactiveness",
2840 .data = &sysctl_compaction_proactiveness,
2841 .maxlen = sizeof(sysctl_compaction_proactiveness),
2843 .proc_handler = proc_dointvec_minmax,
2844 .extra1 = SYSCTL_ZERO,
2845 .extra2 = &one_hundred,
2848 .procname = "extfrag_threshold",
2849 .data = &sysctl_extfrag_threshold,
2850 .maxlen = sizeof(int),
2852 .proc_handler = proc_dointvec_minmax,
2853 .extra1 = &min_extfrag_threshold,
2854 .extra2 = &max_extfrag_threshold,
2857 .procname = "compact_unevictable_allowed",
2858 .data = &sysctl_compact_unevictable_allowed,
2859 .maxlen = sizeof(int),
2861 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2862 .extra1 = SYSCTL_ZERO,
2863 .extra2 = SYSCTL_ONE,
2866 #endif /* CONFIG_COMPACTION */
2868 .procname = "min_free_kbytes",
2869 .data = &min_free_kbytes,
2870 .maxlen = sizeof(min_free_kbytes),
2872 .proc_handler = min_free_kbytes_sysctl_handler,
2873 .extra1 = SYSCTL_ZERO,
2876 .procname = "watermark_boost_factor",
2877 .data = &watermark_boost_factor,
2878 .maxlen = sizeof(watermark_boost_factor),
2880 .proc_handler = proc_dointvec_minmax,
2881 .extra1 = SYSCTL_ZERO,
2884 .procname = "watermark_scale_factor",
2885 .data = &watermark_scale_factor,
2886 .maxlen = sizeof(watermark_scale_factor),
2888 .proc_handler = watermark_scale_factor_sysctl_handler,
2889 .extra1 = SYSCTL_ONE,
2890 .extra2 = &one_thousand,
2893 .procname = "percpu_pagelist_fraction",
2894 .data = &percpu_pagelist_fraction,
2895 .maxlen = sizeof(percpu_pagelist_fraction),
2897 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2898 .extra1 = SYSCTL_ZERO,
2901 .procname = "page_lock_unfairness",
2902 .data = &sysctl_page_lock_unfairness,
2903 .maxlen = sizeof(sysctl_page_lock_unfairness),
2905 .proc_handler = proc_dointvec_minmax,
2906 .extra1 = SYSCTL_ZERO,
2910 .procname = "max_map_count",
2911 .data = &sysctl_max_map_count,
2912 .maxlen = sizeof(sysctl_max_map_count),
2914 .proc_handler = proc_dointvec_minmax,
2915 .extra1 = SYSCTL_ZERO,
2919 .procname = "nr_trim_pages",
2920 .data = &sysctl_nr_trim_pages,
2921 .maxlen = sizeof(sysctl_nr_trim_pages),
2923 .proc_handler = proc_dointvec_minmax,
2924 .extra1 = SYSCTL_ZERO,
2928 .procname = "laptop_mode",
2929 .data = &laptop_mode,
2930 .maxlen = sizeof(laptop_mode),
2932 .proc_handler = proc_dointvec_jiffies,
2935 .procname = "block_dump",
2936 .data = &block_dump,
2937 .maxlen = sizeof(block_dump),
2939 .proc_handler = proc_dointvec_minmax,
2940 .extra1 = SYSCTL_ZERO,
2943 .procname = "vfs_cache_pressure",
2944 .data = &sysctl_vfs_cache_pressure,
2945 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2947 .proc_handler = proc_dointvec_minmax,
2948 .extra1 = SYSCTL_ZERO,
2950 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2951 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2953 .procname = "legacy_va_layout",
2954 .data = &sysctl_legacy_va_layout,
2955 .maxlen = sizeof(sysctl_legacy_va_layout),
2957 .proc_handler = proc_dointvec_minmax,
2958 .extra1 = SYSCTL_ZERO,
2963 .procname = "zone_reclaim_mode",
2964 .data = &node_reclaim_mode,
2965 .maxlen = sizeof(node_reclaim_mode),
2967 .proc_handler = proc_dointvec_minmax,
2968 .extra1 = SYSCTL_ZERO,
2971 .procname = "min_unmapped_ratio",
2972 .data = &sysctl_min_unmapped_ratio,
2973 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2975 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2976 .extra1 = SYSCTL_ZERO,
2977 .extra2 = &one_hundred,
2980 .procname = "min_slab_ratio",
2981 .data = &sysctl_min_slab_ratio,
2982 .maxlen = sizeof(sysctl_min_slab_ratio),
2984 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2985 .extra1 = SYSCTL_ZERO,
2986 .extra2 = &one_hundred,
2991 .procname = "stat_interval",
2992 .data = &sysctl_stat_interval,
2993 .maxlen = sizeof(sysctl_stat_interval),
2995 .proc_handler = proc_dointvec_jiffies,
2998 .procname = "stat_refresh",
3002 .proc_handler = vmstat_refresh,
3007 .procname = "mmap_min_addr",
3008 .data = &dac_mmap_min_addr,
3009 .maxlen = sizeof(unsigned long),
3011 .proc_handler = mmap_min_addr_handler,
3016 .procname = "numa_zonelist_order",
3017 .data = &numa_zonelist_order,
3018 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3020 .proc_handler = numa_zonelist_order_handler,
3023 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3024 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3026 .procname = "vdso_enabled",
3027 #ifdef CONFIG_X86_32
3028 .data = &vdso32_enabled,
3029 .maxlen = sizeof(vdso32_enabled),
3031 .data = &vdso_enabled,
3032 .maxlen = sizeof(vdso_enabled),
3035 .proc_handler = proc_dointvec,
3036 .extra1 = SYSCTL_ZERO,
3039 #ifdef CONFIG_HIGHMEM
3041 .procname = "highmem_is_dirtyable",
3042 .data = &vm_highmem_is_dirtyable,
3043 .maxlen = sizeof(vm_highmem_is_dirtyable),
3045 .proc_handler = proc_dointvec_minmax,
3046 .extra1 = SYSCTL_ZERO,
3047 .extra2 = SYSCTL_ONE,
3050 #ifdef CONFIG_MEMORY_FAILURE
3052 .procname = "memory_failure_early_kill",
3053 .data = &sysctl_memory_failure_early_kill,
3054 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3056 .proc_handler = proc_dointvec_minmax,
3057 .extra1 = SYSCTL_ZERO,
3058 .extra2 = SYSCTL_ONE,
3061 .procname = "memory_failure_recovery",
3062 .data = &sysctl_memory_failure_recovery,
3063 .maxlen = sizeof(sysctl_memory_failure_recovery),
3065 .proc_handler = proc_dointvec_minmax,
3066 .extra1 = SYSCTL_ZERO,
3067 .extra2 = SYSCTL_ONE,
3071 .procname = "user_reserve_kbytes",
3072 .data = &sysctl_user_reserve_kbytes,
3073 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3075 .proc_handler = proc_doulongvec_minmax,
3078 .procname = "admin_reserve_kbytes",
3079 .data = &sysctl_admin_reserve_kbytes,
3080 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3082 .proc_handler = proc_doulongvec_minmax,
3084 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3086 .procname = "mmap_rnd_bits",
3087 .data = &mmap_rnd_bits,
3088 .maxlen = sizeof(mmap_rnd_bits),
3090 .proc_handler = proc_dointvec_minmax,
3091 .extra1 = (void *)&mmap_rnd_bits_min,
3092 .extra2 = (void *)&mmap_rnd_bits_max,
3095 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3097 .procname = "mmap_rnd_compat_bits",
3098 .data = &mmap_rnd_compat_bits,
3099 .maxlen = sizeof(mmap_rnd_compat_bits),
3101 .proc_handler = proc_dointvec_minmax,
3102 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3103 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3106 #ifdef CONFIG_USERFAULTFD
3108 .procname = "unprivileged_userfaultfd",
3109 .data = &sysctl_unprivileged_userfaultfd,
3110 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3112 .proc_handler = proc_dointvec_minmax,
3113 .extra1 = SYSCTL_ZERO,
3114 .extra2 = SYSCTL_ONE,
3120 static struct ctl_table fs_table[] = {
3122 .procname = "inode-nr",
3123 .data = &inodes_stat,
3124 .maxlen = 2*sizeof(long),
3126 .proc_handler = proc_nr_inodes,
3129 .procname = "inode-state",
3130 .data = &inodes_stat,
3131 .maxlen = 7*sizeof(long),
3133 .proc_handler = proc_nr_inodes,
3136 .procname = "file-nr",
3137 .data = &files_stat,
3138 .maxlen = sizeof(files_stat),
3140 .proc_handler = proc_nr_files,
3143 .procname = "file-max",
3144 .data = &files_stat.max_files,
3145 .maxlen = sizeof(files_stat.max_files),
3147 .proc_handler = proc_doulongvec_minmax,
3149 .extra2 = &long_max,
3152 .procname = "nr_open",
3153 .data = &sysctl_nr_open,
3154 .maxlen = sizeof(unsigned int),
3156 .proc_handler = proc_dointvec_minmax,
3157 .extra1 = &sysctl_nr_open_min,
3158 .extra2 = &sysctl_nr_open_max,
3161 .procname = "dentry-state",
3162 .data = &dentry_stat,
3163 .maxlen = 6*sizeof(long),
3165 .proc_handler = proc_nr_dentry,
3168 .procname = "overflowuid",
3169 .data = &fs_overflowuid,
3170 .maxlen = sizeof(int),
3172 .proc_handler = proc_dointvec_minmax,
3173 .extra1 = &minolduid,
3174 .extra2 = &maxolduid,
3177 .procname = "overflowgid",
3178 .data = &fs_overflowgid,
3179 .maxlen = sizeof(int),
3181 .proc_handler = proc_dointvec_minmax,
3182 .extra1 = &minolduid,
3183 .extra2 = &maxolduid,
3185 #ifdef CONFIG_FILE_LOCKING
3187 .procname = "leases-enable",
3188 .data = &leases_enable,
3189 .maxlen = sizeof(int),
3191 .proc_handler = proc_dointvec,
3194 #ifdef CONFIG_DNOTIFY
3196 .procname = "dir-notify-enable",
3197 .data = &dir_notify_enable,
3198 .maxlen = sizeof(int),
3200 .proc_handler = proc_dointvec,
3204 #ifdef CONFIG_FILE_LOCKING
3206 .procname = "lease-break-time",
3207 .data = &lease_break_time,
3208 .maxlen = sizeof(int),
3210 .proc_handler = proc_dointvec,
3215 .procname = "aio-nr",
3217 .maxlen = sizeof(aio_nr),
3219 .proc_handler = proc_doulongvec_minmax,
3222 .procname = "aio-max-nr",
3223 .data = &aio_max_nr,
3224 .maxlen = sizeof(aio_max_nr),
3226 .proc_handler = proc_doulongvec_minmax,
3228 #endif /* CONFIG_AIO */
3229 #ifdef CONFIG_INOTIFY_USER
3231 .procname = "inotify",
3233 .child = inotify_table,
3236 #ifdef CONFIG_FANOTIFY
3238 .procname = "fanotify",
3240 .child = fanotify_table,
3245 .procname = "epoll",
3247 .child = epoll_table,
3252 .procname = "protected_symlinks",
3253 .data = &sysctl_protected_symlinks,
3254 .maxlen = sizeof(int),
3256 .proc_handler = proc_dointvec_minmax,
3257 .extra1 = SYSCTL_ZERO,
3258 .extra2 = SYSCTL_ONE,
3261 .procname = "protected_hardlinks",
3262 .data = &sysctl_protected_hardlinks,
3263 .maxlen = sizeof(int),
3265 .proc_handler = proc_dointvec_minmax,
3266 .extra1 = SYSCTL_ZERO,
3267 .extra2 = SYSCTL_ONE,
3270 .procname = "protected_fifos",
3271 .data = &sysctl_protected_fifos,
3272 .maxlen = sizeof(int),
3274 .proc_handler = proc_dointvec_minmax,
3275 .extra1 = SYSCTL_ZERO,
3279 .procname = "protected_regular",
3280 .data = &sysctl_protected_regular,
3281 .maxlen = sizeof(int),
3283 .proc_handler = proc_dointvec_minmax,
3284 .extra1 = SYSCTL_ZERO,
3288 .procname = "suid_dumpable",
3289 .data = &suid_dumpable,
3290 .maxlen = sizeof(int),
3292 .proc_handler = proc_dointvec_minmax_coredump,
3293 .extra1 = SYSCTL_ZERO,
3296 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3298 .procname = "binfmt_misc",
3300 .child = sysctl_mount_point,
3304 .procname = "pipe-max-size",
3305 .data = &pipe_max_size,
3306 .maxlen = sizeof(pipe_max_size),
3308 .proc_handler = proc_dopipe_max_size,
3311 .procname = "pipe-user-pages-hard",
3312 .data = &pipe_user_pages_hard,
3313 .maxlen = sizeof(pipe_user_pages_hard),
3315 .proc_handler = proc_doulongvec_minmax,
3318 .procname = "pipe-user-pages-soft",
3319 .data = &pipe_user_pages_soft,
3320 .maxlen = sizeof(pipe_user_pages_soft),
3322 .proc_handler = proc_doulongvec_minmax,
3325 .procname = "mount-max",
3326 .data = &sysctl_mount_max,
3327 .maxlen = sizeof(unsigned int),
3329 .proc_handler = proc_dointvec_minmax,
3330 .extra1 = SYSCTL_ONE,
3335 static struct ctl_table debug_table[] = {
3336 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3338 .procname = "exception-trace",
3339 .data = &show_unhandled_signals,
3340 .maxlen = sizeof(int),
3342 .proc_handler = proc_dointvec
3345 #if defined(CONFIG_OPTPROBES)
3347 .procname = "kprobes-optimization",
3348 .data = &sysctl_kprobes_optimization,
3349 .maxlen = sizeof(int),
3351 .proc_handler = proc_kprobes_optimization_handler,
3352 .extra1 = SYSCTL_ZERO,
3353 .extra2 = SYSCTL_ONE,
3359 static struct ctl_table dev_table[] = {
3363 static struct ctl_table sysctl_base_table[] = {
3365 .procname = "kernel",
3367 .child = kern_table,
3380 .procname = "debug",
3382 .child = debug_table,
3392 int __init sysctl_init(void)
3394 struct ctl_table_header *hdr;
3396 hdr = register_sysctl_table(sysctl_base_table);
3397 kmemleak_not_leak(hdr);
3400 #endif /* CONFIG_SYSCTL */
3402 * No sense putting this after each symbol definition, twice,
3403 * exception granted :-)
3405 EXPORT_SYMBOL(proc_dointvec);
3406 EXPORT_SYMBOL(proc_douintvec);
3407 EXPORT_SYMBOL(proc_dointvec_jiffies);
3408 EXPORT_SYMBOL(proc_dointvec_minmax);
3409 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3410 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3411 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3412 EXPORT_SYMBOL(proc_dostring);
3413 EXPORT_SYMBOL(proc_doulongvec_minmax);
3414 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3415 EXPORT_SYMBOL(proc_do_large_bitmap);