1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/sched/coredump.h>
67 #include <linux/kexec.h>
68 #include <linux/bpf.h>
69 #include <linux/mount.h>
70 #include <linux/userfaultfd_k.h>
71 #include <linux/coredump.h>
72 #include <linux/latencytop.h>
73 #include <linux/pid.h>
75 #include "../lib/kstrtox.h"
77 #include <linux/uaccess.h>
78 #include <asm/processor.h>
82 #include <asm/stacktrace.h>
86 #include <asm/setup.h>
88 #ifdef CONFIG_BSD_PROCESS_ACCT
89 #include <linux/acct.h>
91 #ifdef CONFIG_RT_MUTEXES
92 #include <linux/rtmutex.h>
94 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
95 #include <linux/lockdep.h>
97 #ifdef CONFIG_CHR_DEV_SG
100 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101 #include <linux/stackleak.h>
103 #ifdef CONFIG_LOCKUP_DETECTOR
104 #include <linux/nmi.h>
107 #if defined(CONFIG_SYSCTL)
109 /* Constants used for minimum and maximum */
110 #ifdef CONFIG_LOCKUP_DETECTOR
111 static int sixty = 60;
114 static int __maybe_unused neg_one = -1;
115 static int __maybe_unused two = 2;
116 static int __maybe_unused four = 4;
117 static unsigned long zero_ul;
118 static unsigned long one_ul = 1;
119 static unsigned long long_max = LONG_MAX;
120 static int one_hundred = 100;
121 static int one_thousand = 1000;
123 static int ten_thousand = 10000;
125 #ifdef CONFIG_PERF_EVENTS
126 static int six_hundred_forty_kb = 640 * 1024;
129 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
130 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
132 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
133 static int maxolduid = 65535;
134 static int minolduid;
136 static int ngroups_max = NGROUPS_MAX;
137 static const int cap_last_cap = CAP_LAST_CAP;
140 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
141 * and hung_task_check_interval_secs
143 #ifdef CONFIG_DETECT_HUNG_TASK
144 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
147 #ifdef CONFIG_INOTIFY_USER
148 #include <linux/inotify.h>
151 #ifdef CONFIG_PROC_SYSCTL
154 * enum sysctl_writes_mode - supported sysctl write modes
156 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
157 * to be written, and multiple writes on the same sysctl file descriptor
158 * will rewrite the sysctl value, regardless of file position. No warning
159 * is issued when the initial position is not 0.
160 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
162 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
163 * file position 0 and the value must be fully contained in the buffer
164 * sent to the write syscall. If dealing with strings respect the file
165 * position, but restrict this to the max length of the buffer, anything
166 * passed the max length will be ignored. Multiple writes will append
169 * These write modes control how current file position affects the behavior of
170 * updating sysctl values through the proc interface on each write.
172 enum sysctl_writes_mode {
173 SYSCTL_WRITES_LEGACY = -1,
174 SYSCTL_WRITES_WARN = 0,
175 SYSCTL_WRITES_STRICT = 1,
178 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
179 #endif /* CONFIG_PROC_SYSCTL */
181 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
182 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
183 int sysctl_legacy_va_layout;
186 #ifdef CONFIG_SCHED_DEBUG
187 static int min_sched_granularity_ns = 100000; /* 100 usecs */
188 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
189 static int min_wakeup_granularity_ns; /* 0 usecs */
190 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
192 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
193 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
194 #endif /* CONFIG_SMP */
195 #endif /* CONFIG_SCHED_DEBUG */
197 #ifdef CONFIG_COMPACTION
198 static int min_extfrag_threshold;
199 static int max_extfrag_threshold = 1000;
202 #endif /* CONFIG_SYSCTL */
204 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
205 static int bpf_stats_handler(struct ctl_table *table, int write,
206 void __user *buffer, size_t *lenp,
209 struct static_key *key = (struct static_key *)table->data;
210 static int saved_val;
212 struct ctl_table tmp = {
214 .maxlen = sizeof(val),
216 .extra1 = SYSCTL_ZERO,
217 .extra2 = SYSCTL_ONE,
220 if (write && !capable(CAP_SYS_ADMIN))
223 mutex_lock(&bpf_stats_enabled_mutex);
225 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
226 if (write && !ret && val != saved_val) {
228 static_key_slow_inc(key);
230 static_key_slow_dec(key);
233 mutex_unlock(&bpf_stats_enabled_mutex);
242 #ifdef CONFIG_PROC_SYSCTL
244 static int _proc_do_string(char *data, int maxlen, int write,
245 char *buffer, size_t *lenp, loff_t *ppos)
250 if (!data || !maxlen || !*lenp) {
256 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
257 /* Only continue writes not past the end of buffer. */
259 if (len > maxlen - 1)
266 /* Start writing from beginning of buffer. */
272 while ((p - buffer) < *lenp && len < maxlen - 1) {
274 if (c == 0 || c == '\n')
295 memcpy(buffer, data, len);
306 static void warn_sysctl_write(struct ctl_table *table)
308 pr_warn_once("%s wrote to %s when file position was not 0!\n"
309 "This will not be supported in the future. To silence this\n"
310 "warning, set kernel.sysctl_writes_strict = -1\n",
311 current->comm, table->procname);
315 * proc_first_pos_non_zero_ignore - check if first position is allowed
316 * @ppos: file position
317 * @table: the sysctl table
319 * Returns true if the first position is non-zero and the sysctl_writes_strict
320 * mode indicates this is not allowed for numeric input types. String proc
321 * handlers can ignore the return value.
323 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
324 struct ctl_table *table)
329 switch (sysctl_writes_strict) {
330 case SYSCTL_WRITES_STRICT:
332 case SYSCTL_WRITES_WARN:
333 warn_sysctl_write(table);
341 * proc_dostring - read a string sysctl
342 * @table: the sysctl table
343 * @write: %TRUE if this is a write to the sysctl file
344 * @buffer: the user buffer
345 * @lenp: the size of the user buffer
346 * @ppos: file position
348 * Reads/writes a string from/to the user buffer. If the kernel
349 * buffer provided is not large enough to hold the string, the
350 * string is truncated. The copied string is %NULL-terminated.
351 * If the string is being read by the user process, it is copied
352 * and a newline '\n' is added. It is truncated if the buffer is
355 * Returns 0 on success.
357 int proc_dostring(struct ctl_table *table, int write,
358 void *buffer, size_t *lenp, loff_t *ppos)
361 proc_first_pos_non_zero_ignore(ppos, table);
363 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
367 static size_t proc_skip_spaces(char **buf)
370 char *tmp = skip_spaces(*buf);
376 static void proc_skip_char(char **buf, size_t *size, const char v)
387 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
390 * @cp: kernel buffer containing the string to parse
391 * @endp: pointer to store the trailing characters
392 * @base: the base to use
393 * @res: where the parsed integer will be stored
395 * In case of success 0 is returned and @res will contain the parsed integer,
396 * @endp will hold any trailing characters.
397 * This function will fail the parse on overflow. If there wasn't an overflow
398 * the function will defer the decision what characters count as invalid to the
401 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
404 unsigned long long result;
407 cp = _parse_integer_fixup_radix(cp, &base);
408 rv = _parse_integer(cp, base, &result);
409 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
417 *res = (unsigned long)result;
423 * proc_get_long - reads an ASCII formatted integer from a user buffer
425 * @buf: a kernel buffer
426 * @size: size of the kernel buffer
427 * @val: this is where the number will be stored
428 * @neg: set to %TRUE if number is negative
429 * @perm_tr: a vector which contains the allowed trailers
430 * @perm_tr_len: size of the perm_tr vector
431 * @tr: pointer to store the trailer character
433 * In case of success %0 is returned and @buf and @size are updated with
434 * the amount of bytes read. If @tr is non-NULL and a trailing
435 * character exists (size is non-zero after returning from this
436 * function), @tr is updated with the trailing character.
438 static int proc_get_long(char **buf, size_t *size,
439 unsigned long *val, bool *neg,
440 const char *perm_tr, unsigned perm_tr_len, char *tr)
443 char *p, tmp[TMPBUFLEN];
449 if (len > TMPBUFLEN - 1)
452 memcpy(tmp, *buf, len);
456 if (*p == '-' && *size > 1) {
464 if (strtoul_lenient(p, &p, 0, val))
469 /* We don't know if the next char is whitespace thus we may accept
470 * invalid integers (e.g. 1234...a) or two integers instead of one
471 * (e.g. 123...1). So lets not allow such large numbers. */
472 if (len == TMPBUFLEN - 1)
475 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
478 if (tr && (len < *size))
488 * proc_put_long - converts an integer to a decimal ASCII formatted string
490 * @buf: the user buffer
491 * @size: the size of the user buffer
492 * @val: the integer to be converted
493 * @neg: sign of the number, %TRUE for negative
495 * In case of success @buf and @size are updated with the amount of bytes
498 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
501 char tmp[TMPBUFLEN], *p = tmp;
503 sprintf(p, "%s%lu", neg ? "-" : "", val);
507 memcpy(*buf, tmp, len);
513 static void proc_put_char(void **buf, size_t *size, char c)
516 char **buffer = (char **)buf;
525 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
527 int write, void *data)
531 if (*lvalp > (unsigned long) INT_MAX + 1)
535 if (*lvalp > (unsigned long) INT_MAX)
543 *lvalp = -(unsigned long)val;
546 *lvalp = (unsigned long)val;
552 static int do_proc_douintvec_conv(unsigned long *lvalp,
554 int write, void *data)
557 if (*lvalp > UINT_MAX)
561 unsigned int val = *valp;
562 *lvalp = (unsigned long)val;
567 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
569 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
570 int write, void *buffer,
571 size_t *lenp, loff_t *ppos,
572 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
573 int write, void *data),
576 int *i, vleft, first = 1, err = 0;
580 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
585 i = (int *) tbl_data;
586 vleft = table->maxlen / sizeof(*i);
590 conv = do_proc_dointvec_conv;
593 if (proc_first_pos_non_zero_ignore(ppos, table))
596 if (left > PAGE_SIZE - 1)
597 left = PAGE_SIZE - 1;
601 for (; left && vleft--; i++, first=0) {
606 left -= proc_skip_spaces(&p);
610 err = proc_get_long(&p, &left, &lval, &neg,
612 sizeof(proc_wspace_sep), NULL);
615 if (conv(&neg, &lval, i, 1, data)) {
620 if (conv(&neg, &lval, i, 0, data)) {
625 proc_put_char(&buffer, &left, '\t');
626 proc_put_long(&buffer, &left, lval, neg);
630 if (!write && !first && left && !err)
631 proc_put_char(&buffer, &left, '\n');
632 if (write && !err && left)
633 left -= proc_skip_spaces(&p);
635 return err ? : -EINVAL;
642 static int do_proc_dointvec(struct ctl_table *table, int write,
643 void *buffer, size_t *lenp, loff_t *ppos,
644 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
645 int write, void *data),
648 return __do_proc_dointvec(table->data, table, write,
649 buffer, lenp, ppos, conv, data);
652 static int do_proc_douintvec_w(unsigned int *tbl_data,
653 struct ctl_table *table,
655 size_t *lenp, loff_t *ppos,
656 int (*conv)(unsigned long *lvalp,
658 int write, void *data),
669 if (proc_first_pos_non_zero_ignore(ppos, table))
672 if (left > PAGE_SIZE - 1)
673 left = PAGE_SIZE - 1;
675 left -= proc_skip_spaces(&p);
681 err = proc_get_long(&p, &left, &lval, &neg,
683 sizeof(proc_wspace_sep), NULL);
689 if (conv(&lval, tbl_data, 1, data)) {
695 left -= proc_skip_spaces(&p);
703 /* This is in keeping with old __do_proc_dointvec() */
709 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
710 size_t *lenp, loff_t *ppos,
711 int (*conv)(unsigned long *lvalp,
713 int write, void *data),
722 if (conv(&lval, tbl_data, 0, data)) {
727 proc_put_long(&buffer, &left, lval, false);
731 proc_put_char(&buffer, &left, '\n');
740 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
741 int write, void *buffer,
742 size_t *lenp, loff_t *ppos,
743 int (*conv)(unsigned long *lvalp,
745 int write, void *data),
748 unsigned int *i, vleft;
750 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
755 i = (unsigned int *) tbl_data;
756 vleft = table->maxlen / sizeof(*i);
759 * Arrays are not supported, keep this simple. *Do not* add
768 conv = do_proc_douintvec_conv;
771 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
773 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
776 static int do_proc_douintvec(struct ctl_table *table, int write,
777 void *buffer, size_t *lenp, loff_t *ppos,
778 int (*conv)(unsigned long *lvalp,
780 int write, void *data),
783 return __do_proc_douintvec(table->data, table, write,
784 buffer, lenp, ppos, conv, data);
788 * proc_dointvec - read a vector of integers
789 * @table: the sysctl table
790 * @write: %TRUE if this is a write to the sysctl file
791 * @buffer: the user buffer
792 * @lenp: the size of the user buffer
793 * @ppos: file position
795 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
796 * values from/to the user buffer, treated as an ASCII string.
798 * Returns 0 on success.
800 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
801 size_t *lenp, loff_t *ppos)
803 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
806 #ifdef CONFIG_COMPACTION
807 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
808 int write, void *buffer, size_t *lenp, loff_t *ppos)
812 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
813 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
815 old = *(int *)table->data;
816 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
819 if (old != *(int *)table->data)
820 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
821 table->procname, current->comm,
822 task_pid_nr(current));
828 * proc_douintvec - read a vector of unsigned integers
829 * @table: the sysctl table
830 * @write: %TRUE if this is a write to the sysctl file
831 * @buffer: the user buffer
832 * @lenp: the size of the user buffer
833 * @ppos: file position
835 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
836 * values from/to the user buffer, treated as an ASCII string.
838 * Returns 0 on success.
840 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
841 size_t *lenp, loff_t *ppos)
843 return do_proc_douintvec(table, write, buffer, lenp, ppos,
844 do_proc_douintvec_conv, NULL);
848 * Taint values can only be increased
849 * This means we can safely use a temporary.
851 static int proc_taint(struct ctl_table *table, int write,
852 void *buffer, size_t *lenp, loff_t *ppos)
855 unsigned long tmptaint = get_taint();
858 if (write && !capable(CAP_SYS_ADMIN))
863 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
869 * Poor man's atomic or. Not worth adding a primitive
870 * to everyone's atomic.h for this
873 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
874 if ((tmptaint >> i) & 1)
875 add_taint(i, LOCKDEP_STILL_OK);
883 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
884 void *buffer, size_t *lenp, loff_t *ppos)
886 if (write && !capable(CAP_SYS_ADMIN))
889 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
894 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
895 * @min: pointer to minimum allowable value
896 * @max: pointer to maximum allowable value
898 * The do_proc_dointvec_minmax_conv_param structure provides the
899 * minimum and maximum values for doing range checking for those sysctl
900 * parameters that use the proc_dointvec_minmax() handler.
902 struct do_proc_dointvec_minmax_conv_param {
907 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
909 int write, void *data)
912 struct do_proc_dointvec_minmax_conv_param *param = data;
914 * If writing, first do so via a temporary local int so we can
915 * bounds-check it before touching *valp.
917 int *ip = write ? &tmp : valp;
919 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
924 if ((param->min && *param->min > tmp) ||
925 (param->max && *param->max < tmp))
934 * proc_dointvec_minmax - read a vector of integers with min/max values
935 * @table: the sysctl table
936 * @write: %TRUE if this is a write to the sysctl file
937 * @buffer: the user buffer
938 * @lenp: the size of the user buffer
939 * @ppos: file position
941 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
942 * values from/to the user buffer, treated as an ASCII string.
944 * This routine will ensure the values are within the range specified by
945 * table->extra1 (min) and table->extra2 (max).
947 * Returns 0 on success or -EINVAL on write when the range check fails.
949 int proc_dointvec_minmax(struct ctl_table *table, int write,
950 void *buffer, size_t *lenp, loff_t *ppos)
952 struct do_proc_dointvec_minmax_conv_param param = {
953 .min = (int *) table->extra1,
954 .max = (int *) table->extra2,
956 return do_proc_dointvec(table, write, buffer, lenp, ppos,
957 do_proc_dointvec_minmax_conv, ¶m);
961 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
962 * @min: pointer to minimum allowable value
963 * @max: pointer to maximum allowable value
965 * The do_proc_douintvec_minmax_conv_param structure provides the
966 * minimum and maximum values for doing range checking for those sysctl
967 * parameters that use the proc_douintvec_minmax() handler.
969 struct do_proc_douintvec_minmax_conv_param {
974 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
976 int write, void *data)
980 struct do_proc_douintvec_minmax_conv_param *param = data;
981 /* write via temporary local uint for bounds-checking */
982 unsigned int *up = write ? &tmp : valp;
984 ret = do_proc_douintvec_conv(lvalp, up, write, data);
989 if ((param->min && *param->min > tmp) ||
990 (param->max && *param->max < tmp))
1000 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1001 * @table: the sysctl table
1002 * @write: %TRUE if this is a write to the sysctl file
1003 * @buffer: the user buffer
1004 * @lenp: the size of the user buffer
1005 * @ppos: file position
1007 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1008 * values from/to the user buffer, treated as an ASCII string. Negative
1009 * strings are not allowed.
1011 * This routine will ensure the values are within the range specified by
1012 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1013 * check for UINT_MAX to avoid having to support wrap around uses from
1016 * Returns 0 on success or -ERANGE on write when the range check fails.
1018 int proc_douintvec_minmax(struct ctl_table *table, int write,
1019 void *buffer, size_t *lenp, loff_t *ppos)
1021 struct do_proc_douintvec_minmax_conv_param param = {
1022 .min = (unsigned int *) table->extra1,
1023 .max = (unsigned int *) table->extra2,
1025 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1026 do_proc_douintvec_minmax_conv, ¶m);
1029 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1031 int write, void *data)
1036 val = round_pipe_size(*lvalp);
1042 unsigned int val = *valp;
1043 *lvalp = (unsigned long) val;
1049 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1050 void *buffer, size_t *lenp, loff_t *ppos)
1052 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1053 do_proc_dopipe_max_size_conv, NULL);
1056 static void validate_coredump_safety(void)
1058 #ifdef CONFIG_COREDUMP
1059 if (suid_dumpable == SUID_DUMP_ROOT &&
1060 core_pattern[0] != '/' && core_pattern[0] != '|') {
1062 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1063 "Pipe handler or fully qualified core dump path required.\n"
1064 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1070 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1071 void *buffer, size_t *lenp, loff_t *ppos)
1073 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1075 validate_coredump_safety();
1079 #ifdef CONFIG_COREDUMP
1080 static int proc_dostring_coredump(struct ctl_table *table, int write,
1081 void *buffer, size_t *lenp, loff_t *ppos)
1083 int error = proc_dostring(table, write, buffer, lenp, ppos);
1085 validate_coredump_safety();
1090 #ifdef CONFIG_MAGIC_SYSRQ
1091 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1092 void *buffer, size_t *lenp, loff_t *ppos)
1098 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1099 lenp, ppos, NULL, NULL);
1104 sysrq_toggle_support(tmp);
1110 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1111 int write, void *buffer, size_t *lenp, loff_t *ppos,
1112 unsigned long convmul, unsigned long convdiv)
1114 unsigned long *i, *min, *max;
1115 int vleft, first = 1, err = 0;
1119 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1124 i = (unsigned long *) data;
1125 min = (unsigned long *) table->extra1;
1126 max = (unsigned long *) table->extra2;
1127 vleft = table->maxlen / sizeof(unsigned long);
1131 if (proc_first_pos_non_zero_ignore(ppos, table))
1134 if (left > PAGE_SIZE - 1)
1135 left = PAGE_SIZE - 1;
1139 for (; left && vleft--; i++, first = 0) {
1145 left -= proc_skip_spaces(&p);
1149 err = proc_get_long(&p, &left, &val, &neg,
1151 sizeof(proc_wspace_sep), NULL);
1156 val = convmul * val / convdiv;
1157 if ((min && val < *min) || (max && val > *max)) {
1163 val = convdiv * (*i) / convmul;
1165 proc_put_char(&buffer, &left, '\t');
1166 proc_put_long(&buffer, &left, val, false);
1170 if (!write && !first && left && !err)
1171 proc_put_char(&buffer, &left, '\n');
1173 left -= proc_skip_spaces(&p);
1175 return err ? : -EINVAL;
1182 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1183 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1184 unsigned long convdiv)
1186 return __do_proc_doulongvec_minmax(table->data, table, write,
1187 buffer, lenp, ppos, convmul, convdiv);
1191 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1192 * @table: the sysctl table
1193 * @write: %TRUE if this is a write to the sysctl file
1194 * @buffer: the user buffer
1195 * @lenp: the size of the user buffer
1196 * @ppos: file position
1198 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1199 * values from/to the user buffer, treated as an ASCII string.
1201 * This routine will ensure the values are within the range specified by
1202 * table->extra1 (min) and table->extra2 (max).
1204 * Returns 0 on success.
1206 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1207 void *buffer, size_t *lenp, loff_t *ppos)
1209 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1213 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1214 * @table: the sysctl table
1215 * @write: %TRUE if this is a write to the sysctl file
1216 * @buffer: the user buffer
1217 * @lenp: the size of the user buffer
1218 * @ppos: file position
1220 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1221 * values from/to the user buffer, treated as an ASCII string. The values
1222 * are treated as milliseconds, and converted to jiffies when they are stored.
1224 * This routine will ensure the values are within the range specified by
1225 * table->extra1 (min) and table->extra2 (max).
1227 * Returns 0 on success.
1229 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1230 void *buffer, size_t *lenp, loff_t *ppos)
1232 return do_proc_doulongvec_minmax(table, write, buffer,
1233 lenp, ppos, HZ, 1000l);
1237 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1239 int write, void *data)
1242 if (*lvalp > INT_MAX / HZ)
1244 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1250 lval = -(unsigned long)val;
1253 lval = (unsigned long)val;
1260 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1262 int write, void *data)
1265 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1267 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1273 lval = -(unsigned long)val;
1276 lval = (unsigned long)val;
1278 *lvalp = jiffies_to_clock_t(lval);
1283 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1285 int write, void *data)
1288 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1298 lval = -(unsigned long)val;
1301 lval = (unsigned long)val;
1303 *lvalp = jiffies_to_msecs(lval);
1309 * proc_dointvec_jiffies - read a vector of integers as seconds
1310 * @table: the sysctl table
1311 * @write: %TRUE if this is a write to the sysctl file
1312 * @buffer: the user buffer
1313 * @lenp: the size of the user buffer
1314 * @ppos: file position
1316 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1317 * values from/to the user buffer, treated as an ASCII string.
1318 * The values read are assumed to be in seconds, and are converted into
1321 * Returns 0 on success.
1323 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1324 void *buffer, size_t *lenp, loff_t *ppos)
1326 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1327 do_proc_dointvec_jiffies_conv,NULL);
1331 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1332 * @table: the sysctl table
1333 * @write: %TRUE if this is a write to the sysctl file
1334 * @buffer: the user buffer
1335 * @lenp: the size of the user buffer
1336 * @ppos: pointer to the file position
1338 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1339 * values from/to the user buffer, treated as an ASCII string.
1340 * The values read are assumed to be in 1/USER_HZ seconds, and
1341 * are converted into jiffies.
1343 * Returns 0 on success.
1345 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1346 void *buffer, size_t *lenp, loff_t *ppos)
1348 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1349 do_proc_dointvec_userhz_jiffies_conv,NULL);
1353 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1354 * @table: the sysctl table
1355 * @write: %TRUE if this is a write to the sysctl file
1356 * @buffer: the user buffer
1357 * @lenp: the size of the user buffer
1358 * @ppos: file position
1359 * @ppos: the current position in the file
1361 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1362 * values from/to the user buffer, treated as an ASCII string.
1363 * The values read are assumed to be in 1/1000 seconds, and
1364 * are converted into jiffies.
1366 * Returns 0 on success.
1368 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1369 size_t *lenp, loff_t *ppos)
1371 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1372 do_proc_dointvec_ms_jiffies_conv, NULL);
1375 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1376 size_t *lenp, loff_t *ppos)
1378 struct pid *new_pid;
1382 tmp = pid_vnr(cad_pid);
1384 r = __do_proc_dointvec(&tmp, table, write, buffer,
1385 lenp, ppos, NULL, NULL);
1389 new_pid = find_get_pid(tmp);
1393 put_pid(xchg(&cad_pid, new_pid));
1398 * proc_do_large_bitmap - read/write from/to a large bitmap
1399 * @table: the sysctl table
1400 * @write: %TRUE if this is a write to the sysctl file
1401 * @buffer: the user buffer
1402 * @lenp: the size of the user buffer
1403 * @ppos: file position
1405 * The bitmap is stored at table->data and the bitmap length (in bits)
1408 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1409 * large bitmaps may be represented in a compact manner. Writing into
1410 * the file will clear the bitmap then update it with the given input.
1412 * Returns 0 on success.
1414 int proc_do_large_bitmap(struct ctl_table *table, int write,
1415 void *buffer, size_t *lenp, loff_t *ppos)
1419 size_t left = *lenp;
1420 unsigned long bitmap_len = table->maxlen;
1421 unsigned long *bitmap = *(unsigned long **) table->data;
1422 unsigned long *tmp_bitmap = NULL;
1423 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1425 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1434 if (left > PAGE_SIZE - 1) {
1435 left = PAGE_SIZE - 1;
1436 /* How much of the buffer we'll skip this pass */
1437 skipped = *lenp - left;
1440 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1443 proc_skip_char(&p, &left, '\n');
1444 while (!err && left) {
1445 unsigned long val_a, val_b;
1449 /* In case we stop parsing mid-number, we can reset */
1451 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1454 * If we consumed the entirety of a truncated buffer or
1455 * only one char is left (may be a "-"), then stop here,
1456 * reset, & come back for more.
1458 if ((left <= 1) && skipped) {
1465 if (val_a >= bitmap_len || neg) {
1477 err = proc_get_long(&p, &left, &val_b,
1478 &neg, tr_b, sizeof(tr_b),
1481 * If we consumed all of a truncated buffer or
1482 * then stop here, reset, & come back for more.
1484 if (!left && skipped) {
1491 if (val_b >= bitmap_len || neg ||
1502 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1504 proc_skip_char(&p, &left, '\n');
1508 unsigned long bit_a, bit_b = 0;
1511 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1512 if (bit_a >= bitmap_len)
1514 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1518 proc_put_char(&buffer, &left, ',');
1519 proc_put_long(&buffer, &left, bit_a, false);
1520 if (bit_a != bit_b) {
1521 proc_put_char(&buffer, &left, '-');
1522 proc_put_long(&buffer, &left, bit_b, false);
1527 proc_put_char(&buffer, &left, '\n');
1533 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1535 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1541 bitmap_free(tmp_bitmap);
1545 #else /* CONFIG_PROC_SYSCTL */
1547 int proc_dostring(struct ctl_table *table, int write,
1548 void *buffer, size_t *lenp, loff_t *ppos)
1553 int proc_dointvec(struct ctl_table *table, int write,
1554 void *buffer, size_t *lenp, loff_t *ppos)
1559 int proc_douintvec(struct ctl_table *table, int write,
1560 void *buffer, size_t *lenp, loff_t *ppos)
1565 int proc_dointvec_minmax(struct ctl_table *table, int write,
1566 void *buffer, size_t *lenp, loff_t *ppos)
1571 int proc_douintvec_minmax(struct ctl_table *table, int write,
1572 void *buffer, size_t *lenp, loff_t *ppos)
1577 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1578 void *buffer, size_t *lenp, loff_t *ppos)
1583 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1584 void *buffer, size_t *lenp, loff_t *ppos)
1589 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1590 void *buffer, size_t *lenp, loff_t *ppos)
1595 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1596 void *buffer, size_t *lenp, loff_t *ppos)
1601 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1602 void *buffer, size_t *lenp, loff_t *ppos)
1607 int proc_do_large_bitmap(struct ctl_table *table, int write,
1608 void *buffer, size_t *lenp, loff_t *ppos)
1613 #endif /* CONFIG_PROC_SYSCTL */
1615 #if defined(CONFIG_SYSCTL)
1616 int proc_do_static_key(struct ctl_table *table, int write,
1617 void *buffer, size_t *lenp, loff_t *ppos)
1619 struct static_key *key = (struct static_key *)table->data;
1620 static DEFINE_MUTEX(static_key_mutex);
1622 struct ctl_table tmp = {
1624 .maxlen = sizeof(val),
1625 .mode = table->mode,
1626 .extra1 = SYSCTL_ZERO,
1627 .extra2 = SYSCTL_ONE,
1630 if (write && !capable(CAP_SYS_ADMIN))
1633 mutex_lock(&static_key_mutex);
1634 val = static_key_enabled(key);
1635 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1636 if (write && !ret) {
1638 static_key_enable(key);
1640 static_key_disable(key);
1642 mutex_unlock(&static_key_mutex);
1646 static struct ctl_table kern_table[] = {
1648 .procname = "sched_child_runs_first",
1649 .data = &sysctl_sched_child_runs_first,
1650 .maxlen = sizeof(unsigned int),
1652 .proc_handler = proc_dointvec,
1654 #ifdef CONFIG_SCHED_DEBUG
1656 .procname = "sched_min_granularity_ns",
1657 .data = &sysctl_sched_min_granularity,
1658 .maxlen = sizeof(unsigned int),
1660 .proc_handler = sched_proc_update_handler,
1661 .extra1 = &min_sched_granularity_ns,
1662 .extra2 = &max_sched_granularity_ns,
1665 .procname = "sched_latency_ns",
1666 .data = &sysctl_sched_latency,
1667 .maxlen = sizeof(unsigned int),
1669 .proc_handler = sched_proc_update_handler,
1670 .extra1 = &min_sched_granularity_ns,
1671 .extra2 = &max_sched_granularity_ns,
1674 .procname = "sched_wakeup_granularity_ns",
1675 .data = &sysctl_sched_wakeup_granularity,
1676 .maxlen = sizeof(unsigned int),
1678 .proc_handler = sched_proc_update_handler,
1679 .extra1 = &min_wakeup_granularity_ns,
1680 .extra2 = &max_wakeup_granularity_ns,
1684 .procname = "sched_tunable_scaling",
1685 .data = &sysctl_sched_tunable_scaling,
1686 .maxlen = sizeof(enum sched_tunable_scaling),
1688 .proc_handler = sched_proc_update_handler,
1689 .extra1 = &min_sched_tunable_scaling,
1690 .extra2 = &max_sched_tunable_scaling,
1693 .procname = "sched_migration_cost_ns",
1694 .data = &sysctl_sched_migration_cost,
1695 .maxlen = sizeof(unsigned int),
1697 .proc_handler = proc_dointvec,
1700 .procname = "sched_nr_migrate",
1701 .data = &sysctl_sched_nr_migrate,
1702 .maxlen = sizeof(unsigned int),
1704 .proc_handler = proc_dointvec,
1706 #ifdef CONFIG_SCHEDSTATS
1708 .procname = "sched_schedstats",
1710 .maxlen = sizeof(unsigned int),
1712 .proc_handler = sysctl_schedstats,
1713 .extra1 = SYSCTL_ZERO,
1714 .extra2 = SYSCTL_ONE,
1716 #endif /* CONFIG_SCHEDSTATS */
1717 #endif /* CONFIG_SMP */
1718 #ifdef CONFIG_NUMA_BALANCING
1720 .procname = "numa_balancing_scan_delay_ms",
1721 .data = &sysctl_numa_balancing_scan_delay,
1722 .maxlen = sizeof(unsigned int),
1724 .proc_handler = proc_dointvec,
1727 .procname = "numa_balancing_scan_period_min_ms",
1728 .data = &sysctl_numa_balancing_scan_period_min,
1729 .maxlen = sizeof(unsigned int),
1731 .proc_handler = proc_dointvec,
1734 .procname = "numa_balancing_scan_period_max_ms",
1735 .data = &sysctl_numa_balancing_scan_period_max,
1736 .maxlen = sizeof(unsigned int),
1738 .proc_handler = proc_dointvec,
1741 .procname = "numa_balancing_scan_size_mb",
1742 .data = &sysctl_numa_balancing_scan_size,
1743 .maxlen = sizeof(unsigned int),
1745 .proc_handler = proc_dointvec_minmax,
1746 .extra1 = SYSCTL_ONE,
1749 .procname = "numa_balancing",
1750 .data = NULL, /* filled in by handler */
1751 .maxlen = sizeof(unsigned int),
1753 .proc_handler = sysctl_numa_balancing,
1754 .extra1 = SYSCTL_ZERO,
1755 .extra2 = SYSCTL_ONE,
1757 #endif /* CONFIG_NUMA_BALANCING */
1758 #endif /* CONFIG_SCHED_DEBUG */
1760 .procname = "sched_rt_period_us",
1761 .data = &sysctl_sched_rt_period,
1762 .maxlen = sizeof(unsigned int),
1764 .proc_handler = sched_rt_handler,
1767 .procname = "sched_rt_runtime_us",
1768 .data = &sysctl_sched_rt_runtime,
1769 .maxlen = sizeof(int),
1771 .proc_handler = sched_rt_handler,
1774 .procname = "sched_rr_timeslice_ms",
1775 .data = &sysctl_sched_rr_timeslice,
1776 .maxlen = sizeof(int),
1778 .proc_handler = sched_rr_handler,
1780 #ifdef CONFIG_UCLAMP_TASK
1782 .procname = "sched_util_clamp_min",
1783 .data = &sysctl_sched_uclamp_util_min,
1784 .maxlen = sizeof(unsigned int),
1786 .proc_handler = sysctl_sched_uclamp_handler,
1789 .procname = "sched_util_clamp_max",
1790 .data = &sysctl_sched_uclamp_util_max,
1791 .maxlen = sizeof(unsigned int),
1793 .proc_handler = sysctl_sched_uclamp_handler,
1796 #ifdef CONFIG_SCHED_AUTOGROUP
1798 .procname = "sched_autogroup_enabled",
1799 .data = &sysctl_sched_autogroup_enabled,
1800 .maxlen = sizeof(unsigned int),
1802 .proc_handler = proc_dointvec_minmax,
1803 .extra1 = SYSCTL_ZERO,
1804 .extra2 = SYSCTL_ONE,
1807 #ifdef CONFIG_CFS_BANDWIDTH
1809 .procname = "sched_cfs_bandwidth_slice_us",
1810 .data = &sysctl_sched_cfs_bandwidth_slice,
1811 .maxlen = sizeof(unsigned int),
1813 .proc_handler = proc_dointvec_minmax,
1814 .extra1 = SYSCTL_ONE,
1817 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1819 .procname = "sched_energy_aware",
1820 .data = &sysctl_sched_energy_aware,
1821 .maxlen = sizeof(unsigned int),
1823 .proc_handler = sched_energy_aware_handler,
1824 .extra1 = SYSCTL_ZERO,
1825 .extra2 = SYSCTL_ONE,
1828 #ifdef CONFIG_PROVE_LOCKING
1830 .procname = "prove_locking",
1831 .data = &prove_locking,
1832 .maxlen = sizeof(int),
1834 .proc_handler = proc_dointvec,
1837 #ifdef CONFIG_LOCK_STAT
1839 .procname = "lock_stat",
1841 .maxlen = sizeof(int),
1843 .proc_handler = proc_dointvec,
1847 .procname = "panic",
1848 .data = &panic_timeout,
1849 .maxlen = sizeof(int),
1851 .proc_handler = proc_dointvec,
1853 #ifdef CONFIG_COREDUMP
1855 .procname = "core_uses_pid",
1856 .data = &core_uses_pid,
1857 .maxlen = sizeof(int),
1859 .proc_handler = proc_dointvec,
1862 .procname = "core_pattern",
1863 .data = core_pattern,
1864 .maxlen = CORENAME_MAX_SIZE,
1866 .proc_handler = proc_dostring_coredump,
1869 .procname = "core_pipe_limit",
1870 .data = &core_pipe_limit,
1871 .maxlen = sizeof(unsigned int),
1873 .proc_handler = proc_dointvec,
1876 #ifdef CONFIG_PROC_SYSCTL
1878 .procname = "tainted",
1879 .maxlen = sizeof(long),
1881 .proc_handler = proc_taint,
1884 .procname = "sysctl_writes_strict",
1885 .data = &sysctl_writes_strict,
1886 .maxlen = sizeof(int),
1888 .proc_handler = proc_dointvec_minmax,
1890 .extra2 = SYSCTL_ONE,
1893 #ifdef CONFIG_LATENCYTOP
1895 .procname = "latencytop",
1896 .data = &latencytop_enabled,
1897 .maxlen = sizeof(int),
1899 .proc_handler = sysctl_latencytop,
1902 #ifdef CONFIG_BLK_DEV_INITRD
1904 .procname = "real-root-dev",
1905 .data = &real_root_dev,
1906 .maxlen = sizeof(int),
1908 .proc_handler = proc_dointvec,
1912 .procname = "print-fatal-signals",
1913 .data = &print_fatal_signals,
1914 .maxlen = sizeof(int),
1916 .proc_handler = proc_dointvec,
1920 .procname = "reboot-cmd",
1921 .data = reboot_command,
1924 .proc_handler = proc_dostring,
1927 .procname = "stop-a",
1928 .data = &stop_a_enabled,
1929 .maxlen = sizeof (int),
1931 .proc_handler = proc_dointvec,
1934 .procname = "scons-poweroff",
1935 .data = &scons_pwroff,
1936 .maxlen = sizeof (int),
1938 .proc_handler = proc_dointvec,
1941 #ifdef CONFIG_SPARC64
1943 .procname = "tsb-ratio",
1944 .data = &sysctl_tsb_ratio,
1945 .maxlen = sizeof (int),
1947 .proc_handler = proc_dointvec,
1950 #ifdef CONFIG_PARISC
1952 .procname = "soft-power",
1953 .data = &pwrsw_enabled,
1954 .maxlen = sizeof (int),
1956 .proc_handler = proc_dointvec,
1959 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1961 .procname = "unaligned-trap",
1962 .data = &unaligned_enabled,
1963 .maxlen = sizeof (int),
1965 .proc_handler = proc_dointvec,
1969 .procname = "ctrl-alt-del",
1971 .maxlen = sizeof(int),
1973 .proc_handler = proc_dointvec,
1975 #ifdef CONFIG_FUNCTION_TRACER
1977 .procname = "ftrace_enabled",
1978 .data = &ftrace_enabled,
1979 .maxlen = sizeof(int),
1981 .proc_handler = ftrace_enable_sysctl,
1984 #ifdef CONFIG_STACK_TRACER
1986 .procname = "stack_tracer_enabled",
1987 .data = &stack_tracer_enabled,
1988 .maxlen = sizeof(int),
1990 .proc_handler = stack_trace_sysctl,
1993 #ifdef CONFIG_TRACING
1995 .procname = "ftrace_dump_on_oops",
1996 .data = &ftrace_dump_on_oops,
1997 .maxlen = sizeof(int),
1999 .proc_handler = proc_dointvec,
2002 .procname = "traceoff_on_warning",
2003 .data = &__disable_trace_on_warning,
2004 .maxlen = sizeof(__disable_trace_on_warning),
2006 .proc_handler = proc_dointvec,
2009 .procname = "tracepoint_printk",
2010 .data = &tracepoint_printk,
2011 .maxlen = sizeof(tracepoint_printk),
2013 .proc_handler = tracepoint_printk_sysctl,
2016 #ifdef CONFIG_KEXEC_CORE
2018 .procname = "kexec_load_disabled",
2019 .data = &kexec_load_disabled,
2020 .maxlen = sizeof(int),
2022 /* only handle a transition from default "0" to "1" */
2023 .proc_handler = proc_dointvec_minmax,
2024 .extra1 = SYSCTL_ONE,
2025 .extra2 = SYSCTL_ONE,
2028 #ifdef CONFIG_MODULES
2030 .procname = "modprobe",
2031 .data = &modprobe_path,
2032 .maxlen = KMOD_PATH_LEN,
2034 .proc_handler = proc_dostring,
2037 .procname = "modules_disabled",
2038 .data = &modules_disabled,
2039 .maxlen = sizeof(int),
2041 /* only handle a transition from default "0" to "1" */
2042 .proc_handler = proc_dointvec_minmax,
2043 .extra1 = SYSCTL_ONE,
2044 .extra2 = SYSCTL_ONE,
2047 #ifdef CONFIG_UEVENT_HELPER
2049 .procname = "hotplug",
2050 .data = &uevent_helper,
2051 .maxlen = UEVENT_HELPER_PATH_LEN,
2053 .proc_handler = proc_dostring,
2056 #ifdef CONFIG_CHR_DEV_SG
2058 .procname = "sg-big-buff",
2059 .data = &sg_big_buff,
2060 .maxlen = sizeof (int),
2062 .proc_handler = proc_dointvec,
2065 #ifdef CONFIG_BSD_PROCESS_ACCT
2069 .maxlen = 3*sizeof(int),
2071 .proc_handler = proc_dointvec,
2074 #ifdef CONFIG_MAGIC_SYSRQ
2076 .procname = "sysrq",
2078 .maxlen = sizeof (int),
2080 .proc_handler = sysrq_sysctl_handler,
2083 #ifdef CONFIG_PROC_SYSCTL
2085 .procname = "cad_pid",
2087 .maxlen = sizeof (int),
2089 .proc_handler = proc_do_cad_pid,
2093 .procname = "threads-max",
2095 .maxlen = sizeof(int),
2097 .proc_handler = sysctl_max_threads,
2100 .procname = "random",
2102 .child = random_table,
2105 .procname = "usermodehelper",
2107 .child = usermodehelper_table,
2109 #ifdef CONFIG_FW_LOADER_USER_HELPER
2111 .procname = "firmware_config",
2113 .child = firmware_config_table,
2117 .procname = "overflowuid",
2118 .data = &overflowuid,
2119 .maxlen = sizeof(int),
2121 .proc_handler = proc_dointvec_minmax,
2122 .extra1 = &minolduid,
2123 .extra2 = &maxolduid,
2126 .procname = "overflowgid",
2127 .data = &overflowgid,
2128 .maxlen = sizeof(int),
2130 .proc_handler = proc_dointvec_minmax,
2131 .extra1 = &minolduid,
2132 .extra2 = &maxolduid,
2136 .procname = "userprocess_debug",
2137 .data = &show_unhandled_signals,
2138 .maxlen = sizeof(int),
2140 .proc_handler = proc_dointvec,
2144 .procname = "pid_max",
2146 .maxlen = sizeof (int),
2148 .proc_handler = proc_dointvec_minmax,
2149 .extra1 = &pid_max_min,
2150 .extra2 = &pid_max_max,
2153 .procname = "panic_on_oops",
2154 .data = &panic_on_oops,
2155 .maxlen = sizeof(int),
2157 .proc_handler = proc_dointvec,
2160 .procname = "panic_print",
2161 .data = &panic_print,
2162 .maxlen = sizeof(unsigned long),
2164 .proc_handler = proc_doulongvec_minmax,
2166 #if defined CONFIG_PRINTK
2168 .procname = "printk",
2169 .data = &console_loglevel,
2170 .maxlen = 4*sizeof(int),
2172 .proc_handler = proc_dointvec,
2175 .procname = "printk_ratelimit",
2176 .data = &printk_ratelimit_state.interval,
2177 .maxlen = sizeof(int),
2179 .proc_handler = proc_dointvec_jiffies,
2182 .procname = "printk_ratelimit_burst",
2183 .data = &printk_ratelimit_state.burst,
2184 .maxlen = sizeof(int),
2186 .proc_handler = proc_dointvec,
2189 .procname = "printk_delay",
2190 .data = &printk_delay_msec,
2191 .maxlen = sizeof(int),
2193 .proc_handler = proc_dointvec_minmax,
2194 .extra1 = SYSCTL_ZERO,
2195 .extra2 = &ten_thousand,
2198 .procname = "printk_devkmsg",
2199 .data = devkmsg_log_str,
2200 .maxlen = DEVKMSG_STR_MAX_SIZE,
2202 .proc_handler = devkmsg_sysctl_set_loglvl,
2205 .procname = "dmesg_restrict",
2206 .data = &dmesg_restrict,
2207 .maxlen = sizeof(int),
2209 .proc_handler = proc_dointvec_minmax_sysadmin,
2210 .extra1 = SYSCTL_ZERO,
2211 .extra2 = SYSCTL_ONE,
2214 .procname = "kptr_restrict",
2215 .data = &kptr_restrict,
2216 .maxlen = sizeof(int),
2218 .proc_handler = proc_dointvec_minmax_sysadmin,
2219 .extra1 = SYSCTL_ZERO,
2224 .procname = "ngroups_max",
2225 .data = &ngroups_max,
2226 .maxlen = sizeof (int),
2228 .proc_handler = proc_dointvec,
2231 .procname = "cap_last_cap",
2232 .data = (void *)&cap_last_cap,
2233 .maxlen = sizeof(int),
2235 .proc_handler = proc_dointvec,
2237 #if defined(CONFIG_LOCKUP_DETECTOR)
2239 .procname = "watchdog",
2240 .data = &watchdog_user_enabled,
2241 .maxlen = sizeof(int),
2243 .proc_handler = proc_watchdog,
2244 .extra1 = SYSCTL_ZERO,
2245 .extra2 = SYSCTL_ONE,
2248 .procname = "watchdog_thresh",
2249 .data = &watchdog_thresh,
2250 .maxlen = sizeof(int),
2252 .proc_handler = proc_watchdog_thresh,
2253 .extra1 = SYSCTL_ZERO,
2257 .procname = "nmi_watchdog",
2258 .data = &nmi_watchdog_user_enabled,
2259 .maxlen = sizeof(int),
2260 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2261 .proc_handler = proc_nmi_watchdog,
2262 .extra1 = SYSCTL_ZERO,
2263 .extra2 = SYSCTL_ONE,
2266 .procname = "watchdog_cpumask",
2267 .data = &watchdog_cpumask_bits,
2270 .proc_handler = proc_watchdog_cpumask,
2272 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2274 .procname = "soft_watchdog",
2275 .data = &soft_watchdog_user_enabled,
2276 .maxlen = sizeof(int),
2278 .proc_handler = proc_soft_watchdog,
2279 .extra1 = SYSCTL_ZERO,
2280 .extra2 = SYSCTL_ONE,
2283 .procname = "softlockup_panic",
2284 .data = &softlockup_panic,
2285 .maxlen = sizeof(int),
2287 .proc_handler = proc_dointvec_minmax,
2288 .extra1 = SYSCTL_ZERO,
2289 .extra2 = SYSCTL_ONE,
2293 .procname = "softlockup_all_cpu_backtrace",
2294 .data = &sysctl_softlockup_all_cpu_backtrace,
2295 .maxlen = sizeof(int),
2297 .proc_handler = proc_dointvec_minmax,
2298 .extra1 = SYSCTL_ZERO,
2299 .extra2 = SYSCTL_ONE,
2301 #endif /* CONFIG_SMP */
2303 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2305 .procname = "hardlockup_panic",
2306 .data = &hardlockup_panic,
2307 .maxlen = sizeof(int),
2309 .proc_handler = proc_dointvec_minmax,
2310 .extra1 = SYSCTL_ZERO,
2311 .extra2 = SYSCTL_ONE,
2315 .procname = "hardlockup_all_cpu_backtrace",
2316 .data = &sysctl_hardlockup_all_cpu_backtrace,
2317 .maxlen = sizeof(int),
2319 .proc_handler = proc_dointvec_minmax,
2320 .extra1 = SYSCTL_ZERO,
2321 .extra2 = SYSCTL_ONE,
2323 #endif /* CONFIG_SMP */
2327 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2329 .procname = "unknown_nmi_panic",
2330 .data = &unknown_nmi_panic,
2331 .maxlen = sizeof (int),
2333 .proc_handler = proc_dointvec,
2337 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2338 defined(CONFIG_DEBUG_STACKOVERFLOW)
2340 .procname = "panic_on_stackoverflow",
2341 .data = &sysctl_panic_on_stackoverflow,
2342 .maxlen = sizeof(int),
2344 .proc_handler = proc_dointvec,
2347 #if defined(CONFIG_X86)
2349 .procname = "panic_on_unrecovered_nmi",
2350 .data = &panic_on_unrecovered_nmi,
2351 .maxlen = sizeof(int),
2353 .proc_handler = proc_dointvec,
2356 .procname = "panic_on_io_nmi",
2357 .data = &panic_on_io_nmi,
2358 .maxlen = sizeof(int),
2360 .proc_handler = proc_dointvec,
2363 .procname = "bootloader_type",
2364 .data = &bootloader_type,
2365 .maxlen = sizeof (int),
2367 .proc_handler = proc_dointvec,
2370 .procname = "bootloader_version",
2371 .data = &bootloader_version,
2372 .maxlen = sizeof (int),
2374 .proc_handler = proc_dointvec,
2377 .procname = "io_delay_type",
2378 .data = &io_delay_type,
2379 .maxlen = sizeof(int),
2381 .proc_handler = proc_dointvec,
2384 #if defined(CONFIG_MMU)
2386 .procname = "randomize_va_space",
2387 .data = &randomize_va_space,
2388 .maxlen = sizeof(int),
2390 .proc_handler = proc_dointvec,
2393 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2395 .procname = "spin_retry",
2396 .data = &spin_retry,
2397 .maxlen = sizeof (int),
2399 .proc_handler = proc_dointvec,
2402 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2404 .procname = "acpi_video_flags",
2405 .data = &acpi_realmode_flags,
2406 .maxlen = sizeof (unsigned long),
2408 .proc_handler = proc_doulongvec_minmax,
2411 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2413 .procname = "ignore-unaligned-usertrap",
2414 .data = &no_unaligned_warning,
2415 .maxlen = sizeof (int),
2417 .proc_handler = proc_dointvec,
2422 .procname = "unaligned-dump-stack",
2423 .data = &unaligned_dump_stack,
2424 .maxlen = sizeof (int),
2426 .proc_handler = proc_dointvec,
2429 #ifdef CONFIG_DETECT_HUNG_TASK
2431 .procname = "hung_task_panic",
2432 .data = &sysctl_hung_task_panic,
2433 .maxlen = sizeof(int),
2435 .proc_handler = proc_dointvec_minmax,
2436 .extra1 = SYSCTL_ZERO,
2437 .extra2 = SYSCTL_ONE,
2440 .procname = "hung_task_check_count",
2441 .data = &sysctl_hung_task_check_count,
2442 .maxlen = sizeof(int),
2444 .proc_handler = proc_dointvec_minmax,
2445 .extra1 = SYSCTL_ZERO,
2448 .procname = "hung_task_timeout_secs",
2449 .data = &sysctl_hung_task_timeout_secs,
2450 .maxlen = sizeof(unsigned long),
2452 .proc_handler = proc_dohung_task_timeout_secs,
2453 .extra2 = &hung_task_timeout_max,
2456 .procname = "hung_task_check_interval_secs",
2457 .data = &sysctl_hung_task_check_interval_secs,
2458 .maxlen = sizeof(unsigned long),
2460 .proc_handler = proc_dohung_task_timeout_secs,
2461 .extra2 = &hung_task_timeout_max,
2464 .procname = "hung_task_warnings",
2465 .data = &sysctl_hung_task_warnings,
2466 .maxlen = sizeof(int),
2468 .proc_handler = proc_dointvec_minmax,
2472 #ifdef CONFIG_RT_MUTEXES
2474 .procname = "max_lock_depth",
2475 .data = &max_lock_depth,
2476 .maxlen = sizeof(int),
2478 .proc_handler = proc_dointvec,
2482 .procname = "poweroff_cmd",
2483 .data = &poweroff_cmd,
2484 .maxlen = POWEROFF_CMD_PATH_LEN,
2486 .proc_handler = proc_dostring,
2492 .child = key_sysctls,
2495 #ifdef CONFIG_PERF_EVENTS
2497 * User-space scripts rely on the existence of this file
2498 * as a feature check for perf_events being enabled.
2500 * So it's an ABI, do not remove!
2503 .procname = "perf_event_paranoid",
2504 .data = &sysctl_perf_event_paranoid,
2505 .maxlen = sizeof(sysctl_perf_event_paranoid),
2507 .proc_handler = proc_dointvec,
2510 .procname = "perf_event_mlock_kb",
2511 .data = &sysctl_perf_event_mlock,
2512 .maxlen = sizeof(sysctl_perf_event_mlock),
2514 .proc_handler = proc_dointvec,
2517 .procname = "perf_event_max_sample_rate",
2518 .data = &sysctl_perf_event_sample_rate,
2519 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2521 .proc_handler = perf_proc_update_handler,
2522 .extra1 = SYSCTL_ONE,
2525 .procname = "perf_cpu_time_max_percent",
2526 .data = &sysctl_perf_cpu_time_max_percent,
2527 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2529 .proc_handler = perf_cpu_time_max_percent_handler,
2530 .extra1 = SYSCTL_ZERO,
2531 .extra2 = &one_hundred,
2534 .procname = "perf_event_max_stack",
2535 .data = &sysctl_perf_event_max_stack,
2536 .maxlen = sizeof(sysctl_perf_event_max_stack),
2538 .proc_handler = perf_event_max_stack_handler,
2539 .extra1 = SYSCTL_ZERO,
2540 .extra2 = &six_hundred_forty_kb,
2543 .procname = "perf_event_max_contexts_per_stack",
2544 .data = &sysctl_perf_event_max_contexts_per_stack,
2545 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2547 .proc_handler = perf_event_max_stack_handler,
2548 .extra1 = SYSCTL_ZERO,
2549 .extra2 = &one_thousand,
2553 .procname = "panic_on_warn",
2554 .data = &panic_on_warn,
2555 .maxlen = sizeof(int),
2557 .proc_handler = proc_dointvec_minmax,
2558 .extra1 = SYSCTL_ZERO,
2559 .extra2 = SYSCTL_ONE,
2561 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2563 .procname = "timer_migration",
2564 .data = &sysctl_timer_migration,
2565 .maxlen = sizeof(unsigned int),
2567 .proc_handler = timer_migration_handler,
2568 .extra1 = SYSCTL_ZERO,
2569 .extra2 = SYSCTL_ONE,
2572 #ifdef CONFIG_BPF_SYSCALL
2574 .procname = "unprivileged_bpf_disabled",
2575 .data = &sysctl_unprivileged_bpf_disabled,
2576 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2578 /* only handle a transition from default "0" to "1" */
2579 .proc_handler = proc_dointvec_minmax,
2580 .extra1 = SYSCTL_ONE,
2581 .extra2 = SYSCTL_ONE,
2584 .procname = "bpf_stats_enabled",
2585 .data = &bpf_stats_enabled_key.key,
2586 .maxlen = sizeof(bpf_stats_enabled_key),
2588 .proc_handler = bpf_stats_handler,
2591 #if defined(CONFIG_TREE_RCU)
2593 .procname = "panic_on_rcu_stall",
2594 .data = &sysctl_panic_on_rcu_stall,
2595 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2597 .proc_handler = proc_dointvec_minmax,
2598 .extra1 = SYSCTL_ZERO,
2599 .extra2 = SYSCTL_ONE,
2602 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2604 .procname = "stack_erasing",
2606 .maxlen = sizeof(int),
2608 .proc_handler = stack_erasing_sysctl,
2609 .extra1 = SYSCTL_ZERO,
2610 .extra2 = SYSCTL_ONE,
2616 static struct ctl_table vm_table[] = {
2618 .procname = "overcommit_memory",
2619 .data = &sysctl_overcommit_memory,
2620 .maxlen = sizeof(sysctl_overcommit_memory),
2622 .proc_handler = proc_dointvec_minmax,
2623 .extra1 = SYSCTL_ZERO,
2627 .procname = "panic_on_oom",
2628 .data = &sysctl_panic_on_oom,
2629 .maxlen = sizeof(sysctl_panic_on_oom),
2631 .proc_handler = proc_dointvec_minmax,
2632 .extra1 = SYSCTL_ZERO,
2636 .procname = "oom_kill_allocating_task",
2637 .data = &sysctl_oom_kill_allocating_task,
2638 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2640 .proc_handler = proc_dointvec,
2643 .procname = "oom_dump_tasks",
2644 .data = &sysctl_oom_dump_tasks,
2645 .maxlen = sizeof(sysctl_oom_dump_tasks),
2647 .proc_handler = proc_dointvec,
2650 .procname = "overcommit_ratio",
2651 .data = &sysctl_overcommit_ratio,
2652 .maxlen = sizeof(sysctl_overcommit_ratio),
2654 .proc_handler = overcommit_ratio_handler,
2657 .procname = "overcommit_kbytes",
2658 .data = &sysctl_overcommit_kbytes,
2659 .maxlen = sizeof(sysctl_overcommit_kbytes),
2661 .proc_handler = overcommit_kbytes_handler,
2664 .procname = "page-cluster",
2665 .data = &page_cluster,
2666 .maxlen = sizeof(int),
2668 .proc_handler = proc_dointvec_minmax,
2669 .extra1 = SYSCTL_ZERO,
2672 .procname = "dirty_background_ratio",
2673 .data = &dirty_background_ratio,
2674 .maxlen = sizeof(dirty_background_ratio),
2676 .proc_handler = dirty_background_ratio_handler,
2677 .extra1 = SYSCTL_ZERO,
2678 .extra2 = &one_hundred,
2681 .procname = "dirty_background_bytes",
2682 .data = &dirty_background_bytes,
2683 .maxlen = sizeof(dirty_background_bytes),
2685 .proc_handler = dirty_background_bytes_handler,
2689 .procname = "dirty_ratio",
2690 .data = &vm_dirty_ratio,
2691 .maxlen = sizeof(vm_dirty_ratio),
2693 .proc_handler = dirty_ratio_handler,
2694 .extra1 = SYSCTL_ZERO,
2695 .extra2 = &one_hundred,
2698 .procname = "dirty_bytes",
2699 .data = &vm_dirty_bytes,
2700 .maxlen = sizeof(vm_dirty_bytes),
2702 .proc_handler = dirty_bytes_handler,
2703 .extra1 = &dirty_bytes_min,
2706 .procname = "dirty_writeback_centisecs",
2707 .data = &dirty_writeback_interval,
2708 .maxlen = sizeof(dirty_writeback_interval),
2710 .proc_handler = dirty_writeback_centisecs_handler,
2713 .procname = "dirty_expire_centisecs",
2714 .data = &dirty_expire_interval,
2715 .maxlen = sizeof(dirty_expire_interval),
2717 .proc_handler = proc_dointvec_minmax,
2718 .extra1 = SYSCTL_ZERO,
2721 .procname = "dirtytime_expire_seconds",
2722 .data = &dirtytime_expire_interval,
2723 .maxlen = sizeof(dirtytime_expire_interval),
2725 .proc_handler = dirtytime_interval_handler,
2726 .extra1 = SYSCTL_ZERO,
2729 .procname = "swappiness",
2730 .data = &vm_swappiness,
2731 .maxlen = sizeof(vm_swappiness),
2733 .proc_handler = proc_dointvec_minmax,
2734 .extra1 = SYSCTL_ZERO,
2735 .extra2 = &one_hundred,
2737 #ifdef CONFIG_HUGETLB_PAGE
2739 .procname = "nr_hugepages",
2741 .maxlen = sizeof(unsigned long),
2743 .proc_handler = hugetlb_sysctl_handler,
2747 .procname = "nr_hugepages_mempolicy",
2749 .maxlen = sizeof(unsigned long),
2751 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2754 .procname = "numa_stat",
2755 .data = &sysctl_vm_numa_stat,
2756 .maxlen = sizeof(int),
2758 .proc_handler = sysctl_vm_numa_stat_handler,
2759 .extra1 = SYSCTL_ZERO,
2760 .extra2 = SYSCTL_ONE,
2764 .procname = "hugetlb_shm_group",
2765 .data = &sysctl_hugetlb_shm_group,
2766 .maxlen = sizeof(gid_t),
2768 .proc_handler = proc_dointvec,
2771 .procname = "nr_overcommit_hugepages",
2773 .maxlen = sizeof(unsigned long),
2775 .proc_handler = hugetlb_overcommit_handler,
2779 .procname = "lowmem_reserve_ratio",
2780 .data = &sysctl_lowmem_reserve_ratio,
2781 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2783 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2786 .procname = "drop_caches",
2787 .data = &sysctl_drop_caches,
2788 .maxlen = sizeof(int),
2790 .proc_handler = drop_caches_sysctl_handler,
2791 .extra1 = SYSCTL_ONE,
2794 #ifdef CONFIG_COMPACTION
2796 .procname = "compact_memory",
2797 .data = &sysctl_compact_memory,
2798 .maxlen = sizeof(int),
2800 .proc_handler = sysctl_compaction_handler,
2803 .procname = "extfrag_threshold",
2804 .data = &sysctl_extfrag_threshold,
2805 .maxlen = sizeof(int),
2807 .proc_handler = proc_dointvec_minmax,
2808 .extra1 = &min_extfrag_threshold,
2809 .extra2 = &max_extfrag_threshold,
2812 .procname = "compact_unevictable_allowed",
2813 .data = &sysctl_compact_unevictable_allowed,
2814 .maxlen = sizeof(int),
2816 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2817 .extra1 = SYSCTL_ZERO,
2818 .extra2 = SYSCTL_ONE,
2821 #endif /* CONFIG_COMPACTION */
2823 .procname = "min_free_kbytes",
2824 .data = &min_free_kbytes,
2825 .maxlen = sizeof(min_free_kbytes),
2827 .proc_handler = min_free_kbytes_sysctl_handler,
2828 .extra1 = SYSCTL_ZERO,
2831 .procname = "watermark_boost_factor",
2832 .data = &watermark_boost_factor,
2833 .maxlen = sizeof(watermark_boost_factor),
2835 .proc_handler = proc_dointvec_minmax,
2836 .extra1 = SYSCTL_ZERO,
2839 .procname = "watermark_scale_factor",
2840 .data = &watermark_scale_factor,
2841 .maxlen = sizeof(watermark_scale_factor),
2843 .proc_handler = watermark_scale_factor_sysctl_handler,
2844 .extra1 = SYSCTL_ONE,
2845 .extra2 = &one_thousand,
2848 .procname = "percpu_pagelist_fraction",
2849 .data = &percpu_pagelist_fraction,
2850 .maxlen = sizeof(percpu_pagelist_fraction),
2852 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2853 .extra1 = SYSCTL_ZERO,
2857 .procname = "max_map_count",
2858 .data = &sysctl_max_map_count,
2859 .maxlen = sizeof(sysctl_max_map_count),
2861 .proc_handler = proc_dointvec_minmax,
2862 .extra1 = SYSCTL_ZERO,
2866 .procname = "nr_trim_pages",
2867 .data = &sysctl_nr_trim_pages,
2868 .maxlen = sizeof(sysctl_nr_trim_pages),
2870 .proc_handler = proc_dointvec_minmax,
2871 .extra1 = SYSCTL_ZERO,
2875 .procname = "laptop_mode",
2876 .data = &laptop_mode,
2877 .maxlen = sizeof(laptop_mode),
2879 .proc_handler = proc_dointvec_jiffies,
2882 .procname = "block_dump",
2883 .data = &block_dump,
2884 .maxlen = sizeof(block_dump),
2886 .proc_handler = proc_dointvec,
2887 .extra1 = SYSCTL_ZERO,
2890 .procname = "vfs_cache_pressure",
2891 .data = &sysctl_vfs_cache_pressure,
2892 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2894 .proc_handler = proc_dointvec,
2895 .extra1 = SYSCTL_ZERO,
2897 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2898 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2900 .procname = "legacy_va_layout",
2901 .data = &sysctl_legacy_va_layout,
2902 .maxlen = sizeof(sysctl_legacy_va_layout),
2904 .proc_handler = proc_dointvec,
2905 .extra1 = SYSCTL_ZERO,
2910 .procname = "zone_reclaim_mode",
2911 .data = &node_reclaim_mode,
2912 .maxlen = sizeof(node_reclaim_mode),
2914 .proc_handler = proc_dointvec,
2915 .extra1 = SYSCTL_ZERO,
2918 .procname = "min_unmapped_ratio",
2919 .data = &sysctl_min_unmapped_ratio,
2920 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2922 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2923 .extra1 = SYSCTL_ZERO,
2924 .extra2 = &one_hundred,
2927 .procname = "min_slab_ratio",
2928 .data = &sysctl_min_slab_ratio,
2929 .maxlen = sizeof(sysctl_min_slab_ratio),
2931 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2932 .extra1 = SYSCTL_ZERO,
2933 .extra2 = &one_hundred,
2938 .procname = "stat_interval",
2939 .data = &sysctl_stat_interval,
2940 .maxlen = sizeof(sysctl_stat_interval),
2942 .proc_handler = proc_dointvec_jiffies,
2945 .procname = "stat_refresh",
2949 .proc_handler = vmstat_refresh,
2954 .procname = "mmap_min_addr",
2955 .data = &dac_mmap_min_addr,
2956 .maxlen = sizeof(unsigned long),
2958 .proc_handler = mmap_min_addr_handler,
2963 .procname = "numa_zonelist_order",
2964 .data = &numa_zonelist_order,
2965 .maxlen = NUMA_ZONELIST_ORDER_LEN,
2967 .proc_handler = numa_zonelist_order_handler,
2970 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
2971 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
2973 .procname = "vdso_enabled",
2974 #ifdef CONFIG_X86_32
2975 .data = &vdso32_enabled,
2976 .maxlen = sizeof(vdso32_enabled),
2978 .data = &vdso_enabled,
2979 .maxlen = sizeof(vdso_enabled),
2982 .proc_handler = proc_dointvec,
2983 .extra1 = SYSCTL_ZERO,
2986 #ifdef CONFIG_HIGHMEM
2988 .procname = "highmem_is_dirtyable",
2989 .data = &vm_highmem_is_dirtyable,
2990 .maxlen = sizeof(vm_highmem_is_dirtyable),
2992 .proc_handler = proc_dointvec_minmax,
2993 .extra1 = SYSCTL_ZERO,
2994 .extra2 = SYSCTL_ONE,
2997 #ifdef CONFIG_MEMORY_FAILURE
2999 .procname = "memory_failure_early_kill",
3000 .data = &sysctl_memory_failure_early_kill,
3001 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3003 .proc_handler = proc_dointvec_minmax,
3004 .extra1 = SYSCTL_ZERO,
3005 .extra2 = SYSCTL_ONE,
3008 .procname = "memory_failure_recovery",
3009 .data = &sysctl_memory_failure_recovery,
3010 .maxlen = sizeof(sysctl_memory_failure_recovery),
3012 .proc_handler = proc_dointvec_minmax,
3013 .extra1 = SYSCTL_ZERO,
3014 .extra2 = SYSCTL_ONE,
3018 .procname = "user_reserve_kbytes",
3019 .data = &sysctl_user_reserve_kbytes,
3020 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3022 .proc_handler = proc_doulongvec_minmax,
3025 .procname = "admin_reserve_kbytes",
3026 .data = &sysctl_admin_reserve_kbytes,
3027 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3029 .proc_handler = proc_doulongvec_minmax,
3031 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3033 .procname = "mmap_rnd_bits",
3034 .data = &mmap_rnd_bits,
3035 .maxlen = sizeof(mmap_rnd_bits),
3037 .proc_handler = proc_dointvec_minmax,
3038 .extra1 = (void *)&mmap_rnd_bits_min,
3039 .extra2 = (void *)&mmap_rnd_bits_max,
3042 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3044 .procname = "mmap_rnd_compat_bits",
3045 .data = &mmap_rnd_compat_bits,
3046 .maxlen = sizeof(mmap_rnd_compat_bits),
3048 .proc_handler = proc_dointvec_minmax,
3049 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3050 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3053 #ifdef CONFIG_USERFAULTFD
3055 .procname = "unprivileged_userfaultfd",
3056 .data = &sysctl_unprivileged_userfaultfd,
3057 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3059 .proc_handler = proc_dointvec_minmax,
3060 .extra1 = SYSCTL_ZERO,
3061 .extra2 = SYSCTL_ONE,
3067 static struct ctl_table fs_table[] = {
3069 .procname = "inode-nr",
3070 .data = &inodes_stat,
3071 .maxlen = 2*sizeof(long),
3073 .proc_handler = proc_nr_inodes,
3076 .procname = "inode-state",
3077 .data = &inodes_stat,
3078 .maxlen = 7*sizeof(long),
3080 .proc_handler = proc_nr_inodes,
3083 .procname = "file-nr",
3084 .data = &files_stat,
3085 .maxlen = sizeof(files_stat),
3087 .proc_handler = proc_nr_files,
3090 .procname = "file-max",
3091 .data = &files_stat.max_files,
3092 .maxlen = sizeof(files_stat.max_files),
3094 .proc_handler = proc_doulongvec_minmax,
3096 .extra2 = &long_max,
3099 .procname = "nr_open",
3100 .data = &sysctl_nr_open,
3101 .maxlen = sizeof(unsigned int),
3103 .proc_handler = proc_dointvec_minmax,
3104 .extra1 = &sysctl_nr_open_min,
3105 .extra2 = &sysctl_nr_open_max,
3108 .procname = "dentry-state",
3109 .data = &dentry_stat,
3110 .maxlen = 6*sizeof(long),
3112 .proc_handler = proc_nr_dentry,
3115 .procname = "overflowuid",
3116 .data = &fs_overflowuid,
3117 .maxlen = sizeof(int),
3119 .proc_handler = proc_dointvec_minmax,
3120 .extra1 = &minolduid,
3121 .extra2 = &maxolduid,
3124 .procname = "overflowgid",
3125 .data = &fs_overflowgid,
3126 .maxlen = sizeof(int),
3128 .proc_handler = proc_dointvec_minmax,
3129 .extra1 = &minolduid,
3130 .extra2 = &maxolduid,
3132 #ifdef CONFIG_FILE_LOCKING
3134 .procname = "leases-enable",
3135 .data = &leases_enable,
3136 .maxlen = sizeof(int),
3138 .proc_handler = proc_dointvec,
3141 #ifdef CONFIG_DNOTIFY
3143 .procname = "dir-notify-enable",
3144 .data = &dir_notify_enable,
3145 .maxlen = sizeof(int),
3147 .proc_handler = proc_dointvec,
3151 #ifdef CONFIG_FILE_LOCKING
3153 .procname = "lease-break-time",
3154 .data = &lease_break_time,
3155 .maxlen = sizeof(int),
3157 .proc_handler = proc_dointvec,
3162 .procname = "aio-nr",
3164 .maxlen = sizeof(aio_nr),
3166 .proc_handler = proc_doulongvec_minmax,
3169 .procname = "aio-max-nr",
3170 .data = &aio_max_nr,
3171 .maxlen = sizeof(aio_max_nr),
3173 .proc_handler = proc_doulongvec_minmax,
3175 #endif /* CONFIG_AIO */
3176 #ifdef CONFIG_INOTIFY_USER
3178 .procname = "inotify",
3180 .child = inotify_table,
3185 .procname = "epoll",
3187 .child = epoll_table,
3192 .procname = "protected_symlinks",
3193 .data = &sysctl_protected_symlinks,
3194 .maxlen = sizeof(int),
3196 .proc_handler = proc_dointvec_minmax,
3197 .extra1 = SYSCTL_ZERO,
3198 .extra2 = SYSCTL_ONE,
3201 .procname = "protected_hardlinks",
3202 .data = &sysctl_protected_hardlinks,
3203 .maxlen = sizeof(int),
3205 .proc_handler = proc_dointvec_minmax,
3206 .extra1 = SYSCTL_ZERO,
3207 .extra2 = SYSCTL_ONE,
3210 .procname = "protected_fifos",
3211 .data = &sysctl_protected_fifos,
3212 .maxlen = sizeof(int),
3214 .proc_handler = proc_dointvec_minmax,
3215 .extra1 = SYSCTL_ZERO,
3219 .procname = "protected_regular",
3220 .data = &sysctl_protected_regular,
3221 .maxlen = sizeof(int),
3223 .proc_handler = proc_dointvec_minmax,
3224 .extra1 = SYSCTL_ZERO,
3228 .procname = "suid_dumpable",
3229 .data = &suid_dumpable,
3230 .maxlen = sizeof(int),
3232 .proc_handler = proc_dointvec_minmax_coredump,
3233 .extra1 = SYSCTL_ZERO,
3236 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3238 .procname = "binfmt_misc",
3240 .child = sysctl_mount_point,
3244 .procname = "pipe-max-size",
3245 .data = &pipe_max_size,
3246 .maxlen = sizeof(pipe_max_size),
3248 .proc_handler = proc_dopipe_max_size,
3251 .procname = "pipe-user-pages-hard",
3252 .data = &pipe_user_pages_hard,
3253 .maxlen = sizeof(pipe_user_pages_hard),
3255 .proc_handler = proc_doulongvec_minmax,
3258 .procname = "pipe-user-pages-soft",
3259 .data = &pipe_user_pages_soft,
3260 .maxlen = sizeof(pipe_user_pages_soft),
3262 .proc_handler = proc_doulongvec_minmax,
3265 .procname = "mount-max",
3266 .data = &sysctl_mount_max,
3267 .maxlen = sizeof(unsigned int),
3269 .proc_handler = proc_dointvec_minmax,
3270 .extra1 = SYSCTL_ONE,
3275 static struct ctl_table debug_table[] = {
3276 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3278 .procname = "exception-trace",
3279 .data = &show_unhandled_signals,
3280 .maxlen = sizeof(int),
3282 .proc_handler = proc_dointvec
3285 #if defined(CONFIG_OPTPROBES)
3287 .procname = "kprobes-optimization",
3288 .data = &sysctl_kprobes_optimization,
3289 .maxlen = sizeof(int),
3291 .proc_handler = proc_kprobes_optimization_handler,
3292 .extra1 = SYSCTL_ZERO,
3293 .extra2 = SYSCTL_ONE,
3299 static struct ctl_table dev_table[] = {
3303 static struct ctl_table sysctl_base_table[] = {
3305 .procname = "kernel",
3307 .child = kern_table,
3320 .procname = "debug",
3322 .child = debug_table,
3332 int __init sysctl_init(void)
3334 struct ctl_table_header *hdr;
3336 hdr = register_sysctl_table(sysctl_base_table);
3337 kmemleak_not_leak(hdr);
3340 #endif /* CONFIG_SYSCTL */
3342 * No sense putting this after each symbol definition, twice,
3343 * exception granted :-)
3345 EXPORT_SYMBOL(proc_dointvec);
3346 EXPORT_SYMBOL(proc_douintvec);
3347 EXPORT_SYMBOL(proc_dointvec_jiffies);
3348 EXPORT_SYMBOL(proc_dointvec_minmax);
3349 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3350 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3351 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3352 EXPORT_SYMBOL(proc_dostring);
3353 EXPORT_SYMBOL(proc_doulongvec_minmax);
3354 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3355 EXPORT_SYMBOL(proc_do_large_bitmap);