1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/panic.h>
31 #include <linux/printk.h>
32 #include <linux/proc_fs.h>
33 #include <linux/security.h>
34 #include <linux/ctype.h>
35 #include <linux/kmemleak.h>
36 #include <linux/filter.h>
38 #include <linux/init.h>
39 #include <linux/kernel.h>
40 #include <linux/kobject.h>
41 #include <linux/net.h>
42 #include <linux/sysrq.h>
43 #include <linux/highuid.h>
44 #include <linux/writeback.h>
45 #include <linux/ratelimit.h>
46 #include <linux/compaction.h>
47 #include <linux/hugetlb.h>
48 #include <linux/initrd.h>
49 #include <linux/key.h>
50 #include <linux/times.h>
51 #include <linux/limits.h>
52 #include <linux/dcache.h>
53 #include <linux/dnotify.h>
54 #include <linux/syscalls.h>
55 #include <linux/vmstat.h>
56 #include <linux/nfs_fs.h>
57 #include <linux/acpi.h>
58 #include <linux/reboot.h>
59 #include <linux/ftrace.h>
60 #include <linux/perf_event.h>
61 #include <linux/kprobes.h>
62 #include <linux/pipe_fs_i.h>
63 #include <linux/oom.h>
64 #include <linux/kmod.h>
65 #include <linux/capability.h>
66 #include <linux/binfmts.h>
67 #include <linux/sched/sysctl.h>
68 #include <linux/sched/coredump.h>
69 #include <linux/kexec.h>
70 #include <linux/bpf.h>
71 #include <linux/mount.h>
72 #include <linux/userfaultfd_k.h>
73 #include <linux/coredump.h>
74 #include <linux/latencytop.h>
75 #include <linux/pid.h>
76 #include <linux/delayacct.h>
78 #include "../lib/kstrtox.h"
80 #include <linux/uaccess.h>
81 #include <asm/processor.h>
85 #include <asm/stacktrace.h>
89 #include <asm/setup.h>
91 #ifdef CONFIG_BSD_PROCESS_ACCT
92 #include <linux/acct.h>
94 #ifdef CONFIG_RT_MUTEXES
95 #include <linux/rtmutex.h>
97 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
98 #include <linux/lockdep.h>
100 #ifdef CONFIG_CHR_DEV_SG
103 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
104 #include <linux/stackleak.h>
106 #ifdef CONFIG_LOCKUP_DETECTOR
107 #include <linux/nmi.h>
110 #if defined(CONFIG_SYSCTL)
112 /* Constants used for minimum and maximum */
113 #ifdef CONFIG_LOCKUP_DETECTOR
114 static int sixty = 60;
117 static int __maybe_unused neg_one = -1;
118 static int __maybe_unused two = 2;
119 static int __maybe_unused four = 4;
120 static unsigned long zero_ul;
121 static unsigned long one_ul = 1;
122 static unsigned long long_max = LONG_MAX;
123 static int one_hundred = 100;
124 static int two_hundred = 200;
125 static int one_thousand = 1000;
126 static int three_thousand = 3000;
128 static int ten_thousand = 10000;
130 #ifdef CONFIG_PERF_EVENTS
131 static int six_hundred_forty_kb = 640 * 1024;
134 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
135 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
137 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
138 static int maxolduid = 65535;
139 static int minolduid;
141 static int ngroups_max = NGROUPS_MAX;
142 static const int cap_last_cap = CAP_LAST_CAP;
145 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
146 * and hung_task_check_interval_secs
148 #ifdef CONFIG_DETECT_HUNG_TASK
149 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
152 #ifdef CONFIG_INOTIFY_USER
153 #include <linux/inotify.h>
155 #ifdef CONFIG_FANOTIFY
156 #include <linux/fanotify.h>
159 #ifdef CONFIG_PROC_SYSCTL
162 * enum sysctl_writes_mode - supported sysctl write modes
164 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
165 * to be written, and multiple writes on the same sysctl file descriptor
166 * will rewrite the sysctl value, regardless of file position. No warning
167 * is issued when the initial position is not 0.
168 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
170 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
171 * file position 0 and the value must be fully contained in the buffer
172 * sent to the write syscall. If dealing with strings respect the file
173 * position, but restrict this to the max length of the buffer, anything
174 * passed the max length will be ignored. Multiple writes will append
177 * These write modes control how current file position affects the behavior of
178 * updating sysctl values through the proc interface on each write.
180 enum sysctl_writes_mode {
181 SYSCTL_WRITES_LEGACY = -1,
182 SYSCTL_WRITES_WARN = 0,
183 SYSCTL_WRITES_STRICT = 1,
186 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
187 #endif /* CONFIG_PROC_SYSCTL */
189 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
190 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
191 int sysctl_legacy_va_layout;
194 #ifdef CONFIG_COMPACTION
195 static int min_extfrag_threshold;
196 static int max_extfrag_threshold = 1000;
199 #endif /* CONFIG_SYSCTL */
201 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
202 static int bpf_stats_handler(struct ctl_table *table, int write,
203 void *buffer, size_t *lenp, loff_t *ppos)
205 struct static_key *key = (struct static_key *)table->data;
206 static int saved_val;
208 struct ctl_table tmp = {
210 .maxlen = sizeof(val),
212 .extra1 = SYSCTL_ZERO,
213 .extra2 = SYSCTL_ONE,
216 if (write && !capable(CAP_SYS_ADMIN))
219 mutex_lock(&bpf_stats_enabled_mutex);
221 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
222 if (write && !ret && val != saved_val) {
224 static_key_slow_inc(key);
226 static_key_slow_dec(key);
229 mutex_unlock(&bpf_stats_enabled_mutex);
233 static int bpf_unpriv_handler(struct ctl_table *table, int write,
234 void *buffer, size_t *lenp, loff_t *ppos)
236 int ret, unpriv_enable = *(int *)table->data;
237 bool locked_state = unpriv_enable == 1;
238 struct ctl_table tmp = *table;
240 if (write && !capable(CAP_SYS_ADMIN))
243 tmp.data = &unpriv_enable;
244 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
246 if (locked_state && unpriv_enable != 1)
248 *(int *)table->data = unpriv_enable;
252 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
258 #ifdef CONFIG_PROC_SYSCTL
260 static int _proc_do_string(char *data, int maxlen, int write,
261 char *buffer, size_t *lenp, loff_t *ppos)
266 if (!data || !maxlen || !*lenp) {
272 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
273 /* Only continue writes not past the end of buffer. */
275 if (len > maxlen - 1)
282 /* Start writing from beginning of buffer. */
288 while ((p - buffer) < *lenp && len < maxlen - 1) {
290 if (c == 0 || c == '\n')
311 memcpy(buffer, data, len);
322 static void warn_sysctl_write(struct ctl_table *table)
324 pr_warn_once("%s wrote to %s when file position was not 0!\n"
325 "This will not be supported in the future. To silence this\n"
326 "warning, set kernel.sysctl_writes_strict = -1\n",
327 current->comm, table->procname);
331 * proc_first_pos_non_zero_ignore - check if first position is allowed
332 * @ppos: file position
333 * @table: the sysctl table
335 * Returns true if the first position is non-zero and the sysctl_writes_strict
336 * mode indicates this is not allowed for numeric input types. String proc
337 * handlers can ignore the return value.
339 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
340 struct ctl_table *table)
345 switch (sysctl_writes_strict) {
346 case SYSCTL_WRITES_STRICT:
348 case SYSCTL_WRITES_WARN:
349 warn_sysctl_write(table);
357 * proc_dostring - read a string sysctl
358 * @table: the sysctl table
359 * @write: %TRUE if this is a write to the sysctl file
360 * @buffer: the user buffer
361 * @lenp: the size of the user buffer
362 * @ppos: file position
364 * Reads/writes a string from/to the user buffer. If the kernel
365 * buffer provided is not large enough to hold the string, the
366 * string is truncated. The copied string is %NULL-terminated.
367 * If the string is being read by the user process, it is copied
368 * and a newline '\n' is added. It is truncated if the buffer is
371 * Returns 0 on success.
373 int proc_dostring(struct ctl_table *table, int write,
374 void *buffer, size_t *lenp, loff_t *ppos)
377 proc_first_pos_non_zero_ignore(ppos, table);
379 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
383 static size_t proc_skip_spaces(char **buf)
386 char *tmp = skip_spaces(*buf);
392 static void proc_skip_char(char **buf, size_t *size, const char v)
403 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
406 * @cp: kernel buffer containing the string to parse
407 * @endp: pointer to store the trailing characters
408 * @base: the base to use
409 * @res: where the parsed integer will be stored
411 * In case of success 0 is returned and @res will contain the parsed integer,
412 * @endp will hold any trailing characters.
413 * This function will fail the parse on overflow. If there wasn't an overflow
414 * the function will defer the decision what characters count as invalid to the
417 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
420 unsigned long long result;
423 cp = _parse_integer_fixup_radix(cp, &base);
424 rv = _parse_integer(cp, base, &result);
425 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
433 *res = (unsigned long)result;
439 * proc_get_long - reads an ASCII formatted integer from a user buffer
441 * @buf: a kernel buffer
442 * @size: size of the kernel buffer
443 * @val: this is where the number will be stored
444 * @neg: set to %TRUE if number is negative
445 * @perm_tr: a vector which contains the allowed trailers
446 * @perm_tr_len: size of the perm_tr vector
447 * @tr: pointer to store the trailer character
449 * In case of success %0 is returned and @buf and @size are updated with
450 * the amount of bytes read. If @tr is non-NULL and a trailing
451 * character exists (size is non-zero after returning from this
452 * function), @tr is updated with the trailing character.
454 static int proc_get_long(char **buf, size_t *size,
455 unsigned long *val, bool *neg,
456 const char *perm_tr, unsigned perm_tr_len, char *tr)
459 char *p, tmp[TMPBUFLEN];
465 if (len > TMPBUFLEN - 1)
468 memcpy(tmp, *buf, len);
472 if (*p == '-' && *size > 1) {
480 if (strtoul_lenient(p, &p, 0, val))
485 /* We don't know if the next char is whitespace thus we may accept
486 * invalid integers (e.g. 1234...a) or two integers instead of one
487 * (e.g. 123...1). So lets not allow such large numbers. */
488 if (len == TMPBUFLEN - 1)
491 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
494 if (tr && (len < *size))
504 * proc_put_long - converts an integer to a decimal ASCII formatted string
506 * @buf: the user buffer
507 * @size: the size of the user buffer
508 * @val: the integer to be converted
509 * @neg: sign of the number, %TRUE for negative
511 * In case of success @buf and @size are updated with the amount of bytes
514 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
517 char tmp[TMPBUFLEN], *p = tmp;
519 sprintf(p, "%s%lu", neg ? "-" : "", val);
523 memcpy(*buf, tmp, len);
529 static void proc_put_char(void **buf, size_t *size, char c)
532 char **buffer = (char **)buf;
541 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
543 int write, void *data)
546 *(bool *)valp = *lvalp;
548 int val = *(bool *)valp;
550 *lvalp = (unsigned long)val;
556 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
558 int write, void *data)
562 if (*lvalp > (unsigned long) INT_MAX + 1)
566 if (*lvalp > (unsigned long) INT_MAX)
574 *lvalp = -(unsigned long)val;
577 *lvalp = (unsigned long)val;
583 static int do_proc_douintvec_conv(unsigned long *lvalp,
585 int write, void *data)
588 if (*lvalp > UINT_MAX)
592 unsigned int val = *valp;
593 *lvalp = (unsigned long)val;
598 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
600 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
601 int write, void *buffer,
602 size_t *lenp, loff_t *ppos,
603 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
604 int write, void *data),
607 int *i, vleft, first = 1, err = 0;
611 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
616 i = (int *) tbl_data;
617 vleft = table->maxlen / sizeof(*i);
621 conv = do_proc_dointvec_conv;
624 if (proc_first_pos_non_zero_ignore(ppos, table))
627 if (left > PAGE_SIZE - 1)
628 left = PAGE_SIZE - 1;
632 for (; left && vleft--; i++, first=0) {
637 left -= proc_skip_spaces(&p);
641 err = proc_get_long(&p, &left, &lval, &neg,
643 sizeof(proc_wspace_sep), NULL);
646 if (conv(&neg, &lval, i, 1, data)) {
651 if (conv(&neg, &lval, i, 0, data)) {
656 proc_put_char(&buffer, &left, '\t');
657 proc_put_long(&buffer, &left, lval, neg);
661 if (!write && !first && left && !err)
662 proc_put_char(&buffer, &left, '\n');
663 if (write && !err && left)
664 left -= proc_skip_spaces(&p);
666 return err ? : -EINVAL;
673 static int do_proc_dointvec(struct ctl_table *table, int write,
674 void *buffer, size_t *lenp, loff_t *ppos,
675 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
676 int write, void *data),
679 return __do_proc_dointvec(table->data, table, write,
680 buffer, lenp, ppos, conv, data);
683 static int do_proc_douintvec_w(unsigned int *tbl_data,
684 struct ctl_table *table,
686 size_t *lenp, loff_t *ppos,
687 int (*conv)(unsigned long *lvalp,
689 int write, void *data),
700 if (proc_first_pos_non_zero_ignore(ppos, table))
703 if (left > PAGE_SIZE - 1)
704 left = PAGE_SIZE - 1;
706 left -= proc_skip_spaces(&p);
712 err = proc_get_long(&p, &left, &lval, &neg,
714 sizeof(proc_wspace_sep), NULL);
720 if (conv(&lval, tbl_data, 1, data)) {
726 left -= proc_skip_spaces(&p);
734 /* This is in keeping with old __do_proc_dointvec() */
740 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
741 size_t *lenp, loff_t *ppos,
742 int (*conv)(unsigned long *lvalp,
744 int write, void *data),
753 if (conv(&lval, tbl_data, 0, data)) {
758 proc_put_long(&buffer, &left, lval, false);
762 proc_put_char(&buffer, &left, '\n');
771 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
772 int write, void *buffer,
773 size_t *lenp, loff_t *ppos,
774 int (*conv)(unsigned long *lvalp,
776 int write, void *data),
779 unsigned int *i, vleft;
781 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
786 i = (unsigned int *) tbl_data;
787 vleft = table->maxlen / sizeof(*i);
790 * Arrays are not supported, keep this simple. *Do not* add
799 conv = do_proc_douintvec_conv;
802 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
804 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
807 static int do_proc_douintvec(struct ctl_table *table, int write,
808 void *buffer, size_t *lenp, loff_t *ppos,
809 int (*conv)(unsigned long *lvalp,
811 int write, void *data),
814 return __do_proc_douintvec(table->data, table, write,
815 buffer, lenp, ppos, conv, data);
819 * proc_dobool - read/write a bool
820 * @table: the sysctl table
821 * @write: %TRUE if this is a write to the sysctl file
822 * @buffer: the user buffer
823 * @lenp: the size of the user buffer
824 * @ppos: file position
826 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
827 * values from/to the user buffer, treated as an ASCII string.
829 * Returns 0 on success.
831 int proc_dobool(struct ctl_table *table, int write, void *buffer,
832 size_t *lenp, loff_t *ppos)
834 return do_proc_dointvec(table, write, buffer, lenp, ppos,
835 do_proc_dobool_conv, NULL);
839 * proc_dointvec - read a vector of integers
840 * @table: the sysctl table
841 * @write: %TRUE if this is a write to the sysctl file
842 * @buffer: the user buffer
843 * @lenp: the size of the user buffer
844 * @ppos: file position
846 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
847 * values from/to the user buffer, treated as an ASCII string.
849 * Returns 0 on success.
851 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
852 size_t *lenp, loff_t *ppos)
854 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
857 #ifdef CONFIG_COMPACTION
858 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
859 int write, void *buffer, size_t *lenp, loff_t *ppos)
863 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
864 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
866 old = *(int *)table->data;
867 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
870 if (old != *(int *)table->data)
871 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
872 table->procname, current->comm,
873 task_pid_nr(current));
879 * proc_douintvec - read a vector of unsigned integers
880 * @table: the sysctl table
881 * @write: %TRUE if this is a write to the sysctl file
882 * @buffer: the user buffer
883 * @lenp: the size of the user buffer
884 * @ppos: file position
886 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
887 * values from/to the user buffer, treated as an ASCII string.
889 * Returns 0 on success.
891 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
892 size_t *lenp, loff_t *ppos)
894 return do_proc_douintvec(table, write, buffer, lenp, ppos,
895 do_proc_douintvec_conv, NULL);
899 * Taint values can only be increased
900 * This means we can safely use a temporary.
902 static int proc_taint(struct ctl_table *table, int write,
903 void *buffer, size_t *lenp, loff_t *ppos)
906 unsigned long tmptaint = get_taint();
909 if (write && !capable(CAP_SYS_ADMIN))
914 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
922 * If we are relying on panic_on_taint not producing
923 * false positives due to userspace input, bail out
924 * before setting the requested taint flags.
926 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
930 * Poor man's atomic or. Not worth adding a primitive
931 * to everyone's atomic.h for this
933 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
934 if ((1UL << i) & tmptaint)
935 add_taint(i, LOCKDEP_STILL_OK);
942 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
943 void *buffer, size_t *lenp, loff_t *ppos)
945 if (write && !capable(CAP_SYS_ADMIN))
948 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
953 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
954 * @min: pointer to minimum allowable value
955 * @max: pointer to maximum allowable value
957 * The do_proc_dointvec_minmax_conv_param structure provides the
958 * minimum and maximum values for doing range checking for those sysctl
959 * parameters that use the proc_dointvec_minmax() handler.
961 struct do_proc_dointvec_minmax_conv_param {
966 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
968 int write, void *data)
971 struct do_proc_dointvec_minmax_conv_param *param = data;
973 * If writing, first do so via a temporary local int so we can
974 * bounds-check it before touching *valp.
976 int *ip = write ? &tmp : valp;
978 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
983 if ((param->min && *param->min > tmp) ||
984 (param->max && *param->max < tmp))
993 * proc_dointvec_minmax - read a vector of integers with min/max values
994 * @table: the sysctl table
995 * @write: %TRUE if this is a write to the sysctl file
996 * @buffer: the user buffer
997 * @lenp: the size of the user buffer
998 * @ppos: file position
1000 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1001 * values from/to the user buffer, treated as an ASCII string.
1003 * This routine will ensure the values are within the range specified by
1004 * table->extra1 (min) and table->extra2 (max).
1006 * Returns 0 on success or -EINVAL on write when the range check fails.
1008 int proc_dointvec_minmax(struct ctl_table *table, int write,
1009 void *buffer, size_t *lenp, loff_t *ppos)
1011 struct do_proc_dointvec_minmax_conv_param param = {
1012 .min = (int *) table->extra1,
1013 .max = (int *) table->extra2,
1015 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1016 do_proc_dointvec_minmax_conv, ¶m);
1020 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1021 * @min: pointer to minimum allowable value
1022 * @max: pointer to maximum allowable value
1024 * The do_proc_douintvec_minmax_conv_param structure provides the
1025 * minimum and maximum values for doing range checking for those sysctl
1026 * parameters that use the proc_douintvec_minmax() handler.
1028 struct do_proc_douintvec_minmax_conv_param {
1033 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1035 int write, void *data)
1039 struct do_proc_douintvec_minmax_conv_param *param = data;
1040 /* write via temporary local uint for bounds-checking */
1041 unsigned int *up = write ? &tmp : valp;
1043 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1048 if ((param->min && *param->min > tmp) ||
1049 (param->max && *param->max < tmp))
1059 * proc_douintvec_minmax - read a vector of unsigned ints 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(unsigned int) unsigned integer
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). There is a final sanity
1072 * check for UINT_MAX to avoid having to support wrap around uses from
1075 * Returns 0 on success or -ERANGE on write when the range check fails.
1077 int proc_douintvec_minmax(struct ctl_table *table, int write,
1078 void *buffer, size_t *lenp, loff_t *ppos)
1080 struct do_proc_douintvec_minmax_conv_param param = {
1081 .min = (unsigned int *) table->extra1,
1082 .max = (unsigned int *) table->extra2,
1084 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1085 do_proc_douintvec_minmax_conv, ¶m);
1089 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1090 * @table: the sysctl table
1091 * @write: %TRUE if this is a write to the sysctl file
1092 * @buffer: the user buffer
1093 * @lenp: the size of the user buffer
1094 * @ppos: file position
1096 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1097 * values from/to the user buffer, treated as an ASCII string. Negative
1098 * strings are not allowed.
1100 * This routine will ensure the values are within the range specified by
1101 * table->extra1 (min) and table->extra2 (max).
1103 * Returns 0 on success or an error on write when the range check fails.
1105 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1106 void *buffer, size_t *lenp, loff_t *ppos)
1108 struct ctl_table tmp;
1109 unsigned int min = 0, max = 255U, val;
1110 u8 *data = table->data;
1111 struct do_proc_douintvec_minmax_conv_param param = {
1117 /* Do not support arrays yet. */
1118 if (table->maxlen != sizeof(u8))
1121 if (table->extra1) {
1122 min = *(unsigned int *) table->extra1;
1126 if (table->extra2) {
1127 max = *(unsigned int *) table->extra2;
1134 tmp.maxlen = sizeof(val);
1137 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1138 do_proc_douintvec_minmax_conv, ¶m);
1145 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1147 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1149 int write, void *data)
1154 val = round_pipe_size(*lvalp);
1160 unsigned int val = *valp;
1161 *lvalp = (unsigned long) val;
1167 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1168 void *buffer, size_t *lenp, loff_t *ppos)
1170 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1171 do_proc_dopipe_max_size_conv, NULL);
1174 static void validate_coredump_safety(void)
1176 #ifdef CONFIG_COREDUMP
1177 if (suid_dumpable == SUID_DUMP_ROOT &&
1178 core_pattern[0] != '/' && core_pattern[0] != '|') {
1180 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1181 "Pipe handler or fully qualified core dump path required.\n"
1182 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1188 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1189 void *buffer, size_t *lenp, loff_t *ppos)
1191 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1193 validate_coredump_safety();
1197 #ifdef CONFIG_COREDUMP
1198 static int proc_dostring_coredump(struct ctl_table *table, int write,
1199 void *buffer, size_t *lenp, loff_t *ppos)
1201 int error = proc_dostring(table, write, buffer, lenp, ppos);
1203 validate_coredump_safety();
1208 #ifdef CONFIG_MAGIC_SYSRQ
1209 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1210 void *buffer, size_t *lenp, loff_t *ppos)
1216 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1217 lenp, ppos, NULL, NULL);
1222 sysrq_toggle_support(tmp);
1228 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1229 int write, void *buffer, size_t *lenp, loff_t *ppos,
1230 unsigned long convmul, unsigned long convdiv)
1232 unsigned long *i, *min, *max;
1233 int vleft, first = 1, err = 0;
1237 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1242 i = (unsigned long *) data;
1243 min = (unsigned long *) table->extra1;
1244 max = (unsigned long *) table->extra2;
1245 vleft = table->maxlen / sizeof(unsigned long);
1249 if (proc_first_pos_non_zero_ignore(ppos, table))
1252 if (left > PAGE_SIZE - 1)
1253 left = PAGE_SIZE - 1;
1257 for (; left && vleft--; i++, first = 0) {
1263 left -= proc_skip_spaces(&p);
1267 err = proc_get_long(&p, &left, &val, &neg,
1269 sizeof(proc_wspace_sep), NULL);
1274 val = convmul * val / convdiv;
1275 if ((min && val < *min) || (max && val > *max)) {
1281 val = convdiv * (*i) / convmul;
1283 proc_put_char(&buffer, &left, '\t');
1284 proc_put_long(&buffer, &left, val, false);
1288 if (!write && !first && left && !err)
1289 proc_put_char(&buffer, &left, '\n');
1291 left -= proc_skip_spaces(&p);
1293 return err ? : -EINVAL;
1300 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1301 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1302 unsigned long convdiv)
1304 return __do_proc_doulongvec_minmax(table->data, table, write,
1305 buffer, lenp, ppos, convmul, convdiv);
1309 * proc_doulongvec_minmax - read a vector of long integers with min/max values
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 long) unsigned long
1317 * values from/to the user buffer, treated as an ASCII string.
1319 * This routine will ensure the values are within the range specified by
1320 * table->extra1 (min) and table->extra2 (max).
1322 * Returns 0 on success.
1324 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1325 void *buffer, size_t *lenp, loff_t *ppos)
1327 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1331 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
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: file position
1338 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1339 * values from/to the user buffer, treated as an ASCII string. The values
1340 * are treated as milliseconds, and converted to jiffies when they are stored.
1342 * This routine will ensure the values are within the range specified by
1343 * table->extra1 (min) and table->extra2 (max).
1345 * Returns 0 on success.
1347 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1348 void *buffer, size_t *lenp, loff_t *ppos)
1350 return do_proc_doulongvec_minmax(table, write, buffer,
1351 lenp, ppos, HZ, 1000l);
1355 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1357 int write, void *data)
1360 if (*lvalp > INT_MAX / HZ)
1362 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1368 lval = -(unsigned long)val;
1371 lval = (unsigned long)val;
1378 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1380 int write, void *data)
1383 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1385 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1391 lval = -(unsigned long)val;
1394 lval = (unsigned long)val;
1396 *lvalp = jiffies_to_clock_t(lval);
1401 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1403 int write, void *data)
1406 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1416 lval = -(unsigned long)val;
1419 lval = (unsigned long)val;
1421 *lvalp = jiffies_to_msecs(lval);
1427 * proc_dointvec_jiffies - read a vector of integers as seconds
1428 * @table: the sysctl table
1429 * @write: %TRUE if this is a write to the sysctl file
1430 * @buffer: the user buffer
1431 * @lenp: the size of the user buffer
1432 * @ppos: file position
1434 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1435 * values from/to the user buffer, treated as an ASCII string.
1436 * The values read are assumed to be in seconds, and are converted into
1439 * Returns 0 on success.
1441 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1442 void *buffer, size_t *lenp, loff_t *ppos)
1444 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1445 do_proc_dointvec_jiffies_conv,NULL);
1449 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1450 * @table: the sysctl table
1451 * @write: %TRUE if this is a write to the sysctl file
1452 * @buffer: the user buffer
1453 * @lenp: the size of the user buffer
1454 * @ppos: pointer to the file position
1456 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1457 * values from/to the user buffer, treated as an ASCII string.
1458 * The values read are assumed to be in 1/USER_HZ seconds, and
1459 * are converted into jiffies.
1461 * Returns 0 on success.
1463 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1464 void *buffer, size_t *lenp, loff_t *ppos)
1466 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1467 do_proc_dointvec_userhz_jiffies_conv,NULL);
1471 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1472 * @table: the sysctl table
1473 * @write: %TRUE if this is a write to the sysctl file
1474 * @buffer: the user buffer
1475 * @lenp: the size of the user buffer
1476 * @ppos: file position
1477 * @ppos: the current position in the file
1479 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1480 * values from/to the user buffer, treated as an ASCII string.
1481 * The values read are assumed to be in 1/1000 seconds, and
1482 * are converted into jiffies.
1484 * Returns 0 on success.
1486 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1487 size_t *lenp, loff_t *ppos)
1489 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1490 do_proc_dointvec_ms_jiffies_conv, NULL);
1493 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1494 size_t *lenp, loff_t *ppos)
1496 struct pid *new_pid;
1500 tmp = pid_vnr(cad_pid);
1502 r = __do_proc_dointvec(&tmp, table, write, buffer,
1503 lenp, ppos, NULL, NULL);
1507 new_pid = find_get_pid(tmp);
1511 put_pid(xchg(&cad_pid, new_pid));
1516 * proc_do_large_bitmap - read/write from/to a large bitmap
1517 * @table: the sysctl table
1518 * @write: %TRUE if this is a write to the sysctl file
1519 * @buffer: the user buffer
1520 * @lenp: the size of the user buffer
1521 * @ppos: file position
1523 * The bitmap is stored at table->data and the bitmap length (in bits)
1526 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1527 * large bitmaps may be represented in a compact manner. Writing into
1528 * the file will clear the bitmap then update it with the given input.
1530 * Returns 0 on success.
1532 int proc_do_large_bitmap(struct ctl_table *table, int write,
1533 void *buffer, size_t *lenp, loff_t *ppos)
1536 size_t left = *lenp;
1537 unsigned long bitmap_len = table->maxlen;
1538 unsigned long *bitmap = *(unsigned long **) table->data;
1539 unsigned long *tmp_bitmap = NULL;
1540 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1542 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1551 if (left > PAGE_SIZE - 1) {
1552 left = PAGE_SIZE - 1;
1553 /* How much of the buffer we'll skip this pass */
1554 skipped = *lenp - left;
1557 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1560 proc_skip_char(&p, &left, '\n');
1561 while (!err && left) {
1562 unsigned long val_a, val_b;
1566 /* In case we stop parsing mid-number, we can reset */
1568 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1571 * If we consumed the entirety of a truncated buffer or
1572 * only one char is left (may be a "-"), then stop here,
1573 * reset, & come back for more.
1575 if ((left <= 1) && skipped) {
1582 if (val_a >= bitmap_len || neg) {
1594 err = proc_get_long(&p, &left, &val_b,
1595 &neg, tr_b, sizeof(tr_b),
1598 * If we consumed all of a truncated buffer or
1599 * then stop here, reset, & come back for more.
1601 if (!left && skipped) {
1608 if (val_b >= bitmap_len || neg ||
1619 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1620 proc_skip_char(&p, &left, '\n');
1624 unsigned long bit_a, bit_b = 0;
1628 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1629 if (bit_a >= bitmap_len)
1631 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1635 proc_put_char(&buffer, &left, ',');
1636 proc_put_long(&buffer, &left, bit_a, false);
1637 if (bit_a != bit_b) {
1638 proc_put_char(&buffer, &left, '-');
1639 proc_put_long(&buffer, &left, bit_b, false);
1644 proc_put_char(&buffer, &left, '\n');
1650 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1652 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1658 bitmap_free(tmp_bitmap);
1662 #else /* CONFIG_PROC_SYSCTL */
1664 int proc_dostring(struct ctl_table *table, int write,
1665 void *buffer, size_t *lenp, loff_t *ppos)
1670 int proc_dobool(struct ctl_table *table, int write,
1671 void *buffer, size_t *lenp, loff_t *ppos)
1676 int proc_dointvec(struct ctl_table *table, int write,
1677 void *buffer, size_t *lenp, loff_t *ppos)
1682 int proc_douintvec(struct ctl_table *table, int write,
1683 void *buffer, size_t *lenp, loff_t *ppos)
1688 int proc_dointvec_minmax(struct ctl_table *table, int write,
1689 void *buffer, size_t *lenp, loff_t *ppos)
1694 int proc_douintvec_minmax(struct ctl_table *table, int write,
1695 void *buffer, size_t *lenp, loff_t *ppos)
1700 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1701 void *buffer, size_t *lenp, loff_t *ppos)
1706 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1707 void *buffer, size_t *lenp, loff_t *ppos)
1712 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1713 void *buffer, size_t *lenp, loff_t *ppos)
1718 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1719 void *buffer, size_t *lenp, loff_t *ppos)
1724 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1725 void *buffer, size_t *lenp, loff_t *ppos)
1730 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1731 void *buffer, size_t *lenp, loff_t *ppos)
1736 int proc_do_large_bitmap(struct ctl_table *table, int write,
1737 void *buffer, size_t *lenp, loff_t *ppos)
1742 #endif /* CONFIG_PROC_SYSCTL */
1744 #if defined(CONFIG_SYSCTL)
1745 int proc_do_static_key(struct ctl_table *table, int write,
1746 void *buffer, size_t *lenp, loff_t *ppos)
1748 struct static_key *key = (struct static_key *)table->data;
1749 static DEFINE_MUTEX(static_key_mutex);
1751 struct ctl_table tmp = {
1753 .maxlen = sizeof(val),
1754 .mode = table->mode,
1755 .extra1 = SYSCTL_ZERO,
1756 .extra2 = SYSCTL_ONE,
1759 if (write && !capable(CAP_SYS_ADMIN))
1762 mutex_lock(&static_key_mutex);
1763 val = static_key_enabled(key);
1764 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1765 if (write && !ret) {
1767 static_key_enable(key);
1769 static_key_disable(key);
1771 mutex_unlock(&static_key_mutex);
1775 static struct ctl_table kern_table[] = {
1777 .procname = "sched_child_runs_first",
1778 .data = &sysctl_sched_child_runs_first,
1779 .maxlen = sizeof(unsigned int),
1781 .proc_handler = proc_dointvec,
1783 #ifdef CONFIG_SCHEDSTATS
1785 .procname = "sched_schedstats",
1787 .maxlen = sizeof(unsigned int),
1789 .proc_handler = sysctl_schedstats,
1790 .extra1 = SYSCTL_ZERO,
1791 .extra2 = SYSCTL_ONE,
1793 #endif /* CONFIG_SCHEDSTATS */
1794 #ifdef CONFIG_TASK_DELAY_ACCT
1796 .procname = "task_delayacct",
1798 .maxlen = sizeof(unsigned int),
1800 .proc_handler = sysctl_delayacct,
1801 .extra1 = SYSCTL_ZERO,
1802 .extra2 = SYSCTL_ONE,
1804 #endif /* CONFIG_TASK_DELAY_ACCT */
1805 #ifdef CONFIG_NUMA_BALANCING
1807 .procname = "numa_balancing",
1808 .data = NULL, /* filled in by handler */
1809 .maxlen = sizeof(unsigned int),
1811 .proc_handler = sysctl_numa_balancing,
1812 .extra1 = SYSCTL_ZERO,
1813 .extra2 = SYSCTL_ONE,
1815 #endif /* CONFIG_NUMA_BALANCING */
1817 .procname = "sched_rt_period_us",
1818 .data = &sysctl_sched_rt_period,
1819 .maxlen = sizeof(unsigned int),
1821 .proc_handler = sched_rt_handler,
1824 .procname = "sched_rt_runtime_us",
1825 .data = &sysctl_sched_rt_runtime,
1826 .maxlen = sizeof(int),
1828 .proc_handler = sched_rt_handler,
1831 .procname = "sched_deadline_period_max_us",
1832 .data = &sysctl_sched_dl_period_max,
1833 .maxlen = sizeof(unsigned int),
1835 .proc_handler = proc_dointvec,
1838 .procname = "sched_deadline_period_min_us",
1839 .data = &sysctl_sched_dl_period_min,
1840 .maxlen = sizeof(unsigned int),
1842 .proc_handler = proc_dointvec,
1845 .procname = "sched_rr_timeslice_ms",
1846 .data = &sysctl_sched_rr_timeslice,
1847 .maxlen = sizeof(int),
1849 .proc_handler = sched_rr_handler,
1851 #ifdef CONFIG_UCLAMP_TASK
1853 .procname = "sched_util_clamp_min",
1854 .data = &sysctl_sched_uclamp_util_min,
1855 .maxlen = sizeof(unsigned int),
1857 .proc_handler = sysctl_sched_uclamp_handler,
1860 .procname = "sched_util_clamp_max",
1861 .data = &sysctl_sched_uclamp_util_max,
1862 .maxlen = sizeof(unsigned int),
1864 .proc_handler = sysctl_sched_uclamp_handler,
1867 .procname = "sched_util_clamp_min_rt_default",
1868 .data = &sysctl_sched_uclamp_util_min_rt_default,
1869 .maxlen = sizeof(unsigned int),
1871 .proc_handler = sysctl_sched_uclamp_handler,
1874 #ifdef CONFIG_SCHED_AUTOGROUP
1876 .procname = "sched_autogroup_enabled",
1877 .data = &sysctl_sched_autogroup_enabled,
1878 .maxlen = sizeof(unsigned int),
1880 .proc_handler = proc_dointvec_minmax,
1881 .extra1 = SYSCTL_ZERO,
1882 .extra2 = SYSCTL_ONE,
1885 #ifdef CONFIG_CFS_BANDWIDTH
1887 .procname = "sched_cfs_bandwidth_slice_us",
1888 .data = &sysctl_sched_cfs_bandwidth_slice,
1889 .maxlen = sizeof(unsigned int),
1891 .proc_handler = proc_dointvec_minmax,
1892 .extra1 = SYSCTL_ONE,
1895 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1897 .procname = "sched_energy_aware",
1898 .data = &sysctl_sched_energy_aware,
1899 .maxlen = sizeof(unsigned int),
1901 .proc_handler = sched_energy_aware_handler,
1902 .extra1 = SYSCTL_ZERO,
1903 .extra2 = SYSCTL_ONE,
1906 #ifdef CONFIG_PROVE_LOCKING
1908 .procname = "prove_locking",
1909 .data = &prove_locking,
1910 .maxlen = sizeof(int),
1912 .proc_handler = proc_dointvec,
1915 #ifdef CONFIG_LOCK_STAT
1917 .procname = "lock_stat",
1919 .maxlen = sizeof(int),
1921 .proc_handler = proc_dointvec,
1925 .procname = "panic",
1926 .data = &panic_timeout,
1927 .maxlen = sizeof(int),
1929 .proc_handler = proc_dointvec,
1931 #ifdef CONFIG_COREDUMP
1933 .procname = "core_uses_pid",
1934 .data = &core_uses_pid,
1935 .maxlen = sizeof(int),
1937 .proc_handler = proc_dointvec,
1940 .procname = "core_pattern",
1941 .data = core_pattern,
1942 .maxlen = CORENAME_MAX_SIZE,
1944 .proc_handler = proc_dostring_coredump,
1947 .procname = "core_pipe_limit",
1948 .data = &core_pipe_limit,
1949 .maxlen = sizeof(unsigned int),
1951 .proc_handler = proc_dointvec,
1954 #ifdef CONFIG_PROC_SYSCTL
1956 .procname = "tainted",
1957 .maxlen = sizeof(long),
1959 .proc_handler = proc_taint,
1962 .procname = "sysctl_writes_strict",
1963 .data = &sysctl_writes_strict,
1964 .maxlen = sizeof(int),
1966 .proc_handler = proc_dointvec_minmax,
1968 .extra2 = SYSCTL_ONE,
1971 #ifdef CONFIG_LATENCYTOP
1973 .procname = "latencytop",
1974 .data = &latencytop_enabled,
1975 .maxlen = sizeof(int),
1977 .proc_handler = sysctl_latencytop,
1980 #ifdef CONFIG_BLK_DEV_INITRD
1982 .procname = "real-root-dev",
1983 .data = &real_root_dev,
1984 .maxlen = sizeof(int),
1986 .proc_handler = proc_dointvec,
1990 .procname = "print-fatal-signals",
1991 .data = &print_fatal_signals,
1992 .maxlen = sizeof(int),
1994 .proc_handler = proc_dointvec,
1998 .procname = "reboot-cmd",
1999 .data = reboot_command,
2002 .proc_handler = proc_dostring,
2005 .procname = "stop-a",
2006 .data = &stop_a_enabled,
2007 .maxlen = sizeof (int),
2009 .proc_handler = proc_dointvec,
2012 .procname = "scons-poweroff",
2013 .data = &scons_pwroff,
2014 .maxlen = sizeof (int),
2016 .proc_handler = proc_dointvec,
2019 #ifdef CONFIG_SPARC64
2021 .procname = "tsb-ratio",
2022 .data = &sysctl_tsb_ratio,
2023 .maxlen = sizeof (int),
2025 .proc_handler = proc_dointvec,
2028 #ifdef CONFIG_PARISC
2030 .procname = "soft-power",
2031 .data = &pwrsw_enabled,
2032 .maxlen = sizeof (int),
2034 .proc_handler = proc_dointvec,
2037 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2039 .procname = "unaligned-trap",
2040 .data = &unaligned_enabled,
2041 .maxlen = sizeof (int),
2043 .proc_handler = proc_dointvec,
2047 .procname = "ctrl-alt-del",
2049 .maxlen = sizeof(int),
2051 .proc_handler = proc_dointvec,
2053 #ifdef CONFIG_FUNCTION_TRACER
2055 .procname = "ftrace_enabled",
2056 .data = &ftrace_enabled,
2057 .maxlen = sizeof(int),
2059 .proc_handler = ftrace_enable_sysctl,
2062 #ifdef CONFIG_STACK_TRACER
2064 .procname = "stack_tracer_enabled",
2065 .data = &stack_tracer_enabled,
2066 .maxlen = sizeof(int),
2068 .proc_handler = stack_trace_sysctl,
2071 #ifdef CONFIG_TRACING
2073 .procname = "ftrace_dump_on_oops",
2074 .data = &ftrace_dump_on_oops,
2075 .maxlen = sizeof(int),
2077 .proc_handler = proc_dointvec,
2080 .procname = "traceoff_on_warning",
2081 .data = &__disable_trace_on_warning,
2082 .maxlen = sizeof(__disable_trace_on_warning),
2084 .proc_handler = proc_dointvec,
2087 .procname = "tracepoint_printk",
2088 .data = &tracepoint_printk,
2089 .maxlen = sizeof(tracepoint_printk),
2091 .proc_handler = tracepoint_printk_sysctl,
2094 #ifdef CONFIG_KEXEC_CORE
2096 .procname = "kexec_load_disabled",
2097 .data = &kexec_load_disabled,
2098 .maxlen = sizeof(int),
2100 /* only handle a transition from default "0" to "1" */
2101 .proc_handler = proc_dointvec_minmax,
2102 .extra1 = SYSCTL_ONE,
2103 .extra2 = SYSCTL_ONE,
2106 #ifdef CONFIG_MODULES
2108 .procname = "modprobe",
2109 .data = &modprobe_path,
2110 .maxlen = KMOD_PATH_LEN,
2112 .proc_handler = proc_dostring,
2115 .procname = "modules_disabled",
2116 .data = &modules_disabled,
2117 .maxlen = sizeof(int),
2119 /* only handle a transition from default "0" to "1" */
2120 .proc_handler = proc_dointvec_minmax,
2121 .extra1 = SYSCTL_ONE,
2122 .extra2 = SYSCTL_ONE,
2125 #ifdef CONFIG_UEVENT_HELPER
2127 .procname = "hotplug",
2128 .data = &uevent_helper,
2129 .maxlen = UEVENT_HELPER_PATH_LEN,
2131 .proc_handler = proc_dostring,
2134 #ifdef CONFIG_CHR_DEV_SG
2136 .procname = "sg-big-buff",
2137 .data = &sg_big_buff,
2138 .maxlen = sizeof (int),
2140 .proc_handler = proc_dointvec,
2143 #ifdef CONFIG_BSD_PROCESS_ACCT
2147 .maxlen = 3*sizeof(int),
2149 .proc_handler = proc_dointvec,
2152 #ifdef CONFIG_MAGIC_SYSRQ
2154 .procname = "sysrq",
2156 .maxlen = sizeof (int),
2158 .proc_handler = sysrq_sysctl_handler,
2161 #ifdef CONFIG_PROC_SYSCTL
2163 .procname = "cad_pid",
2165 .maxlen = sizeof (int),
2167 .proc_handler = proc_do_cad_pid,
2171 .procname = "threads-max",
2173 .maxlen = sizeof(int),
2175 .proc_handler = sysctl_max_threads,
2178 .procname = "random",
2180 .child = random_table,
2183 .procname = "usermodehelper",
2185 .child = usermodehelper_table,
2187 #ifdef CONFIG_FW_LOADER_USER_HELPER
2189 .procname = "firmware_config",
2191 .child = firmware_config_table,
2195 .procname = "overflowuid",
2196 .data = &overflowuid,
2197 .maxlen = sizeof(int),
2199 .proc_handler = proc_dointvec_minmax,
2200 .extra1 = &minolduid,
2201 .extra2 = &maxolduid,
2204 .procname = "overflowgid",
2205 .data = &overflowgid,
2206 .maxlen = sizeof(int),
2208 .proc_handler = proc_dointvec_minmax,
2209 .extra1 = &minolduid,
2210 .extra2 = &maxolduid,
2214 .procname = "userprocess_debug",
2215 .data = &show_unhandled_signals,
2216 .maxlen = sizeof(int),
2218 .proc_handler = proc_dointvec,
2223 .procname = "oops_all_cpu_backtrace",
2224 .data = &sysctl_oops_all_cpu_backtrace,
2225 .maxlen = sizeof(int),
2227 .proc_handler = proc_dointvec_minmax,
2228 .extra1 = SYSCTL_ZERO,
2229 .extra2 = SYSCTL_ONE,
2231 #endif /* CONFIG_SMP */
2233 .procname = "pid_max",
2235 .maxlen = sizeof (int),
2237 .proc_handler = proc_dointvec_minmax,
2238 .extra1 = &pid_max_min,
2239 .extra2 = &pid_max_max,
2242 .procname = "panic_on_oops",
2243 .data = &panic_on_oops,
2244 .maxlen = sizeof(int),
2246 .proc_handler = proc_dointvec,
2249 .procname = "panic_print",
2250 .data = &panic_print,
2251 .maxlen = sizeof(unsigned long),
2253 .proc_handler = proc_doulongvec_minmax,
2255 #if defined CONFIG_PRINTK
2257 .procname = "printk",
2258 .data = &console_loglevel,
2259 .maxlen = 4*sizeof(int),
2261 .proc_handler = proc_dointvec,
2264 .procname = "printk_ratelimit",
2265 .data = &printk_ratelimit_state.interval,
2266 .maxlen = sizeof(int),
2268 .proc_handler = proc_dointvec_jiffies,
2271 .procname = "printk_ratelimit_burst",
2272 .data = &printk_ratelimit_state.burst,
2273 .maxlen = sizeof(int),
2275 .proc_handler = proc_dointvec,
2278 .procname = "printk_delay",
2279 .data = &printk_delay_msec,
2280 .maxlen = sizeof(int),
2282 .proc_handler = proc_dointvec_minmax,
2283 .extra1 = SYSCTL_ZERO,
2284 .extra2 = &ten_thousand,
2287 .procname = "printk_devkmsg",
2288 .data = devkmsg_log_str,
2289 .maxlen = DEVKMSG_STR_MAX_SIZE,
2291 .proc_handler = devkmsg_sysctl_set_loglvl,
2294 .procname = "dmesg_restrict",
2295 .data = &dmesg_restrict,
2296 .maxlen = sizeof(int),
2298 .proc_handler = proc_dointvec_minmax_sysadmin,
2299 .extra1 = SYSCTL_ZERO,
2300 .extra2 = SYSCTL_ONE,
2303 .procname = "kptr_restrict",
2304 .data = &kptr_restrict,
2305 .maxlen = sizeof(int),
2307 .proc_handler = proc_dointvec_minmax_sysadmin,
2308 .extra1 = SYSCTL_ZERO,
2313 .procname = "ngroups_max",
2314 .data = &ngroups_max,
2315 .maxlen = sizeof (int),
2317 .proc_handler = proc_dointvec,
2320 .procname = "cap_last_cap",
2321 .data = (void *)&cap_last_cap,
2322 .maxlen = sizeof(int),
2324 .proc_handler = proc_dointvec,
2326 #if defined(CONFIG_LOCKUP_DETECTOR)
2328 .procname = "watchdog",
2329 .data = &watchdog_user_enabled,
2330 .maxlen = sizeof(int),
2332 .proc_handler = proc_watchdog,
2333 .extra1 = SYSCTL_ZERO,
2334 .extra2 = SYSCTL_ONE,
2337 .procname = "watchdog_thresh",
2338 .data = &watchdog_thresh,
2339 .maxlen = sizeof(int),
2341 .proc_handler = proc_watchdog_thresh,
2342 .extra1 = SYSCTL_ZERO,
2346 .procname = "nmi_watchdog",
2347 .data = &nmi_watchdog_user_enabled,
2348 .maxlen = sizeof(int),
2349 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2350 .proc_handler = proc_nmi_watchdog,
2351 .extra1 = SYSCTL_ZERO,
2352 .extra2 = SYSCTL_ONE,
2355 .procname = "watchdog_cpumask",
2356 .data = &watchdog_cpumask_bits,
2359 .proc_handler = proc_watchdog_cpumask,
2361 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2363 .procname = "soft_watchdog",
2364 .data = &soft_watchdog_user_enabled,
2365 .maxlen = sizeof(int),
2367 .proc_handler = proc_soft_watchdog,
2368 .extra1 = SYSCTL_ZERO,
2369 .extra2 = SYSCTL_ONE,
2372 .procname = "softlockup_panic",
2373 .data = &softlockup_panic,
2374 .maxlen = sizeof(int),
2376 .proc_handler = proc_dointvec_minmax,
2377 .extra1 = SYSCTL_ZERO,
2378 .extra2 = SYSCTL_ONE,
2382 .procname = "softlockup_all_cpu_backtrace",
2383 .data = &sysctl_softlockup_all_cpu_backtrace,
2384 .maxlen = sizeof(int),
2386 .proc_handler = proc_dointvec_minmax,
2387 .extra1 = SYSCTL_ZERO,
2388 .extra2 = SYSCTL_ONE,
2390 #endif /* CONFIG_SMP */
2392 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2394 .procname = "hardlockup_panic",
2395 .data = &hardlockup_panic,
2396 .maxlen = sizeof(int),
2398 .proc_handler = proc_dointvec_minmax,
2399 .extra1 = SYSCTL_ZERO,
2400 .extra2 = SYSCTL_ONE,
2404 .procname = "hardlockup_all_cpu_backtrace",
2405 .data = &sysctl_hardlockup_all_cpu_backtrace,
2406 .maxlen = sizeof(int),
2408 .proc_handler = proc_dointvec_minmax,
2409 .extra1 = SYSCTL_ZERO,
2410 .extra2 = SYSCTL_ONE,
2412 #endif /* CONFIG_SMP */
2416 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2418 .procname = "unknown_nmi_panic",
2419 .data = &unknown_nmi_panic,
2420 .maxlen = sizeof (int),
2422 .proc_handler = proc_dointvec,
2426 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2427 defined(CONFIG_DEBUG_STACKOVERFLOW)
2429 .procname = "panic_on_stackoverflow",
2430 .data = &sysctl_panic_on_stackoverflow,
2431 .maxlen = sizeof(int),
2433 .proc_handler = proc_dointvec,
2436 #if defined(CONFIG_X86)
2438 .procname = "panic_on_unrecovered_nmi",
2439 .data = &panic_on_unrecovered_nmi,
2440 .maxlen = sizeof(int),
2442 .proc_handler = proc_dointvec,
2445 .procname = "panic_on_io_nmi",
2446 .data = &panic_on_io_nmi,
2447 .maxlen = sizeof(int),
2449 .proc_handler = proc_dointvec,
2452 .procname = "bootloader_type",
2453 .data = &bootloader_type,
2454 .maxlen = sizeof (int),
2456 .proc_handler = proc_dointvec,
2459 .procname = "bootloader_version",
2460 .data = &bootloader_version,
2461 .maxlen = sizeof (int),
2463 .proc_handler = proc_dointvec,
2466 .procname = "io_delay_type",
2467 .data = &io_delay_type,
2468 .maxlen = sizeof(int),
2470 .proc_handler = proc_dointvec,
2473 #if defined(CONFIG_MMU)
2475 .procname = "randomize_va_space",
2476 .data = &randomize_va_space,
2477 .maxlen = sizeof(int),
2479 .proc_handler = proc_dointvec,
2482 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2484 .procname = "spin_retry",
2485 .data = &spin_retry,
2486 .maxlen = sizeof (int),
2488 .proc_handler = proc_dointvec,
2491 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2493 .procname = "acpi_video_flags",
2494 .data = &acpi_realmode_flags,
2495 .maxlen = sizeof (unsigned long),
2497 .proc_handler = proc_doulongvec_minmax,
2500 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2502 .procname = "ignore-unaligned-usertrap",
2503 .data = &no_unaligned_warning,
2504 .maxlen = sizeof (int),
2506 .proc_handler = proc_dointvec,
2511 .procname = "unaligned-dump-stack",
2512 .data = &unaligned_dump_stack,
2513 .maxlen = sizeof (int),
2515 .proc_handler = proc_dointvec,
2518 #ifdef CONFIG_DETECT_HUNG_TASK
2521 .procname = "hung_task_all_cpu_backtrace",
2522 .data = &sysctl_hung_task_all_cpu_backtrace,
2523 .maxlen = sizeof(int),
2525 .proc_handler = proc_dointvec_minmax,
2526 .extra1 = SYSCTL_ZERO,
2527 .extra2 = SYSCTL_ONE,
2529 #endif /* CONFIG_SMP */
2531 .procname = "hung_task_panic",
2532 .data = &sysctl_hung_task_panic,
2533 .maxlen = sizeof(int),
2535 .proc_handler = proc_dointvec_minmax,
2536 .extra1 = SYSCTL_ZERO,
2537 .extra2 = SYSCTL_ONE,
2540 .procname = "hung_task_check_count",
2541 .data = &sysctl_hung_task_check_count,
2542 .maxlen = sizeof(int),
2544 .proc_handler = proc_dointvec_minmax,
2545 .extra1 = SYSCTL_ZERO,
2548 .procname = "hung_task_timeout_secs",
2549 .data = &sysctl_hung_task_timeout_secs,
2550 .maxlen = sizeof(unsigned long),
2552 .proc_handler = proc_dohung_task_timeout_secs,
2553 .extra2 = &hung_task_timeout_max,
2556 .procname = "hung_task_check_interval_secs",
2557 .data = &sysctl_hung_task_check_interval_secs,
2558 .maxlen = sizeof(unsigned long),
2560 .proc_handler = proc_dohung_task_timeout_secs,
2561 .extra2 = &hung_task_timeout_max,
2564 .procname = "hung_task_warnings",
2565 .data = &sysctl_hung_task_warnings,
2566 .maxlen = sizeof(int),
2568 .proc_handler = proc_dointvec_minmax,
2572 #ifdef CONFIG_RT_MUTEXES
2574 .procname = "max_lock_depth",
2575 .data = &max_lock_depth,
2576 .maxlen = sizeof(int),
2578 .proc_handler = proc_dointvec,
2582 .procname = "poweroff_cmd",
2583 .data = &poweroff_cmd,
2584 .maxlen = POWEROFF_CMD_PATH_LEN,
2586 .proc_handler = proc_dostring,
2592 .child = key_sysctls,
2595 #ifdef CONFIG_PERF_EVENTS
2597 * User-space scripts rely on the existence of this file
2598 * as a feature check for perf_events being enabled.
2600 * So it's an ABI, do not remove!
2603 .procname = "perf_event_paranoid",
2604 .data = &sysctl_perf_event_paranoid,
2605 .maxlen = sizeof(sysctl_perf_event_paranoid),
2607 .proc_handler = proc_dointvec,
2610 .procname = "perf_event_mlock_kb",
2611 .data = &sysctl_perf_event_mlock,
2612 .maxlen = sizeof(sysctl_perf_event_mlock),
2614 .proc_handler = proc_dointvec,
2617 .procname = "perf_event_max_sample_rate",
2618 .data = &sysctl_perf_event_sample_rate,
2619 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2621 .proc_handler = perf_proc_update_handler,
2622 .extra1 = SYSCTL_ONE,
2625 .procname = "perf_cpu_time_max_percent",
2626 .data = &sysctl_perf_cpu_time_max_percent,
2627 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2629 .proc_handler = perf_cpu_time_max_percent_handler,
2630 .extra1 = SYSCTL_ZERO,
2631 .extra2 = &one_hundred,
2634 .procname = "perf_event_max_stack",
2635 .data = &sysctl_perf_event_max_stack,
2636 .maxlen = sizeof(sysctl_perf_event_max_stack),
2638 .proc_handler = perf_event_max_stack_handler,
2639 .extra1 = SYSCTL_ZERO,
2640 .extra2 = &six_hundred_forty_kb,
2643 .procname = "perf_event_max_contexts_per_stack",
2644 .data = &sysctl_perf_event_max_contexts_per_stack,
2645 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2647 .proc_handler = perf_event_max_stack_handler,
2648 .extra1 = SYSCTL_ZERO,
2649 .extra2 = &one_thousand,
2653 .procname = "panic_on_warn",
2654 .data = &panic_on_warn,
2655 .maxlen = sizeof(int),
2657 .proc_handler = proc_dointvec_minmax,
2658 .extra1 = SYSCTL_ZERO,
2659 .extra2 = SYSCTL_ONE,
2661 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2663 .procname = "timer_migration",
2664 .data = &sysctl_timer_migration,
2665 .maxlen = sizeof(unsigned int),
2667 .proc_handler = timer_migration_handler,
2668 .extra1 = SYSCTL_ZERO,
2669 .extra2 = SYSCTL_ONE,
2672 #ifdef CONFIG_BPF_SYSCALL
2674 .procname = "unprivileged_bpf_disabled",
2675 .data = &sysctl_unprivileged_bpf_disabled,
2676 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2678 .proc_handler = bpf_unpriv_handler,
2679 .extra1 = SYSCTL_ZERO,
2683 .procname = "bpf_stats_enabled",
2684 .data = &bpf_stats_enabled_key.key,
2685 .maxlen = sizeof(bpf_stats_enabled_key),
2687 .proc_handler = bpf_stats_handler,
2690 #if defined(CONFIG_TREE_RCU)
2692 .procname = "panic_on_rcu_stall",
2693 .data = &sysctl_panic_on_rcu_stall,
2694 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2696 .proc_handler = proc_dointvec_minmax,
2697 .extra1 = SYSCTL_ZERO,
2698 .extra2 = SYSCTL_ONE,
2701 #if defined(CONFIG_TREE_RCU)
2703 .procname = "max_rcu_stall_to_panic",
2704 .data = &sysctl_max_rcu_stall_to_panic,
2705 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2707 .proc_handler = proc_dointvec_minmax,
2708 .extra1 = SYSCTL_ONE,
2709 .extra2 = SYSCTL_INT_MAX,
2712 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2714 .procname = "stack_erasing",
2716 .maxlen = sizeof(int),
2718 .proc_handler = stack_erasing_sysctl,
2719 .extra1 = SYSCTL_ZERO,
2720 .extra2 = SYSCTL_ONE,
2726 static struct ctl_table vm_table[] = {
2728 .procname = "overcommit_memory",
2729 .data = &sysctl_overcommit_memory,
2730 .maxlen = sizeof(sysctl_overcommit_memory),
2732 .proc_handler = overcommit_policy_handler,
2733 .extra1 = SYSCTL_ZERO,
2737 .procname = "panic_on_oom",
2738 .data = &sysctl_panic_on_oom,
2739 .maxlen = sizeof(sysctl_panic_on_oom),
2741 .proc_handler = proc_dointvec_minmax,
2742 .extra1 = SYSCTL_ZERO,
2746 .procname = "oom_kill_allocating_task",
2747 .data = &sysctl_oom_kill_allocating_task,
2748 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2750 .proc_handler = proc_dointvec,
2753 .procname = "oom_dump_tasks",
2754 .data = &sysctl_oom_dump_tasks,
2755 .maxlen = sizeof(sysctl_oom_dump_tasks),
2757 .proc_handler = proc_dointvec,
2760 .procname = "overcommit_ratio",
2761 .data = &sysctl_overcommit_ratio,
2762 .maxlen = sizeof(sysctl_overcommit_ratio),
2764 .proc_handler = overcommit_ratio_handler,
2767 .procname = "overcommit_kbytes",
2768 .data = &sysctl_overcommit_kbytes,
2769 .maxlen = sizeof(sysctl_overcommit_kbytes),
2771 .proc_handler = overcommit_kbytes_handler,
2774 .procname = "page-cluster",
2775 .data = &page_cluster,
2776 .maxlen = sizeof(int),
2778 .proc_handler = proc_dointvec_minmax,
2779 .extra1 = SYSCTL_ZERO,
2782 .procname = "dirty_background_ratio",
2783 .data = &dirty_background_ratio,
2784 .maxlen = sizeof(dirty_background_ratio),
2786 .proc_handler = dirty_background_ratio_handler,
2787 .extra1 = SYSCTL_ZERO,
2788 .extra2 = &one_hundred,
2791 .procname = "dirty_background_bytes",
2792 .data = &dirty_background_bytes,
2793 .maxlen = sizeof(dirty_background_bytes),
2795 .proc_handler = dirty_background_bytes_handler,
2799 .procname = "dirty_ratio",
2800 .data = &vm_dirty_ratio,
2801 .maxlen = sizeof(vm_dirty_ratio),
2803 .proc_handler = dirty_ratio_handler,
2804 .extra1 = SYSCTL_ZERO,
2805 .extra2 = &one_hundred,
2808 .procname = "dirty_bytes",
2809 .data = &vm_dirty_bytes,
2810 .maxlen = sizeof(vm_dirty_bytes),
2812 .proc_handler = dirty_bytes_handler,
2813 .extra1 = &dirty_bytes_min,
2816 .procname = "dirty_writeback_centisecs",
2817 .data = &dirty_writeback_interval,
2818 .maxlen = sizeof(dirty_writeback_interval),
2820 .proc_handler = dirty_writeback_centisecs_handler,
2823 .procname = "dirty_expire_centisecs",
2824 .data = &dirty_expire_interval,
2825 .maxlen = sizeof(dirty_expire_interval),
2827 .proc_handler = proc_dointvec_minmax,
2828 .extra1 = SYSCTL_ZERO,
2831 .procname = "dirtytime_expire_seconds",
2832 .data = &dirtytime_expire_interval,
2833 .maxlen = sizeof(dirtytime_expire_interval),
2835 .proc_handler = dirtytime_interval_handler,
2836 .extra1 = SYSCTL_ZERO,
2839 .procname = "swappiness",
2840 .data = &vm_swappiness,
2841 .maxlen = sizeof(vm_swappiness),
2843 .proc_handler = proc_dointvec_minmax,
2844 .extra1 = SYSCTL_ZERO,
2845 .extra2 = &two_hundred,
2847 #ifdef CONFIG_HUGETLB_PAGE
2849 .procname = "nr_hugepages",
2851 .maxlen = sizeof(unsigned long),
2853 .proc_handler = hugetlb_sysctl_handler,
2857 .procname = "nr_hugepages_mempolicy",
2859 .maxlen = sizeof(unsigned long),
2861 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2864 .procname = "numa_stat",
2865 .data = &sysctl_vm_numa_stat,
2866 .maxlen = sizeof(int),
2868 .proc_handler = sysctl_vm_numa_stat_handler,
2869 .extra1 = SYSCTL_ZERO,
2870 .extra2 = SYSCTL_ONE,
2874 .procname = "hugetlb_shm_group",
2875 .data = &sysctl_hugetlb_shm_group,
2876 .maxlen = sizeof(gid_t),
2878 .proc_handler = proc_dointvec,
2881 .procname = "nr_overcommit_hugepages",
2883 .maxlen = sizeof(unsigned long),
2885 .proc_handler = hugetlb_overcommit_handler,
2889 .procname = "lowmem_reserve_ratio",
2890 .data = &sysctl_lowmem_reserve_ratio,
2891 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2893 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2896 .procname = "drop_caches",
2897 .data = &sysctl_drop_caches,
2898 .maxlen = sizeof(int),
2900 .proc_handler = drop_caches_sysctl_handler,
2901 .extra1 = SYSCTL_ONE,
2904 #ifdef CONFIG_COMPACTION
2906 .procname = "compact_memory",
2908 .maxlen = sizeof(int),
2910 .proc_handler = sysctl_compaction_handler,
2913 .procname = "compaction_proactiveness",
2914 .data = &sysctl_compaction_proactiveness,
2915 .maxlen = sizeof(sysctl_compaction_proactiveness),
2917 .proc_handler = compaction_proactiveness_sysctl_handler,
2918 .extra1 = SYSCTL_ZERO,
2919 .extra2 = &one_hundred,
2922 .procname = "extfrag_threshold",
2923 .data = &sysctl_extfrag_threshold,
2924 .maxlen = sizeof(int),
2926 .proc_handler = proc_dointvec_minmax,
2927 .extra1 = &min_extfrag_threshold,
2928 .extra2 = &max_extfrag_threshold,
2931 .procname = "compact_unevictable_allowed",
2932 .data = &sysctl_compact_unevictable_allowed,
2933 .maxlen = sizeof(int),
2935 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2936 .extra1 = SYSCTL_ZERO,
2937 .extra2 = SYSCTL_ONE,
2940 #endif /* CONFIG_COMPACTION */
2942 .procname = "min_free_kbytes",
2943 .data = &min_free_kbytes,
2944 .maxlen = sizeof(min_free_kbytes),
2946 .proc_handler = min_free_kbytes_sysctl_handler,
2947 .extra1 = SYSCTL_ZERO,
2950 .procname = "watermark_boost_factor",
2951 .data = &watermark_boost_factor,
2952 .maxlen = sizeof(watermark_boost_factor),
2954 .proc_handler = proc_dointvec_minmax,
2955 .extra1 = SYSCTL_ZERO,
2958 .procname = "watermark_scale_factor",
2959 .data = &watermark_scale_factor,
2960 .maxlen = sizeof(watermark_scale_factor),
2962 .proc_handler = watermark_scale_factor_sysctl_handler,
2963 .extra1 = SYSCTL_ONE,
2964 .extra2 = &three_thousand,
2967 .procname = "percpu_pagelist_high_fraction",
2968 .data = &percpu_pagelist_high_fraction,
2969 .maxlen = sizeof(percpu_pagelist_high_fraction),
2971 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2972 .extra1 = SYSCTL_ZERO,
2975 .procname = "page_lock_unfairness",
2976 .data = &sysctl_page_lock_unfairness,
2977 .maxlen = sizeof(sysctl_page_lock_unfairness),
2979 .proc_handler = proc_dointvec_minmax,
2980 .extra1 = SYSCTL_ZERO,
2984 .procname = "max_map_count",
2985 .data = &sysctl_max_map_count,
2986 .maxlen = sizeof(sysctl_max_map_count),
2988 .proc_handler = proc_dointvec_minmax,
2989 .extra1 = SYSCTL_ZERO,
2993 .procname = "nr_trim_pages",
2994 .data = &sysctl_nr_trim_pages,
2995 .maxlen = sizeof(sysctl_nr_trim_pages),
2997 .proc_handler = proc_dointvec_minmax,
2998 .extra1 = SYSCTL_ZERO,
3002 .procname = "laptop_mode",
3003 .data = &laptop_mode,
3004 .maxlen = sizeof(laptop_mode),
3006 .proc_handler = proc_dointvec_jiffies,
3009 .procname = "vfs_cache_pressure",
3010 .data = &sysctl_vfs_cache_pressure,
3011 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3013 .proc_handler = proc_dointvec_minmax,
3014 .extra1 = SYSCTL_ZERO,
3016 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3017 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3019 .procname = "legacy_va_layout",
3020 .data = &sysctl_legacy_va_layout,
3021 .maxlen = sizeof(sysctl_legacy_va_layout),
3023 .proc_handler = proc_dointvec_minmax,
3024 .extra1 = SYSCTL_ZERO,
3029 .procname = "zone_reclaim_mode",
3030 .data = &node_reclaim_mode,
3031 .maxlen = sizeof(node_reclaim_mode),
3033 .proc_handler = proc_dointvec_minmax,
3034 .extra1 = SYSCTL_ZERO,
3037 .procname = "min_unmapped_ratio",
3038 .data = &sysctl_min_unmapped_ratio,
3039 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3041 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3042 .extra1 = SYSCTL_ZERO,
3043 .extra2 = &one_hundred,
3046 .procname = "min_slab_ratio",
3047 .data = &sysctl_min_slab_ratio,
3048 .maxlen = sizeof(sysctl_min_slab_ratio),
3050 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3051 .extra1 = SYSCTL_ZERO,
3052 .extra2 = &one_hundred,
3057 .procname = "stat_interval",
3058 .data = &sysctl_stat_interval,
3059 .maxlen = sizeof(sysctl_stat_interval),
3061 .proc_handler = proc_dointvec_jiffies,
3064 .procname = "stat_refresh",
3068 .proc_handler = vmstat_refresh,
3073 .procname = "mmap_min_addr",
3074 .data = &dac_mmap_min_addr,
3075 .maxlen = sizeof(unsigned long),
3077 .proc_handler = mmap_min_addr_handler,
3082 .procname = "numa_zonelist_order",
3083 .data = &numa_zonelist_order,
3084 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3086 .proc_handler = numa_zonelist_order_handler,
3089 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3090 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3092 .procname = "vdso_enabled",
3093 #ifdef CONFIG_X86_32
3094 .data = &vdso32_enabled,
3095 .maxlen = sizeof(vdso32_enabled),
3097 .data = &vdso_enabled,
3098 .maxlen = sizeof(vdso_enabled),
3101 .proc_handler = proc_dointvec,
3102 .extra1 = SYSCTL_ZERO,
3105 #ifdef CONFIG_HIGHMEM
3107 .procname = "highmem_is_dirtyable",
3108 .data = &vm_highmem_is_dirtyable,
3109 .maxlen = sizeof(vm_highmem_is_dirtyable),
3111 .proc_handler = proc_dointvec_minmax,
3112 .extra1 = SYSCTL_ZERO,
3113 .extra2 = SYSCTL_ONE,
3116 #ifdef CONFIG_MEMORY_FAILURE
3118 .procname = "memory_failure_early_kill",
3119 .data = &sysctl_memory_failure_early_kill,
3120 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3122 .proc_handler = proc_dointvec_minmax,
3123 .extra1 = SYSCTL_ZERO,
3124 .extra2 = SYSCTL_ONE,
3127 .procname = "memory_failure_recovery",
3128 .data = &sysctl_memory_failure_recovery,
3129 .maxlen = sizeof(sysctl_memory_failure_recovery),
3131 .proc_handler = proc_dointvec_minmax,
3132 .extra1 = SYSCTL_ZERO,
3133 .extra2 = SYSCTL_ONE,
3137 .procname = "user_reserve_kbytes",
3138 .data = &sysctl_user_reserve_kbytes,
3139 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3141 .proc_handler = proc_doulongvec_minmax,
3144 .procname = "admin_reserve_kbytes",
3145 .data = &sysctl_admin_reserve_kbytes,
3146 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3148 .proc_handler = proc_doulongvec_minmax,
3150 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3152 .procname = "mmap_rnd_bits",
3153 .data = &mmap_rnd_bits,
3154 .maxlen = sizeof(mmap_rnd_bits),
3156 .proc_handler = proc_dointvec_minmax,
3157 .extra1 = (void *)&mmap_rnd_bits_min,
3158 .extra2 = (void *)&mmap_rnd_bits_max,
3161 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3163 .procname = "mmap_rnd_compat_bits",
3164 .data = &mmap_rnd_compat_bits,
3165 .maxlen = sizeof(mmap_rnd_compat_bits),
3167 .proc_handler = proc_dointvec_minmax,
3168 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3169 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3172 #ifdef CONFIG_USERFAULTFD
3174 .procname = "unprivileged_userfaultfd",
3175 .data = &sysctl_unprivileged_userfaultfd,
3176 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3178 .proc_handler = proc_dointvec_minmax,
3179 .extra1 = SYSCTL_ZERO,
3180 .extra2 = SYSCTL_ONE,
3186 static struct ctl_table fs_table[] = {
3188 .procname = "inode-nr",
3189 .data = &inodes_stat,
3190 .maxlen = 2*sizeof(long),
3192 .proc_handler = proc_nr_inodes,
3195 .procname = "inode-state",
3196 .data = &inodes_stat,
3197 .maxlen = 7*sizeof(long),
3199 .proc_handler = proc_nr_inodes,
3202 .procname = "file-nr",
3203 .data = &files_stat,
3204 .maxlen = sizeof(files_stat),
3206 .proc_handler = proc_nr_files,
3209 .procname = "file-max",
3210 .data = &files_stat.max_files,
3211 .maxlen = sizeof(files_stat.max_files),
3213 .proc_handler = proc_doulongvec_minmax,
3215 .extra2 = &long_max,
3218 .procname = "nr_open",
3219 .data = &sysctl_nr_open,
3220 .maxlen = sizeof(unsigned int),
3222 .proc_handler = proc_dointvec_minmax,
3223 .extra1 = &sysctl_nr_open_min,
3224 .extra2 = &sysctl_nr_open_max,
3227 .procname = "dentry-state",
3228 .data = &dentry_stat,
3229 .maxlen = 6*sizeof(long),
3231 .proc_handler = proc_nr_dentry,
3234 .procname = "overflowuid",
3235 .data = &fs_overflowuid,
3236 .maxlen = sizeof(int),
3238 .proc_handler = proc_dointvec_minmax,
3239 .extra1 = &minolduid,
3240 .extra2 = &maxolduid,
3243 .procname = "overflowgid",
3244 .data = &fs_overflowgid,
3245 .maxlen = sizeof(int),
3247 .proc_handler = proc_dointvec_minmax,
3248 .extra1 = &minolduid,
3249 .extra2 = &maxolduid,
3251 #ifdef CONFIG_FILE_LOCKING
3253 .procname = "leases-enable",
3254 .data = &leases_enable,
3255 .maxlen = sizeof(int),
3257 .proc_handler = proc_dointvec,
3260 #ifdef CONFIG_DNOTIFY
3262 .procname = "dir-notify-enable",
3263 .data = &dir_notify_enable,
3264 .maxlen = sizeof(int),
3266 .proc_handler = proc_dointvec,
3270 #ifdef CONFIG_FILE_LOCKING
3272 .procname = "lease-break-time",
3273 .data = &lease_break_time,
3274 .maxlen = sizeof(int),
3276 .proc_handler = proc_dointvec,
3281 .procname = "aio-nr",
3283 .maxlen = sizeof(aio_nr),
3285 .proc_handler = proc_doulongvec_minmax,
3288 .procname = "aio-max-nr",
3289 .data = &aio_max_nr,
3290 .maxlen = sizeof(aio_max_nr),
3292 .proc_handler = proc_doulongvec_minmax,
3294 #endif /* CONFIG_AIO */
3295 #ifdef CONFIG_INOTIFY_USER
3297 .procname = "inotify",
3299 .child = inotify_table,
3302 #ifdef CONFIG_FANOTIFY
3304 .procname = "fanotify",
3306 .child = fanotify_table,
3311 .procname = "epoll",
3313 .child = epoll_table,
3318 .procname = "protected_symlinks",
3319 .data = &sysctl_protected_symlinks,
3320 .maxlen = sizeof(int),
3322 .proc_handler = proc_dointvec_minmax,
3323 .extra1 = SYSCTL_ZERO,
3324 .extra2 = SYSCTL_ONE,
3327 .procname = "protected_hardlinks",
3328 .data = &sysctl_protected_hardlinks,
3329 .maxlen = sizeof(int),
3331 .proc_handler = proc_dointvec_minmax,
3332 .extra1 = SYSCTL_ZERO,
3333 .extra2 = SYSCTL_ONE,
3336 .procname = "protected_fifos",
3337 .data = &sysctl_protected_fifos,
3338 .maxlen = sizeof(int),
3340 .proc_handler = proc_dointvec_minmax,
3341 .extra1 = SYSCTL_ZERO,
3345 .procname = "protected_regular",
3346 .data = &sysctl_protected_regular,
3347 .maxlen = sizeof(int),
3349 .proc_handler = proc_dointvec_minmax,
3350 .extra1 = SYSCTL_ZERO,
3354 .procname = "suid_dumpable",
3355 .data = &suid_dumpable,
3356 .maxlen = sizeof(int),
3358 .proc_handler = proc_dointvec_minmax_coredump,
3359 .extra1 = SYSCTL_ZERO,
3362 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3364 .procname = "binfmt_misc",
3366 .child = sysctl_mount_point,
3370 .procname = "pipe-max-size",
3371 .data = &pipe_max_size,
3372 .maxlen = sizeof(pipe_max_size),
3374 .proc_handler = proc_dopipe_max_size,
3377 .procname = "pipe-user-pages-hard",
3378 .data = &pipe_user_pages_hard,
3379 .maxlen = sizeof(pipe_user_pages_hard),
3381 .proc_handler = proc_doulongvec_minmax,
3384 .procname = "pipe-user-pages-soft",
3385 .data = &pipe_user_pages_soft,
3386 .maxlen = sizeof(pipe_user_pages_soft),
3388 .proc_handler = proc_doulongvec_minmax,
3391 .procname = "mount-max",
3392 .data = &sysctl_mount_max,
3393 .maxlen = sizeof(unsigned int),
3395 .proc_handler = proc_dointvec_minmax,
3396 .extra1 = SYSCTL_ONE,
3401 static struct ctl_table debug_table[] = {
3402 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3404 .procname = "exception-trace",
3405 .data = &show_unhandled_signals,
3406 .maxlen = sizeof(int),
3408 .proc_handler = proc_dointvec
3411 #if defined(CONFIG_OPTPROBES)
3413 .procname = "kprobes-optimization",
3414 .data = &sysctl_kprobes_optimization,
3415 .maxlen = sizeof(int),
3417 .proc_handler = proc_kprobes_optimization_handler,
3418 .extra1 = SYSCTL_ZERO,
3419 .extra2 = SYSCTL_ONE,
3425 static struct ctl_table dev_table[] = {
3429 static struct ctl_table sysctl_base_table[] = {
3431 .procname = "kernel",
3433 .child = kern_table,
3446 .procname = "debug",
3448 .child = debug_table,
3458 int __init sysctl_init(void)
3460 struct ctl_table_header *hdr;
3462 hdr = register_sysctl_table(sysctl_base_table);
3463 kmemleak_not_leak(hdr);
3466 #endif /* CONFIG_SYSCTL */
3468 * No sense putting this after each symbol definition, twice,
3469 * exception granted :-)
3471 EXPORT_SYMBOL(proc_dobool);
3472 EXPORT_SYMBOL(proc_dointvec);
3473 EXPORT_SYMBOL(proc_douintvec);
3474 EXPORT_SYMBOL(proc_dointvec_jiffies);
3475 EXPORT_SYMBOL(proc_dointvec_minmax);
3476 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3477 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3478 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3479 EXPORT_SYMBOL(proc_dostring);
3480 EXPORT_SYMBOL(proc_doulongvec_minmax);
3481 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3482 EXPORT_SYMBOL(proc_do_large_bitmap);