1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/panic.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.h>
34 #include <linux/kmemleak.h>
35 #include <linux/filter.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
39 #include <linux/kobject.h>
40 #include <linux/net.h>
41 #include <linux/sysrq.h>
42 #include <linux/highuid.h>
43 #include <linux/writeback.h>
44 #include <linux/ratelimit.h>
45 #include <linux/compaction.h>
46 #include <linux/hugetlb.h>
47 #include <linux/initrd.h>
48 #include <linux/key.h>
49 #include <linux/times.h>
50 #include <linux/limits.h>
51 #include <linux/dcache.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/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>
74 #include <linux/delayacct.h>
76 #include "../lib/kstrtox.h"
78 #include <linux/uaccess.h>
79 #include <asm/processor.h>
83 #include <asm/stacktrace.h>
87 #include <asm/setup.h>
89 #ifdef CONFIG_BSD_PROCESS_ACCT
90 #include <linux/acct.h>
92 #ifdef CONFIG_RT_MUTEXES
93 #include <linux/rtmutex.h>
95 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
96 #include <linux/lockdep.h>
98 #ifdef CONFIG_CHR_DEV_SG
101 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
102 #include <linux/stackleak.h>
105 #if defined(CONFIG_SYSCTL)
107 /* Constants used for minimum and maximum */
109 static const unsigned long zero_ul;
110 static const unsigned long one_ul = 1;
111 static const unsigned long long_max = LONG_MAX;
113 static const int ten_thousand = 10000;
115 #ifdef CONFIG_PERF_EVENTS
116 static const int six_hundred_forty_kb = 640 * 1024;
119 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
120 static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
122 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
123 static const int maxolduid = 65535;
124 /* minolduid is SYSCTL_ZERO */
126 static const int ngroups_max = NGROUPS_MAX;
127 static const int cap_last_cap = CAP_LAST_CAP;
129 #ifdef CONFIG_PROC_SYSCTL
132 * enum sysctl_writes_mode - supported sysctl write modes
134 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
135 * to be written, and multiple writes on the same sysctl file descriptor
136 * will rewrite the sysctl value, regardless of file position. No warning
137 * is issued when the initial position is not 0.
138 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
140 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
141 * file position 0 and the value must be fully contained in the buffer
142 * sent to the write syscall. If dealing with strings respect the file
143 * position, but restrict this to the max length of the buffer, anything
144 * passed the max length will be ignored. Multiple writes will append
147 * These write modes control how current file position affects the behavior of
148 * updating sysctl values through the proc interface on each write.
150 enum sysctl_writes_mode {
151 SYSCTL_WRITES_LEGACY = -1,
152 SYSCTL_WRITES_WARN = 0,
153 SYSCTL_WRITES_STRICT = 1,
156 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
157 #endif /* CONFIG_PROC_SYSCTL */
159 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
160 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
161 int sysctl_legacy_va_layout;
164 #ifdef CONFIG_COMPACTION
165 /* min_extfrag_threshold is SYSCTL_ZERO */;
166 static const int max_extfrag_threshold = 1000;
169 #endif /* CONFIG_SYSCTL */
171 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
172 static int bpf_stats_handler(struct ctl_table *table, int write,
173 void *buffer, size_t *lenp, loff_t *ppos)
175 struct static_key *key = (struct static_key *)table->data;
176 static int saved_val;
178 struct ctl_table tmp = {
180 .maxlen = sizeof(val),
182 .extra1 = SYSCTL_ZERO,
183 .extra2 = SYSCTL_ONE,
186 if (write && !capable(CAP_SYS_ADMIN))
189 mutex_lock(&bpf_stats_enabled_mutex);
191 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
192 if (write && !ret && val != saved_val) {
194 static_key_slow_inc(key);
196 static_key_slow_dec(key);
199 mutex_unlock(&bpf_stats_enabled_mutex);
203 static int bpf_unpriv_handler(struct ctl_table *table, int write,
204 void *buffer, size_t *lenp, loff_t *ppos)
206 int ret, unpriv_enable = *(int *)table->data;
207 bool locked_state = unpriv_enable == 1;
208 struct ctl_table tmp = *table;
210 if (write && !capable(CAP_SYS_ADMIN))
213 tmp.data = &unpriv_enable;
214 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
216 if (locked_state && unpriv_enable != 1)
218 *(int *)table->data = unpriv_enable;
222 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
228 #ifdef CONFIG_PROC_SYSCTL
230 static int _proc_do_string(char *data, int maxlen, int write,
231 char *buffer, size_t *lenp, loff_t *ppos)
236 if (!data || !maxlen || !*lenp) {
242 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
243 /* Only continue writes not past the end of buffer. */
245 if (len > maxlen - 1)
252 /* Start writing from beginning of buffer. */
258 while ((p - buffer) < *lenp && len < maxlen - 1) {
260 if (c == 0 || c == '\n')
281 memcpy(buffer, data, len);
292 static void warn_sysctl_write(struct ctl_table *table)
294 pr_warn_once("%s wrote to %s when file position was not 0!\n"
295 "This will not be supported in the future. To silence this\n"
296 "warning, set kernel.sysctl_writes_strict = -1\n",
297 current->comm, table->procname);
301 * proc_first_pos_non_zero_ignore - check if first position is allowed
302 * @ppos: file position
303 * @table: the sysctl table
305 * Returns true if the first position is non-zero and the sysctl_writes_strict
306 * mode indicates this is not allowed for numeric input types. String proc
307 * handlers can ignore the return value.
309 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
310 struct ctl_table *table)
315 switch (sysctl_writes_strict) {
316 case SYSCTL_WRITES_STRICT:
318 case SYSCTL_WRITES_WARN:
319 warn_sysctl_write(table);
327 * proc_dostring - read a string sysctl
328 * @table: the sysctl table
329 * @write: %TRUE if this is a write to the sysctl file
330 * @buffer: the user buffer
331 * @lenp: the size of the user buffer
332 * @ppos: file position
334 * Reads/writes a string from/to the user buffer. If the kernel
335 * buffer provided is not large enough to hold the string, the
336 * string is truncated. The copied string is %NULL-terminated.
337 * If the string is being read by the user process, it is copied
338 * and a newline '\n' is added. It is truncated if the buffer is
341 * Returns 0 on success.
343 int proc_dostring(struct ctl_table *table, int write,
344 void *buffer, size_t *lenp, loff_t *ppos)
347 proc_first_pos_non_zero_ignore(ppos, table);
349 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
353 static size_t proc_skip_spaces(char **buf)
356 char *tmp = skip_spaces(*buf);
362 static void proc_skip_char(char **buf, size_t *size, const char v)
373 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
376 * @cp: kernel buffer containing the string to parse
377 * @endp: pointer to store the trailing characters
378 * @base: the base to use
379 * @res: where the parsed integer will be stored
381 * In case of success 0 is returned and @res will contain the parsed integer,
382 * @endp will hold any trailing characters.
383 * This function will fail the parse on overflow. If there wasn't an overflow
384 * the function will defer the decision what characters count as invalid to the
387 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
390 unsigned long long result;
393 cp = _parse_integer_fixup_radix(cp, &base);
394 rv = _parse_integer(cp, base, &result);
395 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
403 *res = (unsigned long)result;
409 * proc_get_long - reads an ASCII formatted integer from a user buffer
411 * @buf: a kernel buffer
412 * @size: size of the kernel buffer
413 * @val: this is where the number will be stored
414 * @neg: set to %TRUE if number is negative
415 * @perm_tr: a vector which contains the allowed trailers
416 * @perm_tr_len: size of the perm_tr vector
417 * @tr: pointer to store the trailer character
419 * In case of success %0 is returned and @buf and @size are updated with
420 * the amount of bytes read. If @tr is non-NULL and a trailing
421 * character exists (size is non-zero after returning from this
422 * function), @tr is updated with the trailing character.
424 static int proc_get_long(char **buf, size_t *size,
425 unsigned long *val, bool *neg,
426 const char *perm_tr, unsigned perm_tr_len, char *tr)
429 char *p, tmp[TMPBUFLEN];
435 if (len > TMPBUFLEN - 1)
438 memcpy(tmp, *buf, len);
442 if (*p == '-' && *size > 1) {
450 if (strtoul_lenient(p, &p, 0, val))
455 /* We don't know if the next char is whitespace thus we may accept
456 * invalid integers (e.g. 1234...a) or two integers instead of one
457 * (e.g. 123...1). So lets not allow such large numbers. */
458 if (len == TMPBUFLEN - 1)
461 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
464 if (tr && (len < *size))
474 * proc_put_long - converts an integer to a decimal ASCII formatted string
476 * @buf: the user buffer
477 * @size: the size of the user buffer
478 * @val: the integer to be converted
479 * @neg: sign of the number, %TRUE for negative
481 * In case of success @buf and @size are updated with the amount of bytes
484 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
487 char tmp[TMPBUFLEN], *p = tmp;
489 sprintf(p, "%s%lu", neg ? "-" : "", val);
493 memcpy(*buf, tmp, len);
499 static void proc_put_char(void **buf, size_t *size, char c)
502 char **buffer = (char **)buf;
511 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
513 int write, void *data)
516 *(bool *)valp = *lvalp;
518 int val = *(bool *)valp;
520 *lvalp = (unsigned long)val;
526 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
528 int write, void *data)
532 if (*lvalp > (unsigned long) INT_MAX + 1)
536 if (*lvalp > (unsigned long) INT_MAX)
544 *lvalp = -(unsigned long)val;
547 *lvalp = (unsigned long)val;
553 static int do_proc_douintvec_conv(unsigned long *lvalp,
555 int write, void *data)
558 if (*lvalp > UINT_MAX)
562 unsigned int val = *valp;
563 *lvalp = (unsigned long)val;
568 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
570 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
571 int write, void *buffer,
572 size_t *lenp, loff_t *ppos,
573 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
574 int write, void *data),
577 int *i, vleft, first = 1, err = 0;
581 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
586 i = (int *) tbl_data;
587 vleft = table->maxlen / sizeof(*i);
591 conv = do_proc_dointvec_conv;
594 if (proc_first_pos_non_zero_ignore(ppos, table))
597 if (left > PAGE_SIZE - 1)
598 left = PAGE_SIZE - 1;
602 for (; left && vleft--; i++, first=0) {
607 left -= proc_skip_spaces(&p);
611 err = proc_get_long(&p, &left, &lval, &neg,
613 sizeof(proc_wspace_sep), NULL);
616 if (conv(&neg, &lval, i, 1, data)) {
621 if (conv(&neg, &lval, i, 0, data)) {
626 proc_put_char(&buffer, &left, '\t');
627 proc_put_long(&buffer, &left, lval, neg);
631 if (!write && !first && left && !err)
632 proc_put_char(&buffer, &left, '\n');
633 if (write && !err && left)
634 left -= proc_skip_spaces(&p);
636 return err ? : -EINVAL;
643 static int do_proc_dointvec(struct ctl_table *table, int write,
644 void *buffer, size_t *lenp, loff_t *ppos,
645 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
646 int write, void *data),
649 return __do_proc_dointvec(table->data, table, write,
650 buffer, lenp, ppos, conv, data);
653 static int do_proc_douintvec_w(unsigned int *tbl_data,
654 struct ctl_table *table,
656 size_t *lenp, loff_t *ppos,
657 int (*conv)(unsigned long *lvalp,
659 int write, void *data),
670 if (proc_first_pos_non_zero_ignore(ppos, table))
673 if (left > PAGE_SIZE - 1)
674 left = PAGE_SIZE - 1;
676 left -= proc_skip_spaces(&p);
682 err = proc_get_long(&p, &left, &lval, &neg,
684 sizeof(proc_wspace_sep), NULL);
690 if (conv(&lval, tbl_data, 1, data)) {
696 left -= proc_skip_spaces(&p);
704 /* This is in keeping with old __do_proc_dointvec() */
710 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
711 size_t *lenp, loff_t *ppos,
712 int (*conv)(unsigned long *lvalp,
714 int write, void *data),
723 if (conv(&lval, tbl_data, 0, data)) {
728 proc_put_long(&buffer, &left, lval, false);
732 proc_put_char(&buffer, &left, '\n');
741 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
742 int write, void *buffer,
743 size_t *lenp, loff_t *ppos,
744 int (*conv)(unsigned long *lvalp,
746 int write, void *data),
749 unsigned int *i, vleft;
751 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
756 i = (unsigned int *) tbl_data;
757 vleft = table->maxlen / sizeof(*i);
760 * Arrays are not supported, keep this simple. *Do not* add
769 conv = do_proc_douintvec_conv;
772 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
774 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
777 static int do_proc_douintvec(struct ctl_table *table, int write,
778 void *buffer, size_t *lenp, loff_t *ppos,
779 int (*conv)(unsigned long *lvalp,
781 int write, void *data),
784 return __do_proc_douintvec(table->data, table, write,
785 buffer, lenp, ppos, conv, data);
789 * proc_dobool - read/write a bool
790 * @table: the sysctl table
791 * @write: %TRUE if this is a write to the sysctl file
792 * @buffer: the user buffer
793 * @lenp: the size of the user buffer
794 * @ppos: file position
796 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
797 * values from/to the user buffer, treated as an ASCII string.
799 * Returns 0 on success.
801 int proc_dobool(struct ctl_table *table, int write, void *buffer,
802 size_t *lenp, loff_t *ppos)
804 return do_proc_dointvec(table, write, buffer, lenp, ppos,
805 do_proc_dobool_conv, NULL);
809 * proc_dointvec - read a vector of integers
810 * @table: the sysctl table
811 * @write: %TRUE if this is a write to the sysctl file
812 * @buffer: the user buffer
813 * @lenp: the size of the user buffer
814 * @ppos: file position
816 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
817 * values from/to the user buffer, treated as an ASCII string.
819 * Returns 0 on success.
821 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
822 size_t *lenp, loff_t *ppos)
824 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
827 #ifdef CONFIG_COMPACTION
828 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
829 int write, void *buffer, size_t *lenp, loff_t *ppos)
833 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
834 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
836 old = *(int *)table->data;
837 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
840 if (old != *(int *)table->data)
841 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
842 table->procname, current->comm,
843 task_pid_nr(current));
849 * proc_douintvec - read a vector of unsigned integers
850 * @table: the sysctl table
851 * @write: %TRUE if this is a write to the sysctl file
852 * @buffer: the user buffer
853 * @lenp: the size of the user buffer
854 * @ppos: file position
856 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
857 * values from/to the user buffer, treated as an ASCII string.
859 * Returns 0 on success.
861 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
862 size_t *lenp, loff_t *ppos)
864 return do_proc_douintvec(table, write, buffer, lenp, ppos,
865 do_proc_douintvec_conv, NULL);
869 * Taint values can only be increased
870 * This means we can safely use a temporary.
872 static int proc_taint(struct ctl_table *table, int write,
873 void *buffer, size_t *lenp, loff_t *ppos)
876 unsigned long tmptaint = get_taint();
879 if (write && !capable(CAP_SYS_ADMIN))
884 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
892 * If we are relying on panic_on_taint not producing
893 * false positives due to userspace input, bail out
894 * before setting the requested taint flags.
896 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
900 * Poor man's atomic or. Not worth adding a primitive
901 * to everyone's atomic.h for this
903 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
904 if ((1UL << i) & tmptaint)
905 add_taint(i, LOCKDEP_STILL_OK);
912 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
913 void *buffer, size_t *lenp, loff_t *ppos)
915 if (write && !capable(CAP_SYS_ADMIN))
918 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
923 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
924 * @min: pointer to minimum allowable value
925 * @max: pointer to maximum allowable value
927 * The do_proc_dointvec_minmax_conv_param structure provides the
928 * minimum and maximum values for doing range checking for those sysctl
929 * parameters that use the proc_dointvec_minmax() handler.
931 struct do_proc_dointvec_minmax_conv_param {
936 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
938 int write, void *data)
941 struct do_proc_dointvec_minmax_conv_param *param = data;
943 * If writing, first do so via a temporary local int so we can
944 * bounds-check it before touching *valp.
946 int *ip = write ? &tmp : valp;
948 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
953 if ((param->min && *param->min > tmp) ||
954 (param->max && *param->max < tmp))
963 * proc_dointvec_minmax - read a vector of integers with min/max values
964 * @table: the sysctl table
965 * @write: %TRUE if this is a write to the sysctl file
966 * @buffer: the user buffer
967 * @lenp: the size of the user buffer
968 * @ppos: file position
970 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
971 * values from/to the user buffer, treated as an ASCII string.
973 * This routine will ensure the values are within the range specified by
974 * table->extra1 (min) and table->extra2 (max).
976 * Returns 0 on success or -EINVAL on write when the range check fails.
978 int proc_dointvec_minmax(struct ctl_table *table, int write,
979 void *buffer, size_t *lenp, loff_t *ppos)
981 struct do_proc_dointvec_minmax_conv_param param = {
982 .min = (int *) table->extra1,
983 .max = (int *) table->extra2,
985 return do_proc_dointvec(table, write, buffer, lenp, ppos,
986 do_proc_dointvec_minmax_conv, ¶m);
990 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
991 * @min: pointer to minimum allowable value
992 * @max: pointer to maximum allowable value
994 * The do_proc_douintvec_minmax_conv_param structure provides the
995 * minimum and maximum values for doing range checking for those sysctl
996 * parameters that use the proc_douintvec_minmax() handler.
998 struct do_proc_douintvec_minmax_conv_param {
1003 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1005 int write, void *data)
1009 struct do_proc_douintvec_minmax_conv_param *param = data;
1010 /* write via temporary local uint for bounds-checking */
1011 unsigned int *up = write ? &tmp : valp;
1013 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1018 if ((param->min && *param->min > tmp) ||
1019 (param->max && *param->max < tmp))
1029 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1030 * @table: the sysctl table
1031 * @write: %TRUE if this is a write to the sysctl file
1032 * @buffer: the user buffer
1033 * @lenp: the size of the user buffer
1034 * @ppos: file position
1036 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1037 * values from/to the user buffer, treated as an ASCII string. Negative
1038 * strings are not allowed.
1040 * This routine will ensure the values are within the range specified by
1041 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1042 * check for UINT_MAX to avoid having to support wrap around uses from
1045 * Returns 0 on success or -ERANGE on write when the range check fails.
1047 int proc_douintvec_minmax(struct ctl_table *table, int write,
1048 void *buffer, size_t *lenp, loff_t *ppos)
1050 struct do_proc_douintvec_minmax_conv_param param = {
1051 .min = (unsigned int *) table->extra1,
1052 .max = (unsigned int *) table->extra2,
1054 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1055 do_proc_douintvec_minmax_conv, ¶m);
1059 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1060 * @table: the sysctl table
1061 * @write: %TRUE if this is a write to the sysctl file
1062 * @buffer: the user buffer
1063 * @lenp: the size of the user buffer
1064 * @ppos: file position
1066 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1067 * values from/to the user buffer, treated as an ASCII string. Negative
1068 * strings are not allowed.
1070 * This routine will ensure the values are within the range specified by
1071 * table->extra1 (min) and table->extra2 (max).
1073 * Returns 0 on success or an error on write when the range check fails.
1075 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1076 void *buffer, size_t *lenp, loff_t *ppos)
1078 struct ctl_table tmp;
1079 unsigned int min = 0, max = 255U, val;
1080 u8 *data = table->data;
1081 struct do_proc_douintvec_minmax_conv_param param = {
1087 /* Do not support arrays yet. */
1088 if (table->maxlen != sizeof(u8))
1091 if (table->extra1) {
1092 min = *(unsigned int *) table->extra1;
1096 if (table->extra2) {
1097 max = *(unsigned int *) table->extra2;
1104 tmp.maxlen = sizeof(val);
1107 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1108 do_proc_douintvec_minmax_conv, ¶m);
1115 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1117 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1119 int write, void *data)
1124 val = round_pipe_size(*lvalp);
1130 unsigned int val = *valp;
1131 *lvalp = (unsigned long) val;
1137 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1138 void *buffer, size_t *lenp, loff_t *ppos)
1140 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1141 do_proc_dopipe_max_size_conv, NULL);
1144 static void validate_coredump_safety(void)
1146 #ifdef CONFIG_COREDUMP
1147 if (suid_dumpable == SUID_DUMP_ROOT &&
1148 core_pattern[0] != '/' && core_pattern[0] != '|') {
1150 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1151 "Pipe handler or fully qualified core dump path required.\n"
1152 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1158 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1159 void *buffer, size_t *lenp, loff_t *ppos)
1161 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1163 validate_coredump_safety();
1167 #ifdef CONFIG_COREDUMP
1168 static int proc_dostring_coredump(struct ctl_table *table, int write,
1169 void *buffer, size_t *lenp, loff_t *ppos)
1171 int error = proc_dostring(table, write, buffer, lenp, ppos);
1173 validate_coredump_safety();
1178 #ifdef CONFIG_MAGIC_SYSRQ
1179 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1180 void *buffer, size_t *lenp, loff_t *ppos)
1186 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1187 lenp, ppos, NULL, NULL);
1192 sysrq_toggle_support(tmp);
1198 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1199 int write, void *buffer, size_t *lenp, loff_t *ppos,
1200 unsigned long convmul, unsigned long convdiv)
1202 unsigned long *i, *min, *max;
1203 int vleft, first = 1, err = 0;
1207 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1212 i = (unsigned long *) data;
1213 min = (unsigned long *) table->extra1;
1214 max = (unsigned long *) table->extra2;
1215 vleft = table->maxlen / sizeof(unsigned long);
1219 if (proc_first_pos_non_zero_ignore(ppos, table))
1222 if (left > PAGE_SIZE - 1)
1223 left = PAGE_SIZE - 1;
1227 for (; left && vleft--; i++, first = 0) {
1233 left -= proc_skip_spaces(&p);
1237 err = proc_get_long(&p, &left, &val, &neg,
1239 sizeof(proc_wspace_sep), NULL);
1244 val = convmul * val / convdiv;
1245 if ((min && val < *min) || (max && val > *max)) {
1251 val = convdiv * (*i) / convmul;
1253 proc_put_char(&buffer, &left, '\t');
1254 proc_put_long(&buffer, &left, val, false);
1258 if (!write && !first && left && !err)
1259 proc_put_char(&buffer, &left, '\n');
1261 left -= proc_skip_spaces(&p);
1263 return err ? : -EINVAL;
1270 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1271 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1272 unsigned long convdiv)
1274 return __do_proc_doulongvec_minmax(table->data, table, write,
1275 buffer, lenp, ppos, convmul, convdiv);
1279 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1280 * @table: the sysctl table
1281 * @write: %TRUE if this is a write to the sysctl file
1282 * @buffer: the user buffer
1283 * @lenp: the size of the user buffer
1284 * @ppos: file position
1286 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1287 * values from/to the user buffer, treated as an ASCII string.
1289 * This routine will ensure the values are within the range specified by
1290 * table->extra1 (min) and table->extra2 (max).
1292 * Returns 0 on success.
1294 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1295 void *buffer, size_t *lenp, loff_t *ppos)
1297 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1301 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1302 * @table: the sysctl table
1303 * @write: %TRUE if this is a write to the sysctl file
1304 * @buffer: the user buffer
1305 * @lenp: the size of the user buffer
1306 * @ppos: file position
1308 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1309 * values from/to the user buffer, treated as an ASCII string. The values
1310 * are treated as milliseconds, and converted to jiffies when they are stored.
1312 * This routine will ensure the values are within the range specified by
1313 * table->extra1 (min) and table->extra2 (max).
1315 * Returns 0 on success.
1317 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1318 void *buffer, size_t *lenp, loff_t *ppos)
1320 return do_proc_doulongvec_minmax(table, write, buffer,
1321 lenp, ppos, HZ, 1000l);
1325 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1327 int write, void *data)
1330 if (*lvalp > INT_MAX / HZ)
1332 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1338 lval = -(unsigned long)val;
1341 lval = (unsigned long)val;
1348 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1350 int write, void *data)
1353 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1355 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1361 lval = -(unsigned long)val;
1364 lval = (unsigned long)val;
1366 *lvalp = jiffies_to_clock_t(lval);
1371 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1373 int write, void *data)
1376 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1386 lval = -(unsigned long)val;
1389 lval = (unsigned long)val;
1391 *lvalp = jiffies_to_msecs(lval);
1397 * proc_dointvec_jiffies - read a vector of integers as seconds
1398 * @table: the sysctl table
1399 * @write: %TRUE if this is a write to the sysctl file
1400 * @buffer: the user buffer
1401 * @lenp: the size of the user buffer
1402 * @ppos: file position
1404 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1405 * values from/to the user buffer, treated as an ASCII string.
1406 * The values read are assumed to be in seconds, and are converted into
1409 * Returns 0 on success.
1411 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1412 void *buffer, size_t *lenp, loff_t *ppos)
1414 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1415 do_proc_dointvec_jiffies_conv,NULL);
1419 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1420 * @table: the sysctl table
1421 * @write: %TRUE if this is a write to the sysctl file
1422 * @buffer: the user buffer
1423 * @lenp: the size of the user buffer
1424 * @ppos: pointer to the file position
1426 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1427 * values from/to the user buffer, treated as an ASCII string.
1428 * The values read are assumed to be in 1/USER_HZ seconds, and
1429 * are converted into jiffies.
1431 * Returns 0 on success.
1433 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1434 void *buffer, size_t *lenp, loff_t *ppos)
1436 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1437 do_proc_dointvec_userhz_jiffies_conv,NULL);
1441 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1442 * @table: the sysctl table
1443 * @write: %TRUE if this is a write to the sysctl file
1444 * @buffer: the user buffer
1445 * @lenp: the size of the user buffer
1446 * @ppos: file position
1447 * @ppos: the current position in the file
1449 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1450 * values from/to the user buffer, treated as an ASCII string.
1451 * The values read are assumed to be in 1/1000 seconds, and
1452 * are converted into jiffies.
1454 * Returns 0 on success.
1456 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1457 size_t *lenp, loff_t *ppos)
1459 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1460 do_proc_dointvec_ms_jiffies_conv, NULL);
1463 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1464 size_t *lenp, loff_t *ppos)
1466 struct pid *new_pid;
1470 tmp = pid_vnr(cad_pid);
1472 r = __do_proc_dointvec(&tmp, table, write, buffer,
1473 lenp, ppos, NULL, NULL);
1477 new_pid = find_get_pid(tmp);
1481 put_pid(xchg(&cad_pid, new_pid));
1486 * proc_do_large_bitmap - read/write from/to a large bitmap
1487 * @table: the sysctl table
1488 * @write: %TRUE if this is a write to the sysctl file
1489 * @buffer: the user buffer
1490 * @lenp: the size of the user buffer
1491 * @ppos: file position
1493 * The bitmap is stored at table->data and the bitmap length (in bits)
1496 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1497 * large bitmaps may be represented in a compact manner. Writing into
1498 * the file will clear the bitmap then update it with the given input.
1500 * Returns 0 on success.
1502 int proc_do_large_bitmap(struct ctl_table *table, int write,
1503 void *buffer, size_t *lenp, loff_t *ppos)
1506 size_t left = *lenp;
1507 unsigned long bitmap_len = table->maxlen;
1508 unsigned long *bitmap = *(unsigned long **) table->data;
1509 unsigned long *tmp_bitmap = NULL;
1510 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1512 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1521 if (left > PAGE_SIZE - 1) {
1522 left = PAGE_SIZE - 1;
1523 /* How much of the buffer we'll skip this pass */
1524 skipped = *lenp - left;
1527 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1530 proc_skip_char(&p, &left, '\n');
1531 while (!err && left) {
1532 unsigned long val_a, val_b;
1536 /* In case we stop parsing mid-number, we can reset */
1538 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1541 * If we consumed the entirety of a truncated buffer or
1542 * only one char is left (may be a "-"), then stop here,
1543 * reset, & come back for more.
1545 if ((left <= 1) && skipped) {
1552 if (val_a >= bitmap_len || neg) {
1564 err = proc_get_long(&p, &left, &val_b,
1565 &neg, tr_b, sizeof(tr_b),
1568 * If we consumed all of a truncated buffer or
1569 * then stop here, reset, & come back for more.
1571 if (!left && skipped) {
1578 if (val_b >= bitmap_len || neg ||
1589 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1590 proc_skip_char(&p, &left, '\n');
1594 unsigned long bit_a, bit_b = 0;
1598 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1599 if (bit_a >= bitmap_len)
1601 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1605 proc_put_char(&buffer, &left, ',');
1606 proc_put_long(&buffer, &left, bit_a, false);
1607 if (bit_a != bit_b) {
1608 proc_put_char(&buffer, &left, '-');
1609 proc_put_long(&buffer, &left, bit_b, false);
1614 proc_put_char(&buffer, &left, '\n');
1620 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1622 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1628 bitmap_free(tmp_bitmap);
1632 #else /* CONFIG_PROC_SYSCTL */
1634 int proc_dostring(struct ctl_table *table, int write,
1635 void *buffer, size_t *lenp, loff_t *ppos)
1640 int proc_dobool(struct ctl_table *table, int write,
1641 void *buffer, size_t *lenp, loff_t *ppos)
1646 int proc_dointvec(struct ctl_table *table, int write,
1647 void *buffer, size_t *lenp, loff_t *ppos)
1652 int proc_douintvec(struct ctl_table *table, int write,
1653 void *buffer, size_t *lenp, loff_t *ppos)
1658 int proc_dointvec_minmax(struct ctl_table *table, int write,
1659 void *buffer, size_t *lenp, loff_t *ppos)
1664 int proc_douintvec_minmax(struct ctl_table *table, int write,
1665 void *buffer, size_t *lenp, loff_t *ppos)
1670 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1671 void *buffer, size_t *lenp, loff_t *ppos)
1676 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1677 void *buffer, size_t *lenp, loff_t *ppos)
1682 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1683 void *buffer, size_t *lenp, loff_t *ppos)
1688 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1689 void *buffer, size_t *lenp, loff_t *ppos)
1694 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1695 void *buffer, size_t *lenp, loff_t *ppos)
1700 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1701 void *buffer, size_t *lenp, loff_t *ppos)
1706 int proc_do_large_bitmap(struct ctl_table *table, int write,
1707 void *buffer, size_t *lenp, loff_t *ppos)
1712 #endif /* CONFIG_PROC_SYSCTL */
1714 #if defined(CONFIG_SYSCTL)
1715 int proc_do_static_key(struct ctl_table *table, int write,
1716 void *buffer, size_t *lenp, loff_t *ppos)
1718 struct static_key *key = (struct static_key *)table->data;
1719 static DEFINE_MUTEX(static_key_mutex);
1721 struct ctl_table tmp = {
1723 .maxlen = sizeof(val),
1724 .mode = table->mode,
1725 .extra1 = SYSCTL_ZERO,
1726 .extra2 = SYSCTL_ONE,
1729 if (write && !capable(CAP_SYS_ADMIN))
1732 mutex_lock(&static_key_mutex);
1733 val = static_key_enabled(key);
1734 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1735 if (write && !ret) {
1737 static_key_enable(key);
1739 static_key_disable(key);
1741 mutex_unlock(&static_key_mutex);
1745 static struct ctl_table kern_table[] = {
1747 .procname = "sched_child_runs_first",
1748 .data = &sysctl_sched_child_runs_first,
1749 .maxlen = sizeof(unsigned int),
1751 .proc_handler = proc_dointvec,
1753 #ifdef CONFIG_SCHEDSTATS
1755 .procname = "sched_schedstats",
1757 .maxlen = sizeof(unsigned int),
1759 .proc_handler = sysctl_schedstats,
1760 .extra1 = SYSCTL_ZERO,
1761 .extra2 = SYSCTL_ONE,
1763 #endif /* CONFIG_SCHEDSTATS */
1764 #ifdef CONFIG_TASK_DELAY_ACCT
1766 .procname = "task_delayacct",
1768 .maxlen = sizeof(unsigned int),
1770 .proc_handler = sysctl_delayacct,
1771 .extra1 = SYSCTL_ZERO,
1772 .extra2 = SYSCTL_ONE,
1774 #endif /* CONFIG_TASK_DELAY_ACCT */
1775 #ifdef CONFIG_NUMA_BALANCING
1777 .procname = "numa_balancing",
1778 .data = NULL, /* filled in by handler */
1779 .maxlen = sizeof(unsigned int),
1781 .proc_handler = sysctl_numa_balancing,
1782 .extra1 = SYSCTL_ZERO,
1783 .extra2 = SYSCTL_ONE,
1785 #endif /* CONFIG_NUMA_BALANCING */
1787 .procname = "sched_rt_period_us",
1788 .data = &sysctl_sched_rt_period,
1789 .maxlen = sizeof(unsigned int),
1791 .proc_handler = sched_rt_handler,
1794 .procname = "sched_rt_runtime_us",
1795 .data = &sysctl_sched_rt_runtime,
1796 .maxlen = sizeof(int),
1798 .proc_handler = sched_rt_handler,
1801 .procname = "sched_deadline_period_max_us",
1802 .data = &sysctl_sched_dl_period_max,
1803 .maxlen = sizeof(unsigned int),
1805 .proc_handler = proc_dointvec,
1808 .procname = "sched_deadline_period_min_us",
1809 .data = &sysctl_sched_dl_period_min,
1810 .maxlen = sizeof(unsigned int),
1812 .proc_handler = proc_dointvec,
1815 .procname = "sched_rr_timeslice_ms",
1816 .data = &sysctl_sched_rr_timeslice,
1817 .maxlen = sizeof(int),
1819 .proc_handler = sched_rr_handler,
1821 #ifdef CONFIG_UCLAMP_TASK
1823 .procname = "sched_util_clamp_min",
1824 .data = &sysctl_sched_uclamp_util_min,
1825 .maxlen = sizeof(unsigned int),
1827 .proc_handler = sysctl_sched_uclamp_handler,
1830 .procname = "sched_util_clamp_max",
1831 .data = &sysctl_sched_uclamp_util_max,
1832 .maxlen = sizeof(unsigned int),
1834 .proc_handler = sysctl_sched_uclamp_handler,
1837 .procname = "sched_util_clamp_min_rt_default",
1838 .data = &sysctl_sched_uclamp_util_min_rt_default,
1839 .maxlen = sizeof(unsigned int),
1841 .proc_handler = sysctl_sched_uclamp_handler,
1844 #ifdef CONFIG_SCHED_AUTOGROUP
1846 .procname = "sched_autogroup_enabled",
1847 .data = &sysctl_sched_autogroup_enabled,
1848 .maxlen = sizeof(unsigned int),
1850 .proc_handler = proc_dointvec_minmax,
1851 .extra1 = SYSCTL_ZERO,
1852 .extra2 = SYSCTL_ONE,
1855 #ifdef CONFIG_CFS_BANDWIDTH
1857 .procname = "sched_cfs_bandwidth_slice_us",
1858 .data = &sysctl_sched_cfs_bandwidth_slice,
1859 .maxlen = sizeof(unsigned int),
1861 .proc_handler = proc_dointvec_minmax,
1862 .extra1 = SYSCTL_ONE,
1865 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1867 .procname = "sched_energy_aware",
1868 .data = &sysctl_sched_energy_aware,
1869 .maxlen = sizeof(unsigned int),
1871 .proc_handler = sched_energy_aware_handler,
1872 .extra1 = SYSCTL_ZERO,
1873 .extra2 = SYSCTL_ONE,
1876 #ifdef CONFIG_PROVE_LOCKING
1878 .procname = "prove_locking",
1879 .data = &prove_locking,
1880 .maxlen = sizeof(int),
1882 .proc_handler = proc_dointvec,
1885 #ifdef CONFIG_LOCK_STAT
1887 .procname = "lock_stat",
1889 .maxlen = sizeof(int),
1891 .proc_handler = proc_dointvec,
1895 .procname = "panic",
1896 .data = &panic_timeout,
1897 .maxlen = sizeof(int),
1899 .proc_handler = proc_dointvec,
1901 #ifdef CONFIG_COREDUMP
1903 .procname = "core_uses_pid",
1904 .data = &core_uses_pid,
1905 .maxlen = sizeof(int),
1907 .proc_handler = proc_dointvec,
1910 .procname = "core_pattern",
1911 .data = core_pattern,
1912 .maxlen = CORENAME_MAX_SIZE,
1914 .proc_handler = proc_dostring_coredump,
1917 .procname = "core_pipe_limit",
1918 .data = &core_pipe_limit,
1919 .maxlen = sizeof(unsigned int),
1921 .proc_handler = proc_dointvec,
1924 #ifdef CONFIG_PROC_SYSCTL
1926 .procname = "tainted",
1927 .maxlen = sizeof(long),
1929 .proc_handler = proc_taint,
1932 .procname = "sysctl_writes_strict",
1933 .data = &sysctl_writes_strict,
1934 .maxlen = sizeof(int),
1936 .proc_handler = proc_dointvec_minmax,
1937 .extra1 = SYSCTL_NEG_ONE,
1938 .extra2 = SYSCTL_ONE,
1941 #ifdef CONFIG_LATENCYTOP
1943 .procname = "latencytop",
1944 .data = &latencytop_enabled,
1945 .maxlen = sizeof(int),
1947 .proc_handler = sysctl_latencytop,
1950 #ifdef CONFIG_BLK_DEV_INITRD
1952 .procname = "real-root-dev",
1953 .data = &real_root_dev,
1954 .maxlen = sizeof(int),
1956 .proc_handler = proc_dointvec,
1960 .procname = "print-fatal-signals",
1961 .data = &print_fatal_signals,
1962 .maxlen = sizeof(int),
1964 .proc_handler = proc_dointvec,
1968 .procname = "reboot-cmd",
1969 .data = reboot_command,
1972 .proc_handler = proc_dostring,
1975 .procname = "stop-a",
1976 .data = &stop_a_enabled,
1977 .maxlen = sizeof (int),
1979 .proc_handler = proc_dointvec,
1982 .procname = "scons-poweroff",
1983 .data = &scons_pwroff,
1984 .maxlen = sizeof (int),
1986 .proc_handler = proc_dointvec,
1989 #ifdef CONFIG_SPARC64
1991 .procname = "tsb-ratio",
1992 .data = &sysctl_tsb_ratio,
1993 .maxlen = sizeof (int),
1995 .proc_handler = proc_dointvec,
1998 #ifdef CONFIG_PARISC
2000 .procname = "soft-power",
2001 .data = &pwrsw_enabled,
2002 .maxlen = sizeof (int),
2004 .proc_handler = proc_dointvec,
2007 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2009 .procname = "unaligned-trap",
2010 .data = &unaligned_enabled,
2011 .maxlen = sizeof (int),
2013 .proc_handler = proc_dointvec,
2017 .procname = "ctrl-alt-del",
2019 .maxlen = sizeof(int),
2021 .proc_handler = proc_dointvec,
2023 #ifdef CONFIG_FUNCTION_TRACER
2025 .procname = "ftrace_enabled",
2026 .data = &ftrace_enabled,
2027 .maxlen = sizeof(int),
2029 .proc_handler = ftrace_enable_sysctl,
2032 #ifdef CONFIG_STACK_TRACER
2034 .procname = "stack_tracer_enabled",
2035 .data = &stack_tracer_enabled,
2036 .maxlen = sizeof(int),
2038 .proc_handler = stack_trace_sysctl,
2041 #ifdef CONFIG_TRACING
2043 .procname = "ftrace_dump_on_oops",
2044 .data = &ftrace_dump_on_oops,
2045 .maxlen = sizeof(int),
2047 .proc_handler = proc_dointvec,
2050 .procname = "traceoff_on_warning",
2051 .data = &__disable_trace_on_warning,
2052 .maxlen = sizeof(__disable_trace_on_warning),
2054 .proc_handler = proc_dointvec,
2057 .procname = "tracepoint_printk",
2058 .data = &tracepoint_printk,
2059 .maxlen = sizeof(tracepoint_printk),
2061 .proc_handler = tracepoint_printk_sysctl,
2064 #ifdef CONFIG_KEXEC_CORE
2066 .procname = "kexec_load_disabled",
2067 .data = &kexec_load_disabled,
2068 .maxlen = sizeof(int),
2070 /* only handle a transition from default "0" to "1" */
2071 .proc_handler = proc_dointvec_minmax,
2072 .extra1 = SYSCTL_ONE,
2073 .extra2 = SYSCTL_ONE,
2076 #ifdef CONFIG_MODULES
2078 .procname = "modprobe",
2079 .data = &modprobe_path,
2080 .maxlen = KMOD_PATH_LEN,
2082 .proc_handler = proc_dostring,
2085 .procname = "modules_disabled",
2086 .data = &modules_disabled,
2087 .maxlen = sizeof(int),
2089 /* only handle a transition from default "0" to "1" */
2090 .proc_handler = proc_dointvec_minmax,
2091 .extra1 = SYSCTL_ONE,
2092 .extra2 = SYSCTL_ONE,
2095 #ifdef CONFIG_UEVENT_HELPER
2097 .procname = "hotplug",
2098 .data = &uevent_helper,
2099 .maxlen = UEVENT_HELPER_PATH_LEN,
2101 .proc_handler = proc_dostring,
2104 #ifdef CONFIG_CHR_DEV_SG
2106 .procname = "sg-big-buff",
2107 .data = &sg_big_buff,
2108 .maxlen = sizeof (int),
2110 .proc_handler = proc_dointvec,
2113 #ifdef CONFIG_BSD_PROCESS_ACCT
2117 .maxlen = 3*sizeof(int),
2119 .proc_handler = proc_dointvec,
2122 #ifdef CONFIG_MAGIC_SYSRQ
2124 .procname = "sysrq",
2126 .maxlen = sizeof (int),
2128 .proc_handler = sysrq_sysctl_handler,
2131 #ifdef CONFIG_PROC_SYSCTL
2133 .procname = "cad_pid",
2135 .maxlen = sizeof (int),
2137 .proc_handler = proc_do_cad_pid,
2141 .procname = "threads-max",
2143 .maxlen = sizeof(int),
2145 .proc_handler = sysctl_max_threads,
2148 .procname = "random",
2150 .child = random_table,
2153 .procname = "usermodehelper",
2155 .child = usermodehelper_table,
2157 #ifdef CONFIG_FW_LOADER_USER_HELPER
2159 .procname = "firmware_config",
2161 .child = firmware_config_table,
2165 .procname = "overflowuid",
2166 .data = &overflowuid,
2167 .maxlen = sizeof(int),
2169 .proc_handler = proc_dointvec_minmax,
2170 .extra1 = SYSCTL_ZERO,
2171 .extra2 = (void *)&maxolduid,
2174 .procname = "overflowgid",
2175 .data = &overflowgid,
2176 .maxlen = sizeof(int),
2178 .proc_handler = proc_dointvec_minmax,
2179 .extra1 = SYSCTL_ZERO,
2180 .extra2 = (void *)&maxolduid,
2184 .procname = "userprocess_debug",
2185 .data = &show_unhandled_signals,
2186 .maxlen = sizeof(int),
2188 .proc_handler = proc_dointvec,
2193 .procname = "oops_all_cpu_backtrace",
2194 .data = &sysctl_oops_all_cpu_backtrace,
2195 .maxlen = sizeof(int),
2197 .proc_handler = proc_dointvec_minmax,
2198 .extra1 = SYSCTL_ZERO,
2199 .extra2 = SYSCTL_ONE,
2201 #endif /* CONFIG_SMP */
2203 .procname = "pid_max",
2205 .maxlen = sizeof (int),
2207 .proc_handler = proc_dointvec_minmax,
2208 .extra1 = &pid_max_min,
2209 .extra2 = &pid_max_max,
2212 .procname = "panic_on_oops",
2213 .data = &panic_on_oops,
2214 .maxlen = sizeof(int),
2216 .proc_handler = proc_dointvec,
2219 .procname = "panic_print",
2220 .data = &panic_print,
2221 .maxlen = sizeof(unsigned long),
2223 .proc_handler = proc_doulongvec_minmax,
2225 #if defined CONFIG_PRINTK
2227 .procname = "printk",
2228 .data = &console_loglevel,
2229 .maxlen = 4*sizeof(int),
2231 .proc_handler = proc_dointvec,
2234 .procname = "printk_ratelimit",
2235 .data = &printk_ratelimit_state.interval,
2236 .maxlen = sizeof(int),
2238 .proc_handler = proc_dointvec_jiffies,
2241 .procname = "printk_ratelimit_burst",
2242 .data = &printk_ratelimit_state.burst,
2243 .maxlen = sizeof(int),
2245 .proc_handler = proc_dointvec,
2248 .procname = "printk_delay",
2249 .data = &printk_delay_msec,
2250 .maxlen = sizeof(int),
2252 .proc_handler = proc_dointvec_minmax,
2253 .extra1 = SYSCTL_ZERO,
2254 .extra2 = (void *)&ten_thousand,
2257 .procname = "printk_devkmsg",
2258 .data = devkmsg_log_str,
2259 .maxlen = DEVKMSG_STR_MAX_SIZE,
2261 .proc_handler = devkmsg_sysctl_set_loglvl,
2264 .procname = "dmesg_restrict",
2265 .data = &dmesg_restrict,
2266 .maxlen = sizeof(int),
2268 .proc_handler = proc_dointvec_minmax_sysadmin,
2269 .extra1 = SYSCTL_ZERO,
2270 .extra2 = SYSCTL_ONE,
2273 .procname = "kptr_restrict",
2274 .data = &kptr_restrict,
2275 .maxlen = sizeof(int),
2277 .proc_handler = proc_dointvec_minmax_sysadmin,
2278 .extra1 = SYSCTL_ZERO,
2279 .extra2 = SYSCTL_TWO,
2283 .procname = "ngroups_max",
2284 .data = (void *)&ngroups_max,
2285 .maxlen = sizeof (int),
2287 .proc_handler = proc_dointvec,
2290 .procname = "cap_last_cap",
2291 .data = (void *)&cap_last_cap,
2292 .maxlen = sizeof(int),
2294 .proc_handler = proc_dointvec,
2296 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2298 .procname = "unknown_nmi_panic",
2299 .data = &unknown_nmi_panic,
2300 .maxlen = sizeof (int),
2302 .proc_handler = proc_dointvec,
2306 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2307 defined(CONFIG_DEBUG_STACKOVERFLOW)
2309 .procname = "panic_on_stackoverflow",
2310 .data = &sysctl_panic_on_stackoverflow,
2311 .maxlen = sizeof(int),
2313 .proc_handler = proc_dointvec,
2316 #if defined(CONFIG_X86)
2318 .procname = "panic_on_unrecovered_nmi",
2319 .data = &panic_on_unrecovered_nmi,
2320 .maxlen = sizeof(int),
2322 .proc_handler = proc_dointvec,
2325 .procname = "panic_on_io_nmi",
2326 .data = &panic_on_io_nmi,
2327 .maxlen = sizeof(int),
2329 .proc_handler = proc_dointvec,
2332 .procname = "bootloader_type",
2333 .data = &bootloader_type,
2334 .maxlen = sizeof (int),
2336 .proc_handler = proc_dointvec,
2339 .procname = "bootloader_version",
2340 .data = &bootloader_version,
2341 .maxlen = sizeof (int),
2343 .proc_handler = proc_dointvec,
2346 .procname = "io_delay_type",
2347 .data = &io_delay_type,
2348 .maxlen = sizeof(int),
2350 .proc_handler = proc_dointvec,
2353 #if defined(CONFIG_MMU)
2355 .procname = "randomize_va_space",
2356 .data = &randomize_va_space,
2357 .maxlen = sizeof(int),
2359 .proc_handler = proc_dointvec,
2362 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2364 .procname = "spin_retry",
2365 .data = &spin_retry,
2366 .maxlen = sizeof (int),
2368 .proc_handler = proc_dointvec,
2371 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2373 .procname = "acpi_video_flags",
2374 .data = &acpi_realmode_flags,
2375 .maxlen = sizeof (unsigned long),
2377 .proc_handler = proc_doulongvec_minmax,
2380 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2382 .procname = "ignore-unaligned-usertrap",
2383 .data = &no_unaligned_warning,
2384 .maxlen = sizeof (int),
2386 .proc_handler = proc_dointvec,
2391 .procname = "unaligned-dump-stack",
2392 .data = &unaligned_dump_stack,
2393 .maxlen = sizeof (int),
2395 .proc_handler = proc_dointvec,
2398 #ifdef CONFIG_RT_MUTEXES
2400 .procname = "max_lock_depth",
2401 .data = &max_lock_depth,
2402 .maxlen = sizeof(int),
2404 .proc_handler = proc_dointvec,
2408 .procname = "poweroff_cmd",
2409 .data = &poweroff_cmd,
2410 .maxlen = POWEROFF_CMD_PATH_LEN,
2412 .proc_handler = proc_dostring,
2418 .child = key_sysctls,
2421 #ifdef CONFIG_PERF_EVENTS
2423 * User-space scripts rely on the existence of this file
2424 * as a feature check for perf_events being enabled.
2426 * So it's an ABI, do not remove!
2429 .procname = "perf_event_paranoid",
2430 .data = &sysctl_perf_event_paranoid,
2431 .maxlen = sizeof(sysctl_perf_event_paranoid),
2433 .proc_handler = proc_dointvec,
2436 .procname = "perf_event_mlock_kb",
2437 .data = &sysctl_perf_event_mlock,
2438 .maxlen = sizeof(sysctl_perf_event_mlock),
2440 .proc_handler = proc_dointvec,
2443 .procname = "perf_event_max_sample_rate",
2444 .data = &sysctl_perf_event_sample_rate,
2445 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2447 .proc_handler = perf_proc_update_handler,
2448 .extra1 = SYSCTL_ONE,
2451 .procname = "perf_cpu_time_max_percent",
2452 .data = &sysctl_perf_cpu_time_max_percent,
2453 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2455 .proc_handler = perf_cpu_time_max_percent_handler,
2456 .extra1 = SYSCTL_ZERO,
2457 .extra2 = SYSCTL_ONE_HUNDRED,
2460 .procname = "perf_event_max_stack",
2461 .data = &sysctl_perf_event_max_stack,
2462 .maxlen = sizeof(sysctl_perf_event_max_stack),
2464 .proc_handler = perf_event_max_stack_handler,
2465 .extra1 = SYSCTL_ZERO,
2466 .extra2 = (void *)&six_hundred_forty_kb,
2469 .procname = "perf_event_max_contexts_per_stack",
2470 .data = &sysctl_perf_event_max_contexts_per_stack,
2471 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2473 .proc_handler = perf_event_max_stack_handler,
2474 .extra1 = SYSCTL_ZERO,
2475 .extra2 = SYSCTL_ONE_THOUSAND,
2479 .procname = "panic_on_warn",
2480 .data = &panic_on_warn,
2481 .maxlen = sizeof(int),
2483 .proc_handler = proc_dointvec_minmax,
2484 .extra1 = SYSCTL_ZERO,
2485 .extra2 = SYSCTL_ONE,
2487 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2489 .procname = "timer_migration",
2490 .data = &sysctl_timer_migration,
2491 .maxlen = sizeof(unsigned int),
2493 .proc_handler = timer_migration_handler,
2494 .extra1 = SYSCTL_ZERO,
2495 .extra2 = SYSCTL_ONE,
2498 #ifdef CONFIG_BPF_SYSCALL
2500 .procname = "unprivileged_bpf_disabled",
2501 .data = &sysctl_unprivileged_bpf_disabled,
2502 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2504 .proc_handler = bpf_unpriv_handler,
2505 .extra1 = SYSCTL_ZERO,
2506 .extra2 = SYSCTL_TWO,
2509 .procname = "bpf_stats_enabled",
2510 .data = &bpf_stats_enabled_key.key,
2511 .maxlen = sizeof(bpf_stats_enabled_key),
2513 .proc_handler = bpf_stats_handler,
2516 #if defined(CONFIG_TREE_RCU)
2518 .procname = "panic_on_rcu_stall",
2519 .data = &sysctl_panic_on_rcu_stall,
2520 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2522 .proc_handler = proc_dointvec_minmax,
2523 .extra1 = SYSCTL_ZERO,
2524 .extra2 = SYSCTL_ONE,
2527 #if defined(CONFIG_TREE_RCU)
2529 .procname = "max_rcu_stall_to_panic",
2530 .data = &sysctl_max_rcu_stall_to_panic,
2531 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2533 .proc_handler = proc_dointvec_minmax,
2534 .extra1 = SYSCTL_ONE,
2535 .extra2 = SYSCTL_INT_MAX,
2538 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2540 .procname = "stack_erasing",
2542 .maxlen = sizeof(int),
2544 .proc_handler = stack_erasing_sysctl,
2545 .extra1 = SYSCTL_ZERO,
2546 .extra2 = SYSCTL_ONE,
2552 static struct ctl_table vm_table[] = {
2554 .procname = "overcommit_memory",
2555 .data = &sysctl_overcommit_memory,
2556 .maxlen = sizeof(sysctl_overcommit_memory),
2558 .proc_handler = overcommit_policy_handler,
2559 .extra1 = SYSCTL_ZERO,
2560 .extra2 = SYSCTL_TWO,
2563 .procname = "panic_on_oom",
2564 .data = &sysctl_panic_on_oom,
2565 .maxlen = sizeof(sysctl_panic_on_oom),
2567 .proc_handler = proc_dointvec_minmax,
2568 .extra1 = SYSCTL_ZERO,
2569 .extra2 = SYSCTL_TWO,
2572 .procname = "oom_kill_allocating_task",
2573 .data = &sysctl_oom_kill_allocating_task,
2574 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2576 .proc_handler = proc_dointvec,
2579 .procname = "oom_dump_tasks",
2580 .data = &sysctl_oom_dump_tasks,
2581 .maxlen = sizeof(sysctl_oom_dump_tasks),
2583 .proc_handler = proc_dointvec,
2586 .procname = "overcommit_ratio",
2587 .data = &sysctl_overcommit_ratio,
2588 .maxlen = sizeof(sysctl_overcommit_ratio),
2590 .proc_handler = overcommit_ratio_handler,
2593 .procname = "overcommit_kbytes",
2594 .data = &sysctl_overcommit_kbytes,
2595 .maxlen = sizeof(sysctl_overcommit_kbytes),
2597 .proc_handler = overcommit_kbytes_handler,
2600 .procname = "page-cluster",
2601 .data = &page_cluster,
2602 .maxlen = sizeof(int),
2604 .proc_handler = proc_dointvec_minmax,
2605 .extra1 = SYSCTL_ZERO,
2608 .procname = "dirty_background_ratio",
2609 .data = &dirty_background_ratio,
2610 .maxlen = sizeof(dirty_background_ratio),
2612 .proc_handler = dirty_background_ratio_handler,
2613 .extra1 = SYSCTL_ZERO,
2614 .extra2 = SYSCTL_ONE_HUNDRED,
2617 .procname = "dirty_background_bytes",
2618 .data = &dirty_background_bytes,
2619 .maxlen = sizeof(dirty_background_bytes),
2621 .proc_handler = dirty_background_bytes_handler,
2622 .extra1 = (void *)&one_ul,
2625 .procname = "dirty_ratio",
2626 .data = &vm_dirty_ratio,
2627 .maxlen = sizeof(vm_dirty_ratio),
2629 .proc_handler = dirty_ratio_handler,
2630 .extra1 = SYSCTL_ZERO,
2631 .extra2 = SYSCTL_ONE_HUNDRED,
2634 .procname = "dirty_bytes",
2635 .data = &vm_dirty_bytes,
2636 .maxlen = sizeof(vm_dirty_bytes),
2638 .proc_handler = dirty_bytes_handler,
2639 .extra1 = (void *)&dirty_bytes_min,
2642 .procname = "dirty_writeback_centisecs",
2643 .data = &dirty_writeback_interval,
2644 .maxlen = sizeof(dirty_writeback_interval),
2646 .proc_handler = dirty_writeback_centisecs_handler,
2649 .procname = "dirty_expire_centisecs",
2650 .data = &dirty_expire_interval,
2651 .maxlen = sizeof(dirty_expire_interval),
2653 .proc_handler = proc_dointvec_minmax,
2654 .extra1 = SYSCTL_ZERO,
2657 .procname = "dirtytime_expire_seconds",
2658 .data = &dirtytime_expire_interval,
2659 .maxlen = sizeof(dirtytime_expire_interval),
2661 .proc_handler = dirtytime_interval_handler,
2662 .extra1 = SYSCTL_ZERO,
2665 .procname = "swappiness",
2666 .data = &vm_swappiness,
2667 .maxlen = sizeof(vm_swappiness),
2669 .proc_handler = proc_dointvec_minmax,
2670 .extra1 = SYSCTL_ZERO,
2671 .extra2 = SYSCTL_TWO_HUNDRED,
2673 #ifdef CONFIG_HUGETLB_PAGE
2675 .procname = "nr_hugepages",
2677 .maxlen = sizeof(unsigned long),
2679 .proc_handler = hugetlb_sysctl_handler,
2683 .procname = "nr_hugepages_mempolicy",
2685 .maxlen = sizeof(unsigned long),
2687 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2690 .procname = "numa_stat",
2691 .data = &sysctl_vm_numa_stat,
2692 .maxlen = sizeof(int),
2694 .proc_handler = sysctl_vm_numa_stat_handler,
2695 .extra1 = SYSCTL_ZERO,
2696 .extra2 = SYSCTL_ONE,
2700 .procname = "hugetlb_shm_group",
2701 .data = &sysctl_hugetlb_shm_group,
2702 .maxlen = sizeof(gid_t),
2704 .proc_handler = proc_dointvec,
2707 .procname = "nr_overcommit_hugepages",
2709 .maxlen = sizeof(unsigned long),
2711 .proc_handler = hugetlb_overcommit_handler,
2715 .procname = "lowmem_reserve_ratio",
2716 .data = &sysctl_lowmem_reserve_ratio,
2717 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2719 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2722 .procname = "drop_caches",
2723 .data = &sysctl_drop_caches,
2724 .maxlen = sizeof(int),
2726 .proc_handler = drop_caches_sysctl_handler,
2727 .extra1 = SYSCTL_ONE,
2728 .extra2 = SYSCTL_FOUR,
2730 #ifdef CONFIG_COMPACTION
2732 .procname = "compact_memory",
2734 .maxlen = sizeof(int),
2736 .proc_handler = sysctl_compaction_handler,
2739 .procname = "compaction_proactiveness",
2740 .data = &sysctl_compaction_proactiveness,
2741 .maxlen = sizeof(sysctl_compaction_proactiveness),
2743 .proc_handler = compaction_proactiveness_sysctl_handler,
2744 .extra1 = SYSCTL_ZERO,
2745 .extra2 = SYSCTL_ONE_HUNDRED,
2748 .procname = "extfrag_threshold",
2749 .data = &sysctl_extfrag_threshold,
2750 .maxlen = sizeof(int),
2752 .proc_handler = proc_dointvec_minmax,
2753 .extra1 = SYSCTL_ZERO,
2754 .extra2 = (void *)&max_extfrag_threshold,
2757 .procname = "compact_unevictable_allowed",
2758 .data = &sysctl_compact_unevictable_allowed,
2759 .maxlen = sizeof(int),
2761 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2762 .extra1 = SYSCTL_ZERO,
2763 .extra2 = SYSCTL_ONE,
2766 #endif /* CONFIG_COMPACTION */
2768 .procname = "min_free_kbytes",
2769 .data = &min_free_kbytes,
2770 .maxlen = sizeof(min_free_kbytes),
2772 .proc_handler = min_free_kbytes_sysctl_handler,
2773 .extra1 = SYSCTL_ZERO,
2776 .procname = "watermark_boost_factor",
2777 .data = &watermark_boost_factor,
2778 .maxlen = sizeof(watermark_boost_factor),
2780 .proc_handler = proc_dointvec_minmax,
2781 .extra1 = SYSCTL_ZERO,
2784 .procname = "watermark_scale_factor",
2785 .data = &watermark_scale_factor,
2786 .maxlen = sizeof(watermark_scale_factor),
2788 .proc_handler = watermark_scale_factor_sysctl_handler,
2789 .extra1 = SYSCTL_ONE,
2790 .extra2 = SYSCTL_THREE_THOUSAND,
2793 .procname = "percpu_pagelist_high_fraction",
2794 .data = &percpu_pagelist_high_fraction,
2795 .maxlen = sizeof(percpu_pagelist_high_fraction),
2797 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2798 .extra1 = SYSCTL_ZERO,
2801 .procname = "page_lock_unfairness",
2802 .data = &sysctl_page_lock_unfairness,
2803 .maxlen = sizeof(sysctl_page_lock_unfairness),
2805 .proc_handler = proc_dointvec_minmax,
2806 .extra1 = SYSCTL_ZERO,
2810 .procname = "max_map_count",
2811 .data = &sysctl_max_map_count,
2812 .maxlen = sizeof(sysctl_max_map_count),
2814 .proc_handler = proc_dointvec_minmax,
2815 .extra1 = SYSCTL_ZERO,
2819 .procname = "nr_trim_pages",
2820 .data = &sysctl_nr_trim_pages,
2821 .maxlen = sizeof(sysctl_nr_trim_pages),
2823 .proc_handler = proc_dointvec_minmax,
2824 .extra1 = SYSCTL_ZERO,
2828 .procname = "laptop_mode",
2829 .data = &laptop_mode,
2830 .maxlen = sizeof(laptop_mode),
2832 .proc_handler = proc_dointvec_jiffies,
2835 .procname = "vfs_cache_pressure",
2836 .data = &sysctl_vfs_cache_pressure,
2837 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2839 .proc_handler = proc_dointvec_minmax,
2840 .extra1 = SYSCTL_ZERO,
2842 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2843 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2845 .procname = "legacy_va_layout",
2846 .data = &sysctl_legacy_va_layout,
2847 .maxlen = sizeof(sysctl_legacy_va_layout),
2849 .proc_handler = proc_dointvec_minmax,
2850 .extra1 = SYSCTL_ZERO,
2855 .procname = "zone_reclaim_mode",
2856 .data = &node_reclaim_mode,
2857 .maxlen = sizeof(node_reclaim_mode),
2859 .proc_handler = proc_dointvec_minmax,
2860 .extra1 = SYSCTL_ZERO,
2863 .procname = "min_unmapped_ratio",
2864 .data = &sysctl_min_unmapped_ratio,
2865 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2867 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2868 .extra1 = SYSCTL_ZERO,
2869 .extra2 = SYSCTL_ONE_HUNDRED,
2872 .procname = "min_slab_ratio",
2873 .data = &sysctl_min_slab_ratio,
2874 .maxlen = sizeof(sysctl_min_slab_ratio),
2876 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2877 .extra1 = SYSCTL_ZERO,
2878 .extra2 = SYSCTL_ONE_HUNDRED,
2883 .procname = "stat_interval",
2884 .data = &sysctl_stat_interval,
2885 .maxlen = sizeof(sysctl_stat_interval),
2887 .proc_handler = proc_dointvec_jiffies,
2890 .procname = "stat_refresh",
2894 .proc_handler = vmstat_refresh,
2899 .procname = "mmap_min_addr",
2900 .data = &dac_mmap_min_addr,
2901 .maxlen = sizeof(unsigned long),
2903 .proc_handler = mmap_min_addr_handler,
2908 .procname = "numa_zonelist_order",
2909 .data = &numa_zonelist_order,
2910 .maxlen = NUMA_ZONELIST_ORDER_LEN,
2912 .proc_handler = numa_zonelist_order_handler,
2915 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
2916 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
2918 .procname = "vdso_enabled",
2919 #ifdef CONFIG_X86_32
2920 .data = &vdso32_enabled,
2921 .maxlen = sizeof(vdso32_enabled),
2923 .data = &vdso_enabled,
2924 .maxlen = sizeof(vdso_enabled),
2927 .proc_handler = proc_dointvec,
2928 .extra1 = SYSCTL_ZERO,
2931 #ifdef CONFIG_HIGHMEM
2933 .procname = "highmem_is_dirtyable",
2934 .data = &vm_highmem_is_dirtyable,
2935 .maxlen = sizeof(vm_highmem_is_dirtyable),
2937 .proc_handler = proc_dointvec_minmax,
2938 .extra1 = SYSCTL_ZERO,
2939 .extra2 = SYSCTL_ONE,
2942 #ifdef CONFIG_MEMORY_FAILURE
2944 .procname = "memory_failure_early_kill",
2945 .data = &sysctl_memory_failure_early_kill,
2946 .maxlen = sizeof(sysctl_memory_failure_early_kill),
2948 .proc_handler = proc_dointvec_minmax,
2949 .extra1 = SYSCTL_ZERO,
2950 .extra2 = SYSCTL_ONE,
2953 .procname = "memory_failure_recovery",
2954 .data = &sysctl_memory_failure_recovery,
2955 .maxlen = sizeof(sysctl_memory_failure_recovery),
2957 .proc_handler = proc_dointvec_minmax,
2958 .extra1 = SYSCTL_ZERO,
2959 .extra2 = SYSCTL_ONE,
2963 .procname = "user_reserve_kbytes",
2964 .data = &sysctl_user_reserve_kbytes,
2965 .maxlen = sizeof(sysctl_user_reserve_kbytes),
2967 .proc_handler = proc_doulongvec_minmax,
2970 .procname = "admin_reserve_kbytes",
2971 .data = &sysctl_admin_reserve_kbytes,
2972 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
2974 .proc_handler = proc_doulongvec_minmax,
2976 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
2978 .procname = "mmap_rnd_bits",
2979 .data = &mmap_rnd_bits,
2980 .maxlen = sizeof(mmap_rnd_bits),
2982 .proc_handler = proc_dointvec_minmax,
2983 .extra1 = (void *)&mmap_rnd_bits_min,
2984 .extra2 = (void *)&mmap_rnd_bits_max,
2987 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
2989 .procname = "mmap_rnd_compat_bits",
2990 .data = &mmap_rnd_compat_bits,
2991 .maxlen = sizeof(mmap_rnd_compat_bits),
2993 .proc_handler = proc_dointvec_minmax,
2994 .extra1 = (void *)&mmap_rnd_compat_bits_min,
2995 .extra2 = (void *)&mmap_rnd_compat_bits_max,
2998 #ifdef CONFIG_USERFAULTFD
3000 .procname = "unprivileged_userfaultfd",
3001 .data = &sysctl_unprivileged_userfaultfd,
3002 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3004 .proc_handler = proc_dointvec_minmax,
3005 .extra1 = SYSCTL_ZERO,
3006 .extra2 = SYSCTL_ONE,
3012 static struct ctl_table fs_table[] = {
3014 .procname = "inode-nr",
3015 .data = &inodes_stat,
3016 .maxlen = 2*sizeof(long),
3018 .proc_handler = proc_nr_inodes,
3021 .procname = "inode-state",
3022 .data = &inodes_stat,
3023 .maxlen = 7*sizeof(long),
3025 .proc_handler = proc_nr_inodes,
3028 .procname = "file-nr",
3029 .data = &files_stat,
3030 .maxlen = sizeof(files_stat),
3032 .proc_handler = proc_nr_files,
3035 .procname = "file-max",
3036 .data = &files_stat.max_files,
3037 .maxlen = sizeof(files_stat.max_files),
3039 .proc_handler = proc_doulongvec_minmax,
3040 .extra1 = (void *)&zero_ul,
3041 .extra2 = (void *)&long_max,
3044 .procname = "nr_open",
3045 .data = &sysctl_nr_open,
3046 .maxlen = sizeof(unsigned int),
3048 .proc_handler = proc_dointvec_minmax,
3049 .extra1 = &sysctl_nr_open_min,
3050 .extra2 = &sysctl_nr_open_max,
3053 .procname = "dentry-state",
3054 .data = &dentry_stat,
3055 .maxlen = 6*sizeof(long),
3057 .proc_handler = proc_nr_dentry,
3060 .procname = "overflowuid",
3061 .data = &fs_overflowuid,
3062 .maxlen = sizeof(int),
3064 .proc_handler = proc_dointvec_minmax,
3065 .extra1 = SYSCTL_ZERO,
3066 .extra2 = (void *)&maxolduid,
3069 .procname = "overflowgid",
3070 .data = &fs_overflowgid,
3071 .maxlen = sizeof(int),
3073 .proc_handler = proc_dointvec_minmax,
3074 .extra1 = SYSCTL_ZERO,
3075 .extra2 = (void *)&maxolduid,
3077 #ifdef CONFIG_FILE_LOCKING
3079 .procname = "leases-enable",
3080 .data = &leases_enable,
3081 .maxlen = sizeof(int),
3083 .proc_handler = proc_dointvec,
3087 #ifdef CONFIG_FILE_LOCKING
3089 .procname = "lease-break-time",
3090 .data = &lease_break_time,
3091 .maxlen = sizeof(int),
3093 .proc_handler = proc_dointvec,
3098 .procname = "epoll",
3100 .child = epoll_table,
3105 .procname = "protected_symlinks",
3106 .data = &sysctl_protected_symlinks,
3107 .maxlen = sizeof(int),
3109 .proc_handler = proc_dointvec_minmax,
3110 .extra1 = SYSCTL_ZERO,
3111 .extra2 = SYSCTL_ONE,
3114 .procname = "protected_hardlinks",
3115 .data = &sysctl_protected_hardlinks,
3116 .maxlen = sizeof(int),
3118 .proc_handler = proc_dointvec_minmax,
3119 .extra1 = SYSCTL_ZERO,
3120 .extra2 = SYSCTL_ONE,
3123 .procname = "protected_fifos",
3124 .data = &sysctl_protected_fifos,
3125 .maxlen = sizeof(int),
3127 .proc_handler = proc_dointvec_minmax,
3128 .extra1 = SYSCTL_ZERO,
3129 .extra2 = SYSCTL_TWO,
3132 .procname = "protected_regular",
3133 .data = &sysctl_protected_regular,
3134 .maxlen = sizeof(int),
3136 .proc_handler = proc_dointvec_minmax,
3137 .extra1 = SYSCTL_ZERO,
3138 .extra2 = SYSCTL_TWO,
3141 .procname = "suid_dumpable",
3142 .data = &suid_dumpable,
3143 .maxlen = sizeof(int),
3145 .proc_handler = proc_dointvec_minmax_coredump,
3146 .extra1 = SYSCTL_ZERO,
3147 .extra2 = SYSCTL_TWO,
3149 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3151 .procname = "binfmt_misc",
3153 .child = sysctl_mount_point,
3157 .procname = "pipe-max-size",
3158 .data = &pipe_max_size,
3159 .maxlen = sizeof(pipe_max_size),
3161 .proc_handler = proc_dopipe_max_size,
3164 .procname = "pipe-user-pages-hard",
3165 .data = &pipe_user_pages_hard,
3166 .maxlen = sizeof(pipe_user_pages_hard),
3168 .proc_handler = proc_doulongvec_minmax,
3171 .procname = "pipe-user-pages-soft",
3172 .data = &pipe_user_pages_soft,
3173 .maxlen = sizeof(pipe_user_pages_soft),
3175 .proc_handler = proc_doulongvec_minmax,
3178 .procname = "mount-max",
3179 .data = &sysctl_mount_max,
3180 .maxlen = sizeof(unsigned int),
3182 .proc_handler = proc_dointvec_minmax,
3183 .extra1 = SYSCTL_ONE,
3188 static struct ctl_table debug_table[] = {
3189 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3191 .procname = "exception-trace",
3192 .data = &show_unhandled_signals,
3193 .maxlen = sizeof(int),
3195 .proc_handler = proc_dointvec
3198 #if defined(CONFIG_OPTPROBES)
3200 .procname = "kprobes-optimization",
3201 .data = &sysctl_kprobes_optimization,
3202 .maxlen = sizeof(int),
3204 .proc_handler = proc_kprobes_optimization_handler,
3205 .extra1 = SYSCTL_ZERO,
3206 .extra2 = SYSCTL_ONE,
3212 static struct ctl_table dev_table[] = {
3216 static struct ctl_table sysctl_base_table[] = {
3218 .procname = "kernel",
3220 .child = kern_table,
3233 .procname = "debug",
3235 .child = debug_table,
3245 int __init sysctl_init(void)
3247 struct ctl_table_header *hdr;
3249 hdr = register_sysctl_table(sysctl_base_table);
3250 kmemleak_not_leak(hdr);
3253 #endif /* CONFIG_SYSCTL */
3255 * No sense putting this after each symbol definition, twice,
3256 * exception granted :-)
3258 EXPORT_SYMBOL(proc_dobool);
3259 EXPORT_SYMBOL(proc_dointvec);
3260 EXPORT_SYMBOL(proc_douintvec);
3261 EXPORT_SYMBOL(proc_dointvec_jiffies);
3262 EXPORT_SYMBOL(proc_dointvec_minmax);
3263 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3264 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3265 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3266 EXPORT_SYMBOL(proc_dostring);
3267 EXPORT_SYMBOL(proc_doulongvec_minmax);
3268 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3269 EXPORT_SYMBOL(proc_do_large_bitmap);