1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/sched/coredump.h>
67 #include <linux/kexec.h>
68 #include <linux/bpf.h>
69 #include <linux/mount.h>
70 #include <linux/userfaultfd_k.h>
71 #include <linux/coredump.h>
72 #include <linux/latencytop.h>
73 #include <linux/pid.h>
75 #include "../lib/kstrtox.h"
77 #include <linux/uaccess.h>
78 #include <asm/processor.h>
82 #include <asm/stacktrace.h>
86 #include <asm/setup.h>
88 #ifdef CONFIG_BSD_PROCESS_ACCT
89 #include <linux/acct.h>
91 #ifdef CONFIG_RT_MUTEXES
92 #include <linux/rtmutex.h>
94 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
95 #include <linux/lockdep.h>
97 #ifdef CONFIG_CHR_DEV_SG
100 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101 #include <linux/stackleak.h>
103 #ifdef CONFIG_LOCKUP_DETECTOR
104 #include <linux/nmi.h>
107 #if defined(CONFIG_SYSCTL)
109 /* Constants used for minimum and maximum */
110 #ifdef CONFIG_LOCKUP_DETECTOR
111 static int sixty = 60;
114 static unsigned long zero_ul;
115 static unsigned long one_ul = 1;
116 static unsigned long long_max = LONG_MAX;
118 static int ten_thousand = 10000;
120 #ifdef CONFIG_PERF_EVENTS
121 static int six_hundred_forty_kb = 640 * 1024;
124 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
125 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
127 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
128 static int maxolduid = 65535;
129 static int minolduid;
131 static int ngroups_max = NGROUPS_MAX;
132 static const int cap_last_cap = CAP_LAST_CAP;
135 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
136 * and hung_task_check_interval_secs
138 #ifdef CONFIG_DETECT_HUNG_TASK
139 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
142 #ifdef CONFIG_INOTIFY_USER
143 #include <linux/inotify.h>
146 #ifdef CONFIG_PROC_SYSCTL
149 * enum sysctl_writes_mode - supported sysctl write modes
151 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
152 * to be written, and multiple writes on the same sysctl file descriptor
153 * will rewrite the sysctl value, regardless of file position. No warning
154 * is issued when the initial position is not 0.
155 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
157 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
158 * file position 0 and the value must be fully contained in the buffer
159 * sent to the write syscall. If dealing with strings respect the file
160 * position, but restrict this to the max length of the buffer, anything
161 * passed the max length will be ignored. Multiple writes will append
164 * These write modes control how current file position affects the behavior of
165 * updating sysctl values through the proc interface on each write.
167 enum sysctl_writes_mode {
168 SYSCTL_WRITES_LEGACY = -1,
169 SYSCTL_WRITES_WARN = 0,
170 SYSCTL_WRITES_STRICT = 1,
173 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
174 #endif /* CONFIG_PROC_SYSCTL */
176 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
177 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
178 int sysctl_legacy_va_layout;
181 #ifdef CONFIG_SCHED_DEBUG
182 static int min_sched_granularity_ns = 100000; /* 100 usecs */
183 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
184 static int min_wakeup_granularity_ns; /* 0 usecs */
185 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
187 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
188 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
189 #endif /* CONFIG_SMP */
190 #endif /* CONFIG_SCHED_DEBUG */
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 void proc_skip_spaces(char **buf, size_t *size)
398 static void proc_skip_char(char **buf, size_t *size, const char v)
409 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
412 * @cp: kernel buffer containing the string to parse
413 * @endp: pointer to store the trailing characters
414 * @base: the base to use
415 * @res: where the parsed integer will be stored
417 * In case of success 0 is returned and @res will contain the parsed integer,
418 * @endp will hold any trailing characters.
419 * This function will fail the parse on overflow. If there wasn't an overflow
420 * the function will defer the decision what characters count as invalid to the
423 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
426 unsigned long long result;
429 cp = _parse_integer_fixup_radix(cp, &base);
430 rv = _parse_integer(cp, base, &result);
431 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
439 *res = (unsigned long)result;
445 * proc_get_long - reads an ASCII formatted integer from a user buffer
447 * @buf: a kernel buffer
448 * @size: size of the kernel buffer
449 * @val: this is where the number will be stored
450 * @neg: set to %TRUE if number is negative
451 * @perm_tr: a vector which contains the allowed trailers
452 * @perm_tr_len: size of the perm_tr vector
453 * @tr: pointer to store the trailer character
455 * In case of success %0 is returned and @buf and @size are updated with
456 * the amount of bytes read. If @tr is non-NULL and a trailing
457 * character exists (size is non-zero after returning from this
458 * function), @tr is updated with the trailing character.
460 static int proc_get_long(char **buf, size_t *size,
461 unsigned long *val, bool *neg,
462 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_dointvec_conv(bool *negp, unsigned long *lvalp,
548 int write, void *data)
552 if (*lvalp > (unsigned long) INT_MAX + 1)
554 WRITE_ONCE(*valp, -*lvalp);
556 if (*lvalp > (unsigned long) INT_MAX)
558 WRITE_ONCE(*valp, *lvalp);
561 int val = READ_ONCE(*valp);
564 *lvalp = -(unsigned long)val;
567 *lvalp = (unsigned long)val;
573 static int do_proc_douintvec_conv(unsigned long *lvalp,
575 int write, void *data)
578 if (*lvalp > UINT_MAX)
580 WRITE_ONCE(*valp, *lvalp);
582 unsigned int val = READ_ONCE(*valp);
583 *lvalp = (unsigned long)val;
588 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
590 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
591 int write, void *buffer,
592 size_t *lenp, loff_t *ppos,
593 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
594 int write, void *data),
597 int *i, vleft, first = 1, err = 0;
601 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
606 i = (int *) tbl_data;
607 vleft = table->maxlen / sizeof(*i);
611 conv = do_proc_dointvec_conv;
614 if (proc_first_pos_non_zero_ignore(ppos, table))
617 if (left > PAGE_SIZE - 1)
618 left = PAGE_SIZE - 1;
622 for (; left && vleft--; i++, first=0) {
627 proc_skip_spaces(&p, &left);
631 err = proc_get_long(&p, &left, &lval, &neg,
633 sizeof(proc_wspace_sep), NULL);
636 if (conv(&neg, &lval, i, 1, data)) {
641 if (conv(&neg, &lval, i, 0, data)) {
646 proc_put_char(&buffer, &left, '\t');
647 proc_put_long(&buffer, &left, lval, neg);
651 if (!write && !first && left && !err)
652 proc_put_char(&buffer, &left, '\n');
653 if (write && !err && left)
654 proc_skip_spaces(&p, &left);
656 return err ? : -EINVAL;
663 static int do_proc_dointvec(struct ctl_table *table, int write,
664 void *buffer, size_t *lenp, loff_t *ppos,
665 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
666 int write, void *data),
669 return __do_proc_dointvec(table->data, table, write,
670 buffer, lenp, ppos, conv, data);
673 static int do_proc_douintvec_w(unsigned int *tbl_data,
674 struct ctl_table *table,
676 size_t *lenp, loff_t *ppos,
677 int (*conv)(unsigned long *lvalp,
679 int write, void *data),
690 if (proc_first_pos_non_zero_ignore(ppos, table))
693 if (left > PAGE_SIZE - 1)
694 left = PAGE_SIZE - 1;
696 proc_skip_spaces(&p, &left);
702 err = proc_get_long(&p, &left, &lval, &neg,
704 sizeof(proc_wspace_sep), NULL);
710 if (conv(&lval, tbl_data, 1, data)) {
716 proc_skip_spaces(&p, &left);
724 /* This is in keeping with old __do_proc_dointvec() */
730 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
731 size_t *lenp, loff_t *ppos,
732 int (*conv)(unsigned long *lvalp,
734 int write, void *data),
743 if (conv(&lval, tbl_data, 0, data)) {
748 proc_put_long(&buffer, &left, lval, false);
752 proc_put_char(&buffer, &left, '\n');
761 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
762 int write, void *buffer,
763 size_t *lenp, loff_t *ppos,
764 int (*conv)(unsigned long *lvalp,
766 int write, void *data),
769 unsigned int *i, vleft;
771 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
776 i = (unsigned int *) tbl_data;
777 vleft = table->maxlen / sizeof(*i);
780 * Arrays are not supported, keep this simple. *Do not* add
789 conv = do_proc_douintvec_conv;
792 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
794 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
797 static int do_proc_douintvec(struct ctl_table *table, int write,
798 void *buffer, size_t *lenp, loff_t *ppos,
799 int (*conv)(unsigned long *lvalp,
801 int write, void *data),
804 return __do_proc_douintvec(table->data, table, write,
805 buffer, lenp, ppos, conv, data);
809 * proc_dointvec - read a vector of integers
810 * @table: the sysctl table
811 * @write: %TRUE if this is a write to the sysctl file
812 * @buffer: the user buffer
813 * @lenp: the size of the user buffer
814 * @ppos: file position
816 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
817 * values from/to the user buffer, treated as an ASCII string.
819 * Returns 0 on success.
821 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
822 size_t *lenp, loff_t *ppos)
824 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
827 #ifdef CONFIG_COMPACTION
828 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
829 int write, void *buffer, size_t *lenp, loff_t *ppos)
833 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
834 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
836 old = *(int *)table->data;
837 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
840 if (old != *(int *)table->data)
841 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
842 table->procname, current->comm,
843 task_pid_nr(current));
849 * proc_douintvec - read a vector of unsigned integers
850 * @table: the sysctl table
851 * @write: %TRUE if this is a write to the sysctl file
852 * @buffer: the user buffer
853 * @lenp: the size of the user buffer
854 * @ppos: file position
856 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
857 * values from/to the user buffer, treated as an ASCII string.
859 * Returns 0 on success.
861 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
862 size_t *lenp, loff_t *ppos)
864 return do_proc_douintvec(table, write, buffer, lenp, ppos,
865 do_proc_douintvec_conv, NULL);
869 * Taint values can only be increased
870 * This means we can safely use a temporary.
872 static int proc_taint(struct ctl_table *table, int write,
873 void *buffer, size_t *lenp, loff_t *ppos)
876 unsigned long tmptaint = get_taint();
879 if (write && !capable(CAP_SYS_ADMIN))
884 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
892 * If we are relying on panic_on_taint not producing
893 * false positives due to userspace input, bail out
894 * before setting the requested taint flags.
896 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
900 * Poor man's atomic or. Not worth adding a primitive
901 * to everyone's atomic.h for this
903 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
904 if ((1UL << i) & tmptaint)
905 add_taint(i, LOCKDEP_STILL_OK);
912 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
913 void *buffer, size_t *lenp, loff_t *ppos)
915 if (write && !capable(CAP_SYS_ADMIN))
918 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
923 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
924 * @min: pointer to minimum allowable value
925 * @max: pointer to maximum allowable value
927 * The do_proc_dointvec_minmax_conv_param structure provides the
928 * minimum and maximum values for doing range checking for those sysctl
929 * parameters that use the proc_dointvec_minmax() handler.
931 struct do_proc_dointvec_minmax_conv_param {
936 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
938 int write, void *data)
941 struct do_proc_dointvec_minmax_conv_param *param = data;
943 * If writing, first do so via a temporary local int so we can
944 * bounds-check it before touching *valp.
946 int *ip = write ? &tmp : valp;
948 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
953 if ((param->min && *param->min > tmp) ||
954 (param->max && *param->max < tmp))
956 WRITE_ONCE(*valp, tmp);
963 * proc_dointvec_minmax - read a vector of integers with min/max values
964 * @table: the sysctl table
965 * @write: %TRUE if this is a write to the sysctl file
966 * @buffer: the user buffer
967 * @lenp: the size of the user buffer
968 * @ppos: file position
970 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
971 * values from/to the user buffer, treated as an ASCII string.
973 * This routine will ensure the values are within the range specified by
974 * table->extra1 (min) and table->extra2 (max).
976 * Returns 0 on success or -EINVAL on write when the range check fails.
978 int proc_dointvec_minmax(struct ctl_table *table, int write,
979 void *buffer, size_t *lenp, loff_t *ppos)
981 struct do_proc_dointvec_minmax_conv_param param = {
982 .min = (int *) table->extra1,
983 .max = (int *) table->extra2,
985 return do_proc_dointvec(table, write, buffer, lenp, ppos,
986 do_proc_dointvec_minmax_conv, ¶m);
990 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
991 * @min: pointer to minimum allowable value
992 * @max: pointer to maximum allowable value
994 * The do_proc_douintvec_minmax_conv_param structure provides the
995 * minimum and maximum values for doing range checking for those sysctl
996 * parameters that use the proc_douintvec_minmax() handler.
998 struct do_proc_douintvec_minmax_conv_param {
1003 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1005 int write, void *data)
1009 struct do_proc_douintvec_minmax_conv_param *param = data;
1010 /* write via temporary local uint for bounds-checking */
1011 unsigned int *up = write ? &tmp : valp;
1013 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1018 if ((param->min && *param->min > tmp) ||
1019 (param->max && *param->max < tmp))
1022 WRITE_ONCE(*valp, tmp);
1029 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1030 * @table: the sysctl table
1031 * @write: %TRUE if this is a write to the sysctl file
1032 * @buffer: the user buffer
1033 * @lenp: the size of the user buffer
1034 * @ppos: file position
1036 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1037 * values from/to the user buffer, treated as an ASCII string. Negative
1038 * strings are not allowed.
1040 * This routine will ensure the values are within the range specified by
1041 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1042 * check for UINT_MAX to avoid having to support wrap around uses from
1045 * Returns 0 on success or -ERANGE on write when the range check fails.
1047 int proc_douintvec_minmax(struct ctl_table *table, int write,
1048 void *buffer, size_t *lenp, loff_t *ppos)
1050 struct do_proc_douintvec_minmax_conv_param param = {
1051 .min = (unsigned int *) table->extra1,
1052 .max = (unsigned int *) table->extra2,
1054 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1055 do_proc_douintvec_minmax_conv, ¶m);
1059 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1060 * @table: the sysctl table
1061 * @write: %TRUE if this is a write to the sysctl file
1062 * @buffer: the user buffer
1063 * @lenp: the size of the user buffer
1064 * @ppos: file position
1066 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1067 * values from/to the user buffer, treated as an ASCII string. Negative
1068 * strings are not allowed.
1070 * This routine will ensure the values are within the range specified by
1071 * table->extra1 (min) and table->extra2 (max).
1073 * Returns 0 on success or an error on write when the range check fails.
1075 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1076 void *buffer, size_t *lenp, loff_t *ppos)
1078 struct ctl_table tmp;
1079 unsigned int min = 0, max = 255U, val;
1080 u8 *data = table->data;
1081 struct do_proc_douintvec_minmax_conv_param param = {
1087 /* Do not support arrays yet. */
1088 if (table->maxlen != sizeof(u8))
1091 if (table->extra1) {
1092 min = *(unsigned int *) table->extra1;
1096 if (table->extra2) {
1097 max = *(unsigned int *) table->extra2;
1104 tmp.maxlen = sizeof(val);
1106 val = READ_ONCE(*data);
1107 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1108 do_proc_douintvec_minmax_conv, ¶m);
1112 WRITE_ONCE(*data, val);
1115 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1117 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1119 int write, void *data)
1124 val = round_pipe_size(*lvalp);
1130 unsigned int val = *valp;
1131 *lvalp = (unsigned long) val;
1137 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1138 void *buffer, size_t *lenp, loff_t *ppos)
1140 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1141 do_proc_dopipe_max_size_conv, NULL);
1144 static void validate_coredump_safety(void)
1146 #ifdef CONFIG_COREDUMP
1147 if (suid_dumpable == SUID_DUMP_ROOT &&
1148 core_pattern[0] != '/' && core_pattern[0] != '|') {
1150 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1151 "Pipe handler or fully qualified core dump path required.\n"
1152 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1158 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1159 void *buffer, size_t *lenp, loff_t *ppos)
1161 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1163 validate_coredump_safety();
1167 #ifdef CONFIG_COREDUMP
1168 static int proc_dostring_coredump(struct ctl_table *table, int write,
1169 void *buffer, size_t *lenp, loff_t *ppos)
1171 int error = proc_dostring(table, write, buffer, lenp, ppos);
1173 validate_coredump_safety();
1178 #ifdef CONFIG_MAGIC_SYSRQ
1179 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1180 void *buffer, size_t *lenp, loff_t *ppos)
1186 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1187 lenp, ppos, NULL, NULL);
1192 sysrq_toggle_support(tmp);
1198 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1199 int write, void *buffer, size_t *lenp, loff_t *ppos,
1200 unsigned long convmul, unsigned long convdiv)
1202 unsigned long *i, *min, *max;
1203 int vleft, first = 1, err = 0;
1207 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1212 i = (unsigned long *) data;
1213 min = (unsigned long *) table->extra1;
1214 max = (unsigned long *) table->extra2;
1215 vleft = table->maxlen / sizeof(unsigned long);
1219 if (proc_first_pos_non_zero_ignore(ppos, table))
1222 if (left > PAGE_SIZE - 1)
1223 left = PAGE_SIZE - 1;
1227 for (; left && vleft--; i++, first = 0) {
1233 proc_skip_spaces(&p, &left);
1237 err = proc_get_long(&p, &left, &val, &neg,
1239 sizeof(proc_wspace_sep), NULL);
1244 val = convmul * val / convdiv;
1245 if ((min && val < *min) || (max && val > *max)) {
1249 WRITE_ONCE(*i, val);
1251 val = convdiv * READ_ONCE(*i) / convmul;
1253 proc_put_char(&buffer, &left, '\t');
1254 proc_put_long(&buffer, &left, val, false);
1258 if (!write && !first && left && !err)
1259 proc_put_char(&buffer, &left, '\n');
1261 proc_skip_spaces(&p, &left);
1263 return err ? : -EINVAL;
1270 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1271 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1272 unsigned long convdiv)
1274 return __do_proc_doulongvec_minmax(table->data, table, write,
1275 buffer, lenp, ppos, convmul, convdiv);
1279 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1280 * @table: the sysctl table
1281 * @write: %TRUE if this is a write to the sysctl file
1282 * @buffer: the user buffer
1283 * @lenp: the size of the user buffer
1284 * @ppos: file position
1286 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1287 * values from/to the user buffer, treated as an ASCII string.
1289 * This routine will ensure the values are within the range specified by
1290 * table->extra1 (min) and table->extra2 (max).
1292 * Returns 0 on success.
1294 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1295 void *buffer, size_t *lenp, loff_t *ppos)
1297 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1301 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1302 * @table: the sysctl table
1303 * @write: %TRUE if this is a write to the sysctl file
1304 * @buffer: the user buffer
1305 * @lenp: the size of the user buffer
1306 * @ppos: file position
1308 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1309 * values from/to the user buffer, treated as an ASCII string. The values
1310 * are treated as milliseconds, and converted to jiffies when they are stored.
1312 * This routine will ensure the values are within the range specified by
1313 * table->extra1 (min) and table->extra2 (max).
1315 * Returns 0 on success.
1317 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1318 void *buffer, size_t *lenp, loff_t *ppos)
1320 return do_proc_doulongvec_minmax(table, write, buffer,
1321 lenp, ppos, HZ, 1000l);
1325 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1327 int write, void *data)
1330 if (*lvalp > INT_MAX / HZ)
1333 WRITE_ONCE(*valp, -*lvalp * HZ);
1335 WRITE_ONCE(*valp, *lvalp * HZ);
1337 int val = READ_ONCE(*valp);
1341 lval = -(unsigned long)val;
1344 lval = (unsigned long)val;
1351 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1353 int write, void *data)
1356 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1358 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1364 lval = -(unsigned long)val;
1367 lval = (unsigned long)val;
1369 *lvalp = jiffies_to_clock_t(lval);
1374 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1376 int write, void *data)
1379 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1383 WRITE_ONCE(*valp, (int)jif);
1385 int val = READ_ONCE(*valp);
1389 lval = -(unsigned long)val;
1392 lval = (unsigned long)val;
1394 *lvalp = jiffies_to_msecs(lval);
1400 * proc_dointvec_jiffies - read a vector of integers as seconds
1401 * @table: the sysctl table
1402 * @write: %TRUE if this is a write to the sysctl file
1403 * @buffer: the user buffer
1404 * @lenp: the size of the user buffer
1405 * @ppos: file position
1407 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1408 * values from/to the user buffer, treated as an ASCII string.
1409 * The values read are assumed to be in seconds, and are converted into
1412 * Returns 0 on success.
1414 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1415 void *buffer, size_t *lenp, loff_t *ppos)
1417 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1418 do_proc_dointvec_jiffies_conv,NULL);
1422 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1423 * @table: the sysctl table
1424 * @write: %TRUE if this is a write to the sysctl file
1425 * @buffer: the user buffer
1426 * @lenp: the size of the user buffer
1427 * @ppos: pointer to the file position
1429 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1430 * values from/to the user buffer, treated as an ASCII string.
1431 * The values read are assumed to be in 1/USER_HZ seconds, and
1432 * are converted into jiffies.
1434 * Returns 0 on success.
1436 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1437 void *buffer, size_t *lenp, loff_t *ppos)
1439 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1440 do_proc_dointvec_userhz_jiffies_conv,NULL);
1444 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1445 * @table: the sysctl table
1446 * @write: %TRUE if this is a write to the sysctl file
1447 * @buffer: the user buffer
1448 * @lenp: the size of the user buffer
1449 * @ppos: file position
1450 * @ppos: the current position in the file
1452 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1453 * values from/to the user buffer, treated as an ASCII string.
1454 * The values read are assumed to be in 1/1000 seconds, and
1455 * are converted into jiffies.
1457 * Returns 0 on success.
1459 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1460 size_t *lenp, loff_t *ppos)
1462 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1463 do_proc_dointvec_ms_jiffies_conv, NULL);
1466 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1467 size_t *lenp, loff_t *ppos)
1469 struct pid *new_pid;
1473 tmp = pid_vnr(cad_pid);
1475 r = __do_proc_dointvec(&tmp, table, write, buffer,
1476 lenp, ppos, NULL, NULL);
1480 new_pid = find_get_pid(tmp);
1484 put_pid(xchg(&cad_pid, new_pid));
1489 * proc_do_large_bitmap - read/write from/to a large bitmap
1490 * @table: the sysctl table
1491 * @write: %TRUE if this is a write to the sysctl file
1492 * @buffer: the user buffer
1493 * @lenp: the size of the user buffer
1494 * @ppos: file position
1496 * The bitmap is stored at table->data and the bitmap length (in bits)
1499 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1500 * large bitmaps may be represented in a compact manner. Writing into
1501 * the file will clear the bitmap then update it with the given input.
1503 * Returns 0 on success.
1505 int proc_do_large_bitmap(struct ctl_table *table, int write,
1506 void *buffer, size_t *lenp, loff_t *ppos)
1510 size_t left = *lenp;
1511 unsigned long bitmap_len = table->maxlen;
1512 unsigned long *bitmap = *(unsigned long **) table->data;
1513 unsigned long *tmp_bitmap = NULL;
1514 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1516 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1525 if (left > PAGE_SIZE - 1) {
1526 left = PAGE_SIZE - 1;
1527 /* How much of the buffer we'll skip this pass */
1528 skipped = *lenp - left;
1531 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1534 proc_skip_char(&p, &left, '\n');
1535 while (!err && left) {
1536 unsigned long val_a, val_b;
1540 /* In case we stop parsing mid-number, we can reset */
1542 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1545 * If we consumed the entirety of a truncated buffer or
1546 * only one char is left (may be a "-"), then stop here,
1547 * reset, & come back for more.
1549 if ((left <= 1) && skipped) {
1556 if (val_a >= bitmap_len || neg) {
1568 err = proc_get_long(&p, &left, &val_b,
1569 &neg, tr_b, sizeof(tr_b),
1572 * If we consumed all of a truncated buffer or
1573 * then stop here, reset, & come back for more.
1575 if (!left && skipped) {
1582 if (val_b >= bitmap_len || neg ||
1593 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1595 proc_skip_char(&p, &left, '\n');
1599 unsigned long bit_a, bit_b = 0;
1602 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1603 if (bit_a >= bitmap_len)
1605 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1609 proc_put_char(&buffer, &left, ',');
1610 proc_put_long(&buffer, &left, bit_a, false);
1611 if (bit_a != bit_b) {
1612 proc_put_char(&buffer, &left, '-');
1613 proc_put_long(&buffer, &left, bit_b, false);
1618 proc_put_char(&buffer, &left, '\n');
1624 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1626 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1632 bitmap_free(tmp_bitmap);
1636 #else /* CONFIG_PROC_SYSCTL */
1638 int proc_dostring(struct ctl_table *table, int write,
1639 void *buffer, size_t *lenp, loff_t *ppos)
1644 int proc_dointvec(struct ctl_table *table, int write,
1645 void *buffer, size_t *lenp, loff_t *ppos)
1650 int proc_douintvec(struct ctl_table *table, int write,
1651 void *buffer, size_t *lenp, loff_t *ppos)
1656 int proc_dointvec_minmax(struct ctl_table *table, int write,
1657 void *buffer, size_t *lenp, loff_t *ppos)
1662 int proc_douintvec_minmax(struct ctl_table *table, int write,
1663 void *buffer, size_t *lenp, loff_t *ppos)
1668 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1669 void *buffer, size_t *lenp, loff_t *ppos)
1674 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1675 void *buffer, size_t *lenp, loff_t *ppos)
1680 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1681 void *buffer, size_t *lenp, loff_t *ppos)
1686 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1687 void *buffer, size_t *lenp, loff_t *ppos)
1692 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1693 void *buffer, size_t *lenp, loff_t *ppos)
1698 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1699 void *buffer, size_t *lenp, loff_t *ppos)
1704 int proc_do_large_bitmap(struct ctl_table *table, int write,
1705 void *buffer, size_t *lenp, loff_t *ppos)
1710 #endif /* CONFIG_PROC_SYSCTL */
1712 #if defined(CONFIG_SYSCTL)
1713 int proc_do_static_key(struct ctl_table *table, int write,
1714 void *buffer, size_t *lenp, loff_t *ppos)
1716 struct static_key *key = (struct static_key *)table->data;
1717 static DEFINE_MUTEX(static_key_mutex);
1719 struct ctl_table tmp = {
1721 .maxlen = sizeof(val),
1722 .mode = table->mode,
1723 .extra1 = SYSCTL_ZERO,
1724 .extra2 = SYSCTL_ONE,
1727 if (write && !capable(CAP_SYS_ADMIN))
1730 mutex_lock(&static_key_mutex);
1731 val = static_key_enabled(key);
1732 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1733 if (write && !ret) {
1735 static_key_enable(key);
1737 static_key_disable(key);
1739 mutex_unlock(&static_key_mutex);
1743 static struct ctl_table kern_table[] = {
1745 .procname = "sched_child_runs_first",
1746 .data = &sysctl_sched_child_runs_first,
1747 .maxlen = sizeof(unsigned int),
1749 .proc_handler = proc_dointvec,
1751 #ifdef CONFIG_SCHED_DEBUG
1753 .procname = "sched_min_granularity_ns",
1754 .data = &sysctl_sched_min_granularity,
1755 .maxlen = sizeof(unsigned int),
1757 .proc_handler = sched_proc_update_handler,
1758 .extra1 = &min_sched_granularity_ns,
1759 .extra2 = &max_sched_granularity_ns,
1762 .procname = "sched_latency_ns",
1763 .data = &sysctl_sched_latency,
1764 .maxlen = sizeof(unsigned int),
1766 .proc_handler = sched_proc_update_handler,
1767 .extra1 = &min_sched_granularity_ns,
1768 .extra2 = &max_sched_granularity_ns,
1771 .procname = "sched_wakeup_granularity_ns",
1772 .data = &sysctl_sched_wakeup_granularity,
1773 .maxlen = sizeof(unsigned int),
1775 .proc_handler = sched_proc_update_handler,
1776 .extra1 = &min_wakeup_granularity_ns,
1777 .extra2 = &max_wakeup_granularity_ns,
1781 .procname = "sched_tunable_scaling",
1782 .data = &sysctl_sched_tunable_scaling,
1783 .maxlen = sizeof(enum sched_tunable_scaling),
1785 .proc_handler = sched_proc_update_handler,
1786 .extra1 = &min_sched_tunable_scaling,
1787 .extra2 = &max_sched_tunable_scaling,
1790 .procname = "sched_migration_cost_ns",
1791 .data = &sysctl_sched_migration_cost,
1792 .maxlen = sizeof(unsigned int),
1794 .proc_handler = proc_dointvec,
1797 .procname = "sched_nr_migrate",
1798 .data = &sysctl_sched_nr_migrate,
1799 .maxlen = sizeof(unsigned int),
1801 .proc_handler = proc_dointvec,
1803 #ifdef CONFIG_SCHEDSTATS
1805 .procname = "sched_schedstats",
1807 .maxlen = sizeof(unsigned int),
1809 .proc_handler = sysctl_schedstats,
1810 .extra1 = SYSCTL_ZERO,
1811 .extra2 = SYSCTL_ONE,
1813 #endif /* CONFIG_SCHEDSTATS */
1814 #endif /* CONFIG_SMP */
1815 #ifdef CONFIG_NUMA_BALANCING
1817 .procname = "numa_balancing_scan_delay_ms",
1818 .data = &sysctl_numa_balancing_scan_delay,
1819 .maxlen = sizeof(unsigned int),
1821 .proc_handler = proc_dointvec,
1824 .procname = "numa_balancing_scan_period_min_ms",
1825 .data = &sysctl_numa_balancing_scan_period_min,
1826 .maxlen = sizeof(unsigned int),
1828 .proc_handler = proc_dointvec,
1831 .procname = "numa_balancing_scan_period_max_ms",
1832 .data = &sysctl_numa_balancing_scan_period_max,
1833 .maxlen = sizeof(unsigned int),
1835 .proc_handler = proc_dointvec,
1838 .procname = "numa_balancing_scan_size_mb",
1839 .data = &sysctl_numa_balancing_scan_size,
1840 .maxlen = sizeof(unsigned int),
1842 .proc_handler = proc_dointvec_minmax,
1843 .extra1 = SYSCTL_ONE,
1846 .procname = "numa_balancing",
1847 .data = NULL, /* filled in by handler */
1848 .maxlen = sizeof(unsigned int),
1850 .proc_handler = sysctl_numa_balancing,
1851 .extra1 = SYSCTL_ZERO,
1852 .extra2 = SYSCTL_ONE,
1854 #endif /* CONFIG_NUMA_BALANCING */
1855 #endif /* CONFIG_SCHED_DEBUG */
1857 .procname = "sched_rt_period_us",
1858 .data = &sysctl_sched_rt_period,
1859 .maxlen = sizeof(unsigned int),
1861 .proc_handler = sched_rt_handler,
1862 .extra1 = SYSCTL_ONE,
1863 .extra2 = SYSCTL_INT_MAX,
1866 .procname = "sched_rt_runtime_us",
1867 .data = &sysctl_sched_rt_runtime,
1868 .maxlen = sizeof(int),
1870 .proc_handler = sched_rt_handler,
1871 .extra1 = SYSCTL_NEG_ONE,
1872 .extra2 = SYSCTL_INT_MAX,
1875 .procname = "sched_deadline_period_max_us",
1876 .data = &sysctl_sched_dl_period_max,
1877 .maxlen = sizeof(unsigned int),
1879 .proc_handler = proc_dointvec,
1882 .procname = "sched_deadline_period_min_us",
1883 .data = &sysctl_sched_dl_period_min,
1884 .maxlen = sizeof(unsigned int),
1886 .proc_handler = proc_dointvec,
1889 .procname = "sched_rr_timeslice_ms",
1890 .data = &sysctl_sched_rr_timeslice,
1891 .maxlen = sizeof(int),
1893 .proc_handler = sched_rr_handler,
1895 #ifdef CONFIG_UCLAMP_TASK
1897 .procname = "sched_util_clamp_min",
1898 .data = &sysctl_sched_uclamp_util_min,
1899 .maxlen = sizeof(unsigned int),
1901 .proc_handler = sysctl_sched_uclamp_handler,
1904 .procname = "sched_util_clamp_max",
1905 .data = &sysctl_sched_uclamp_util_max,
1906 .maxlen = sizeof(unsigned int),
1908 .proc_handler = sysctl_sched_uclamp_handler,
1911 .procname = "sched_util_clamp_min_rt_default",
1912 .data = &sysctl_sched_uclamp_util_min_rt_default,
1913 .maxlen = sizeof(unsigned int),
1915 .proc_handler = sysctl_sched_uclamp_handler,
1918 #ifdef CONFIG_SCHED_AUTOGROUP
1920 .procname = "sched_autogroup_enabled",
1921 .data = &sysctl_sched_autogroup_enabled,
1922 .maxlen = sizeof(unsigned int),
1924 .proc_handler = proc_dointvec_minmax,
1925 .extra1 = SYSCTL_ZERO,
1926 .extra2 = SYSCTL_ONE,
1929 #ifdef CONFIG_CFS_BANDWIDTH
1931 .procname = "sched_cfs_bandwidth_slice_us",
1932 .data = &sysctl_sched_cfs_bandwidth_slice,
1933 .maxlen = sizeof(unsigned int),
1935 .proc_handler = proc_dointvec_minmax,
1936 .extra1 = SYSCTL_ONE,
1939 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1941 .procname = "sched_energy_aware",
1942 .data = &sysctl_sched_energy_aware,
1943 .maxlen = sizeof(unsigned int),
1945 .proc_handler = sched_energy_aware_handler,
1946 .extra1 = SYSCTL_ZERO,
1947 .extra2 = SYSCTL_ONE,
1950 #ifdef CONFIG_PROVE_LOCKING
1952 .procname = "prove_locking",
1953 .data = &prove_locking,
1954 .maxlen = sizeof(int),
1956 .proc_handler = proc_dointvec,
1959 #ifdef CONFIG_LOCK_STAT
1961 .procname = "lock_stat",
1963 .maxlen = sizeof(int),
1965 .proc_handler = proc_dointvec,
1969 .procname = "panic",
1970 .data = &panic_timeout,
1971 .maxlen = sizeof(int),
1973 .proc_handler = proc_dointvec,
1975 #ifdef CONFIG_COREDUMP
1977 .procname = "core_uses_pid",
1978 .data = &core_uses_pid,
1979 .maxlen = sizeof(int),
1981 .proc_handler = proc_dointvec,
1984 .procname = "core_pattern",
1985 .data = core_pattern,
1986 .maxlen = CORENAME_MAX_SIZE,
1988 .proc_handler = proc_dostring_coredump,
1991 .procname = "core_pipe_limit",
1992 .data = &core_pipe_limit,
1993 .maxlen = sizeof(unsigned int),
1995 .proc_handler = proc_dointvec,
1998 #ifdef CONFIG_PROC_SYSCTL
2000 .procname = "tainted",
2001 .maxlen = sizeof(long),
2003 .proc_handler = proc_taint,
2006 .procname = "sysctl_writes_strict",
2007 .data = &sysctl_writes_strict,
2008 .maxlen = sizeof(int),
2010 .proc_handler = proc_dointvec_minmax,
2011 .extra1 = SYSCTL_NEG_ONE,
2012 .extra2 = SYSCTL_ONE,
2015 #ifdef CONFIG_LATENCYTOP
2017 .procname = "latencytop",
2018 .data = &latencytop_enabled,
2019 .maxlen = sizeof(int),
2021 .proc_handler = sysctl_latencytop,
2024 #ifdef CONFIG_BLK_DEV_INITRD
2026 .procname = "real-root-dev",
2027 .data = &real_root_dev,
2028 .maxlen = sizeof(int),
2030 .proc_handler = proc_dointvec,
2034 .procname = "print-fatal-signals",
2035 .data = &print_fatal_signals,
2036 .maxlen = sizeof(int),
2038 .proc_handler = proc_dointvec,
2042 .procname = "reboot-cmd",
2043 .data = reboot_command,
2046 .proc_handler = proc_dostring,
2049 .procname = "stop-a",
2050 .data = &stop_a_enabled,
2051 .maxlen = sizeof (int),
2053 .proc_handler = proc_dointvec,
2056 .procname = "scons-poweroff",
2057 .data = &scons_pwroff,
2058 .maxlen = sizeof (int),
2060 .proc_handler = proc_dointvec,
2063 #ifdef CONFIG_SPARC64
2065 .procname = "tsb-ratio",
2066 .data = &sysctl_tsb_ratio,
2067 .maxlen = sizeof (int),
2069 .proc_handler = proc_dointvec,
2072 #ifdef CONFIG_PARISC
2074 .procname = "soft-power",
2075 .data = &pwrsw_enabled,
2076 .maxlen = sizeof (int),
2078 .proc_handler = proc_dointvec,
2081 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2083 .procname = "unaligned-trap",
2084 .data = &unaligned_enabled,
2085 .maxlen = sizeof (int),
2087 .proc_handler = proc_dointvec,
2091 .procname = "ctrl-alt-del",
2093 .maxlen = sizeof(int),
2095 .proc_handler = proc_dointvec,
2097 #ifdef CONFIG_FUNCTION_TRACER
2099 .procname = "ftrace_enabled",
2100 .data = &ftrace_enabled,
2101 .maxlen = sizeof(int),
2103 .proc_handler = ftrace_enable_sysctl,
2106 #ifdef CONFIG_STACK_TRACER
2108 .procname = "stack_tracer_enabled",
2109 .data = &stack_tracer_enabled,
2110 .maxlen = sizeof(int),
2112 .proc_handler = stack_trace_sysctl,
2115 #ifdef CONFIG_TRACING
2117 .procname = "ftrace_dump_on_oops",
2118 .data = &ftrace_dump_on_oops,
2119 .maxlen = sizeof(int),
2121 .proc_handler = proc_dointvec,
2124 .procname = "traceoff_on_warning",
2125 .data = &__disable_trace_on_warning,
2126 .maxlen = sizeof(__disable_trace_on_warning),
2128 .proc_handler = proc_dointvec,
2131 .procname = "tracepoint_printk",
2132 .data = &tracepoint_printk,
2133 .maxlen = sizeof(tracepoint_printk),
2135 .proc_handler = tracepoint_printk_sysctl,
2138 #ifdef CONFIG_KEXEC_CORE
2140 .procname = "kexec_load_disabled",
2141 .data = &kexec_load_disabled,
2142 .maxlen = sizeof(int),
2144 /* only handle a transition from default "0" to "1" */
2145 .proc_handler = proc_dointvec_minmax,
2146 .extra1 = SYSCTL_ONE,
2147 .extra2 = SYSCTL_ONE,
2150 #ifdef CONFIG_MODULES
2152 .procname = "modprobe",
2153 .data = &modprobe_path,
2154 .maxlen = KMOD_PATH_LEN,
2156 .proc_handler = proc_dostring,
2159 .procname = "modules_disabled",
2160 .data = &modules_disabled,
2161 .maxlen = sizeof(int),
2163 /* only handle a transition from default "0" to "1" */
2164 .proc_handler = proc_dointvec_minmax,
2165 .extra1 = SYSCTL_ONE,
2166 .extra2 = SYSCTL_ONE,
2169 #ifdef CONFIG_UEVENT_HELPER
2171 .procname = "hotplug",
2172 .data = &uevent_helper,
2173 .maxlen = UEVENT_HELPER_PATH_LEN,
2175 .proc_handler = proc_dostring,
2178 #ifdef CONFIG_CHR_DEV_SG
2180 .procname = "sg-big-buff",
2181 .data = &sg_big_buff,
2182 .maxlen = sizeof (int),
2184 .proc_handler = proc_dointvec,
2187 #ifdef CONFIG_BSD_PROCESS_ACCT
2191 .maxlen = 3*sizeof(int),
2193 .proc_handler = proc_dointvec,
2196 #ifdef CONFIG_MAGIC_SYSRQ
2198 .procname = "sysrq",
2200 .maxlen = sizeof (int),
2202 .proc_handler = sysrq_sysctl_handler,
2205 #ifdef CONFIG_PROC_SYSCTL
2207 .procname = "cad_pid",
2209 .maxlen = sizeof (int),
2211 .proc_handler = proc_do_cad_pid,
2215 .procname = "threads-max",
2217 .maxlen = sizeof(int),
2219 .proc_handler = sysctl_max_threads,
2222 .procname = "random",
2224 .child = random_table,
2227 .procname = "usermodehelper",
2229 .child = usermodehelper_table,
2231 #ifdef CONFIG_FW_LOADER_USER_HELPER
2233 .procname = "firmware_config",
2235 .child = firmware_config_table,
2239 .procname = "overflowuid",
2240 .data = &overflowuid,
2241 .maxlen = sizeof(int),
2243 .proc_handler = proc_dointvec_minmax,
2244 .extra1 = &minolduid,
2245 .extra2 = &maxolduid,
2248 .procname = "overflowgid",
2249 .data = &overflowgid,
2250 .maxlen = sizeof(int),
2252 .proc_handler = proc_dointvec_minmax,
2253 .extra1 = &minolduid,
2254 .extra2 = &maxolduid,
2258 .procname = "userprocess_debug",
2259 .data = &show_unhandled_signals,
2260 .maxlen = sizeof(int),
2262 .proc_handler = proc_dointvec,
2266 .procname = "pid_max",
2268 .maxlen = sizeof (int),
2270 .proc_handler = proc_dointvec_minmax,
2271 .extra1 = &pid_max_min,
2272 .extra2 = &pid_max_max,
2275 .procname = "panic_on_oops",
2276 .data = &panic_on_oops,
2277 .maxlen = sizeof(int),
2279 .proc_handler = proc_dointvec,
2282 .procname = "panic_print",
2283 .data = &panic_print,
2284 .maxlen = sizeof(unsigned long),
2286 .proc_handler = proc_doulongvec_minmax,
2288 #if defined CONFIG_PRINTK
2290 .procname = "printk",
2291 .data = &console_loglevel,
2292 .maxlen = 4*sizeof(int),
2294 .proc_handler = proc_dointvec,
2297 .procname = "printk_ratelimit",
2298 .data = &printk_ratelimit_state.interval,
2299 .maxlen = sizeof(int),
2301 .proc_handler = proc_dointvec_jiffies,
2304 .procname = "printk_ratelimit_burst",
2305 .data = &printk_ratelimit_state.burst,
2306 .maxlen = sizeof(int),
2308 .proc_handler = proc_dointvec,
2311 .procname = "printk_delay",
2312 .data = &printk_delay_msec,
2313 .maxlen = sizeof(int),
2315 .proc_handler = proc_dointvec_minmax,
2316 .extra1 = SYSCTL_ZERO,
2317 .extra2 = &ten_thousand,
2320 .procname = "printk_devkmsg",
2321 .data = devkmsg_log_str,
2322 .maxlen = DEVKMSG_STR_MAX_SIZE,
2324 .proc_handler = devkmsg_sysctl_set_loglvl,
2327 .procname = "dmesg_restrict",
2328 .data = &dmesg_restrict,
2329 .maxlen = sizeof(int),
2331 .proc_handler = proc_dointvec_minmax_sysadmin,
2332 .extra1 = SYSCTL_ZERO,
2333 .extra2 = SYSCTL_ONE,
2336 .procname = "kptr_restrict",
2337 .data = &kptr_restrict,
2338 .maxlen = sizeof(int),
2340 .proc_handler = proc_dointvec_minmax_sysadmin,
2341 .extra1 = SYSCTL_ZERO,
2342 .extra2 = SYSCTL_TWO,
2346 .procname = "ngroups_max",
2347 .data = &ngroups_max,
2348 .maxlen = sizeof (int),
2350 .proc_handler = proc_dointvec,
2353 .procname = "cap_last_cap",
2354 .data = (void *)&cap_last_cap,
2355 .maxlen = sizeof(int),
2357 .proc_handler = proc_dointvec,
2359 #if defined(CONFIG_LOCKUP_DETECTOR)
2361 .procname = "watchdog",
2362 .data = &watchdog_user_enabled,
2363 .maxlen = sizeof(int),
2365 .proc_handler = proc_watchdog,
2366 .extra1 = SYSCTL_ZERO,
2367 .extra2 = SYSCTL_ONE,
2370 .procname = "watchdog_thresh",
2371 .data = &watchdog_thresh,
2372 .maxlen = sizeof(int),
2374 .proc_handler = proc_watchdog_thresh,
2375 .extra1 = SYSCTL_ZERO,
2379 .procname = "nmi_watchdog",
2380 .data = &nmi_watchdog_user_enabled,
2381 .maxlen = sizeof(int),
2382 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2383 .proc_handler = proc_nmi_watchdog,
2384 .extra1 = SYSCTL_ZERO,
2385 .extra2 = SYSCTL_ONE,
2388 .procname = "watchdog_cpumask",
2389 .data = &watchdog_cpumask_bits,
2392 .proc_handler = proc_watchdog_cpumask,
2394 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2396 .procname = "soft_watchdog",
2397 .data = &soft_watchdog_user_enabled,
2398 .maxlen = sizeof(int),
2400 .proc_handler = proc_soft_watchdog,
2401 .extra1 = SYSCTL_ZERO,
2402 .extra2 = SYSCTL_ONE,
2405 .procname = "softlockup_panic",
2406 .data = &softlockup_panic,
2407 .maxlen = sizeof(int),
2409 .proc_handler = proc_dointvec_minmax,
2410 .extra1 = SYSCTL_ZERO,
2411 .extra2 = SYSCTL_ONE,
2415 .procname = "softlockup_all_cpu_backtrace",
2416 .data = &sysctl_softlockup_all_cpu_backtrace,
2417 .maxlen = sizeof(int),
2419 .proc_handler = proc_dointvec_minmax,
2420 .extra1 = SYSCTL_ZERO,
2421 .extra2 = SYSCTL_ONE,
2423 #endif /* CONFIG_SMP */
2425 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2427 .procname = "hardlockup_panic",
2428 .data = &hardlockup_panic,
2429 .maxlen = sizeof(int),
2431 .proc_handler = proc_dointvec_minmax,
2432 .extra1 = SYSCTL_ZERO,
2433 .extra2 = SYSCTL_ONE,
2437 .procname = "hardlockup_all_cpu_backtrace",
2438 .data = &sysctl_hardlockup_all_cpu_backtrace,
2439 .maxlen = sizeof(int),
2441 .proc_handler = proc_dointvec_minmax,
2442 .extra1 = SYSCTL_ZERO,
2443 .extra2 = SYSCTL_ONE,
2445 #endif /* CONFIG_SMP */
2449 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2451 .procname = "unknown_nmi_panic",
2452 .data = &unknown_nmi_panic,
2453 .maxlen = sizeof (int),
2455 .proc_handler = proc_dointvec,
2459 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2460 defined(CONFIG_DEBUG_STACKOVERFLOW)
2462 .procname = "panic_on_stackoverflow",
2463 .data = &sysctl_panic_on_stackoverflow,
2464 .maxlen = sizeof(int),
2466 .proc_handler = proc_dointvec,
2469 #if defined(CONFIG_X86)
2471 .procname = "panic_on_unrecovered_nmi",
2472 .data = &panic_on_unrecovered_nmi,
2473 .maxlen = sizeof(int),
2475 .proc_handler = proc_dointvec,
2478 .procname = "panic_on_io_nmi",
2479 .data = &panic_on_io_nmi,
2480 .maxlen = sizeof(int),
2482 .proc_handler = proc_dointvec,
2485 .procname = "bootloader_type",
2486 .data = &bootloader_type,
2487 .maxlen = sizeof (int),
2489 .proc_handler = proc_dointvec,
2492 .procname = "bootloader_version",
2493 .data = &bootloader_version,
2494 .maxlen = sizeof (int),
2496 .proc_handler = proc_dointvec,
2499 .procname = "io_delay_type",
2500 .data = &io_delay_type,
2501 .maxlen = sizeof(int),
2503 .proc_handler = proc_dointvec,
2506 #if defined(CONFIG_MMU)
2508 .procname = "randomize_va_space",
2509 .data = &randomize_va_space,
2510 .maxlen = sizeof(int),
2512 .proc_handler = proc_dointvec,
2515 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2517 .procname = "spin_retry",
2518 .data = &spin_retry,
2519 .maxlen = sizeof (int),
2521 .proc_handler = proc_dointvec,
2524 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2526 .procname = "acpi_video_flags",
2527 .data = &acpi_realmode_flags,
2528 .maxlen = sizeof (unsigned long),
2530 .proc_handler = proc_doulongvec_minmax,
2533 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2535 .procname = "ignore-unaligned-usertrap",
2536 .data = &no_unaligned_warning,
2537 .maxlen = sizeof (int),
2539 .proc_handler = proc_dointvec,
2544 .procname = "unaligned-dump-stack",
2545 .data = &unaligned_dump_stack,
2546 .maxlen = sizeof (int),
2548 .proc_handler = proc_dointvec,
2551 #ifdef CONFIG_DETECT_HUNG_TASK
2554 .procname = "hung_task_all_cpu_backtrace",
2555 .data = &sysctl_hung_task_all_cpu_backtrace,
2556 .maxlen = sizeof(int),
2558 .proc_handler = proc_dointvec_minmax,
2559 .extra1 = SYSCTL_ZERO,
2560 .extra2 = SYSCTL_ONE,
2562 #endif /* CONFIG_SMP */
2564 .procname = "hung_task_panic",
2565 .data = &sysctl_hung_task_panic,
2566 .maxlen = sizeof(int),
2568 .proc_handler = proc_dointvec_minmax,
2569 .extra1 = SYSCTL_ZERO,
2570 .extra2 = SYSCTL_ONE,
2573 .procname = "hung_task_check_count",
2574 .data = &sysctl_hung_task_check_count,
2575 .maxlen = sizeof(int),
2577 .proc_handler = proc_dointvec_minmax,
2578 .extra1 = SYSCTL_ZERO,
2581 .procname = "hung_task_timeout_secs",
2582 .data = &sysctl_hung_task_timeout_secs,
2583 .maxlen = sizeof(unsigned long),
2585 .proc_handler = proc_dohung_task_timeout_secs,
2586 .extra2 = &hung_task_timeout_max,
2589 .procname = "hung_task_check_interval_secs",
2590 .data = &sysctl_hung_task_check_interval_secs,
2591 .maxlen = sizeof(unsigned long),
2593 .proc_handler = proc_dohung_task_timeout_secs,
2594 .extra2 = &hung_task_timeout_max,
2597 .procname = "hung_task_warnings",
2598 .data = &sysctl_hung_task_warnings,
2599 .maxlen = sizeof(int),
2601 .proc_handler = proc_dointvec_minmax,
2602 .extra1 = SYSCTL_NEG_ONE,
2605 #ifdef CONFIG_RT_MUTEXES
2607 .procname = "max_lock_depth",
2608 .data = &max_lock_depth,
2609 .maxlen = sizeof(int),
2611 .proc_handler = proc_dointvec,
2615 .procname = "poweroff_cmd",
2616 .data = &poweroff_cmd,
2617 .maxlen = POWEROFF_CMD_PATH_LEN,
2619 .proc_handler = proc_dostring,
2625 .child = key_sysctls,
2628 #ifdef CONFIG_PERF_EVENTS
2630 * User-space scripts rely on the existence of this file
2631 * as a feature check for perf_events being enabled.
2633 * So it's an ABI, do not remove!
2636 .procname = "perf_event_paranoid",
2637 .data = &sysctl_perf_event_paranoid,
2638 .maxlen = sizeof(sysctl_perf_event_paranoid),
2640 .proc_handler = proc_dointvec,
2643 .procname = "perf_event_mlock_kb",
2644 .data = &sysctl_perf_event_mlock,
2645 .maxlen = sizeof(sysctl_perf_event_mlock),
2647 .proc_handler = proc_dointvec,
2650 .procname = "perf_event_max_sample_rate",
2651 .data = &sysctl_perf_event_sample_rate,
2652 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2654 .proc_handler = perf_proc_update_handler,
2655 .extra1 = SYSCTL_ONE,
2658 .procname = "perf_cpu_time_max_percent",
2659 .data = &sysctl_perf_cpu_time_max_percent,
2660 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2662 .proc_handler = perf_cpu_time_max_percent_handler,
2663 .extra1 = SYSCTL_ZERO,
2664 .extra2 = SYSCTL_ONE_HUNDRED,
2667 .procname = "perf_event_max_stack",
2668 .data = &sysctl_perf_event_max_stack,
2669 .maxlen = sizeof(sysctl_perf_event_max_stack),
2671 .proc_handler = perf_event_max_stack_handler,
2672 .extra1 = SYSCTL_ZERO,
2673 .extra2 = &six_hundred_forty_kb,
2676 .procname = "perf_event_max_contexts_per_stack",
2677 .data = &sysctl_perf_event_max_contexts_per_stack,
2678 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2680 .proc_handler = perf_event_max_stack_handler,
2681 .extra1 = SYSCTL_ZERO,
2682 .extra2 = SYSCTL_ONE_THOUSAND,
2686 .procname = "panic_on_warn",
2687 .data = &panic_on_warn,
2688 .maxlen = sizeof(int),
2690 .proc_handler = proc_dointvec_minmax,
2691 .extra1 = SYSCTL_ZERO,
2692 .extra2 = SYSCTL_ONE,
2694 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2696 .procname = "timer_migration",
2697 .data = &sysctl_timer_migration,
2698 .maxlen = sizeof(unsigned int),
2700 .proc_handler = timer_migration_handler,
2701 .extra1 = SYSCTL_ZERO,
2702 .extra2 = SYSCTL_ONE,
2705 #ifdef CONFIG_BPF_SYSCALL
2707 .procname = "unprivileged_bpf_disabled",
2708 .data = &sysctl_unprivileged_bpf_disabled,
2709 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2711 .proc_handler = bpf_unpriv_handler,
2712 .extra1 = SYSCTL_ZERO,
2713 .extra2 = SYSCTL_TWO,
2716 .procname = "bpf_stats_enabled",
2717 .data = &bpf_stats_enabled_key.key,
2718 .maxlen = sizeof(bpf_stats_enabled_key),
2720 .proc_handler = bpf_stats_handler,
2723 #if defined(CONFIG_TREE_RCU)
2725 .procname = "panic_on_rcu_stall",
2726 .data = &sysctl_panic_on_rcu_stall,
2727 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2729 .proc_handler = proc_dointvec_minmax,
2730 .extra1 = SYSCTL_ZERO,
2731 .extra2 = SYSCTL_ONE,
2734 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2736 .procname = "stack_erasing",
2738 .maxlen = sizeof(int),
2740 .proc_handler = stack_erasing_sysctl,
2741 .extra1 = SYSCTL_ZERO,
2742 .extra2 = SYSCTL_ONE,
2748 static struct ctl_table vm_table[] = {
2750 .procname = "overcommit_memory",
2751 .data = &sysctl_overcommit_memory,
2752 .maxlen = sizeof(sysctl_overcommit_memory),
2754 .proc_handler = overcommit_policy_handler,
2755 .extra1 = SYSCTL_ZERO,
2756 .extra2 = SYSCTL_TWO,
2759 .procname = "panic_on_oom",
2760 .data = &sysctl_panic_on_oom,
2761 .maxlen = sizeof(sysctl_panic_on_oom),
2763 .proc_handler = proc_dointvec_minmax,
2764 .extra1 = SYSCTL_ZERO,
2765 .extra2 = SYSCTL_TWO,
2768 .procname = "oom_kill_allocating_task",
2769 .data = &sysctl_oom_kill_allocating_task,
2770 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2772 .proc_handler = proc_dointvec,
2775 .procname = "oom_dump_tasks",
2776 .data = &sysctl_oom_dump_tasks,
2777 .maxlen = sizeof(sysctl_oom_dump_tasks),
2779 .proc_handler = proc_dointvec,
2782 .procname = "overcommit_ratio",
2783 .data = &sysctl_overcommit_ratio,
2784 .maxlen = sizeof(sysctl_overcommit_ratio),
2786 .proc_handler = overcommit_ratio_handler,
2789 .procname = "overcommit_kbytes",
2790 .data = &sysctl_overcommit_kbytes,
2791 .maxlen = sizeof(sysctl_overcommit_kbytes),
2793 .proc_handler = overcommit_kbytes_handler,
2796 .procname = "page-cluster",
2797 .data = &page_cluster,
2798 .maxlen = sizeof(int),
2800 .proc_handler = proc_dointvec_minmax,
2801 .extra1 = SYSCTL_ZERO,
2804 .procname = "dirty_background_ratio",
2805 .data = &dirty_background_ratio,
2806 .maxlen = sizeof(dirty_background_ratio),
2808 .proc_handler = dirty_background_ratio_handler,
2809 .extra1 = SYSCTL_ZERO,
2810 .extra2 = SYSCTL_ONE_HUNDRED,
2813 .procname = "dirty_background_bytes",
2814 .data = &dirty_background_bytes,
2815 .maxlen = sizeof(dirty_background_bytes),
2817 .proc_handler = dirty_background_bytes_handler,
2821 .procname = "dirty_ratio",
2822 .data = &vm_dirty_ratio,
2823 .maxlen = sizeof(vm_dirty_ratio),
2825 .proc_handler = dirty_ratio_handler,
2826 .extra1 = SYSCTL_ZERO,
2827 .extra2 = SYSCTL_ONE_HUNDRED,
2830 .procname = "dirty_bytes",
2831 .data = &vm_dirty_bytes,
2832 .maxlen = sizeof(vm_dirty_bytes),
2834 .proc_handler = dirty_bytes_handler,
2835 .extra1 = &dirty_bytes_min,
2838 .procname = "dirty_writeback_centisecs",
2839 .data = &dirty_writeback_interval,
2840 .maxlen = sizeof(dirty_writeback_interval),
2842 .proc_handler = dirty_writeback_centisecs_handler,
2845 .procname = "dirty_expire_centisecs",
2846 .data = &dirty_expire_interval,
2847 .maxlen = sizeof(dirty_expire_interval),
2849 .proc_handler = proc_dointvec_minmax,
2850 .extra1 = SYSCTL_ZERO,
2853 .procname = "dirtytime_expire_seconds",
2854 .data = &dirtytime_expire_interval,
2855 .maxlen = sizeof(dirtytime_expire_interval),
2857 .proc_handler = dirtytime_interval_handler,
2858 .extra1 = SYSCTL_ZERO,
2861 .procname = "swappiness",
2862 .data = &vm_swappiness,
2863 .maxlen = sizeof(vm_swappiness),
2865 .proc_handler = proc_dointvec_minmax,
2866 .extra1 = SYSCTL_ZERO,
2867 .extra2 = SYSCTL_TWO_HUNDRED,
2871 .procname = "numa_stat",
2872 .data = &sysctl_vm_numa_stat,
2873 .maxlen = sizeof(int),
2875 .proc_handler = sysctl_vm_numa_stat_handler,
2876 .extra1 = SYSCTL_ZERO,
2877 .extra2 = SYSCTL_ONE,
2880 #ifdef CONFIG_HUGETLB_PAGE
2882 .procname = "nr_hugepages",
2884 .maxlen = sizeof(unsigned long),
2886 .proc_handler = hugetlb_sysctl_handler,
2890 .procname = "nr_hugepages_mempolicy",
2892 .maxlen = sizeof(unsigned long),
2894 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2898 .procname = "hugetlb_shm_group",
2899 .data = &sysctl_hugetlb_shm_group,
2900 .maxlen = sizeof(gid_t),
2902 .proc_handler = proc_dointvec,
2905 .procname = "nr_overcommit_hugepages",
2907 .maxlen = sizeof(unsigned long),
2909 .proc_handler = hugetlb_overcommit_handler,
2913 .procname = "lowmem_reserve_ratio",
2914 .data = &sysctl_lowmem_reserve_ratio,
2915 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2917 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2920 .procname = "drop_caches",
2921 .data = &sysctl_drop_caches,
2922 .maxlen = sizeof(int),
2924 .proc_handler = drop_caches_sysctl_handler,
2925 .extra1 = SYSCTL_ONE,
2926 .extra2 = SYSCTL_FOUR,
2928 #ifdef CONFIG_COMPACTION
2930 .procname = "compact_memory",
2931 .data = &sysctl_compact_memory,
2932 .maxlen = sizeof(int),
2934 .proc_handler = sysctl_compaction_handler,
2937 .procname = "compaction_proactiveness",
2938 .data = &sysctl_compaction_proactiveness,
2939 .maxlen = sizeof(sysctl_compaction_proactiveness),
2941 .proc_handler = proc_dointvec_minmax,
2942 .extra1 = SYSCTL_ZERO,
2943 .extra2 = SYSCTL_ONE_HUNDRED,
2946 .procname = "extfrag_threshold",
2947 .data = &sysctl_extfrag_threshold,
2948 .maxlen = sizeof(int),
2950 .proc_handler = proc_dointvec_minmax,
2951 .extra1 = &min_extfrag_threshold,
2952 .extra2 = &max_extfrag_threshold,
2955 .procname = "compact_unevictable_allowed",
2956 .data = &sysctl_compact_unevictable_allowed,
2957 .maxlen = sizeof(int),
2959 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2960 .extra1 = SYSCTL_ZERO,
2961 .extra2 = SYSCTL_ONE,
2964 #endif /* CONFIG_COMPACTION */
2966 .procname = "min_free_kbytes",
2967 .data = &min_free_kbytes,
2968 .maxlen = sizeof(min_free_kbytes),
2970 .proc_handler = min_free_kbytes_sysctl_handler,
2971 .extra1 = SYSCTL_ZERO,
2974 .procname = "watermark_boost_factor",
2975 .data = &watermark_boost_factor,
2976 .maxlen = sizeof(watermark_boost_factor),
2978 .proc_handler = proc_dointvec_minmax,
2979 .extra1 = SYSCTL_ZERO,
2982 .procname = "watermark_scale_factor",
2983 .data = &watermark_scale_factor,
2984 .maxlen = sizeof(watermark_scale_factor),
2986 .proc_handler = watermark_scale_factor_sysctl_handler,
2987 .extra1 = SYSCTL_ONE,
2988 .extra2 = SYSCTL_THREE_THOUSAND,
2991 .procname = "percpu_pagelist_fraction",
2992 .data = &percpu_pagelist_fraction,
2993 .maxlen = sizeof(percpu_pagelist_fraction),
2995 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2996 .extra1 = SYSCTL_ZERO,
2999 .procname = "page_lock_unfairness",
3000 .data = &sysctl_page_lock_unfairness,
3001 .maxlen = sizeof(sysctl_page_lock_unfairness),
3003 .proc_handler = proc_dointvec_minmax,
3004 .extra1 = SYSCTL_ZERO,
3008 .procname = "max_map_count",
3009 .data = &sysctl_max_map_count,
3010 .maxlen = sizeof(sysctl_max_map_count),
3012 .proc_handler = proc_dointvec_minmax,
3013 .extra1 = SYSCTL_ZERO,
3017 .procname = "nr_trim_pages",
3018 .data = &sysctl_nr_trim_pages,
3019 .maxlen = sizeof(sysctl_nr_trim_pages),
3021 .proc_handler = proc_dointvec_minmax,
3022 .extra1 = SYSCTL_ZERO,
3026 .procname = "laptop_mode",
3027 .data = &laptop_mode,
3028 .maxlen = sizeof(laptop_mode),
3030 .proc_handler = proc_dointvec_jiffies,
3033 .procname = "block_dump",
3034 .data = &block_dump,
3035 .maxlen = sizeof(block_dump),
3037 .proc_handler = proc_dointvec_minmax,
3038 .extra1 = SYSCTL_ZERO,
3041 .procname = "vfs_cache_pressure",
3042 .data = &sysctl_vfs_cache_pressure,
3043 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3045 .proc_handler = proc_dointvec_minmax,
3046 .extra1 = SYSCTL_ZERO,
3048 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3049 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3051 .procname = "legacy_va_layout",
3052 .data = &sysctl_legacy_va_layout,
3053 .maxlen = sizeof(sysctl_legacy_va_layout),
3055 .proc_handler = proc_dointvec_minmax,
3056 .extra1 = SYSCTL_ZERO,
3061 .procname = "zone_reclaim_mode",
3062 .data = &node_reclaim_mode,
3063 .maxlen = sizeof(node_reclaim_mode),
3065 .proc_handler = proc_dointvec_minmax,
3066 .extra1 = SYSCTL_ZERO,
3069 .procname = "min_unmapped_ratio",
3070 .data = &sysctl_min_unmapped_ratio,
3071 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3073 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3074 .extra1 = SYSCTL_ZERO,
3075 .extra2 = SYSCTL_ONE_HUNDRED,
3078 .procname = "min_slab_ratio",
3079 .data = &sysctl_min_slab_ratio,
3080 .maxlen = sizeof(sysctl_min_slab_ratio),
3082 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3083 .extra1 = SYSCTL_ZERO,
3084 .extra2 = SYSCTL_ONE_HUNDRED,
3089 .procname = "stat_interval",
3090 .data = &sysctl_stat_interval,
3091 .maxlen = sizeof(sysctl_stat_interval),
3093 .proc_handler = proc_dointvec_jiffies,
3096 .procname = "stat_refresh",
3100 .proc_handler = vmstat_refresh,
3105 .procname = "mmap_min_addr",
3106 .data = &dac_mmap_min_addr,
3107 .maxlen = sizeof(unsigned long),
3109 .proc_handler = mmap_min_addr_handler,
3114 .procname = "numa_zonelist_order",
3115 .data = &numa_zonelist_order,
3116 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3118 .proc_handler = numa_zonelist_order_handler,
3121 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3122 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3124 .procname = "vdso_enabled",
3125 #ifdef CONFIG_X86_32
3126 .data = &vdso32_enabled,
3127 .maxlen = sizeof(vdso32_enabled),
3129 .data = &vdso_enabled,
3130 .maxlen = sizeof(vdso_enabled),
3133 .proc_handler = proc_dointvec,
3134 .extra1 = SYSCTL_ZERO,
3137 #ifdef CONFIG_HIGHMEM
3139 .procname = "highmem_is_dirtyable",
3140 .data = &vm_highmem_is_dirtyable,
3141 .maxlen = sizeof(vm_highmem_is_dirtyable),
3143 .proc_handler = proc_dointvec_minmax,
3144 .extra1 = SYSCTL_ZERO,
3145 .extra2 = SYSCTL_ONE,
3148 #ifdef CONFIG_MEMORY_FAILURE
3150 .procname = "memory_failure_early_kill",
3151 .data = &sysctl_memory_failure_early_kill,
3152 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3154 .proc_handler = proc_dointvec_minmax,
3155 .extra1 = SYSCTL_ZERO,
3156 .extra2 = SYSCTL_ONE,
3159 .procname = "memory_failure_recovery",
3160 .data = &sysctl_memory_failure_recovery,
3161 .maxlen = sizeof(sysctl_memory_failure_recovery),
3163 .proc_handler = proc_dointvec_minmax,
3164 .extra1 = SYSCTL_ZERO,
3165 .extra2 = SYSCTL_ONE,
3169 .procname = "user_reserve_kbytes",
3170 .data = &sysctl_user_reserve_kbytes,
3171 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3173 .proc_handler = proc_doulongvec_minmax,
3176 .procname = "admin_reserve_kbytes",
3177 .data = &sysctl_admin_reserve_kbytes,
3178 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3180 .proc_handler = proc_doulongvec_minmax,
3182 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3184 .procname = "mmap_rnd_bits",
3185 .data = &mmap_rnd_bits,
3186 .maxlen = sizeof(mmap_rnd_bits),
3188 .proc_handler = proc_dointvec_minmax,
3189 .extra1 = (void *)&mmap_rnd_bits_min,
3190 .extra2 = (void *)&mmap_rnd_bits_max,
3193 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3195 .procname = "mmap_rnd_compat_bits",
3196 .data = &mmap_rnd_compat_bits,
3197 .maxlen = sizeof(mmap_rnd_compat_bits),
3199 .proc_handler = proc_dointvec_minmax,
3200 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3201 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3204 #ifdef CONFIG_USERFAULTFD
3206 .procname = "unprivileged_userfaultfd",
3207 .data = &sysctl_unprivileged_userfaultfd,
3208 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3210 .proc_handler = proc_dointvec_minmax,
3211 .extra1 = SYSCTL_ZERO,
3212 .extra2 = SYSCTL_ONE,
3218 static struct ctl_table fs_table[] = {
3220 .procname = "inode-nr",
3221 .data = &inodes_stat,
3222 .maxlen = 2*sizeof(long),
3224 .proc_handler = proc_nr_inodes,
3227 .procname = "inode-state",
3228 .data = &inodes_stat,
3229 .maxlen = 7*sizeof(long),
3231 .proc_handler = proc_nr_inodes,
3234 .procname = "file-nr",
3235 .data = &files_stat,
3236 .maxlen = sizeof(files_stat),
3238 .proc_handler = proc_nr_files,
3241 .procname = "file-max",
3242 .data = &files_stat.max_files,
3243 .maxlen = sizeof(files_stat.max_files),
3245 .proc_handler = proc_doulongvec_minmax,
3247 .extra2 = &long_max,
3250 .procname = "nr_open",
3251 .data = &sysctl_nr_open,
3252 .maxlen = sizeof(unsigned int),
3254 .proc_handler = proc_dointvec_minmax,
3255 .extra1 = &sysctl_nr_open_min,
3256 .extra2 = &sysctl_nr_open_max,
3259 .procname = "dentry-state",
3260 .data = &dentry_stat,
3261 .maxlen = 6*sizeof(long),
3263 .proc_handler = proc_nr_dentry,
3266 .procname = "overflowuid",
3267 .data = &fs_overflowuid,
3268 .maxlen = sizeof(int),
3270 .proc_handler = proc_dointvec_minmax,
3271 .extra1 = &minolduid,
3272 .extra2 = &maxolduid,
3275 .procname = "overflowgid",
3276 .data = &fs_overflowgid,
3277 .maxlen = sizeof(int),
3279 .proc_handler = proc_dointvec_minmax,
3280 .extra1 = &minolduid,
3281 .extra2 = &maxolduid,
3283 #ifdef CONFIG_FILE_LOCKING
3285 .procname = "leases-enable",
3286 .data = &leases_enable,
3287 .maxlen = sizeof(int),
3289 .proc_handler = proc_dointvec,
3292 #ifdef CONFIG_DNOTIFY
3294 .procname = "dir-notify-enable",
3295 .data = &dir_notify_enable,
3296 .maxlen = sizeof(int),
3298 .proc_handler = proc_dointvec,
3302 #ifdef CONFIG_FILE_LOCKING
3304 .procname = "lease-break-time",
3305 .data = &lease_break_time,
3306 .maxlen = sizeof(int),
3308 .proc_handler = proc_dointvec,
3313 .procname = "aio-nr",
3315 .maxlen = sizeof(aio_nr),
3317 .proc_handler = proc_doulongvec_minmax,
3320 .procname = "aio-max-nr",
3321 .data = &aio_max_nr,
3322 .maxlen = sizeof(aio_max_nr),
3324 .proc_handler = proc_doulongvec_minmax,
3326 #endif /* CONFIG_AIO */
3327 #ifdef CONFIG_INOTIFY_USER
3329 .procname = "inotify",
3331 .child = inotify_table,
3336 .procname = "epoll",
3338 .child = epoll_table,
3343 .procname = "protected_symlinks",
3344 .data = &sysctl_protected_symlinks,
3345 .maxlen = sizeof(int),
3347 .proc_handler = proc_dointvec_minmax,
3348 .extra1 = SYSCTL_ZERO,
3349 .extra2 = SYSCTL_ONE,
3352 .procname = "protected_hardlinks",
3353 .data = &sysctl_protected_hardlinks,
3354 .maxlen = sizeof(int),
3356 .proc_handler = proc_dointvec_minmax,
3357 .extra1 = SYSCTL_ZERO,
3358 .extra2 = SYSCTL_ONE,
3361 .procname = "protected_fifos",
3362 .data = &sysctl_protected_fifos,
3363 .maxlen = sizeof(int),
3365 .proc_handler = proc_dointvec_minmax,
3366 .extra1 = SYSCTL_ZERO,
3367 .extra2 = SYSCTL_TWO,
3370 .procname = "protected_regular",
3371 .data = &sysctl_protected_regular,
3372 .maxlen = sizeof(int),
3374 .proc_handler = proc_dointvec_minmax,
3375 .extra1 = SYSCTL_ZERO,
3376 .extra2 = SYSCTL_TWO,
3379 .procname = "suid_dumpable",
3380 .data = &suid_dumpable,
3381 .maxlen = sizeof(int),
3383 .proc_handler = proc_dointvec_minmax_coredump,
3384 .extra1 = SYSCTL_ZERO,
3385 .extra2 = SYSCTL_TWO,
3387 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3389 .procname = "binfmt_misc",
3391 .child = sysctl_mount_point,
3395 .procname = "pipe-max-size",
3396 .data = &pipe_max_size,
3397 .maxlen = sizeof(pipe_max_size),
3399 .proc_handler = proc_dopipe_max_size,
3402 .procname = "pipe-user-pages-hard",
3403 .data = &pipe_user_pages_hard,
3404 .maxlen = sizeof(pipe_user_pages_hard),
3406 .proc_handler = proc_doulongvec_minmax,
3409 .procname = "pipe-user-pages-soft",
3410 .data = &pipe_user_pages_soft,
3411 .maxlen = sizeof(pipe_user_pages_soft),
3413 .proc_handler = proc_doulongvec_minmax,
3416 .procname = "mount-max",
3417 .data = &sysctl_mount_max,
3418 .maxlen = sizeof(unsigned int),
3420 .proc_handler = proc_dointvec_minmax,
3421 .extra1 = SYSCTL_ONE,
3426 static struct ctl_table debug_table[] = {
3427 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3429 .procname = "exception-trace",
3430 .data = &show_unhandled_signals,
3431 .maxlen = sizeof(int),
3433 .proc_handler = proc_dointvec
3436 #if defined(CONFIG_OPTPROBES)
3438 .procname = "kprobes-optimization",
3439 .data = &sysctl_kprobes_optimization,
3440 .maxlen = sizeof(int),
3442 .proc_handler = proc_kprobes_optimization_handler,
3443 .extra1 = SYSCTL_ZERO,
3444 .extra2 = SYSCTL_ONE,
3450 static struct ctl_table dev_table[] = {
3454 static struct ctl_table sysctl_base_table[] = {
3456 .procname = "kernel",
3458 .child = kern_table,
3471 .procname = "debug",
3473 .child = debug_table,
3483 int __init sysctl_init(void)
3485 struct ctl_table_header *hdr;
3487 hdr = register_sysctl_table(sysctl_base_table);
3488 kmemleak_not_leak(hdr);
3491 #endif /* CONFIG_SYSCTL */
3493 * No sense putting this after each symbol definition, twice,
3494 * exception granted :-)
3496 EXPORT_SYMBOL(proc_dointvec);
3497 EXPORT_SYMBOL(proc_douintvec);
3498 EXPORT_SYMBOL(proc_dointvec_jiffies);
3499 EXPORT_SYMBOL(proc_dointvec_minmax);
3500 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3501 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3502 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3503 EXPORT_SYMBOL(proc_dostring);
3504 EXPORT_SYMBOL(proc_doulongvec_minmax);
3505 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3506 EXPORT_SYMBOL(proc_do_large_bitmap);