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/panic.h>
31 #include <linux/printk.h>
32 #include <linux/proc_fs.h>
33 #include <linux/security.h>
34 #include <linux/ctype.h>
35 #include <linux/kmemleak.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/dnotify.h>
53 #include <linux/syscalls.h>
54 #include <linux/vmstat.h>
55 #include <linux/nfs_fs.h>
56 #include <linux/acpi.h>
57 #include <linux/reboot.h>
58 #include <linux/ftrace.h>
59 #include <linux/perf_event.h>
60 #include <linux/kprobes.h>
61 #include <linux/pipe_fs_i.h>
62 #include <linux/oom.h>
63 #include <linux/kmod.h>
64 #include <linux/capability.h>
65 #include <linux/binfmts.h>
66 #include <linux/sched/sysctl.h>
67 #include <linux/sched/coredump.h>
68 #include <linux/kexec.h>
69 #include <linux/bpf.h>
70 #include <linux/mount.h>
71 #include <linux/userfaultfd_k.h>
72 #include <linux/coredump.h>
73 #include <linux/latencytop.h>
74 #include <linux/pid.h>
75 #include <linux/delayacct.h>
77 #include "../lib/kstrtox.h"
79 #include <linux/uaccess.h>
80 #include <asm/processor.h>
84 #include <asm/stacktrace.h>
88 #include <asm/setup.h>
90 #ifdef CONFIG_BSD_PROCESS_ACCT
91 #include <linux/acct.h>
93 #ifdef CONFIG_RT_MUTEXES
94 #include <linux/rtmutex.h>
96 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
97 #include <linux/lockdep.h>
99 #ifdef CONFIG_CHR_DEV_SG
102 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
103 #include <linux/stackleak.h>
105 #ifdef CONFIG_LOCKUP_DETECTOR
106 #include <linux/nmi.h>
109 #if defined(CONFIG_SYSCTL)
111 /* Constants used for minimum and maximum */
112 #ifdef CONFIG_LOCKUP_DETECTOR
113 static int sixty = 60;
116 static int __maybe_unused neg_one = -1;
117 static int __maybe_unused two = 2;
118 static int __maybe_unused four = 4;
119 static unsigned long zero_ul;
120 static unsigned long one_ul = 1;
121 static unsigned long long_max = LONG_MAX;
122 static int one_hundred = 100;
123 static int two_hundred = 200;
124 static int one_thousand = 1000;
126 static int ten_thousand = 10000;
128 #ifdef CONFIG_PERF_EVENTS
129 static int six_hundred_forty_kb = 640 * 1024;
132 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
133 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
135 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
136 static int maxolduid = 65535;
137 static int minolduid;
139 static int ngroups_max = NGROUPS_MAX;
140 static const int cap_last_cap = CAP_LAST_CAP;
143 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
144 * and hung_task_check_interval_secs
146 #ifdef CONFIG_DETECT_HUNG_TASK
147 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150 #ifdef CONFIG_INOTIFY_USER
151 #include <linux/inotify.h>
153 #ifdef CONFIG_FANOTIFY
154 #include <linux/fanotify.h>
157 #ifdef CONFIG_PROC_SYSCTL
160 * enum sysctl_writes_mode - supported sysctl write modes
162 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
163 * to be written, and multiple writes on the same sysctl file descriptor
164 * will rewrite the sysctl value, regardless of file position. No warning
165 * is issued when the initial position is not 0.
166 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
168 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
169 * file position 0 and the value must be fully contained in the buffer
170 * sent to the write syscall. If dealing with strings respect the file
171 * position, but restrict this to the max length of the buffer, anything
172 * passed the max length will be ignored. Multiple writes will append
175 * These write modes control how current file position affects the behavior of
176 * updating sysctl values through the proc interface on each write.
178 enum sysctl_writes_mode {
179 SYSCTL_WRITES_LEGACY = -1,
180 SYSCTL_WRITES_WARN = 0,
181 SYSCTL_WRITES_STRICT = 1,
184 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
185 #endif /* CONFIG_PROC_SYSCTL */
187 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
188 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
189 int sysctl_legacy_va_layout;
192 #ifdef CONFIG_COMPACTION
193 static int min_extfrag_threshold;
194 static int max_extfrag_threshold = 1000;
197 #endif /* CONFIG_SYSCTL */
199 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
200 static int bpf_stats_handler(struct ctl_table *table, int write,
201 void *buffer, size_t *lenp, loff_t *ppos)
203 struct static_key *key = (struct static_key *)table->data;
204 static int saved_val;
206 struct ctl_table tmp = {
208 .maxlen = sizeof(val),
210 .extra1 = SYSCTL_ZERO,
211 .extra2 = SYSCTL_ONE,
214 if (write && !capable(CAP_SYS_ADMIN))
217 mutex_lock(&bpf_stats_enabled_mutex);
219 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
220 if (write && !ret && val != saved_val) {
222 static_key_slow_inc(key);
224 static_key_slow_dec(key);
227 mutex_unlock(&bpf_stats_enabled_mutex);
231 void __weak unpriv_ebpf_notify(int new_state)
235 static int bpf_unpriv_handler(struct ctl_table *table, int write,
236 void *buffer, size_t *lenp, loff_t *ppos)
238 int ret, unpriv_enable = *(int *)table->data;
239 bool locked_state = unpriv_enable == 1;
240 struct ctl_table tmp = *table;
242 if (write && !capable(CAP_SYS_ADMIN))
245 tmp.data = &unpriv_enable;
246 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
248 if (locked_state && unpriv_enable != 1)
250 *(int *)table->data = unpriv_enable;
253 unpriv_ebpf_notify(unpriv_enable);
257 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
263 #ifdef CONFIG_PROC_SYSCTL
265 static int _proc_do_string(char *data, int maxlen, int write,
266 char *buffer, size_t *lenp, loff_t *ppos)
271 if (!data || !maxlen || !*lenp) {
277 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
278 /* Only continue writes not past the end of buffer. */
280 if (len > maxlen - 1)
287 /* Start writing from beginning of buffer. */
293 while ((p - buffer) < *lenp && len < maxlen - 1) {
295 if (c == 0 || c == '\n')
316 memcpy(buffer, data, len);
327 static void warn_sysctl_write(struct ctl_table *table)
329 pr_warn_once("%s wrote to %s when file position was not 0!\n"
330 "This will not be supported in the future. To silence this\n"
331 "warning, set kernel.sysctl_writes_strict = -1\n",
332 current->comm, table->procname);
336 * proc_first_pos_non_zero_ignore - check if first position is allowed
337 * @ppos: file position
338 * @table: the sysctl table
340 * Returns true if the first position is non-zero and the sysctl_writes_strict
341 * mode indicates this is not allowed for numeric input types. String proc
342 * handlers can ignore the return value.
344 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
345 struct ctl_table *table)
350 switch (sysctl_writes_strict) {
351 case SYSCTL_WRITES_STRICT:
353 case SYSCTL_WRITES_WARN:
354 warn_sysctl_write(table);
362 * proc_dostring - read a string sysctl
363 * @table: the sysctl table
364 * @write: %TRUE if this is a write to the sysctl file
365 * @buffer: the user buffer
366 * @lenp: the size of the user buffer
367 * @ppos: file position
369 * Reads/writes a string from/to the user buffer. If the kernel
370 * buffer provided is not large enough to hold the string, the
371 * string is truncated. The copied string is %NULL-terminated.
372 * If the string is being read by the user process, it is copied
373 * and a newline '\n' is added. It is truncated if the buffer is
376 * Returns 0 on success.
378 int proc_dostring(struct ctl_table *table, int write,
379 void *buffer, size_t *lenp, loff_t *ppos)
382 proc_first_pos_non_zero_ignore(ppos, table);
384 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
388 static size_t proc_skip_spaces(char **buf)
391 char *tmp = skip_spaces(*buf);
397 static void proc_skip_char(char **buf, size_t *size, const char v)
408 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
411 * @cp: kernel buffer containing the string to parse
412 * @endp: pointer to store the trailing characters
413 * @base: the base to use
414 * @res: where the parsed integer will be stored
416 * In case of success 0 is returned and @res will contain the parsed integer,
417 * @endp will hold any trailing characters.
418 * This function will fail the parse on overflow. If there wasn't an overflow
419 * the function will defer the decision what characters count as invalid to the
422 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
425 unsigned long long result;
428 cp = _parse_integer_fixup_radix(cp, &base);
429 rv = _parse_integer(cp, base, &result);
430 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
438 *res = (unsigned long)result;
444 * proc_get_long - reads an ASCII formatted integer from a user buffer
446 * @buf: a kernel buffer
447 * @size: size of the kernel buffer
448 * @val: this is where the number will be stored
449 * @neg: set to %TRUE if number is negative
450 * @perm_tr: a vector which contains the allowed trailers
451 * @perm_tr_len: size of the perm_tr vector
452 * @tr: pointer to store the trailer character
454 * In case of success %0 is returned and @buf and @size are updated with
455 * the amount of bytes read. If @tr is non-NULL and a trailing
456 * character exists (size is non-zero after returning from this
457 * function), @tr is updated with the trailing character.
459 static int proc_get_long(char **buf, size_t *size,
460 unsigned long *val, bool *neg,
461 const char *perm_tr, unsigned perm_tr_len, char *tr)
464 char *p, tmp[TMPBUFLEN];
470 if (len > TMPBUFLEN - 1)
473 memcpy(tmp, *buf, len);
477 if (*p == '-' && *size > 1) {
485 if (strtoul_lenient(p, &p, 0, val))
490 /* We don't know if the next char is whitespace thus we may accept
491 * invalid integers (e.g. 1234...a) or two integers instead of one
492 * (e.g. 123...1). So lets not allow such large numbers. */
493 if (len == TMPBUFLEN - 1)
496 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
499 if (tr && (len < *size))
509 * proc_put_long - converts an integer to a decimal ASCII formatted string
511 * @buf: the user buffer
512 * @size: the size of the user buffer
513 * @val: the integer to be converted
514 * @neg: sign of the number, %TRUE for negative
516 * In case of success @buf and @size are updated with the amount of bytes
519 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
522 char tmp[TMPBUFLEN], *p = tmp;
524 sprintf(p, "%s%lu", neg ? "-" : "", val);
528 memcpy(*buf, tmp, len);
534 static void proc_put_char(void **buf, size_t *size, char c)
537 char **buffer = (char **)buf;
546 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
548 int write, void *data)
551 *(bool *)valp = *lvalp;
553 int val = *(bool *)valp;
555 *lvalp = (unsigned long)val;
561 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
563 int write, void *data)
567 if (*lvalp > (unsigned long) INT_MAX + 1)
569 WRITE_ONCE(*valp, -*lvalp);
571 if (*lvalp > (unsigned long) INT_MAX)
573 WRITE_ONCE(*valp, *lvalp);
576 int val = READ_ONCE(*valp);
579 *lvalp = -(unsigned long)val;
582 *lvalp = (unsigned long)val;
588 static int do_proc_douintvec_conv(unsigned long *lvalp,
590 int write, void *data)
593 if (*lvalp > UINT_MAX)
595 WRITE_ONCE(*valp, *lvalp);
597 unsigned int val = READ_ONCE(*valp);
598 *lvalp = (unsigned long)val;
603 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
605 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
606 int write, void *buffer,
607 size_t *lenp, loff_t *ppos,
608 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
609 int write, void *data),
612 int *i, vleft, first = 1, err = 0;
616 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
621 i = (int *) tbl_data;
622 vleft = table->maxlen / sizeof(*i);
626 conv = do_proc_dointvec_conv;
629 if (proc_first_pos_non_zero_ignore(ppos, table))
632 if (left > PAGE_SIZE - 1)
633 left = PAGE_SIZE - 1;
637 for (; left && vleft--; i++, first=0) {
642 left -= proc_skip_spaces(&p);
646 err = proc_get_long(&p, &left, &lval, &neg,
648 sizeof(proc_wspace_sep), NULL);
651 if (conv(&neg, &lval, i, 1, data)) {
656 if (conv(&neg, &lval, i, 0, data)) {
661 proc_put_char(&buffer, &left, '\t');
662 proc_put_long(&buffer, &left, lval, neg);
666 if (!write && !first && left && !err)
667 proc_put_char(&buffer, &left, '\n');
668 if (write && !err && left)
669 left -= proc_skip_spaces(&p);
671 return err ? : -EINVAL;
678 static int do_proc_dointvec(struct ctl_table *table, int write,
679 void *buffer, size_t *lenp, loff_t *ppos,
680 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
681 int write, void *data),
684 return __do_proc_dointvec(table->data, table, write,
685 buffer, lenp, ppos, conv, data);
688 static int do_proc_douintvec_w(unsigned int *tbl_data,
689 struct ctl_table *table,
691 size_t *lenp, loff_t *ppos,
692 int (*conv)(unsigned long *lvalp,
694 int write, void *data),
705 if (proc_first_pos_non_zero_ignore(ppos, table))
708 if (left > PAGE_SIZE - 1)
709 left = PAGE_SIZE - 1;
711 left -= proc_skip_spaces(&p);
717 err = proc_get_long(&p, &left, &lval, &neg,
719 sizeof(proc_wspace_sep), NULL);
725 if (conv(&lval, tbl_data, 1, data)) {
731 left -= proc_skip_spaces(&p);
739 /* This is in keeping with old __do_proc_dointvec() */
745 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
746 size_t *lenp, loff_t *ppos,
747 int (*conv)(unsigned long *lvalp,
749 int write, void *data),
758 if (conv(&lval, tbl_data, 0, data)) {
763 proc_put_long(&buffer, &left, lval, false);
767 proc_put_char(&buffer, &left, '\n');
776 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
777 int write, void *buffer,
778 size_t *lenp, loff_t *ppos,
779 int (*conv)(unsigned long *lvalp,
781 int write, void *data),
784 unsigned int *i, vleft;
786 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
791 i = (unsigned int *) tbl_data;
792 vleft = table->maxlen / sizeof(*i);
795 * Arrays are not supported, keep this simple. *Do not* add
804 conv = do_proc_douintvec_conv;
807 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
809 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
812 static int do_proc_douintvec(struct ctl_table *table, int write,
813 void *buffer, size_t *lenp, loff_t *ppos,
814 int (*conv)(unsigned long *lvalp,
816 int write, void *data),
819 return __do_proc_douintvec(table->data, table, write,
820 buffer, lenp, ppos, conv, data);
824 * proc_dobool - read/write a bool
825 * @table: the sysctl table
826 * @write: %TRUE if this is a write to the sysctl file
827 * @buffer: the user buffer
828 * @lenp: the size of the user buffer
829 * @ppos: file position
831 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
832 * values from/to the user buffer, treated as an ASCII string.
834 * Returns 0 on success.
836 int proc_dobool(struct ctl_table *table, int write, void *buffer,
837 size_t *lenp, loff_t *ppos)
839 return do_proc_dointvec(table, write, buffer, lenp, ppos,
840 do_proc_dobool_conv, NULL);
844 * proc_dointvec - read a vector of integers
845 * @table: the sysctl table
846 * @write: %TRUE if this is a write to the sysctl file
847 * @buffer: the user buffer
848 * @lenp: the size of the user buffer
849 * @ppos: file position
851 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
852 * values from/to the user buffer, treated as an ASCII string.
854 * Returns 0 on success.
856 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
857 size_t *lenp, loff_t *ppos)
859 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
862 #ifdef CONFIG_COMPACTION
863 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
864 int write, void *buffer, size_t *lenp, loff_t *ppos)
868 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
869 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
871 old = *(int *)table->data;
872 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
875 if (old != *(int *)table->data)
876 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
877 table->procname, current->comm,
878 task_pid_nr(current));
884 * proc_douintvec - read a vector of unsigned integers
885 * @table: the sysctl table
886 * @write: %TRUE if this is a write to the sysctl file
887 * @buffer: the user buffer
888 * @lenp: the size of the user buffer
889 * @ppos: file position
891 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
892 * values from/to the user buffer, treated as an ASCII string.
894 * Returns 0 on success.
896 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
897 size_t *lenp, loff_t *ppos)
899 return do_proc_douintvec(table, write, buffer, lenp, ppos,
900 do_proc_douintvec_conv, NULL);
904 * Taint values can only be increased
905 * This means we can safely use a temporary.
907 static int proc_taint(struct ctl_table *table, int write,
908 void *buffer, size_t *lenp, loff_t *ppos)
911 unsigned long tmptaint = get_taint();
914 if (write && !capable(CAP_SYS_ADMIN))
919 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
927 * If we are relying on panic_on_taint not producing
928 * false positives due to userspace input, bail out
929 * before setting the requested taint flags.
931 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
935 * Poor man's atomic or. Not worth adding a primitive
936 * to everyone's atomic.h for this
938 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
939 if ((1UL << i) & tmptaint)
940 add_taint(i, LOCKDEP_STILL_OK);
947 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
948 void *buffer, size_t *lenp, loff_t *ppos)
950 if (write && !capable(CAP_SYS_ADMIN))
953 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
958 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
959 * @min: pointer to minimum allowable value
960 * @max: pointer to maximum allowable value
962 * The do_proc_dointvec_minmax_conv_param structure provides the
963 * minimum and maximum values for doing range checking for those sysctl
964 * parameters that use the proc_dointvec_minmax() handler.
966 struct do_proc_dointvec_minmax_conv_param {
971 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
973 int write, void *data)
976 struct do_proc_dointvec_minmax_conv_param *param = data;
978 * If writing, first do so via a temporary local int so we can
979 * bounds-check it before touching *valp.
981 int *ip = write ? &tmp : valp;
983 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
988 if ((param->min && *param->min > tmp) ||
989 (param->max && *param->max < tmp))
991 WRITE_ONCE(*valp, tmp);
998 * proc_dointvec_minmax - read a vector of integers with min/max values
999 * @table: the sysctl table
1000 * @write: %TRUE if this is a write to the sysctl file
1001 * @buffer: the user buffer
1002 * @lenp: the size of the user buffer
1003 * @ppos: file position
1005 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1006 * values from/to the user buffer, treated as an ASCII string.
1008 * This routine will ensure the values are within the range specified by
1009 * table->extra1 (min) and table->extra2 (max).
1011 * Returns 0 on success or -EINVAL on write when the range check fails.
1013 int proc_dointvec_minmax(struct ctl_table *table, int write,
1014 void *buffer, size_t *lenp, loff_t *ppos)
1016 struct do_proc_dointvec_minmax_conv_param param = {
1017 .min = (int *) table->extra1,
1018 .max = (int *) table->extra2,
1020 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1021 do_proc_dointvec_minmax_conv, ¶m);
1025 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1026 * @min: pointer to minimum allowable value
1027 * @max: pointer to maximum allowable value
1029 * The do_proc_douintvec_minmax_conv_param structure provides the
1030 * minimum and maximum values for doing range checking for those sysctl
1031 * parameters that use the proc_douintvec_minmax() handler.
1033 struct do_proc_douintvec_minmax_conv_param {
1038 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1040 int write, void *data)
1044 struct do_proc_douintvec_minmax_conv_param *param = data;
1045 /* write via temporary local uint for bounds-checking */
1046 unsigned int *up = write ? &tmp : valp;
1048 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1053 if ((param->min && *param->min > tmp) ||
1054 (param->max && *param->max < tmp))
1064 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1065 * @table: the sysctl table
1066 * @write: %TRUE if this is a write to the sysctl file
1067 * @buffer: the user buffer
1068 * @lenp: the size of the user buffer
1069 * @ppos: file position
1071 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1072 * values from/to the user buffer, treated as an ASCII string. Negative
1073 * strings are not allowed.
1075 * This routine will ensure the values are within the range specified by
1076 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1077 * check for UINT_MAX to avoid having to support wrap around uses from
1080 * Returns 0 on success or -ERANGE on write when the range check fails.
1082 int proc_douintvec_minmax(struct ctl_table *table, int write,
1083 void *buffer, size_t *lenp, loff_t *ppos)
1085 struct do_proc_douintvec_minmax_conv_param param = {
1086 .min = (unsigned int *) table->extra1,
1087 .max = (unsigned int *) table->extra2,
1089 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1090 do_proc_douintvec_minmax_conv, ¶m);
1094 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1095 * @table: the sysctl table
1096 * @write: %TRUE if this is a write to the sysctl file
1097 * @buffer: the user buffer
1098 * @lenp: the size of the user buffer
1099 * @ppos: file position
1101 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1102 * values from/to the user buffer, treated as an ASCII string. Negative
1103 * strings are not allowed.
1105 * This routine will ensure the values are within the range specified by
1106 * table->extra1 (min) and table->extra2 (max).
1108 * Returns 0 on success or an error on write when the range check fails.
1110 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1111 void *buffer, size_t *lenp, loff_t *ppos)
1113 struct ctl_table tmp;
1114 unsigned int min = 0, max = 255U, val;
1115 u8 *data = table->data;
1116 struct do_proc_douintvec_minmax_conv_param param = {
1122 /* Do not support arrays yet. */
1123 if (table->maxlen != sizeof(u8))
1126 if (table->extra1) {
1127 min = *(unsigned int *) table->extra1;
1131 if (table->extra2) {
1132 max = *(unsigned int *) table->extra2;
1139 tmp.maxlen = sizeof(val);
1142 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1143 do_proc_douintvec_minmax_conv, ¶m);
1150 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1152 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1154 int write, void *data)
1159 val = round_pipe_size(*lvalp);
1165 unsigned int val = *valp;
1166 *lvalp = (unsigned long) val;
1172 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1173 void *buffer, size_t *lenp, loff_t *ppos)
1175 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1176 do_proc_dopipe_max_size_conv, NULL);
1179 static void validate_coredump_safety(void)
1181 #ifdef CONFIG_COREDUMP
1182 if (suid_dumpable == SUID_DUMP_ROOT &&
1183 core_pattern[0] != '/' && core_pattern[0] != '|') {
1185 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1186 "Pipe handler or fully qualified core dump path required.\n"
1187 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1193 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1194 void *buffer, size_t *lenp, loff_t *ppos)
1196 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1198 validate_coredump_safety();
1202 #ifdef CONFIG_COREDUMP
1203 static int proc_dostring_coredump(struct ctl_table *table, int write,
1204 void *buffer, size_t *lenp, loff_t *ppos)
1206 int error = proc_dostring(table, write, buffer, lenp, ppos);
1208 validate_coredump_safety();
1213 #ifdef CONFIG_MAGIC_SYSRQ
1214 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1215 void *buffer, size_t *lenp, loff_t *ppos)
1221 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1222 lenp, ppos, NULL, NULL);
1227 sysrq_toggle_support(tmp);
1233 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1234 int write, void *buffer, size_t *lenp, loff_t *ppos,
1235 unsigned long convmul, unsigned long convdiv)
1237 unsigned long *i, *min, *max;
1238 int vleft, first = 1, err = 0;
1242 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1247 i = (unsigned long *) data;
1248 min = (unsigned long *) table->extra1;
1249 max = (unsigned long *) table->extra2;
1250 vleft = table->maxlen / sizeof(unsigned long);
1254 if (proc_first_pos_non_zero_ignore(ppos, table))
1257 if (left > PAGE_SIZE - 1)
1258 left = PAGE_SIZE - 1;
1262 for (; left && vleft--; i++, first = 0) {
1268 left -= proc_skip_spaces(&p);
1272 err = proc_get_long(&p, &left, &val, &neg,
1274 sizeof(proc_wspace_sep), NULL);
1279 val = convmul * val / convdiv;
1280 if ((min && val < *min) || (max && val > *max)) {
1286 val = convdiv * (*i) / convmul;
1288 proc_put_char(&buffer, &left, '\t');
1289 proc_put_long(&buffer, &left, val, false);
1293 if (!write && !first && left && !err)
1294 proc_put_char(&buffer, &left, '\n');
1296 left -= proc_skip_spaces(&p);
1298 return err ? : -EINVAL;
1305 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1306 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1307 unsigned long convdiv)
1309 return __do_proc_doulongvec_minmax(table->data, table, write,
1310 buffer, lenp, ppos, convmul, convdiv);
1314 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1315 * @table: the sysctl table
1316 * @write: %TRUE if this is a write to the sysctl file
1317 * @buffer: the user buffer
1318 * @lenp: the size of the user buffer
1319 * @ppos: file position
1321 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1322 * values from/to the user buffer, treated as an ASCII string.
1324 * This routine will ensure the values are within the range specified by
1325 * table->extra1 (min) and table->extra2 (max).
1327 * Returns 0 on success.
1329 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1330 void *buffer, size_t *lenp, loff_t *ppos)
1332 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1336 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1337 * @table: the sysctl table
1338 * @write: %TRUE if this is a write to the sysctl file
1339 * @buffer: the user buffer
1340 * @lenp: the size of the user buffer
1341 * @ppos: file position
1343 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1344 * values from/to the user buffer, treated as an ASCII string. The values
1345 * are treated as milliseconds, and converted to jiffies when they are stored.
1347 * This routine will ensure the values are within the range specified by
1348 * table->extra1 (min) and table->extra2 (max).
1350 * Returns 0 on success.
1352 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1353 void *buffer, size_t *lenp, loff_t *ppos)
1355 return do_proc_doulongvec_minmax(table, write, buffer,
1356 lenp, ppos, HZ, 1000l);
1360 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1362 int write, void *data)
1365 if (*lvalp > INT_MAX / HZ)
1367 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1373 lval = -(unsigned long)val;
1376 lval = (unsigned long)val;
1383 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1385 int write, void *data)
1388 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1390 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1396 lval = -(unsigned long)val;
1399 lval = (unsigned long)val;
1401 *lvalp = jiffies_to_clock_t(lval);
1406 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1408 int write, void *data)
1411 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1421 lval = -(unsigned long)val;
1424 lval = (unsigned long)val;
1426 *lvalp = jiffies_to_msecs(lval);
1432 * proc_dointvec_jiffies - read a vector of integers as seconds
1433 * @table: the sysctl table
1434 * @write: %TRUE if this is a write to the sysctl file
1435 * @buffer: the user buffer
1436 * @lenp: the size of the user buffer
1437 * @ppos: file position
1439 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1440 * values from/to the user buffer, treated as an ASCII string.
1441 * The values read are assumed to be in seconds, and are converted into
1444 * Returns 0 on success.
1446 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1447 void *buffer, size_t *lenp, loff_t *ppos)
1449 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1450 do_proc_dointvec_jiffies_conv,NULL);
1454 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1455 * @table: the sysctl table
1456 * @write: %TRUE if this is a write to the sysctl file
1457 * @buffer: the user buffer
1458 * @lenp: the size of the user buffer
1459 * @ppos: pointer to the file position
1461 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1462 * values from/to the user buffer, treated as an ASCII string.
1463 * The values read are assumed to be in 1/USER_HZ seconds, and
1464 * are converted into jiffies.
1466 * Returns 0 on success.
1468 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1469 void *buffer, size_t *lenp, loff_t *ppos)
1471 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1472 do_proc_dointvec_userhz_jiffies_conv,NULL);
1476 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1477 * @table: the sysctl table
1478 * @write: %TRUE if this is a write to the sysctl file
1479 * @buffer: the user buffer
1480 * @lenp: the size of the user buffer
1481 * @ppos: file position
1482 * @ppos: the current position in the file
1484 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1485 * values from/to the user buffer, treated as an ASCII string.
1486 * The values read are assumed to be in 1/1000 seconds, and
1487 * are converted into jiffies.
1489 * Returns 0 on success.
1491 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1492 size_t *lenp, loff_t *ppos)
1494 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1495 do_proc_dointvec_ms_jiffies_conv, NULL);
1498 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1499 size_t *lenp, loff_t *ppos)
1501 struct pid *new_pid;
1505 tmp = pid_vnr(cad_pid);
1507 r = __do_proc_dointvec(&tmp, table, write, buffer,
1508 lenp, ppos, NULL, NULL);
1512 new_pid = find_get_pid(tmp);
1516 put_pid(xchg(&cad_pid, new_pid));
1521 * proc_do_large_bitmap - read/write from/to a large bitmap
1522 * @table: the sysctl table
1523 * @write: %TRUE if this is a write to the sysctl file
1524 * @buffer: the user buffer
1525 * @lenp: the size of the user buffer
1526 * @ppos: file position
1528 * The bitmap is stored at table->data and the bitmap length (in bits)
1531 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1532 * large bitmaps may be represented in a compact manner. Writing into
1533 * the file will clear the bitmap then update it with the given input.
1535 * Returns 0 on success.
1537 int proc_do_large_bitmap(struct ctl_table *table, int write,
1538 void *buffer, size_t *lenp, loff_t *ppos)
1541 size_t left = *lenp;
1542 unsigned long bitmap_len = table->maxlen;
1543 unsigned long *bitmap = *(unsigned long **) table->data;
1544 unsigned long *tmp_bitmap = NULL;
1545 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1547 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1556 if (left > PAGE_SIZE - 1) {
1557 left = PAGE_SIZE - 1;
1558 /* How much of the buffer we'll skip this pass */
1559 skipped = *lenp - left;
1562 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1565 proc_skip_char(&p, &left, '\n');
1566 while (!err && left) {
1567 unsigned long val_a, val_b;
1571 /* In case we stop parsing mid-number, we can reset */
1573 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1576 * If we consumed the entirety of a truncated buffer or
1577 * only one char is left (may be a "-"), then stop here,
1578 * reset, & come back for more.
1580 if ((left <= 1) && skipped) {
1587 if (val_a >= bitmap_len || neg) {
1599 err = proc_get_long(&p, &left, &val_b,
1600 &neg, tr_b, sizeof(tr_b),
1603 * If we consumed all of a truncated buffer or
1604 * then stop here, reset, & come back for more.
1606 if (!left && skipped) {
1613 if (val_b >= bitmap_len || neg ||
1624 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1625 proc_skip_char(&p, &left, '\n');
1629 unsigned long bit_a, bit_b = 0;
1633 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1634 if (bit_a >= bitmap_len)
1636 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1640 proc_put_char(&buffer, &left, ',');
1641 proc_put_long(&buffer, &left, bit_a, false);
1642 if (bit_a != bit_b) {
1643 proc_put_char(&buffer, &left, '-');
1644 proc_put_long(&buffer, &left, bit_b, false);
1649 proc_put_char(&buffer, &left, '\n');
1655 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1657 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1663 bitmap_free(tmp_bitmap);
1667 #else /* CONFIG_PROC_SYSCTL */
1669 int proc_dostring(struct ctl_table *table, int write,
1670 void *buffer, size_t *lenp, loff_t *ppos)
1675 int proc_dobool(struct ctl_table *table, int write,
1676 void *buffer, size_t *lenp, loff_t *ppos)
1681 int proc_dointvec(struct ctl_table *table, int write,
1682 void *buffer, size_t *lenp, loff_t *ppos)
1687 int proc_douintvec(struct ctl_table *table, int write,
1688 void *buffer, size_t *lenp, loff_t *ppos)
1693 int proc_dointvec_minmax(struct ctl_table *table, int write,
1694 void *buffer, size_t *lenp, loff_t *ppos)
1699 int proc_douintvec_minmax(struct ctl_table *table, int write,
1700 void *buffer, size_t *lenp, loff_t *ppos)
1705 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1706 void *buffer, size_t *lenp, loff_t *ppos)
1711 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1712 void *buffer, size_t *lenp, loff_t *ppos)
1717 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1718 void *buffer, size_t *lenp, loff_t *ppos)
1723 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1724 void *buffer, size_t *lenp, loff_t *ppos)
1729 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1730 void *buffer, size_t *lenp, loff_t *ppos)
1735 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1736 void *buffer, size_t *lenp, loff_t *ppos)
1741 int proc_do_large_bitmap(struct ctl_table *table, int write,
1742 void *buffer, size_t *lenp, loff_t *ppos)
1747 #endif /* CONFIG_PROC_SYSCTL */
1749 #if defined(CONFIG_SYSCTL)
1750 int proc_do_static_key(struct ctl_table *table, int write,
1751 void *buffer, size_t *lenp, loff_t *ppos)
1753 struct static_key *key = (struct static_key *)table->data;
1754 static DEFINE_MUTEX(static_key_mutex);
1756 struct ctl_table tmp = {
1758 .maxlen = sizeof(val),
1759 .mode = table->mode,
1760 .extra1 = SYSCTL_ZERO,
1761 .extra2 = SYSCTL_ONE,
1764 if (write && !capable(CAP_SYS_ADMIN))
1767 mutex_lock(&static_key_mutex);
1768 val = static_key_enabled(key);
1769 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1770 if (write && !ret) {
1772 static_key_enable(key);
1774 static_key_disable(key);
1776 mutex_unlock(&static_key_mutex);
1780 static struct ctl_table kern_table[] = {
1782 .procname = "sched_child_runs_first",
1783 .data = &sysctl_sched_child_runs_first,
1784 .maxlen = sizeof(unsigned int),
1786 .proc_handler = proc_dointvec,
1788 #ifdef CONFIG_SCHEDSTATS
1790 .procname = "sched_schedstats",
1792 .maxlen = sizeof(unsigned int),
1794 .proc_handler = sysctl_schedstats,
1795 .extra1 = SYSCTL_ZERO,
1796 .extra2 = SYSCTL_ONE,
1798 #endif /* CONFIG_SCHEDSTATS */
1799 #ifdef CONFIG_TASK_DELAY_ACCT
1801 .procname = "task_delayacct",
1803 .maxlen = sizeof(unsigned int),
1805 .proc_handler = sysctl_delayacct,
1806 .extra1 = SYSCTL_ZERO,
1807 .extra2 = SYSCTL_ONE,
1809 #endif /* CONFIG_TASK_DELAY_ACCT */
1810 #ifdef CONFIG_NUMA_BALANCING
1812 .procname = "numa_balancing",
1813 .data = NULL, /* filled in by handler */
1814 .maxlen = sizeof(unsigned int),
1816 .proc_handler = sysctl_numa_balancing,
1817 .extra1 = SYSCTL_ZERO,
1818 .extra2 = SYSCTL_ONE,
1820 #endif /* CONFIG_NUMA_BALANCING */
1822 .procname = "sched_rt_period_us",
1823 .data = &sysctl_sched_rt_period,
1824 .maxlen = sizeof(unsigned int),
1826 .proc_handler = sched_rt_handler,
1829 .procname = "sched_rt_runtime_us",
1830 .data = &sysctl_sched_rt_runtime,
1831 .maxlen = sizeof(int),
1833 .proc_handler = sched_rt_handler,
1836 .procname = "sched_deadline_period_max_us",
1837 .data = &sysctl_sched_dl_period_max,
1838 .maxlen = sizeof(unsigned int),
1840 .proc_handler = proc_dointvec,
1843 .procname = "sched_deadline_period_min_us",
1844 .data = &sysctl_sched_dl_period_min,
1845 .maxlen = sizeof(unsigned int),
1847 .proc_handler = proc_dointvec,
1850 .procname = "sched_rr_timeslice_ms",
1851 .data = &sysctl_sched_rr_timeslice,
1852 .maxlen = sizeof(int),
1854 .proc_handler = sched_rr_handler,
1856 #ifdef CONFIG_UCLAMP_TASK
1858 .procname = "sched_util_clamp_min",
1859 .data = &sysctl_sched_uclamp_util_min,
1860 .maxlen = sizeof(unsigned int),
1862 .proc_handler = sysctl_sched_uclamp_handler,
1865 .procname = "sched_util_clamp_max",
1866 .data = &sysctl_sched_uclamp_util_max,
1867 .maxlen = sizeof(unsigned int),
1869 .proc_handler = sysctl_sched_uclamp_handler,
1872 .procname = "sched_util_clamp_min_rt_default",
1873 .data = &sysctl_sched_uclamp_util_min_rt_default,
1874 .maxlen = sizeof(unsigned int),
1876 .proc_handler = sysctl_sched_uclamp_handler,
1879 #ifdef CONFIG_SCHED_AUTOGROUP
1881 .procname = "sched_autogroup_enabled",
1882 .data = &sysctl_sched_autogroup_enabled,
1883 .maxlen = sizeof(unsigned int),
1885 .proc_handler = proc_dointvec_minmax,
1886 .extra1 = SYSCTL_ZERO,
1887 .extra2 = SYSCTL_ONE,
1890 #ifdef CONFIG_CFS_BANDWIDTH
1892 .procname = "sched_cfs_bandwidth_slice_us",
1893 .data = &sysctl_sched_cfs_bandwidth_slice,
1894 .maxlen = sizeof(unsigned int),
1896 .proc_handler = proc_dointvec_minmax,
1897 .extra1 = SYSCTL_ONE,
1900 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1902 .procname = "sched_energy_aware",
1903 .data = &sysctl_sched_energy_aware,
1904 .maxlen = sizeof(unsigned int),
1906 .proc_handler = sched_energy_aware_handler,
1907 .extra1 = SYSCTL_ZERO,
1908 .extra2 = SYSCTL_ONE,
1911 #ifdef CONFIG_PROVE_LOCKING
1913 .procname = "prove_locking",
1914 .data = &prove_locking,
1915 .maxlen = sizeof(int),
1917 .proc_handler = proc_dointvec,
1920 #ifdef CONFIG_LOCK_STAT
1922 .procname = "lock_stat",
1924 .maxlen = sizeof(int),
1926 .proc_handler = proc_dointvec,
1930 .procname = "panic",
1931 .data = &panic_timeout,
1932 .maxlen = sizeof(int),
1934 .proc_handler = proc_dointvec,
1936 #ifdef CONFIG_COREDUMP
1938 .procname = "core_uses_pid",
1939 .data = &core_uses_pid,
1940 .maxlen = sizeof(int),
1942 .proc_handler = proc_dointvec,
1945 .procname = "core_pattern",
1946 .data = core_pattern,
1947 .maxlen = CORENAME_MAX_SIZE,
1949 .proc_handler = proc_dostring_coredump,
1952 .procname = "core_pipe_limit",
1953 .data = &core_pipe_limit,
1954 .maxlen = sizeof(unsigned int),
1956 .proc_handler = proc_dointvec,
1959 #ifdef CONFIG_PROC_SYSCTL
1961 .procname = "tainted",
1962 .maxlen = sizeof(long),
1964 .proc_handler = proc_taint,
1967 .procname = "sysctl_writes_strict",
1968 .data = &sysctl_writes_strict,
1969 .maxlen = sizeof(int),
1971 .proc_handler = proc_dointvec_minmax,
1973 .extra2 = SYSCTL_ONE,
1976 #ifdef CONFIG_LATENCYTOP
1978 .procname = "latencytop",
1979 .data = &latencytop_enabled,
1980 .maxlen = sizeof(int),
1982 .proc_handler = sysctl_latencytop,
1985 #ifdef CONFIG_BLK_DEV_INITRD
1987 .procname = "real-root-dev",
1988 .data = &real_root_dev,
1989 .maxlen = sizeof(int),
1991 .proc_handler = proc_dointvec,
1995 .procname = "print-fatal-signals",
1996 .data = &print_fatal_signals,
1997 .maxlen = sizeof(int),
1999 .proc_handler = proc_dointvec,
2003 .procname = "reboot-cmd",
2004 .data = reboot_command,
2007 .proc_handler = proc_dostring,
2010 .procname = "stop-a",
2011 .data = &stop_a_enabled,
2012 .maxlen = sizeof (int),
2014 .proc_handler = proc_dointvec,
2017 .procname = "scons-poweroff",
2018 .data = &scons_pwroff,
2019 .maxlen = sizeof (int),
2021 .proc_handler = proc_dointvec,
2024 #ifdef CONFIG_SPARC64
2026 .procname = "tsb-ratio",
2027 .data = &sysctl_tsb_ratio,
2028 .maxlen = sizeof (int),
2030 .proc_handler = proc_dointvec,
2033 #ifdef CONFIG_PARISC
2035 .procname = "soft-power",
2036 .data = &pwrsw_enabled,
2037 .maxlen = sizeof (int),
2039 .proc_handler = proc_dointvec,
2042 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2044 .procname = "unaligned-trap",
2045 .data = &unaligned_enabled,
2046 .maxlen = sizeof (int),
2048 .proc_handler = proc_dointvec,
2052 .procname = "ctrl-alt-del",
2054 .maxlen = sizeof(int),
2056 .proc_handler = proc_dointvec,
2058 #ifdef CONFIG_FUNCTION_TRACER
2060 .procname = "ftrace_enabled",
2061 .data = &ftrace_enabled,
2062 .maxlen = sizeof(int),
2064 .proc_handler = ftrace_enable_sysctl,
2067 #ifdef CONFIG_STACK_TRACER
2069 .procname = "stack_tracer_enabled",
2070 .data = &stack_tracer_enabled,
2071 .maxlen = sizeof(int),
2073 .proc_handler = stack_trace_sysctl,
2076 #ifdef CONFIG_TRACING
2078 .procname = "ftrace_dump_on_oops",
2079 .data = &ftrace_dump_on_oops,
2080 .maxlen = sizeof(int),
2082 .proc_handler = proc_dointvec,
2085 .procname = "traceoff_on_warning",
2086 .data = &__disable_trace_on_warning,
2087 .maxlen = sizeof(__disable_trace_on_warning),
2089 .proc_handler = proc_dointvec,
2092 .procname = "tracepoint_printk",
2093 .data = &tracepoint_printk,
2094 .maxlen = sizeof(tracepoint_printk),
2096 .proc_handler = tracepoint_printk_sysctl,
2099 #ifdef CONFIG_KEXEC_CORE
2101 .procname = "kexec_load_disabled",
2102 .data = &kexec_load_disabled,
2103 .maxlen = sizeof(int),
2105 /* only handle a transition from default "0" to "1" */
2106 .proc_handler = proc_dointvec_minmax,
2107 .extra1 = SYSCTL_ONE,
2108 .extra2 = SYSCTL_ONE,
2111 #ifdef CONFIG_MODULES
2113 .procname = "modprobe",
2114 .data = &modprobe_path,
2115 .maxlen = KMOD_PATH_LEN,
2117 .proc_handler = proc_dostring,
2120 .procname = "modules_disabled",
2121 .data = &modules_disabled,
2122 .maxlen = sizeof(int),
2124 /* only handle a transition from default "0" to "1" */
2125 .proc_handler = proc_dointvec_minmax,
2126 .extra1 = SYSCTL_ONE,
2127 .extra2 = SYSCTL_ONE,
2130 #ifdef CONFIG_UEVENT_HELPER
2132 .procname = "hotplug",
2133 .data = &uevent_helper,
2134 .maxlen = UEVENT_HELPER_PATH_LEN,
2136 .proc_handler = proc_dostring,
2139 #ifdef CONFIG_CHR_DEV_SG
2141 .procname = "sg-big-buff",
2142 .data = &sg_big_buff,
2143 .maxlen = sizeof (int),
2145 .proc_handler = proc_dointvec,
2148 #ifdef CONFIG_BSD_PROCESS_ACCT
2152 .maxlen = 3*sizeof(int),
2154 .proc_handler = proc_dointvec,
2157 #ifdef CONFIG_MAGIC_SYSRQ
2159 .procname = "sysrq",
2161 .maxlen = sizeof (int),
2163 .proc_handler = sysrq_sysctl_handler,
2166 #ifdef CONFIG_PROC_SYSCTL
2168 .procname = "cad_pid",
2170 .maxlen = sizeof (int),
2172 .proc_handler = proc_do_cad_pid,
2176 .procname = "threads-max",
2178 .maxlen = sizeof(int),
2180 .proc_handler = sysctl_max_threads,
2183 .procname = "random",
2185 .child = random_table,
2188 .procname = "usermodehelper",
2190 .child = usermodehelper_table,
2192 #ifdef CONFIG_FW_LOADER_USER_HELPER
2194 .procname = "firmware_config",
2196 .child = firmware_config_table,
2200 .procname = "overflowuid",
2201 .data = &overflowuid,
2202 .maxlen = sizeof(int),
2204 .proc_handler = proc_dointvec_minmax,
2205 .extra1 = &minolduid,
2206 .extra2 = &maxolduid,
2209 .procname = "overflowgid",
2210 .data = &overflowgid,
2211 .maxlen = sizeof(int),
2213 .proc_handler = proc_dointvec_minmax,
2214 .extra1 = &minolduid,
2215 .extra2 = &maxolduid,
2219 .procname = "userprocess_debug",
2220 .data = &show_unhandled_signals,
2221 .maxlen = sizeof(int),
2223 .proc_handler = proc_dointvec,
2228 .procname = "oops_all_cpu_backtrace",
2229 .data = &sysctl_oops_all_cpu_backtrace,
2230 .maxlen = sizeof(int),
2232 .proc_handler = proc_dointvec_minmax,
2233 .extra1 = SYSCTL_ZERO,
2234 .extra2 = SYSCTL_ONE,
2236 #endif /* CONFIG_SMP */
2238 .procname = "pid_max",
2240 .maxlen = sizeof (int),
2242 .proc_handler = proc_dointvec_minmax,
2243 .extra1 = &pid_max_min,
2244 .extra2 = &pid_max_max,
2247 .procname = "panic_on_oops",
2248 .data = &panic_on_oops,
2249 .maxlen = sizeof(int),
2251 .proc_handler = proc_dointvec,
2254 .procname = "panic_print",
2255 .data = &panic_print,
2256 .maxlen = sizeof(unsigned long),
2258 .proc_handler = proc_doulongvec_minmax,
2260 #if defined CONFIG_PRINTK
2262 .procname = "printk",
2263 .data = &console_loglevel,
2264 .maxlen = 4*sizeof(int),
2266 .proc_handler = proc_dointvec,
2269 .procname = "printk_ratelimit",
2270 .data = &printk_ratelimit_state.interval,
2271 .maxlen = sizeof(int),
2273 .proc_handler = proc_dointvec_jiffies,
2276 .procname = "printk_ratelimit_burst",
2277 .data = &printk_ratelimit_state.burst,
2278 .maxlen = sizeof(int),
2280 .proc_handler = proc_dointvec,
2283 .procname = "printk_delay",
2284 .data = &printk_delay_msec,
2285 .maxlen = sizeof(int),
2287 .proc_handler = proc_dointvec_minmax,
2288 .extra1 = SYSCTL_ZERO,
2289 .extra2 = &ten_thousand,
2292 .procname = "printk_devkmsg",
2293 .data = devkmsg_log_str,
2294 .maxlen = DEVKMSG_STR_MAX_SIZE,
2296 .proc_handler = devkmsg_sysctl_set_loglvl,
2299 .procname = "dmesg_restrict",
2300 .data = &dmesg_restrict,
2301 .maxlen = sizeof(int),
2303 .proc_handler = proc_dointvec_minmax_sysadmin,
2304 .extra1 = SYSCTL_ZERO,
2305 .extra2 = SYSCTL_ONE,
2308 .procname = "kptr_restrict",
2309 .data = &kptr_restrict,
2310 .maxlen = sizeof(int),
2312 .proc_handler = proc_dointvec_minmax_sysadmin,
2313 .extra1 = SYSCTL_ZERO,
2318 .procname = "ngroups_max",
2319 .data = &ngroups_max,
2320 .maxlen = sizeof (int),
2322 .proc_handler = proc_dointvec,
2325 .procname = "cap_last_cap",
2326 .data = (void *)&cap_last_cap,
2327 .maxlen = sizeof(int),
2329 .proc_handler = proc_dointvec,
2331 #if defined(CONFIG_LOCKUP_DETECTOR)
2333 .procname = "watchdog",
2334 .data = &watchdog_user_enabled,
2335 .maxlen = sizeof(int),
2337 .proc_handler = proc_watchdog,
2338 .extra1 = SYSCTL_ZERO,
2339 .extra2 = SYSCTL_ONE,
2342 .procname = "watchdog_thresh",
2343 .data = &watchdog_thresh,
2344 .maxlen = sizeof(int),
2346 .proc_handler = proc_watchdog_thresh,
2347 .extra1 = SYSCTL_ZERO,
2351 .procname = "nmi_watchdog",
2352 .data = &nmi_watchdog_user_enabled,
2353 .maxlen = sizeof(int),
2354 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2355 .proc_handler = proc_nmi_watchdog,
2356 .extra1 = SYSCTL_ZERO,
2357 .extra2 = SYSCTL_ONE,
2360 .procname = "watchdog_cpumask",
2361 .data = &watchdog_cpumask_bits,
2364 .proc_handler = proc_watchdog_cpumask,
2366 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2368 .procname = "soft_watchdog",
2369 .data = &soft_watchdog_user_enabled,
2370 .maxlen = sizeof(int),
2372 .proc_handler = proc_soft_watchdog,
2373 .extra1 = SYSCTL_ZERO,
2374 .extra2 = SYSCTL_ONE,
2377 .procname = "softlockup_panic",
2378 .data = &softlockup_panic,
2379 .maxlen = sizeof(int),
2381 .proc_handler = proc_dointvec_minmax,
2382 .extra1 = SYSCTL_ZERO,
2383 .extra2 = SYSCTL_ONE,
2387 .procname = "softlockup_all_cpu_backtrace",
2388 .data = &sysctl_softlockup_all_cpu_backtrace,
2389 .maxlen = sizeof(int),
2391 .proc_handler = proc_dointvec_minmax,
2392 .extra1 = SYSCTL_ZERO,
2393 .extra2 = SYSCTL_ONE,
2395 #endif /* CONFIG_SMP */
2397 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2399 .procname = "hardlockup_panic",
2400 .data = &hardlockup_panic,
2401 .maxlen = sizeof(int),
2403 .proc_handler = proc_dointvec_minmax,
2404 .extra1 = SYSCTL_ZERO,
2405 .extra2 = SYSCTL_ONE,
2409 .procname = "hardlockup_all_cpu_backtrace",
2410 .data = &sysctl_hardlockup_all_cpu_backtrace,
2411 .maxlen = sizeof(int),
2413 .proc_handler = proc_dointvec_minmax,
2414 .extra1 = SYSCTL_ZERO,
2415 .extra2 = SYSCTL_ONE,
2417 #endif /* CONFIG_SMP */
2421 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2423 .procname = "unknown_nmi_panic",
2424 .data = &unknown_nmi_panic,
2425 .maxlen = sizeof (int),
2427 .proc_handler = proc_dointvec,
2431 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2432 defined(CONFIG_DEBUG_STACKOVERFLOW)
2434 .procname = "panic_on_stackoverflow",
2435 .data = &sysctl_panic_on_stackoverflow,
2436 .maxlen = sizeof(int),
2438 .proc_handler = proc_dointvec,
2441 #if defined(CONFIG_X86)
2443 .procname = "panic_on_unrecovered_nmi",
2444 .data = &panic_on_unrecovered_nmi,
2445 .maxlen = sizeof(int),
2447 .proc_handler = proc_dointvec,
2450 .procname = "panic_on_io_nmi",
2451 .data = &panic_on_io_nmi,
2452 .maxlen = sizeof(int),
2454 .proc_handler = proc_dointvec,
2457 .procname = "bootloader_type",
2458 .data = &bootloader_type,
2459 .maxlen = sizeof (int),
2461 .proc_handler = proc_dointvec,
2464 .procname = "bootloader_version",
2465 .data = &bootloader_version,
2466 .maxlen = sizeof (int),
2468 .proc_handler = proc_dointvec,
2471 .procname = "io_delay_type",
2472 .data = &io_delay_type,
2473 .maxlen = sizeof(int),
2475 .proc_handler = proc_dointvec,
2478 #if defined(CONFIG_MMU)
2480 .procname = "randomize_va_space",
2481 .data = &randomize_va_space,
2482 .maxlen = sizeof(int),
2484 .proc_handler = proc_dointvec,
2487 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2489 .procname = "spin_retry",
2490 .data = &spin_retry,
2491 .maxlen = sizeof (int),
2493 .proc_handler = proc_dointvec,
2496 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2498 .procname = "acpi_video_flags",
2499 .data = &acpi_realmode_flags,
2500 .maxlen = sizeof (unsigned long),
2502 .proc_handler = proc_doulongvec_minmax,
2505 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2507 .procname = "ignore-unaligned-usertrap",
2508 .data = &no_unaligned_warning,
2509 .maxlen = sizeof (int),
2511 .proc_handler = proc_dointvec,
2516 .procname = "unaligned-dump-stack",
2517 .data = &unaligned_dump_stack,
2518 .maxlen = sizeof (int),
2520 .proc_handler = proc_dointvec,
2523 #ifdef CONFIG_DETECT_HUNG_TASK
2526 .procname = "hung_task_all_cpu_backtrace",
2527 .data = &sysctl_hung_task_all_cpu_backtrace,
2528 .maxlen = sizeof(int),
2530 .proc_handler = proc_dointvec_minmax,
2531 .extra1 = SYSCTL_ZERO,
2532 .extra2 = SYSCTL_ONE,
2534 #endif /* CONFIG_SMP */
2536 .procname = "hung_task_panic",
2537 .data = &sysctl_hung_task_panic,
2538 .maxlen = sizeof(int),
2540 .proc_handler = proc_dointvec_minmax,
2541 .extra1 = SYSCTL_ZERO,
2542 .extra2 = SYSCTL_ONE,
2545 .procname = "hung_task_check_count",
2546 .data = &sysctl_hung_task_check_count,
2547 .maxlen = sizeof(int),
2549 .proc_handler = proc_dointvec_minmax,
2550 .extra1 = SYSCTL_ZERO,
2553 .procname = "hung_task_timeout_secs",
2554 .data = &sysctl_hung_task_timeout_secs,
2555 .maxlen = sizeof(unsigned long),
2557 .proc_handler = proc_dohung_task_timeout_secs,
2558 .extra2 = &hung_task_timeout_max,
2561 .procname = "hung_task_check_interval_secs",
2562 .data = &sysctl_hung_task_check_interval_secs,
2563 .maxlen = sizeof(unsigned long),
2565 .proc_handler = proc_dohung_task_timeout_secs,
2566 .extra2 = &hung_task_timeout_max,
2569 .procname = "hung_task_warnings",
2570 .data = &sysctl_hung_task_warnings,
2571 .maxlen = sizeof(int),
2573 .proc_handler = proc_dointvec_minmax,
2577 #ifdef CONFIG_RT_MUTEXES
2579 .procname = "max_lock_depth",
2580 .data = &max_lock_depth,
2581 .maxlen = sizeof(int),
2583 .proc_handler = proc_dointvec,
2587 .procname = "poweroff_cmd",
2588 .data = &poweroff_cmd,
2589 .maxlen = POWEROFF_CMD_PATH_LEN,
2591 .proc_handler = proc_dostring,
2597 .child = key_sysctls,
2600 #ifdef CONFIG_PERF_EVENTS
2602 * User-space scripts rely on the existence of this file
2603 * as a feature check for perf_events being enabled.
2605 * So it's an ABI, do not remove!
2608 .procname = "perf_event_paranoid",
2609 .data = &sysctl_perf_event_paranoid,
2610 .maxlen = sizeof(sysctl_perf_event_paranoid),
2612 .proc_handler = proc_dointvec,
2615 .procname = "perf_event_mlock_kb",
2616 .data = &sysctl_perf_event_mlock,
2617 .maxlen = sizeof(sysctl_perf_event_mlock),
2619 .proc_handler = proc_dointvec,
2622 .procname = "perf_event_max_sample_rate",
2623 .data = &sysctl_perf_event_sample_rate,
2624 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2626 .proc_handler = perf_proc_update_handler,
2627 .extra1 = SYSCTL_ONE,
2630 .procname = "perf_cpu_time_max_percent",
2631 .data = &sysctl_perf_cpu_time_max_percent,
2632 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2634 .proc_handler = perf_cpu_time_max_percent_handler,
2635 .extra1 = SYSCTL_ZERO,
2636 .extra2 = &one_hundred,
2639 .procname = "perf_event_max_stack",
2640 .data = &sysctl_perf_event_max_stack,
2641 .maxlen = sizeof(sysctl_perf_event_max_stack),
2643 .proc_handler = perf_event_max_stack_handler,
2644 .extra1 = SYSCTL_ZERO,
2645 .extra2 = &six_hundred_forty_kb,
2648 .procname = "perf_event_max_contexts_per_stack",
2649 .data = &sysctl_perf_event_max_contexts_per_stack,
2650 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2652 .proc_handler = perf_event_max_stack_handler,
2653 .extra1 = SYSCTL_ZERO,
2654 .extra2 = &one_thousand,
2658 .procname = "panic_on_warn",
2659 .data = &panic_on_warn,
2660 .maxlen = sizeof(int),
2662 .proc_handler = proc_dointvec_minmax,
2663 .extra1 = SYSCTL_ZERO,
2664 .extra2 = SYSCTL_ONE,
2666 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2668 .procname = "timer_migration",
2669 .data = &sysctl_timer_migration,
2670 .maxlen = sizeof(unsigned int),
2672 .proc_handler = timer_migration_handler,
2673 .extra1 = SYSCTL_ZERO,
2674 .extra2 = SYSCTL_ONE,
2677 #ifdef CONFIG_BPF_SYSCALL
2679 .procname = "unprivileged_bpf_disabled",
2680 .data = &sysctl_unprivileged_bpf_disabled,
2681 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2683 .proc_handler = bpf_unpriv_handler,
2684 .extra1 = SYSCTL_ZERO,
2688 .procname = "bpf_stats_enabled",
2689 .data = &bpf_stats_enabled_key.key,
2690 .maxlen = sizeof(bpf_stats_enabled_key),
2692 .proc_handler = bpf_stats_handler,
2695 #if defined(CONFIG_TREE_RCU)
2697 .procname = "panic_on_rcu_stall",
2698 .data = &sysctl_panic_on_rcu_stall,
2699 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2701 .proc_handler = proc_dointvec_minmax,
2702 .extra1 = SYSCTL_ZERO,
2703 .extra2 = SYSCTL_ONE,
2706 #if defined(CONFIG_TREE_RCU)
2708 .procname = "max_rcu_stall_to_panic",
2709 .data = &sysctl_max_rcu_stall_to_panic,
2710 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2712 .proc_handler = proc_dointvec_minmax,
2713 .extra1 = SYSCTL_ONE,
2714 .extra2 = SYSCTL_INT_MAX,
2717 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2719 .procname = "stack_erasing",
2721 .maxlen = sizeof(int),
2723 .proc_handler = stack_erasing_sysctl,
2724 .extra1 = SYSCTL_ZERO,
2725 .extra2 = SYSCTL_ONE,
2731 static struct ctl_table vm_table[] = {
2733 .procname = "overcommit_memory",
2734 .data = &sysctl_overcommit_memory,
2735 .maxlen = sizeof(sysctl_overcommit_memory),
2737 .proc_handler = overcommit_policy_handler,
2738 .extra1 = SYSCTL_ZERO,
2742 .procname = "panic_on_oom",
2743 .data = &sysctl_panic_on_oom,
2744 .maxlen = sizeof(sysctl_panic_on_oom),
2746 .proc_handler = proc_dointvec_minmax,
2747 .extra1 = SYSCTL_ZERO,
2751 .procname = "oom_kill_allocating_task",
2752 .data = &sysctl_oom_kill_allocating_task,
2753 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2755 .proc_handler = proc_dointvec,
2758 .procname = "oom_dump_tasks",
2759 .data = &sysctl_oom_dump_tasks,
2760 .maxlen = sizeof(sysctl_oom_dump_tasks),
2762 .proc_handler = proc_dointvec,
2765 .procname = "overcommit_ratio",
2766 .data = &sysctl_overcommit_ratio,
2767 .maxlen = sizeof(sysctl_overcommit_ratio),
2769 .proc_handler = overcommit_ratio_handler,
2772 .procname = "overcommit_kbytes",
2773 .data = &sysctl_overcommit_kbytes,
2774 .maxlen = sizeof(sysctl_overcommit_kbytes),
2776 .proc_handler = overcommit_kbytes_handler,
2779 .procname = "page-cluster",
2780 .data = &page_cluster,
2781 .maxlen = sizeof(int),
2783 .proc_handler = proc_dointvec_minmax,
2784 .extra1 = SYSCTL_ZERO,
2787 .procname = "dirty_background_ratio",
2788 .data = &dirty_background_ratio,
2789 .maxlen = sizeof(dirty_background_ratio),
2791 .proc_handler = dirty_background_ratio_handler,
2792 .extra1 = SYSCTL_ZERO,
2793 .extra2 = &one_hundred,
2796 .procname = "dirty_background_bytes",
2797 .data = &dirty_background_bytes,
2798 .maxlen = sizeof(dirty_background_bytes),
2800 .proc_handler = dirty_background_bytes_handler,
2804 .procname = "dirty_ratio",
2805 .data = &vm_dirty_ratio,
2806 .maxlen = sizeof(vm_dirty_ratio),
2808 .proc_handler = dirty_ratio_handler,
2809 .extra1 = SYSCTL_ZERO,
2810 .extra2 = &one_hundred,
2813 .procname = "dirty_bytes",
2814 .data = &vm_dirty_bytes,
2815 .maxlen = sizeof(vm_dirty_bytes),
2817 .proc_handler = dirty_bytes_handler,
2818 .extra1 = &dirty_bytes_min,
2821 .procname = "dirty_writeback_centisecs",
2822 .data = &dirty_writeback_interval,
2823 .maxlen = sizeof(dirty_writeback_interval),
2825 .proc_handler = dirty_writeback_centisecs_handler,
2828 .procname = "dirty_expire_centisecs",
2829 .data = &dirty_expire_interval,
2830 .maxlen = sizeof(dirty_expire_interval),
2832 .proc_handler = proc_dointvec_minmax,
2833 .extra1 = SYSCTL_ZERO,
2836 .procname = "dirtytime_expire_seconds",
2837 .data = &dirtytime_expire_interval,
2838 .maxlen = sizeof(dirtytime_expire_interval),
2840 .proc_handler = dirtytime_interval_handler,
2841 .extra1 = SYSCTL_ZERO,
2844 .procname = "swappiness",
2845 .data = &vm_swappiness,
2846 .maxlen = sizeof(vm_swappiness),
2848 .proc_handler = proc_dointvec_minmax,
2849 .extra1 = SYSCTL_ZERO,
2850 .extra2 = &two_hundred,
2852 #ifdef CONFIG_HUGETLB_PAGE
2854 .procname = "nr_hugepages",
2856 .maxlen = sizeof(unsigned long),
2858 .proc_handler = hugetlb_sysctl_handler,
2862 .procname = "nr_hugepages_mempolicy",
2864 .maxlen = sizeof(unsigned long),
2866 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2869 .procname = "numa_stat",
2870 .data = &sysctl_vm_numa_stat,
2871 .maxlen = sizeof(int),
2873 .proc_handler = sysctl_vm_numa_stat_handler,
2874 .extra1 = SYSCTL_ZERO,
2875 .extra2 = SYSCTL_ONE,
2879 .procname = "hugetlb_shm_group",
2880 .data = &sysctl_hugetlb_shm_group,
2881 .maxlen = sizeof(gid_t),
2883 .proc_handler = proc_dointvec,
2886 .procname = "nr_overcommit_hugepages",
2888 .maxlen = sizeof(unsigned long),
2890 .proc_handler = hugetlb_overcommit_handler,
2894 .procname = "lowmem_reserve_ratio",
2895 .data = &sysctl_lowmem_reserve_ratio,
2896 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2898 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2901 .procname = "drop_caches",
2902 .data = &sysctl_drop_caches,
2903 .maxlen = sizeof(int),
2905 .proc_handler = drop_caches_sysctl_handler,
2906 .extra1 = SYSCTL_ONE,
2909 #ifdef CONFIG_COMPACTION
2911 .procname = "compact_memory",
2913 .maxlen = sizeof(int),
2915 .proc_handler = sysctl_compaction_handler,
2918 .procname = "compaction_proactiveness",
2919 .data = &sysctl_compaction_proactiveness,
2920 .maxlen = sizeof(sysctl_compaction_proactiveness),
2922 .proc_handler = compaction_proactiveness_sysctl_handler,
2923 .extra1 = SYSCTL_ZERO,
2924 .extra2 = &one_hundred,
2927 .procname = "extfrag_threshold",
2928 .data = &sysctl_extfrag_threshold,
2929 .maxlen = sizeof(int),
2931 .proc_handler = proc_dointvec_minmax,
2932 .extra1 = &min_extfrag_threshold,
2933 .extra2 = &max_extfrag_threshold,
2936 .procname = "compact_unevictable_allowed",
2937 .data = &sysctl_compact_unevictable_allowed,
2938 .maxlen = sizeof(int),
2940 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2941 .extra1 = SYSCTL_ZERO,
2942 .extra2 = SYSCTL_ONE,
2945 #endif /* CONFIG_COMPACTION */
2947 .procname = "min_free_kbytes",
2948 .data = &min_free_kbytes,
2949 .maxlen = sizeof(min_free_kbytes),
2951 .proc_handler = min_free_kbytes_sysctl_handler,
2952 .extra1 = SYSCTL_ZERO,
2955 .procname = "watermark_boost_factor",
2956 .data = &watermark_boost_factor,
2957 .maxlen = sizeof(watermark_boost_factor),
2959 .proc_handler = proc_dointvec_minmax,
2960 .extra1 = SYSCTL_ZERO,
2963 .procname = "watermark_scale_factor",
2964 .data = &watermark_scale_factor,
2965 .maxlen = sizeof(watermark_scale_factor),
2967 .proc_handler = watermark_scale_factor_sysctl_handler,
2968 .extra1 = SYSCTL_ONE,
2969 .extra2 = &one_thousand,
2972 .procname = "percpu_pagelist_high_fraction",
2973 .data = &percpu_pagelist_high_fraction,
2974 .maxlen = sizeof(percpu_pagelist_high_fraction),
2976 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2977 .extra1 = SYSCTL_ZERO,
2980 .procname = "page_lock_unfairness",
2981 .data = &sysctl_page_lock_unfairness,
2982 .maxlen = sizeof(sysctl_page_lock_unfairness),
2984 .proc_handler = proc_dointvec_minmax,
2985 .extra1 = SYSCTL_ZERO,
2989 .procname = "max_map_count",
2990 .data = &sysctl_max_map_count,
2991 .maxlen = sizeof(sysctl_max_map_count),
2993 .proc_handler = proc_dointvec_minmax,
2994 .extra1 = SYSCTL_ZERO,
2998 .procname = "nr_trim_pages",
2999 .data = &sysctl_nr_trim_pages,
3000 .maxlen = sizeof(sysctl_nr_trim_pages),
3002 .proc_handler = proc_dointvec_minmax,
3003 .extra1 = SYSCTL_ZERO,
3007 .procname = "laptop_mode",
3008 .data = &laptop_mode,
3009 .maxlen = sizeof(laptop_mode),
3011 .proc_handler = proc_dointvec_jiffies,
3014 .procname = "vfs_cache_pressure",
3015 .data = &sysctl_vfs_cache_pressure,
3016 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3018 .proc_handler = proc_dointvec_minmax,
3019 .extra1 = SYSCTL_ZERO,
3021 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3022 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3024 .procname = "legacy_va_layout",
3025 .data = &sysctl_legacy_va_layout,
3026 .maxlen = sizeof(sysctl_legacy_va_layout),
3028 .proc_handler = proc_dointvec_minmax,
3029 .extra1 = SYSCTL_ZERO,
3034 .procname = "zone_reclaim_mode",
3035 .data = &node_reclaim_mode,
3036 .maxlen = sizeof(node_reclaim_mode),
3038 .proc_handler = proc_dointvec_minmax,
3039 .extra1 = SYSCTL_ZERO,
3042 .procname = "min_unmapped_ratio",
3043 .data = &sysctl_min_unmapped_ratio,
3044 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3046 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3047 .extra1 = SYSCTL_ZERO,
3048 .extra2 = &one_hundred,
3051 .procname = "min_slab_ratio",
3052 .data = &sysctl_min_slab_ratio,
3053 .maxlen = sizeof(sysctl_min_slab_ratio),
3055 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3056 .extra1 = SYSCTL_ZERO,
3057 .extra2 = &one_hundred,
3062 .procname = "stat_interval",
3063 .data = &sysctl_stat_interval,
3064 .maxlen = sizeof(sysctl_stat_interval),
3066 .proc_handler = proc_dointvec_jiffies,
3069 .procname = "stat_refresh",
3073 .proc_handler = vmstat_refresh,
3078 .procname = "mmap_min_addr",
3079 .data = &dac_mmap_min_addr,
3080 .maxlen = sizeof(unsigned long),
3082 .proc_handler = mmap_min_addr_handler,
3087 .procname = "numa_zonelist_order",
3088 .data = &numa_zonelist_order,
3089 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3091 .proc_handler = numa_zonelist_order_handler,
3094 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3095 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3097 .procname = "vdso_enabled",
3098 #ifdef CONFIG_X86_32
3099 .data = &vdso32_enabled,
3100 .maxlen = sizeof(vdso32_enabled),
3102 .data = &vdso_enabled,
3103 .maxlen = sizeof(vdso_enabled),
3106 .proc_handler = proc_dointvec,
3107 .extra1 = SYSCTL_ZERO,
3110 #ifdef CONFIG_HIGHMEM
3112 .procname = "highmem_is_dirtyable",
3113 .data = &vm_highmem_is_dirtyable,
3114 .maxlen = sizeof(vm_highmem_is_dirtyable),
3116 .proc_handler = proc_dointvec_minmax,
3117 .extra1 = SYSCTL_ZERO,
3118 .extra2 = SYSCTL_ONE,
3121 #ifdef CONFIG_MEMORY_FAILURE
3123 .procname = "memory_failure_early_kill",
3124 .data = &sysctl_memory_failure_early_kill,
3125 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3127 .proc_handler = proc_dointvec_minmax,
3128 .extra1 = SYSCTL_ZERO,
3129 .extra2 = SYSCTL_ONE,
3132 .procname = "memory_failure_recovery",
3133 .data = &sysctl_memory_failure_recovery,
3134 .maxlen = sizeof(sysctl_memory_failure_recovery),
3136 .proc_handler = proc_dointvec_minmax,
3137 .extra1 = SYSCTL_ZERO,
3138 .extra2 = SYSCTL_ONE,
3142 .procname = "user_reserve_kbytes",
3143 .data = &sysctl_user_reserve_kbytes,
3144 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3146 .proc_handler = proc_doulongvec_minmax,
3149 .procname = "admin_reserve_kbytes",
3150 .data = &sysctl_admin_reserve_kbytes,
3151 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3153 .proc_handler = proc_doulongvec_minmax,
3155 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3157 .procname = "mmap_rnd_bits",
3158 .data = &mmap_rnd_bits,
3159 .maxlen = sizeof(mmap_rnd_bits),
3161 .proc_handler = proc_dointvec_minmax,
3162 .extra1 = (void *)&mmap_rnd_bits_min,
3163 .extra2 = (void *)&mmap_rnd_bits_max,
3166 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3168 .procname = "mmap_rnd_compat_bits",
3169 .data = &mmap_rnd_compat_bits,
3170 .maxlen = sizeof(mmap_rnd_compat_bits),
3172 .proc_handler = proc_dointvec_minmax,
3173 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3174 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3177 #ifdef CONFIG_USERFAULTFD
3179 .procname = "unprivileged_userfaultfd",
3180 .data = &sysctl_unprivileged_userfaultfd,
3181 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3183 .proc_handler = proc_dointvec_minmax,
3184 .extra1 = SYSCTL_ZERO,
3185 .extra2 = SYSCTL_ONE,
3191 static struct ctl_table fs_table[] = {
3193 .procname = "inode-nr",
3194 .data = &inodes_stat,
3195 .maxlen = 2*sizeof(long),
3197 .proc_handler = proc_nr_inodes,
3200 .procname = "inode-state",
3201 .data = &inodes_stat,
3202 .maxlen = 7*sizeof(long),
3204 .proc_handler = proc_nr_inodes,
3207 .procname = "file-nr",
3208 .data = &files_stat,
3209 .maxlen = sizeof(files_stat),
3211 .proc_handler = proc_nr_files,
3214 .procname = "file-max",
3215 .data = &files_stat.max_files,
3216 .maxlen = sizeof(files_stat.max_files),
3218 .proc_handler = proc_doulongvec_minmax,
3220 .extra2 = &long_max,
3223 .procname = "nr_open",
3224 .data = &sysctl_nr_open,
3225 .maxlen = sizeof(unsigned int),
3227 .proc_handler = proc_dointvec_minmax,
3228 .extra1 = &sysctl_nr_open_min,
3229 .extra2 = &sysctl_nr_open_max,
3232 .procname = "dentry-state",
3233 .data = &dentry_stat,
3234 .maxlen = 6*sizeof(long),
3236 .proc_handler = proc_nr_dentry,
3239 .procname = "overflowuid",
3240 .data = &fs_overflowuid,
3241 .maxlen = sizeof(int),
3243 .proc_handler = proc_dointvec_minmax,
3244 .extra1 = &minolduid,
3245 .extra2 = &maxolduid,
3248 .procname = "overflowgid",
3249 .data = &fs_overflowgid,
3250 .maxlen = sizeof(int),
3252 .proc_handler = proc_dointvec_minmax,
3253 .extra1 = &minolduid,
3254 .extra2 = &maxolduid,
3256 #ifdef CONFIG_FILE_LOCKING
3258 .procname = "leases-enable",
3259 .data = &leases_enable,
3260 .maxlen = sizeof(int),
3262 .proc_handler = proc_dointvec,
3265 #ifdef CONFIG_DNOTIFY
3267 .procname = "dir-notify-enable",
3268 .data = &dir_notify_enable,
3269 .maxlen = sizeof(int),
3271 .proc_handler = proc_dointvec,
3275 #ifdef CONFIG_FILE_LOCKING
3277 .procname = "lease-break-time",
3278 .data = &lease_break_time,
3279 .maxlen = sizeof(int),
3281 .proc_handler = proc_dointvec,
3286 .procname = "aio-nr",
3288 .maxlen = sizeof(aio_nr),
3290 .proc_handler = proc_doulongvec_minmax,
3293 .procname = "aio-max-nr",
3294 .data = &aio_max_nr,
3295 .maxlen = sizeof(aio_max_nr),
3297 .proc_handler = proc_doulongvec_minmax,
3299 #endif /* CONFIG_AIO */
3300 #ifdef CONFIG_INOTIFY_USER
3302 .procname = "inotify",
3304 .child = inotify_table,
3307 #ifdef CONFIG_FANOTIFY
3309 .procname = "fanotify",
3311 .child = fanotify_table,
3316 .procname = "epoll",
3318 .child = epoll_table,
3323 .procname = "protected_symlinks",
3324 .data = &sysctl_protected_symlinks,
3325 .maxlen = sizeof(int),
3327 .proc_handler = proc_dointvec_minmax,
3328 .extra1 = SYSCTL_ZERO,
3329 .extra2 = SYSCTL_ONE,
3332 .procname = "protected_hardlinks",
3333 .data = &sysctl_protected_hardlinks,
3334 .maxlen = sizeof(int),
3336 .proc_handler = proc_dointvec_minmax,
3337 .extra1 = SYSCTL_ZERO,
3338 .extra2 = SYSCTL_ONE,
3341 .procname = "protected_fifos",
3342 .data = &sysctl_protected_fifos,
3343 .maxlen = sizeof(int),
3345 .proc_handler = proc_dointvec_minmax,
3346 .extra1 = SYSCTL_ZERO,
3350 .procname = "protected_regular",
3351 .data = &sysctl_protected_regular,
3352 .maxlen = sizeof(int),
3354 .proc_handler = proc_dointvec_minmax,
3355 .extra1 = SYSCTL_ZERO,
3359 .procname = "suid_dumpable",
3360 .data = &suid_dumpable,
3361 .maxlen = sizeof(int),
3363 .proc_handler = proc_dointvec_minmax_coredump,
3364 .extra1 = SYSCTL_ZERO,
3367 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3369 .procname = "binfmt_misc",
3371 .child = sysctl_mount_point,
3375 .procname = "pipe-max-size",
3376 .data = &pipe_max_size,
3377 .maxlen = sizeof(pipe_max_size),
3379 .proc_handler = proc_dopipe_max_size,
3382 .procname = "pipe-user-pages-hard",
3383 .data = &pipe_user_pages_hard,
3384 .maxlen = sizeof(pipe_user_pages_hard),
3386 .proc_handler = proc_doulongvec_minmax,
3389 .procname = "pipe-user-pages-soft",
3390 .data = &pipe_user_pages_soft,
3391 .maxlen = sizeof(pipe_user_pages_soft),
3393 .proc_handler = proc_doulongvec_minmax,
3396 .procname = "mount-max",
3397 .data = &sysctl_mount_max,
3398 .maxlen = sizeof(unsigned int),
3400 .proc_handler = proc_dointvec_minmax,
3401 .extra1 = SYSCTL_ONE,
3406 static struct ctl_table debug_table[] = {
3407 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3409 .procname = "exception-trace",
3410 .data = &show_unhandled_signals,
3411 .maxlen = sizeof(int),
3413 .proc_handler = proc_dointvec
3416 #if defined(CONFIG_OPTPROBES)
3418 .procname = "kprobes-optimization",
3419 .data = &sysctl_kprobes_optimization,
3420 .maxlen = sizeof(int),
3422 .proc_handler = proc_kprobes_optimization_handler,
3423 .extra1 = SYSCTL_ZERO,
3424 .extra2 = SYSCTL_ONE,
3430 static struct ctl_table dev_table[] = {
3434 static struct ctl_table sysctl_base_table[] = {
3436 .procname = "kernel",
3438 .child = kern_table,
3451 .procname = "debug",
3453 .child = debug_table,
3463 int __init sysctl_init(void)
3465 struct ctl_table_header *hdr;
3467 hdr = register_sysctl_table(sysctl_base_table);
3468 kmemleak_not_leak(hdr);
3471 #endif /* CONFIG_SYSCTL */
3473 * No sense putting this after each symbol definition, twice,
3474 * exception granted :-)
3476 EXPORT_SYMBOL(proc_dobool);
3477 EXPORT_SYMBOL(proc_dointvec);
3478 EXPORT_SYMBOL(proc_douintvec);
3479 EXPORT_SYMBOL(proc_dointvec_jiffies);
3480 EXPORT_SYMBOL(proc_dointvec_minmax);
3481 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3482 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3483 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3484 EXPORT_SYMBOL(proc_dostring);
3485 EXPORT_SYMBOL(proc_doulongvec_minmax);
3486 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3487 EXPORT_SYMBOL(proc_do_large_bitmap);