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>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/panic.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>
35 #include <linux/filter.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
39 #include <linux/kobject.h>
40 #include <linux/net.h>
41 #include <linux/sysrq.h>
42 #include <linux/highuid.h>
43 #include <linux/writeback.h>
44 #include <linux/ratelimit.h>
45 #include <linux/compaction.h>
46 #include <linux/hugetlb.h>
47 #include <linux/initrd.h>
48 #include <linux/key.h>
49 #include <linux/times.h>
50 #include <linux/limits.h>
51 #include <linux/dcache.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/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/kexec.h>
66 #include <linux/bpf.h>
67 #include <linux/mount.h>
68 #include <linux/userfaultfd_k.h>
69 #include <linux/latencytop.h>
70 #include <linux/pid.h>
71 #include <linux/delayacct.h>
73 #include "../lib/kstrtox.h"
75 #include <linux/uaccess.h>
76 #include <asm/processor.h>
80 #include <asm/stacktrace.h>
84 #include <asm/setup.h>
86 #ifdef CONFIG_BSD_PROCESS_ACCT
87 #include <linux/acct.h>
89 #ifdef CONFIG_RT_MUTEXES
90 #include <linux/rtmutex.h>
92 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
93 #include <linux/lockdep.h>
96 #if defined(CONFIG_SYSCTL)
98 /* Constants used for minimum and maximum */
101 static const int ten_thousand = 10000;
103 #ifdef CONFIG_PERF_EVENTS
104 static const int six_hundred_forty_kb = 640 * 1024;
107 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
108 static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
110 static const int ngroups_max = NGROUPS_MAX;
111 static const int cap_last_cap = CAP_LAST_CAP;
113 #ifdef CONFIG_PROC_SYSCTL
116 * enum sysctl_writes_mode - supported sysctl write modes
118 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
119 * to be written, and multiple writes on the same sysctl file descriptor
120 * will rewrite the sysctl value, regardless of file position. No warning
121 * is issued when the initial position is not 0.
122 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
124 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
125 * file position 0 and the value must be fully contained in the buffer
126 * sent to the write syscall. If dealing with strings respect the file
127 * position, but restrict this to the max length of the buffer, anything
128 * passed the max length will be ignored. Multiple writes will append
131 * These write modes control how current file position affects the behavior of
132 * updating sysctl values through the proc interface on each write.
134 enum sysctl_writes_mode {
135 SYSCTL_WRITES_LEGACY = -1,
136 SYSCTL_WRITES_WARN = 0,
137 SYSCTL_WRITES_STRICT = 1,
140 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
141 #endif /* CONFIG_PROC_SYSCTL */
143 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
144 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
145 int sysctl_legacy_va_layout;
148 #ifdef CONFIG_COMPACTION
149 /* min_extfrag_threshold is SYSCTL_ZERO */;
150 static const int max_extfrag_threshold = 1000;
153 #endif /* CONFIG_SYSCTL */
155 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
156 static int bpf_stats_handler(struct ctl_table *table, int write,
157 void *buffer, size_t *lenp, loff_t *ppos)
159 struct static_key *key = (struct static_key *)table->data;
160 static int saved_val;
162 struct ctl_table tmp = {
164 .maxlen = sizeof(val),
166 .extra1 = SYSCTL_ZERO,
167 .extra2 = SYSCTL_ONE,
170 if (write && !capable(CAP_SYS_ADMIN))
173 mutex_lock(&bpf_stats_enabled_mutex);
175 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
176 if (write && !ret && val != saved_val) {
178 static_key_slow_inc(key);
180 static_key_slow_dec(key);
183 mutex_unlock(&bpf_stats_enabled_mutex);
187 static int bpf_unpriv_handler(struct ctl_table *table, int write,
188 void *buffer, size_t *lenp, loff_t *ppos)
190 int ret, unpriv_enable = *(int *)table->data;
191 bool locked_state = unpriv_enable == 1;
192 struct ctl_table tmp = *table;
194 if (write && !capable(CAP_SYS_ADMIN))
197 tmp.data = &unpriv_enable;
198 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
200 if (locked_state && unpriv_enable != 1)
202 *(int *)table->data = unpriv_enable;
206 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
212 #ifdef CONFIG_PROC_SYSCTL
214 static int _proc_do_string(char *data, int maxlen, int write,
215 char *buffer, size_t *lenp, loff_t *ppos)
220 if (!data || !maxlen || !*lenp) {
226 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
227 /* Only continue writes not past the end of buffer. */
229 if (len > maxlen - 1)
236 /* Start writing from beginning of buffer. */
242 while ((p - buffer) < *lenp && len < maxlen - 1) {
244 if (c == 0 || c == '\n')
265 memcpy(buffer, data, len);
276 static void warn_sysctl_write(struct ctl_table *table)
278 pr_warn_once("%s wrote to %s when file position was not 0!\n"
279 "This will not be supported in the future. To silence this\n"
280 "warning, set kernel.sysctl_writes_strict = -1\n",
281 current->comm, table->procname);
285 * proc_first_pos_non_zero_ignore - check if first position is allowed
286 * @ppos: file position
287 * @table: the sysctl table
289 * Returns true if the first position is non-zero and the sysctl_writes_strict
290 * mode indicates this is not allowed for numeric input types. String proc
291 * handlers can ignore the return value.
293 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
294 struct ctl_table *table)
299 switch (sysctl_writes_strict) {
300 case SYSCTL_WRITES_STRICT:
302 case SYSCTL_WRITES_WARN:
303 warn_sysctl_write(table);
311 * proc_dostring - read a string sysctl
312 * @table: the sysctl table
313 * @write: %TRUE if this is a write to the sysctl file
314 * @buffer: the user buffer
315 * @lenp: the size of the user buffer
316 * @ppos: file position
318 * Reads/writes a string from/to the user buffer. If the kernel
319 * buffer provided is not large enough to hold the string, the
320 * string is truncated. The copied string is %NULL-terminated.
321 * If the string is being read by the user process, it is copied
322 * and a newline '\n' is added. It is truncated if the buffer is
325 * Returns 0 on success.
327 int proc_dostring(struct ctl_table *table, int write,
328 void *buffer, size_t *lenp, loff_t *ppos)
331 proc_first_pos_non_zero_ignore(ppos, table);
333 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
337 static size_t proc_skip_spaces(char **buf)
340 char *tmp = skip_spaces(*buf);
346 static void proc_skip_char(char **buf, size_t *size, const char v)
357 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
360 * @cp: kernel buffer containing the string to parse
361 * @endp: pointer to store the trailing characters
362 * @base: the base to use
363 * @res: where the parsed integer will be stored
365 * In case of success 0 is returned and @res will contain the parsed integer,
366 * @endp will hold any trailing characters.
367 * This function will fail the parse on overflow. If there wasn't an overflow
368 * the function will defer the decision what characters count as invalid to the
371 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
374 unsigned long long result;
377 cp = _parse_integer_fixup_radix(cp, &base);
378 rv = _parse_integer(cp, base, &result);
379 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
387 *res = (unsigned long)result;
393 * proc_get_long - reads an ASCII formatted integer from a user buffer
395 * @buf: a kernel buffer
396 * @size: size of the kernel buffer
397 * @val: this is where the number will be stored
398 * @neg: set to %TRUE if number is negative
399 * @perm_tr: a vector which contains the allowed trailers
400 * @perm_tr_len: size of the perm_tr vector
401 * @tr: pointer to store the trailer character
403 * In case of success %0 is returned and @buf and @size are updated with
404 * the amount of bytes read. If @tr is non-NULL and a trailing
405 * character exists (size is non-zero after returning from this
406 * function), @tr is updated with the trailing character.
408 static int proc_get_long(char **buf, size_t *size,
409 unsigned long *val, bool *neg,
410 const char *perm_tr, unsigned perm_tr_len, char *tr)
413 char *p, tmp[TMPBUFLEN];
419 if (len > TMPBUFLEN - 1)
422 memcpy(tmp, *buf, len);
426 if (*p == '-' && *size > 1) {
434 if (strtoul_lenient(p, &p, 0, val))
439 /* We don't know if the next char is whitespace thus we may accept
440 * invalid integers (e.g. 1234...a) or two integers instead of one
441 * (e.g. 123...1). So lets not allow such large numbers. */
442 if (len == TMPBUFLEN - 1)
445 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
448 if (tr && (len < *size))
458 * proc_put_long - converts an integer to a decimal ASCII formatted string
460 * @buf: the user buffer
461 * @size: the size of the user buffer
462 * @val: the integer to be converted
463 * @neg: sign of the number, %TRUE for negative
465 * In case of success @buf and @size are updated with the amount of bytes
468 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
471 char tmp[TMPBUFLEN], *p = tmp;
473 sprintf(p, "%s%lu", neg ? "-" : "", val);
477 memcpy(*buf, tmp, len);
483 static void proc_put_char(void **buf, size_t *size, char c)
486 char **buffer = (char **)buf;
495 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
497 int write, void *data)
500 *(bool *)valp = *lvalp;
502 int val = *(bool *)valp;
504 *lvalp = (unsigned long)val;
510 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
512 int write, void *data)
516 if (*lvalp > (unsigned long) INT_MAX + 1)
520 if (*lvalp > (unsigned long) INT_MAX)
528 *lvalp = -(unsigned long)val;
531 *lvalp = (unsigned long)val;
537 static int do_proc_douintvec_conv(unsigned long *lvalp,
539 int write, void *data)
542 if (*lvalp > UINT_MAX)
546 unsigned int val = *valp;
547 *lvalp = (unsigned long)val;
552 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
554 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
555 int write, void *buffer,
556 size_t *lenp, loff_t *ppos,
557 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
558 int write, void *data),
561 int *i, vleft, first = 1, err = 0;
565 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
570 i = (int *) tbl_data;
571 vleft = table->maxlen / sizeof(*i);
575 conv = do_proc_dointvec_conv;
578 if (proc_first_pos_non_zero_ignore(ppos, table))
581 if (left > PAGE_SIZE - 1)
582 left = PAGE_SIZE - 1;
586 for (; left && vleft--; i++, first=0) {
591 left -= proc_skip_spaces(&p);
595 err = proc_get_long(&p, &left, &lval, &neg,
597 sizeof(proc_wspace_sep), NULL);
600 if (conv(&neg, &lval, i, 1, data)) {
605 if (conv(&neg, &lval, i, 0, data)) {
610 proc_put_char(&buffer, &left, '\t');
611 proc_put_long(&buffer, &left, lval, neg);
615 if (!write && !first && left && !err)
616 proc_put_char(&buffer, &left, '\n');
617 if (write && !err && left)
618 left -= proc_skip_spaces(&p);
620 return err ? : -EINVAL;
627 static int do_proc_dointvec(struct ctl_table *table, int write,
628 void *buffer, size_t *lenp, loff_t *ppos,
629 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
630 int write, void *data),
633 return __do_proc_dointvec(table->data, table, write,
634 buffer, lenp, ppos, conv, data);
637 static int do_proc_douintvec_w(unsigned int *tbl_data,
638 struct ctl_table *table,
640 size_t *lenp, loff_t *ppos,
641 int (*conv)(unsigned long *lvalp,
643 int write, void *data),
654 if (proc_first_pos_non_zero_ignore(ppos, table))
657 if (left > PAGE_SIZE - 1)
658 left = PAGE_SIZE - 1;
660 left -= proc_skip_spaces(&p);
666 err = proc_get_long(&p, &left, &lval, &neg,
668 sizeof(proc_wspace_sep), NULL);
674 if (conv(&lval, tbl_data, 1, data)) {
680 left -= proc_skip_spaces(&p);
688 /* This is in keeping with old __do_proc_dointvec() */
694 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
695 size_t *lenp, loff_t *ppos,
696 int (*conv)(unsigned long *lvalp,
698 int write, void *data),
707 if (conv(&lval, tbl_data, 0, data)) {
712 proc_put_long(&buffer, &left, lval, false);
716 proc_put_char(&buffer, &left, '\n');
725 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
726 int write, void *buffer,
727 size_t *lenp, loff_t *ppos,
728 int (*conv)(unsigned long *lvalp,
730 int write, void *data),
733 unsigned int *i, vleft;
735 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
740 i = (unsigned int *) tbl_data;
741 vleft = table->maxlen / sizeof(*i);
744 * Arrays are not supported, keep this simple. *Do not* add
753 conv = do_proc_douintvec_conv;
756 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
758 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
761 int do_proc_douintvec(struct ctl_table *table, int write,
762 void *buffer, size_t *lenp, loff_t *ppos,
763 int (*conv)(unsigned long *lvalp,
765 int write, void *data),
768 return __do_proc_douintvec(table->data, table, write,
769 buffer, lenp, ppos, conv, data);
773 * proc_dobool - read/write a bool
774 * @table: the sysctl table
775 * @write: %TRUE if this is a write to the sysctl file
776 * @buffer: the user buffer
777 * @lenp: the size of the user buffer
778 * @ppos: file position
780 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
781 * values from/to the user buffer, treated as an ASCII string.
783 * Returns 0 on success.
785 int proc_dobool(struct ctl_table *table, int write, void *buffer,
786 size_t *lenp, loff_t *ppos)
788 return do_proc_dointvec(table, write, buffer, lenp, ppos,
789 do_proc_dobool_conv, NULL);
793 * proc_dointvec - read a vector of integers
794 * @table: the sysctl table
795 * @write: %TRUE if this is a write to the sysctl file
796 * @buffer: the user buffer
797 * @lenp: the size of the user buffer
798 * @ppos: file position
800 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
801 * values from/to the user buffer, treated as an ASCII string.
803 * Returns 0 on success.
805 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
806 size_t *lenp, loff_t *ppos)
808 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
811 #ifdef CONFIG_COMPACTION
812 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
813 int write, void *buffer, size_t *lenp, loff_t *ppos)
817 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
818 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
820 old = *(int *)table->data;
821 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
824 if (old != *(int *)table->data)
825 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
826 table->procname, current->comm,
827 task_pid_nr(current));
833 * proc_douintvec - read a vector of unsigned integers
834 * @table: the sysctl table
835 * @write: %TRUE if this is a write to the sysctl file
836 * @buffer: the user buffer
837 * @lenp: the size of the user buffer
838 * @ppos: file position
840 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
841 * values from/to the user buffer, treated as an ASCII string.
843 * Returns 0 on success.
845 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
846 size_t *lenp, loff_t *ppos)
848 return do_proc_douintvec(table, write, buffer, lenp, ppos,
849 do_proc_douintvec_conv, NULL);
853 * Taint values can only be increased
854 * This means we can safely use a temporary.
856 static int proc_taint(struct ctl_table *table, int write,
857 void *buffer, size_t *lenp, loff_t *ppos)
860 unsigned long tmptaint = get_taint();
863 if (write && !capable(CAP_SYS_ADMIN))
868 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
876 * If we are relying on panic_on_taint not producing
877 * false positives due to userspace input, bail out
878 * before setting the requested taint flags.
880 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
884 * Poor man's atomic or. Not worth adding a primitive
885 * to everyone's atomic.h for this
887 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
888 if ((1UL << i) & tmptaint)
889 add_taint(i, LOCKDEP_STILL_OK);
896 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
897 * @min: pointer to minimum allowable value
898 * @max: pointer to maximum allowable value
900 * The do_proc_dointvec_minmax_conv_param structure provides the
901 * minimum and maximum values for doing range checking for those sysctl
902 * parameters that use the proc_dointvec_minmax() handler.
904 struct do_proc_dointvec_minmax_conv_param {
909 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
911 int write, void *data)
914 struct do_proc_dointvec_minmax_conv_param *param = data;
916 * If writing, first do so via a temporary local int so we can
917 * bounds-check it before touching *valp.
919 int *ip = write ? &tmp : valp;
921 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
926 if ((param->min && *param->min > tmp) ||
927 (param->max && *param->max < tmp))
936 * proc_dointvec_minmax - read a vector of integers with min/max values
937 * @table: the sysctl table
938 * @write: %TRUE if this is a write to the sysctl file
939 * @buffer: the user buffer
940 * @lenp: the size of the user buffer
941 * @ppos: file position
943 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
944 * values from/to the user buffer, treated as an ASCII string.
946 * This routine will ensure the values are within the range specified by
947 * table->extra1 (min) and table->extra2 (max).
949 * Returns 0 on success or -EINVAL on write when the range check fails.
951 int proc_dointvec_minmax(struct ctl_table *table, int write,
952 void *buffer, size_t *lenp, loff_t *ppos)
954 struct do_proc_dointvec_minmax_conv_param param = {
955 .min = (int *) table->extra1,
956 .max = (int *) table->extra2,
958 return do_proc_dointvec(table, write, buffer, lenp, ppos,
959 do_proc_dointvec_minmax_conv, ¶m);
963 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
964 * @min: pointer to minimum allowable value
965 * @max: pointer to maximum allowable value
967 * The do_proc_douintvec_minmax_conv_param structure provides the
968 * minimum and maximum values for doing range checking for those sysctl
969 * parameters that use the proc_douintvec_minmax() handler.
971 struct do_proc_douintvec_minmax_conv_param {
976 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
978 int write, void *data)
982 struct do_proc_douintvec_minmax_conv_param *param = data;
983 /* write via temporary local uint for bounds-checking */
984 unsigned int *up = write ? &tmp : valp;
986 ret = do_proc_douintvec_conv(lvalp, up, write, data);
991 if ((param->min && *param->min > tmp) ||
992 (param->max && *param->max < tmp))
1002 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1003 * @table: the sysctl table
1004 * @write: %TRUE if this is a write to the sysctl file
1005 * @buffer: the user buffer
1006 * @lenp: the size of the user buffer
1007 * @ppos: file position
1009 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1010 * values from/to the user buffer, treated as an ASCII string. Negative
1011 * strings are not allowed.
1013 * This routine will ensure the values are within the range specified by
1014 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1015 * check for UINT_MAX to avoid having to support wrap around uses from
1018 * Returns 0 on success or -ERANGE on write when the range check fails.
1020 int proc_douintvec_minmax(struct ctl_table *table, int write,
1021 void *buffer, size_t *lenp, loff_t *ppos)
1023 struct do_proc_douintvec_minmax_conv_param param = {
1024 .min = (unsigned int *) table->extra1,
1025 .max = (unsigned int *) table->extra2,
1027 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1028 do_proc_douintvec_minmax_conv, ¶m);
1032 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1033 * @table: the sysctl table
1034 * @write: %TRUE if this is a write to the sysctl file
1035 * @buffer: the user buffer
1036 * @lenp: the size of the user buffer
1037 * @ppos: file position
1039 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1040 * values from/to the user buffer, treated as an ASCII string. Negative
1041 * strings are not allowed.
1043 * This routine will ensure the values are within the range specified by
1044 * table->extra1 (min) and table->extra2 (max).
1046 * Returns 0 on success or an error on write when the range check fails.
1048 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1049 void *buffer, size_t *lenp, loff_t *ppos)
1051 struct ctl_table tmp;
1052 unsigned int min = 0, max = 255U, val;
1053 u8 *data = table->data;
1054 struct do_proc_douintvec_minmax_conv_param param = {
1060 /* Do not support arrays yet. */
1061 if (table->maxlen != sizeof(u8))
1064 if (table->extra1) {
1065 min = *(unsigned int *) table->extra1;
1069 if (table->extra2) {
1070 max = *(unsigned int *) table->extra2;
1077 tmp.maxlen = sizeof(val);
1080 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1081 do_proc_douintvec_minmax_conv, ¶m);
1088 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1090 #ifdef CONFIG_MAGIC_SYSRQ
1091 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1092 void *buffer, size_t *lenp, loff_t *ppos)
1098 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1099 lenp, ppos, NULL, NULL);
1104 sysrq_toggle_support(tmp);
1110 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1111 int write, void *buffer, size_t *lenp, loff_t *ppos,
1112 unsigned long convmul, unsigned long convdiv)
1114 unsigned long *i, *min, *max;
1115 int vleft, first = 1, err = 0;
1119 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1124 i = (unsigned long *) data;
1125 min = (unsigned long *) table->extra1;
1126 max = (unsigned long *) table->extra2;
1127 vleft = table->maxlen / sizeof(unsigned long);
1131 if (proc_first_pos_non_zero_ignore(ppos, table))
1134 if (left > PAGE_SIZE - 1)
1135 left = PAGE_SIZE - 1;
1139 for (; left && vleft--; i++, first = 0) {
1145 left -= proc_skip_spaces(&p);
1149 err = proc_get_long(&p, &left, &val, &neg,
1151 sizeof(proc_wspace_sep), NULL);
1156 val = convmul * val / convdiv;
1157 if ((min && val < *min) || (max && val > *max)) {
1163 val = convdiv * (*i) / convmul;
1165 proc_put_char(&buffer, &left, '\t');
1166 proc_put_long(&buffer, &left, val, false);
1170 if (!write && !first && left && !err)
1171 proc_put_char(&buffer, &left, '\n');
1173 left -= proc_skip_spaces(&p);
1175 return err ? : -EINVAL;
1182 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1183 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1184 unsigned long convdiv)
1186 return __do_proc_doulongvec_minmax(table->data, table, write,
1187 buffer, lenp, ppos, convmul, convdiv);
1191 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1192 * @table: the sysctl table
1193 * @write: %TRUE if this is a write to the sysctl file
1194 * @buffer: the user buffer
1195 * @lenp: the size of the user buffer
1196 * @ppos: file position
1198 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1199 * values from/to the user buffer, treated as an ASCII string.
1201 * This routine will ensure the values are within the range specified by
1202 * table->extra1 (min) and table->extra2 (max).
1204 * Returns 0 on success.
1206 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1207 void *buffer, size_t *lenp, loff_t *ppos)
1209 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1213 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1214 * @table: the sysctl table
1215 * @write: %TRUE if this is a write to the sysctl file
1216 * @buffer: the user buffer
1217 * @lenp: the size of the user buffer
1218 * @ppos: file position
1220 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1221 * values from/to the user buffer, treated as an ASCII string. The values
1222 * are treated as milliseconds, and converted to jiffies when they are stored.
1224 * This routine will ensure the values are within the range specified by
1225 * table->extra1 (min) and table->extra2 (max).
1227 * Returns 0 on success.
1229 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1230 void *buffer, size_t *lenp, loff_t *ppos)
1232 return do_proc_doulongvec_minmax(table, write, buffer,
1233 lenp, ppos, HZ, 1000l);
1237 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1239 int write, void *data)
1242 if (*lvalp > INT_MAX / HZ)
1244 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1250 lval = -(unsigned long)val;
1253 lval = (unsigned long)val;
1260 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1262 int write, void *data)
1265 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1267 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1273 lval = -(unsigned long)val;
1276 lval = (unsigned long)val;
1278 *lvalp = jiffies_to_clock_t(lval);
1283 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1285 int write, void *data)
1288 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1298 lval = -(unsigned long)val;
1301 lval = (unsigned long)val;
1303 *lvalp = jiffies_to_msecs(lval);
1309 * proc_dointvec_jiffies - read a vector of integers as seconds
1310 * @table: the sysctl table
1311 * @write: %TRUE if this is a write to the sysctl file
1312 * @buffer: the user buffer
1313 * @lenp: the size of the user buffer
1314 * @ppos: file position
1316 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1317 * values from/to the user buffer, treated as an ASCII string.
1318 * The values read are assumed to be in seconds, and are converted into
1321 * Returns 0 on success.
1323 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1324 void *buffer, size_t *lenp, loff_t *ppos)
1326 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1327 do_proc_dointvec_jiffies_conv,NULL);
1331 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1332 * @table: the sysctl table
1333 * @write: %TRUE if this is a write to the sysctl file
1334 * @buffer: the user buffer
1335 * @lenp: the size of the user buffer
1336 * @ppos: pointer to the file position
1338 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1339 * values from/to the user buffer, treated as an ASCII string.
1340 * The values read are assumed to be in 1/USER_HZ seconds, and
1341 * are converted into jiffies.
1343 * Returns 0 on success.
1345 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1346 void *buffer, size_t *lenp, loff_t *ppos)
1348 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1349 do_proc_dointvec_userhz_jiffies_conv,NULL);
1353 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1354 * @table: the sysctl table
1355 * @write: %TRUE if this is a write to the sysctl file
1356 * @buffer: the user buffer
1357 * @lenp: the size of the user buffer
1358 * @ppos: file position
1359 * @ppos: the current position in the file
1361 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1362 * values from/to the user buffer, treated as an ASCII string.
1363 * The values read are assumed to be in 1/1000 seconds, and
1364 * are converted into jiffies.
1366 * Returns 0 on success.
1368 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1369 size_t *lenp, loff_t *ppos)
1371 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1372 do_proc_dointvec_ms_jiffies_conv, NULL);
1375 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1376 size_t *lenp, loff_t *ppos)
1378 struct pid *new_pid;
1382 tmp = pid_vnr(cad_pid);
1384 r = __do_proc_dointvec(&tmp, table, write, buffer,
1385 lenp, ppos, NULL, NULL);
1389 new_pid = find_get_pid(tmp);
1393 put_pid(xchg(&cad_pid, new_pid));
1398 * proc_do_large_bitmap - read/write from/to a large bitmap
1399 * @table: the sysctl table
1400 * @write: %TRUE if this is a write to the sysctl file
1401 * @buffer: the user buffer
1402 * @lenp: the size of the user buffer
1403 * @ppos: file position
1405 * The bitmap is stored at table->data and the bitmap length (in bits)
1408 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1409 * large bitmaps may be represented in a compact manner. Writing into
1410 * the file will clear the bitmap then update it with the given input.
1412 * Returns 0 on success.
1414 int proc_do_large_bitmap(struct ctl_table *table, int write,
1415 void *buffer, size_t *lenp, loff_t *ppos)
1418 size_t left = *lenp;
1419 unsigned long bitmap_len = table->maxlen;
1420 unsigned long *bitmap = *(unsigned long **) table->data;
1421 unsigned long *tmp_bitmap = NULL;
1422 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1424 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1433 if (left > PAGE_SIZE - 1) {
1434 left = PAGE_SIZE - 1;
1435 /* How much of the buffer we'll skip this pass */
1436 skipped = *lenp - left;
1439 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1442 proc_skip_char(&p, &left, '\n');
1443 while (!err && left) {
1444 unsigned long val_a, val_b;
1448 /* In case we stop parsing mid-number, we can reset */
1450 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1453 * If we consumed the entirety of a truncated buffer or
1454 * only one char is left (may be a "-"), then stop here,
1455 * reset, & come back for more.
1457 if ((left <= 1) && skipped) {
1464 if (val_a >= bitmap_len || neg) {
1476 err = proc_get_long(&p, &left, &val_b,
1477 &neg, tr_b, sizeof(tr_b),
1480 * If we consumed all of a truncated buffer or
1481 * then stop here, reset, & come back for more.
1483 if (!left && skipped) {
1490 if (val_b >= bitmap_len || neg ||
1501 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1502 proc_skip_char(&p, &left, '\n');
1506 unsigned long bit_a, bit_b = 0;
1510 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1511 if (bit_a >= bitmap_len)
1513 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1517 proc_put_char(&buffer, &left, ',');
1518 proc_put_long(&buffer, &left, bit_a, false);
1519 if (bit_a != bit_b) {
1520 proc_put_char(&buffer, &left, '-');
1521 proc_put_long(&buffer, &left, bit_b, false);
1526 proc_put_char(&buffer, &left, '\n');
1532 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1534 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1540 bitmap_free(tmp_bitmap);
1544 #else /* CONFIG_PROC_SYSCTL */
1546 int proc_dostring(struct ctl_table *table, int write,
1547 void *buffer, size_t *lenp, loff_t *ppos)
1552 int proc_dobool(struct ctl_table *table, int write,
1553 void *buffer, size_t *lenp, loff_t *ppos)
1558 int proc_dointvec(struct ctl_table *table, int write,
1559 void *buffer, size_t *lenp, loff_t *ppos)
1564 int proc_douintvec(struct ctl_table *table, int write,
1565 void *buffer, size_t *lenp, loff_t *ppos)
1570 int proc_dointvec_minmax(struct ctl_table *table, int write,
1571 void *buffer, size_t *lenp, loff_t *ppos)
1576 int proc_douintvec_minmax(struct ctl_table *table, int write,
1577 void *buffer, size_t *lenp, loff_t *ppos)
1582 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1583 void *buffer, size_t *lenp, loff_t *ppos)
1588 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1589 void *buffer, size_t *lenp, loff_t *ppos)
1594 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1595 void *buffer, size_t *lenp, loff_t *ppos)
1600 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1601 void *buffer, size_t *lenp, loff_t *ppos)
1606 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1607 void *buffer, size_t *lenp, loff_t *ppos)
1612 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1613 void *buffer, size_t *lenp, loff_t *ppos)
1618 int proc_do_large_bitmap(struct ctl_table *table, int write,
1619 void *buffer, size_t *lenp, loff_t *ppos)
1624 #endif /* CONFIG_PROC_SYSCTL */
1626 #if defined(CONFIG_SYSCTL)
1627 int proc_do_static_key(struct ctl_table *table, int write,
1628 void *buffer, size_t *lenp, loff_t *ppos)
1630 struct static_key *key = (struct static_key *)table->data;
1631 static DEFINE_MUTEX(static_key_mutex);
1633 struct ctl_table tmp = {
1635 .maxlen = sizeof(val),
1636 .mode = table->mode,
1637 .extra1 = SYSCTL_ZERO,
1638 .extra2 = SYSCTL_ONE,
1641 if (write && !capable(CAP_SYS_ADMIN))
1644 mutex_lock(&static_key_mutex);
1645 val = static_key_enabled(key);
1646 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1647 if (write && !ret) {
1649 static_key_enable(key);
1651 static_key_disable(key);
1653 mutex_unlock(&static_key_mutex);
1657 static struct ctl_table kern_table[] = {
1659 .procname = "sched_child_runs_first",
1660 .data = &sysctl_sched_child_runs_first,
1661 .maxlen = sizeof(unsigned int),
1663 .proc_handler = proc_dointvec,
1665 #ifdef CONFIG_SCHEDSTATS
1667 .procname = "sched_schedstats",
1669 .maxlen = sizeof(unsigned int),
1671 .proc_handler = sysctl_schedstats,
1672 .extra1 = SYSCTL_ZERO,
1673 .extra2 = SYSCTL_ONE,
1675 #endif /* CONFIG_SCHEDSTATS */
1676 #ifdef CONFIG_TASK_DELAY_ACCT
1678 .procname = "task_delayacct",
1680 .maxlen = sizeof(unsigned int),
1682 .proc_handler = sysctl_delayacct,
1683 .extra1 = SYSCTL_ZERO,
1684 .extra2 = SYSCTL_ONE,
1686 #endif /* CONFIG_TASK_DELAY_ACCT */
1687 #ifdef CONFIG_NUMA_BALANCING
1689 .procname = "numa_balancing",
1690 .data = NULL, /* filled in by handler */
1691 .maxlen = sizeof(unsigned int),
1693 .proc_handler = sysctl_numa_balancing,
1694 .extra1 = SYSCTL_ZERO,
1695 .extra2 = SYSCTL_ONE,
1697 #endif /* CONFIG_NUMA_BALANCING */
1699 .procname = "sched_rt_period_us",
1700 .data = &sysctl_sched_rt_period,
1701 .maxlen = sizeof(unsigned int),
1703 .proc_handler = sched_rt_handler,
1706 .procname = "sched_rt_runtime_us",
1707 .data = &sysctl_sched_rt_runtime,
1708 .maxlen = sizeof(int),
1710 .proc_handler = sched_rt_handler,
1713 .procname = "sched_deadline_period_max_us",
1714 .data = &sysctl_sched_dl_period_max,
1715 .maxlen = sizeof(unsigned int),
1717 .proc_handler = proc_dointvec,
1720 .procname = "sched_deadline_period_min_us",
1721 .data = &sysctl_sched_dl_period_min,
1722 .maxlen = sizeof(unsigned int),
1724 .proc_handler = proc_dointvec,
1727 .procname = "sched_rr_timeslice_ms",
1728 .data = &sysctl_sched_rr_timeslice,
1729 .maxlen = sizeof(int),
1731 .proc_handler = sched_rr_handler,
1733 #ifdef CONFIG_UCLAMP_TASK
1735 .procname = "sched_util_clamp_min",
1736 .data = &sysctl_sched_uclamp_util_min,
1737 .maxlen = sizeof(unsigned int),
1739 .proc_handler = sysctl_sched_uclamp_handler,
1742 .procname = "sched_util_clamp_max",
1743 .data = &sysctl_sched_uclamp_util_max,
1744 .maxlen = sizeof(unsigned int),
1746 .proc_handler = sysctl_sched_uclamp_handler,
1749 .procname = "sched_util_clamp_min_rt_default",
1750 .data = &sysctl_sched_uclamp_util_min_rt_default,
1751 .maxlen = sizeof(unsigned int),
1753 .proc_handler = sysctl_sched_uclamp_handler,
1756 #ifdef CONFIG_SCHED_AUTOGROUP
1758 .procname = "sched_autogroup_enabled",
1759 .data = &sysctl_sched_autogroup_enabled,
1760 .maxlen = sizeof(unsigned int),
1762 .proc_handler = proc_dointvec_minmax,
1763 .extra1 = SYSCTL_ZERO,
1764 .extra2 = SYSCTL_ONE,
1767 #ifdef CONFIG_CFS_BANDWIDTH
1769 .procname = "sched_cfs_bandwidth_slice_us",
1770 .data = &sysctl_sched_cfs_bandwidth_slice,
1771 .maxlen = sizeof(unsigned int),
1773 .proc_handler = proc_dointvec_minmax,
1774 .extra1 = SYSCTL_ONE,
1777 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1779 .procname = "sched_energy_aware",
1780 .data = &sysctl_sched_energy_aware,
1781 .maxlen = sizeof(unsigned int),
1783 .proc_handler = sched_energy_aware_handler,
1784 .extra1 = SYSCTL_ZERO,
1785 .extra2 = SYSCTL_ONE,
1788 #ifdef CONFIG_PROVE_LOCKING
1790 .procname = "prove_locking",
1791 .data = &prove_locking,
1792 .maxlen = sizeof(int),
1794 .proc_handler = proc_dointvec,
1797 #ifdef CONFIG_LOCK_STAT
1799 .procname = "lock_stat",
1801 .maxlen = sizeof(int),
1803 .proc_handler = proc_dointvec,
1807 .procname = "panic",
1808 .data = &panic_timeout,
1809 .maxlen = sizeof(int),
1811 .proc_handler = proc_dointvec,
1813 #ifdef CONFIG_PROC_SYSCTL
1815 .procname = "tainted",
1816 .maxlen = sizeof(long),
1818 .proc_handler = proc_taint,
1821 .procname = "sysctl_writes_strict",
1822 .data = &sysctl_writes_strict,
1823 .maxlen = sizeof(int),
1825 .proc_handler = proc_dointvec_minmax,
1826 .extra1 = SYSCTL_NEG_ONE,
1827 .extra2 = SYSCTL_ONE,
1830 #ifdef CONFIG_LATENCYTOP
1832 .procname = "latencytop",
1833 .data = &latencytop_enabled,
1834 .maxlen = sizeof(int),
1836 .proc_handler = sysctl_latencytop,
1839 #ifdef CONFIG_BLK_DEV_INITRD
1841 .procname = "real-root-dev",
1842 .data = &real_root_dev,
1843 .maxlen = sizeof(int),
1845 .proc_handler = proc_dointvec,
1849 .procname = "print-fatal-signals",
1850 .data = &print_fatal_signals,
1851 .maxlen = sizeof(int),
1853 .proc_handler = proc_dointvec,
1857 .procname = "reboot-cmd",
1858 .data = reboot_command,
1861 .proc_handler = proc_dostring,
1864 .procname = "stop-a",
1865 .data = &stop_a_enabled,
1866 .maxlen = sizeof (int),
1868 .proc_handler = proc_dointvec,
1871 .procname = "scons-poweroff",
1872 .data = &scons_pwroff,
1873 .maxlen = sizeof (int),
1875 .proc_handler = proc_dointvec,
1878 #ifdef CONFIG_SPARC64
1880 .procname = "tsb-ratio",
1881 .data = &sysctl_tsb_ratio,
1882 .maxlen = sizeof (int),
1884 .proc_handler = proc_dointvec,
1887 #ifdef CONFIG_PARISC
1889 .procname = "soft-power",
1890 .data = &pwrsw_enabled,
1891 .maxlen = sizeof (int),
1893 .proc_handler = proc_dointvec,
1896 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1898 .procname = "unaligned-trap",
1899 .data = &unaligned_enabled,
1900 .maxlen = sizeof (int),
1902 .proc_handler = proc_dointvec,
1906 .procname = "ctrl-alt-del",
1908 .maxlen = sizeof(int),
1910 .proc_handler = proc_dointvec,
1912 #ifdef CONFIG_FUNCTION_TRACER
1914 .procname = "ftrace_enabled",
1915 .data = &ftrace_enabled,
1916 .maxlen = sizeof(int),
1918 .proc_handler = ftrace_enable_sysctl,
1921 #ifdef CONFIG_STACK_TRACER
1923 .procname = "stack_tracer_enabled",
1924 .data = &stack_tracer_enabled,
1925 .maxlen = sizeof(int),
1927 .proc_handler = stack_trace_sysctl,
1930 #ifdef CONFIG_TRACING
1932 .procname = "ftrace_dump_on_oops",
1933 .data = &ftrace_dump_on_oops,
1934 .maxlen = sizeof(int),
1936 .proc_handler = proc_dointvec,
1939 .procname = "traceoff_on_warning",
1940 .data = &__disable_trace_on_warning,
1941 .maxlen = sizeof(__disable_trace_on_warning),
1943 .proc_handler = proc_dointvec,
1946 .procname = "tracepoint_printk",
1947 .data = &tracepoint_printk,
1948 .maxlen = sizeof(tracepoint_printk),
1950 .proc_handler = tracepoint_printk_sysctl,
1953 #ifdef CONFIG_KEXEC_CORE
1955 .procname = "kexec_load_disabled",
1956 .data = &kexec_load_disabled,
1957 .maxlen = sizeof(int),
1959 /* only handle a transition from default "0" to "1" */
1960 .proc_handler = proc_dointvec_minmax,
1961 .extra1 = SYSCTL_ONE,
1962 .extra2 = SYSCTL_ONE,
1965 #ifdef CONFIG_MODULES
1967 .procname = "modprobe",
1968 .data = &modprobe_path,
1969 .maxlen = KMOD_PATH_LEN,
1971 .proc_handler = proc_dostring,
1974 .procname = "modules_disabled",
1975 .data = &modules_disabled,
1976 .maxlen = sizeof(int),
1978 /* only handle a transition from default "0" to "1" */
1979 .proc_handler = proc_dointvec_minmax,
1980 .extra1 = SYSCTL_ONE,
1981 .extra2 = SYSCTL_ONE,
1984 #ifdef CONFIG_UEVENT_HELPER
1986 .procname = "hotplug",
1987 .data = &uevent_helper,
1988 .maxlen = UEVENT_HELPER_PATH_LEN,
1990 .proc_handler = proc_dostring,
1993 #ifdef CONFIG_BSD_PROCESS_ACCT
1997 .maxlen = 3*sizeof(int),
1999 .proc_handler = proc_dointvec,
2002 #ifdef CONFIG_MAGIC_SYSRQ
2004 .procname = "sysrq",
2006 .maxlen = sizeof (int),
2008 .proc_handler = sysrq_sysctl_handler,
2011 #ifdef CONFIG_PROC_SYSCTL
2013 .procname = "cad_pid",
2015 .maxlen = sizeof (int),
2017 .proc_handler = proc_do_cad_pid,
2021 .procname = "threads-max",
2023 .maxlen = sizeof(int),
2025 .proc_handler = sysctl_max_threads,
2028 .procname = "usermodehelper",
2030 .child = usermodehelper_table,
2033 .procname = "overflowuid",
2034 .data = &overflowuid,
2035 .maxlen = sizeof(int),
2037 .proc_handler = proc_dointvec_minmax,
2038 .extra1 = SYSCTL_ZERO,
2039 .extra2 = SYSCTL_MAXOLDUID,
2042 .procname = "overflowgid",
2043 .data = &overflowgid,
2044 .maxlen = sizeof(int),
2046 .proc_handler = proc_dointvec_minmax,
2047 .extra1 = SYSCTL_ZERO,
2048 .extra2 = SYSCTL_MAXOLDUID,
2052 .procname = "userprocess_debug",
2053 .data = &show_unhandled_signals,
2054 .maxlen = sizeof(int),
2056 .proc_handler = proc_dointvec,
2061 .procname = "oops_all_cpu_backtrace",
2062 .data = &sysctl_oops_all_cpu_backtrace,
2063 .maxlen = sizeof(int),
2065 .proc_handler = proc_dointvec_minmax,
2066 .extra1 = SYSCTL_ZERO,
2067 .extra2 = SYSCTL_ONE,
2069 #endif /* CONFIG_SMP */
2071 .procname = "pid_max",
2073 .maxlen = sizeof (int),
2075 .proc_handler = proc_dointvec_minmax,
2076 .extra1 = &pid_max_min,
2077 .extra2 = &pid_max_max,
2080 .procname = "panic_on_oops",
2081 .data = &panic_on_oops,
2082 .maxlen = sizeof(int),
2084 .proc_handler = proc_dointvec,
2087 .procname = "panic_print",
2088 .data = &panic_print,
2089 .maxlen = sizeof(unsigned long),
2091 .proc_handler = proc_doulongvec_minmax,
2094 .procname = "ngroups_max",
2095 .data = (void *)&ngroups_max,
2096 .maxlen = sizeof (int),
2098 .proc_handler = proc_dointvec,
2101 .procname = "cap_last_cap",
2102 .data = (void *)&cap_last_cap,
2103 .maxlen = sizeof(int),
2105 .proc_handler = proc_dointvec,
2107 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2109 .procname = "unknown_nmi_panic",
2110 .data = &unknown_nmi_panic,
2111 .maxlen = sizeof (int),
2113 .proc_handler = proc_dointvec,
2117 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2118 defined(CONFIG_DEBUG_STACKOVERFLOW)
2120 .procname = "panic_on_stackoverflow",
2121 .data = &sysctl_panic_on_stackoverflow,
2122 .maxlen = sizeof(int),
2124 .proc_handler = proc_dointvec,
2127 #if defined(CONFIG_X86)
2129 .procname = "panic_on_unrecovered_nmi",
2130 .data = &panic_on_unrecovered_nmi,
2131 .maxlen = sizeof(int),
2133 .proc_handler = proc_dointvec,
2136 .procname = "panic_on_io_nmi",
2137 .data = &panic_on_io_nmi,
2138 .maxlen = sizeof(int),
2140 .proc_handler = proc_dointvec,
2143 .procname = "bootloader_type",
2144 .data = &bootloader_type,
2145 .maxlen = sizeof (int),
2147 .proc_handler = proc_dointvec,
2150 .procname = "bootloader_version",
2151 .data = &bootloader_version,
2152 .maxlen = sizeof (int),
2154 .proc_handler = proc_dointvec,
2157 .procname = "io_delay_type",
2158 .data = &io_delay_type,
2159 .maxlen = sizeof(int),
2161 .proc_handler = proc_dointvec,
2164 #if defined(CONFIG_MMU)
2166 .procname = "randomize_va_space",
2167 .data = &randomize_va_space,
2168 .maxlen = sizeof(int),
2170 .proc_handler = proc_dointvec,
2173 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2175 .procname = "spin_retry",
2176 .data = &spin_retry,
2177 .maxlen = sizeof (int),
2179 .proc_handler = proc_dointvec,
2182 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2184 .procname = "acpi_video_flags",
2185 .data = &acpi_realmode_flags,
2186 .maxlen = sizeof (unsigned long),
2188 .proc_handler = proc_doulongvec_minmax,
2191 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2193 .procname = "ignore-unaligned-usertrap",
2194 .data = &no_unaligned_warning,
2195 .maxlen = sizeof (int),
2197 .proc_handler = proc_dointvec,
2202 .procname = "unaligned-dump-stack",
2203 .data = &unaligned_dump_stack,
2204 .maxlen = sizeof (int),
2206 .proc_handler = proc_dointvec,
2209 #ifdef CONFIG_RT_MUTEXES
2211 .procname = "max_lock_depth",
2212 .data = &max_lock_depth,
2213 .maxlen = sizeof(int),
2215 .proc_handler = proc_dointvec,
2219 .procname = "poweroff_cmd",
2220 .data = &poweroff_cmd,
2221 .maxlen = POWEROFF_CMD_PATH_LEN,
2223 .proc_handler = proc_dostring,
2229 .child = key_sysctls,
2232 #ifdef CONFIG_PERF_EVENTS
2234 * User-space scripts rely on the existence of this file
2235 * as a feature check for perf_events being enabled.
2237 * So it's an ABI, do not remove!
2240 .procname = "perf_event_paranoid",
2241 .data = &sysctl_perf_event_paranoid,
2242 .maxlen = sizeof(sysctl_perf_event_paranoid),
2244 .proc_handler = proc_dointvec,
2247 .procname = "perf_event_mlock_kb",
2248 .data = &sysctl_perf_event_mlock,
2249 .maxlen = sizeof(sysctl_perf_event_mlock),
2251 .proc_handler = proc_dointvec,
2254 .procname = "perf_event_max_sample_rate",
2255 .data = &sysctl_perf_event_sample_rate,
2256 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2258 .proc_handler = perf_proc_update_handler,
2259 .extra1 = SYSCTL_ONE,
2262 .procname = "perf_cpu_time_max_percent",
2263 .data = &sysctl_perf_cpu_time_max_percent,
2264 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2266 .proc_handler = perf_cpu_time_max_percent_handler,
2267 .extra1 = SYSCTL_ZERO,
2268 .extra2 = SYSCTL_ONE_HUNDRED,
2271 .procname = "perf_event_max_stack",
2272 .data = &sysctl_perf_event_max_stack,
2273 .maxlen = sizeof(sysctl_perf_event_max_stack),
2275 .proc_handler = perf_event_max_stack_handler,
2276 .extra1 = SYSCTL_ZERO,
2277 .extra2 = (void *)&six_hundred_forty_kb,
2280 .procname = "perf_event_max_contexts_per_stack",
2281 .data = &sysctl_perf_event_max_contexts_per_stack,
2282 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2284 .proc_handler = perf_event_max_stack_handler,
2285 .extra1 = SYSCTL_ZERO,
2286 .extra2 = SYSCTL_ONE_THOUSAND,
2290 .procname = "panic_on_warn",
2291 .data = &panic_on_warn,
2292 .maxlen = sizeof(int),
2294 .proc_handler = proc_dointvec_minmax,
2295 .extra1 = SYSCTL_ZERO,
2296 .extra2 = SYSCTL_ONE,
2298 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2300 .procname = "timer_migration",
2301 .data = &sysctl_timer_migration,
2302 .maxlen = sizeof(unsigned int),
2304 .proc_handler = timer_migration_handler,
2305 .extra1 = SYSCTL_ZERO,
2306 .extra2 = SYSCTL_ONE,
2309 #ifdef CONFIG_BPF_SYSCALL
2311 .procname = "unprivileged_bpf_disabled",
2312 .data = &sysctl_unprivileged_bpf_disabled,
2313 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2315 .proc_handler = bpf_unpriv_handler,
2316 .extra1 = SYSCTL_ZERO,
2317 .extra2 = SYSCTL_TWO,
2320 .procname = "bpf_stats_enabled",
2321 .data = &bpf_stats_enabled_key.key,
2322 .maxlen = sizeof(bpf_stats_enabled_key),
2324 .proc_handler = bpf_stats_handler,
2327 #if defined(CONFIG_TREE_RCU)
2329 .procname = "panic_on_rcu_stall",
2330 .data = &sysctl_panic_on_rcu_stall,
2331 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2333 .proc_handler = proc_dointvec_minmax,
2334 .extra1 = SYSCTL_ZERO,
2335 .extra2 = SYSCTL_ONE,
2338 #if defined(CONFIG_TREE_RCU)
2340 .procname = "max_rcu_stall_to_panic",
2341 .data = &sysctl_max_rcu_stall_to_panic,
2342 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2344 .proc_handler = proc_dointvec_minmax,
2345 .extra1 = SYSCTL_ONE,
2346 .extra2 = SYSCTL_INT_MAX,
2352 static struct ctl_table vm_table[] = {
2354 .procname = "overcommit_memory",
2355 .data = &sysctl_overcommit_memory,
2356 .maxlen = sizeof(sysctl_overcommit_memory),
2358 .proc_handler = overcommit_policy_handler,
2359 .extra1 = SYSCTL_ZERO,
2360 .extra2 = SYSCTL_TWO,
2363 .procname = "panic_on_oom",
2364 .data = &sysctl_panic_on_oom,
2365 .maxlen = sizeof(sysctl_panic_on_oom),
2367 .proc_handler = proc_dointvec_minmax,
2368 .extra1 = SYSCTL_ZERO,
2369 .extra2 = SYSCTL_TWO,
2372 .procname = "oom_kill_allocating_task",
2373 .data = &sysctl_oom_kill_allocating_task,
2374 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2376 .proc_handler = proc_dointvec,
2379 .procname = "oom_dump_tasks",
2380 .data = &sysctl_oom_dump_tasks,
2381 .maxlen = sizeof(sysctl_oom_dump_tasks),
2383 .proc_handler = proc_dointvec,
2386 .procname = "overcommit_ratio",
2387 .data = &sysctl_overcommit_ratio,
2388 .maxlen = sizeof(sysctl_overcommit_ratio),
2390 .proc_handler = overcommit_ratio_handler,
2393 .procname = "overcommit_kbytes",
2394 .data = &sysctl_overcommit_kbytes,
2395 .maxlen = sizeof(sysctl_overcommit_kbytes),
2397 .proc_handler = overcommit_kbytes_handler,
2400 .procname = "page-cluster",
2401 .data = &page_cluster,
2402 .maxlen = sizeof(int),
2404 .proc_handler = proc_dointvec_minmax,
2405 .extra1 = SYSCTL_ZERO,
2408 .procname = "dirty_background_ratio",
2409 .data = &dirty_background_ratio,
2410 .maxlen = sizeof(dirty_background_ratio),
2412 .proc_handler = dirty_background_ratio_handler,
2413 .extra1 = SYSCTL_ZERO,
2414 .extra2 = SYSCTL_ONE_HUNDRED,
2417 .procname = "dirty_background_bytes",
2418 .data = &dirty_background_bytes,
2419 .maxlen = sizeof(dirty_background_bytes),
2421 .proc_handler = dirty_background_bytes_handler,
2422 .extra1 = SYSCTL_LONG_ONE,
2425 .procname = "dirty_ratio",
2426 .data = &vm_dirty_ratio,
2427 .maxlen = sizeof(vm_dirty_ratio),
2429 .proc_handler = dirty_ratio_handler,
2430 .extra1 = SYSCTL_ZERO,
2431 .extra2 = SYSCTL_ONE_HUNDRED,
2434 .procname = "dirty_bytes",
2435 .data = &vm_dirty_bytes,
2436 .maxlen = sizeof(vm_dirty_bytes),
2438 .proc_handler = dirty_bytes_handler,
2439 .extra1 = (void *)&dirty_bytes_min,
2442 .procname = "dirty_writeback_centisecs",
2443 .data = &dirty_writeback_interval,
2444 .maxlen = sizeof(dirty_writeback_interval),
2446 .proc_handler = dirty_writeback_centisecs_handler,
2449 .procname = "dirty_expire_centisecs",
2450 .data = &dirty_expire_interval,
2451 .maxlen = sizeof(dirty_expire_interval),
2453 .proc_handler = proc_dointvec_minmax,
2454 .extra1 = SYSCTL_ZERO,
2457 .procname = "dirtytime_expire_seconds",
2458 .data = &dirtytime_expire_interval,
2459 .maxlen = sizeof(dirtytime_expire_interval),
2461 .proc_handler = dirtytime_interval_handler,
2462 .extra1 = SYSCTL_ZERO,
2465 .procname = "swappiness",
2466 .data = &vm_swappiness,
2467 .maxlen = sizeof(vm_swappiness),
2469 .proc_handler = proc_dointvec_minmax,
2470 .extra1 = SYSCTL_ZERO,
2471 .extra2 = SYSCTL_TWO_HUNDRED,
2473 #ifdef CONFIG_HUGETLB_PAGE
2475 .procname = "nr_hugepages",
2477 .maxlen = sizeof(unsigned long),
2479 .proc_handler = hugetlb_sysctl_handler,
2483 .procname = "nr_hugepages_mempolicy",
2485 .maxlen = sizeof(unsigned long),
2487 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2490 .procname = "numa_stat",
2491 .data = &sysctl_vm_numa_stat,
2492 .maxlen = sizeof(int),
2494 .proc_handler = sysctl_vm_numa_stat_handler,
2495 .extra1 = SYSCTL_ZERO,
2496 .extra2 = SYSCTL_ONE,
2500 .procname = "hugetlb_shm_group",
2501 .data = &sysctl_hugetlb_shm_group,
2502 .maxlen = sizeof(gid_t),
2504 .proc_handler = proc_dointvec,
2507 .procname = "nr_overcommit_hugepages",
2509 .maxlen = sizeof(unsigned long),
2511 .proc_handler = hugetlb_overcommit_handler,
2515 .procname = "lowmem_reserve_ratio",
2516 .data = &sysctl_lowmem_reserve_ratio,
2517 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2519 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2522 .procname = "drop_caches",
2523 .data = &sysctl_drop_caches,
2524 .maxlen = sizeof(int),
2526 .proc_handler = drop_caches_sysctl_handler,
2527 .extra1 = SYSCTL_ONE,
2528 .extra2 = SYSCTL_FOUR,
2530 #ifdef CONFIG_COMPACTION
2532 .procname = "compact_memory",
2534 .maxlen = sizeof(int),
2536 .proc_handler = sysctl_compaction_handler,
2539 .procname = "compaction_proactiveness",
2540 .data = &sysctl_compaction_proactiveness,
2541 .maxlen = sizeof(sysctl_compaction_proactiveness),
2543 .proc_handler = compaction_proactiveness_sysctl_handler,
2544 .extra1 = SYSCTL_ZERO,
2545 .extra2 = SYSCTL_ONE_HUNDRED,
2548 .procname = "extfrag_threshold",
2549 .data = &sysctl_extfrag_threshold,
2550 .maxlen = sizeof(int),
2552 .proc_handler = proc_dointvec_minmax,
2553 .extra1 = SYSCTL_ZERO,
2554 .extra2 = (void *)&max_extfrag_threshold,
2557 .procname = "compact_unevictable_allowed",
2558 .data = &sysctl_compact_unevictable_allowed,
2559 .maxlen = sizeof(int),
2561 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2562 .extra1 = SYSCTL_ZERO,
2563 .extra2 = SYSCTL_ONE,
2566 #endif /* CONFIG_COMPACTION */
2568 .procname = "min_free_kbytes",
2569 .data = &min_free_kbytes,
2570 .maxlen = sizeof(min_free_kbytes),
2572 .proc_handler = min_free_kbytes_sysctl_handler,
2573 .extra1 = SYSCTL_ZERO,
2576 .procname = "watermark_boost_factor",
2577 .data = &watermark_boost_factor,
2578 .maxlen = sizeof(watermark_boost_factor),
2580 .proc_handler = proc_dointvec_minmax,
2581 .extra1 = SYSCTL_ZERO,
2584 .procname = "watermark_scale_factor",
2585 .data = &watermark_scale_factor,
2586 .maxlen = sizeof(watermark_scale_factor),
2588 .proc_handler = watermark_scale_factor_sysctl_handler,
2589 .extra1 = SYSCTL_ONE,
2590 .extra2 = SYSCTL_THREE_THOUSAND,
2593 .procname = "percpu_pagelist_high_fraction",
2594 .data = &percpu_pagelist_high_fraction,
2595 .maxlen = sizeof(percpu_pagelist_high_fraction),
2597 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2598 .extra1 = SYSCTL_ZERO,
2601 .procname = "page_lock_unfairness",
2602 .data = &sysctl_page_lock_unfairness,
2603 .maxlen = sizeof(sysctl_page_lock_unfairness),
2605 .proc_handler = proc_dointvec_minmax,
2606 .extra1 = SYSCTL_ZERO,
2610 .procname = "max_map_count",
2611 .data = &sysctl_max_map_count,
2612 .maxlen = sizeof(sysctl_max_map_count),
2614 .proc_handler = proc_dointvec_minmax,
2615 .extra1 = SYSCTL_ZERO,
2619 .procname = "nr_trim_pages",
2620 .data = &sysctl_nr_trim_pages,
2621 .maxlen = sizeof(sysctl_nr_trim_pages),
2623 .proc_handler = proc_dointvec_minmax,
2624 .extra1 = SYSCTL_ZERO,
2628 .procname = "laptop_mode",
2629 .data = &laptop_mode,
2630 .maxlen = sizeof(laptop_mode),
2632 .proc_handler = proc_dointvec_jiffies,
2635 .procname = "vfs_cache_pressure",
2636 .data = &sysctl_vfs_cache_pressure,
2637 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2639 .proc_handler = proc_dointvec_minmax,
2640 .extra1 = SYSCTL_ZERO,
2642 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2643 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2645 .procname = "legacy_va_layout",
2646 .data = &sysctl_legacy_va_layout,
2647 .maxlen = sizeof(sysctl_legacy_va_layout),
2649 .proc_handler = proc_dointvec_minmax,
2650 .extra1 = SYSCTL_ZERO,
2655 .procname = "zone_reclaim_mode",
2656 .data = &node_reclaim_mode,
2657 .maxlen = sizeof(node_reclaim_mode),
2659 .proc_handler = proc_dointvec_minmax,
2660 .extra1 = SYSCTL_ZERO,
2663 .procname = "min_unmapped_ratio",
2664 .data = &sysctl_min_unmapped_ratio,
2665 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2667 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2668 .extra1 = SYSCTL_ZERO,
2669 .extra2 = SYSCTL_ONE_HUNDRED,
2672 .procname = "min_slab_ratio",
2673 .data = &sysctl_min_slab_ratio,
2674 .maxlen = sizeof(sysctl_min_slab_ratio),
2676 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2677 .extra1 = SYSCTL_ZERO,
2678 .extra2 = SYSCTL_ONE_HUNDRED,
2683 .procname = "stat_interval",
2684 .data = &sysctl_stat_interval,
2685 .maxlen = sizeof(sysctl_stat_interval),
2687 .proc_handler = proc_dointvec_jiffies,
2690 .procname = "stat_refresh",
2694 .proc_handler = vmstat_refresh,
2699 .procname = "mmap_min_addr",
2700 .data = &dac_mmap_min_addr,
2701 .maxlen = sizeof(unsigned long),
2703 .proc_handler = mmap_min_addr_handler,
2708 .procname = "numa_zonelist_order",
2709 .data = &numa_zonelist_order,
2710 .maxlen = NUMA_ZONELIST_ORDER_LEN,
2712 .proc_handler = numa_zonelist_order_handler,
2715 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
2716 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
2718 .procname = "vdso_enabled",
2719 #ifdef CONFIG_X86_32
2720 .data = &vdso32_enabled,
2721 .maxlen = sizeof(vdso32_enabled),
2723 .data = &vdso_enabled,
2724 .maxlen = sizeof(vdso_enabled),
2727 .proc_handler = proc_dointvec,
2728 .extra1 = SYSCTL_ZERO,
2731 #ifdef CONFIG_HIGHMEM
2733 .procname = "highmem_is_dirtyable",
2734 .data = &vm_highmem_is_dirtyable,
2735 .maxlen = sizeof(vm_highmem_is_dirtyable),
2737 .proc_handler = proc_dointvec_minmax,
2738 .extra1 = SYSCTL_ZERO,
2739 .extra2 = SYSCTL_ONE,
2742 #ifdef CONFIG_MEMORY_FAILURE
2744 .procname = "memory_failure_early_kill",
2745 .data = &sysctl_memory_failure_early_kill,
2746 .maxlen = sizeof(sysctl_memory_failure_early_kill),
2748 .proc_handler = proc_dointvec_minmax,
2749 .extra1 = SYSCTL_ZERO,
2750 .extra2 = SYSCTL_ONE,
2753 .procname = "memory_failure_recovery",
2754 .data = &sysctl_memory_failure_recovery,
2755 .maxlen = sizeof(sysctl_memory_failure_recovery),
2757 .proc_handler = proc_dointvec_minmax,
2758 .extra1 = SYSCTL_ZERO,
2759 .extra2 = SYSCTL_ONE,
2763 .procname = "user_reserve_kbytes",
2764 .data = &sysctl_user_reserve_kbytes,
2765 .maxlen = sizeof(sysctl_user_reserve_kbytes),
2767 .proc_handler = proc_doulongvec_minmax,
2770 .procname = "admin_reserve_kbytes",
2771 .data = &sysctl_admin_reserve_kbytes,
2772 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
2774 .proc_handler = proc_doulongvec_minmax,
2776 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
2778 .procname = "mmap_rnd_bits",
2779 .data = &mmap_rnd_bits,
2780 .maxlen = sizeof(mmap_rnd_bits),
2782 .proc_handler = proc_dointvec_minmax,
2783 .extra1 = (void *)&mmap_rnd_bits_min,
2784 .extra2 = (void *)&mmap_rnd_bits_max,
2787 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
2789 .procname = "mmap_rnd_compat_bits",
2790 .data = &mmap_rnd_compat_bits,
2791 .maxlen = sizeof(mmap_rnd_compat_bits),
2793 .proc_handler = proc_dointvec_minmax,
2794 .extra1 = (void *)&mmap_rnd_compat_bits_min,
2795 .extra2 = (void *)&mmap_rnd_compat_bits_max,
2798 #ifdef CONFIG_USERFAULTFD
2800 .procname = "unprivileged_userfaultfd",
2801 .data = &sysctl_unprivileged_userfaultfd,
2802 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
2804 .proc_handler = proc_dointvec_minmax,
2805 .extra1 = SYSCTL_ZERO,
2806 .extra2 = SYSCTL_ONE,
2812 static struct ctl_table debug_table[] = {
2813 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
2815 .procname = "exception-trace",
2816 .data = &show_unhandled_signals,
2817 .maxlen = sizeof(int),
2819 .proc_handler = proc_dointvec
2822 #if defined(CONFIG_OPTPROBES)
2824 .procname = "kprobes-optimization",
2825 .data = &sysctl_kprobes_optimization,
2826 .maxlen = sizeof(int),
2828 .proc_handler = proc_kprobes_optimization_handler,
2829 .extra1 = SYSCTL_ZERO,
2830 .extra2 = SYSCTL_ONE,
2836 static struct ctl_table dev_table[] = {
2840 DECLARE_SYSCTL_BASE(kernel, kern_table);
2841 DECLARE_SYSCTL_BASE(vm, vm_table);
2842 DECLARE_SYSCTL_BASE(debug, debug_table);
2843 DECLARE_SYSCTL_BASE(dev, dev_table);
2845 int __init sysctl_init_bases(void)
2847 register_sysctl_base(kernel);
2848 register_sysctl_base(vm);
2849 register_sysctl_base(debug);
2850 register_sysctl_base(dev);
2854 #endif /* CONFIG_SYSCTL */
2856 * No sense putting this after each symbol definition, twice,
2857 * exception granted :-)
2859 EXPORT_SYMBOL(proc_dobool);
2860 EXPORT_SYMBOL(proc_dointvec);
2861 EXPORT_SYMBOL(proc_douintvec);
2862 EXPORT_SYMBOL(proc_dointvec_jiffies);
2863 EXPORT_SYMBOL(proc_dointvec_minmax);
2864 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
2865 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2866 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2867 EXPORT_SYMBOL(proc_dostring);
2868 EXPORT_SYMBOL(proc_doulongvec_minmax);
2869 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2870 EXPORT_SYMBOL(proc_do_large_bitmap);