1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/panic.h>
31 #include <linux/printk.h>
32 #include <linux/proc_fs.h>
33 #include <linux/security.h>
34 #include <linux/ctype.h>
35 #include <linux/kmemleak.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
39 #include <linux/kobject.h>
40 #include <linux/net.h>
41 #include <linux/sysrq.h>
42 #include <linux/highuid.h>
43 #include <linux/writeback.h>
44 #include <linux/ratelimit.h>
45 #include <linux/compaction.h>
46 #include <linux/hugetlb.h>
47 #include <linux/initrd.h>
48 #include <linux/key.h>
49 #include <linux/times.h>
50 #include <linux/limits.h>
51 #include <linux/dcache.h>
52 #include <linux/dnotify.h>
53 #include <linux/syscalls.h>
54 #include <linux/vmstat.h>
55 #include <linux/nfs_fs.h>
56 #include <linux/acpi.h>
57 #include <linux/reboot.h>
58 #include <linux/ftrace.h>
59 #include <linux/perf_event.h>
60 #include <linux/kprobes.h>
61 #include <linux/pipe_fs_i.h>
62 #include <linux/oom.h>
63 #include <linux/kmod.h>
64 #include <linux/capability.h>
65 #include <linux/binfmts.h>
66 #include <linux/sched/sysctl.h>
67 #include <linux/sched/coredump.h>
68 #include <linux/kexec.h>
69 #include <linux/bpf.h>
70 #include <linux/mount.h>
71 #include <linux/userfaultfd_k.h>
72 #include <linux/coredump.h>
73 #include <linux/latencytop.h>
74 #include <linux/pid.h>
75 #include <linux/delayacct.h>
77 #include "../lib/kstrtox.h"
79 #include <linux/uaccess.h>
80 #include <asm/processor.h>
84 #include <asm/stacktrace.h>
88 #include <asm/setup.h>
90 #ifdef CONFIG_BSD_PROCESS_ACCT
91 #include <linux/acct.h>
93 #ifdef CONFIG_RT_MUTEXES
94 #include <linux/rtmutex.h>
96 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
97 #include <linux/lockdep.h>
99 #ifdef CONFIG_CHR_DEV_SG
102 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
103 #include <linux/stackleak.h>
105 #ifdef CONFIG_LOCKUP_DETECTOR
106 #include <linux/nmi.h>
109 #if defined(CONFIG_SYSCTL)
111 /* Constants used for minimum and maximum */
112 #ifdef CONFIG_LOCKUP_DETECTOR
113 static int sixty = 60;
116 static unsigned long zero_ul;
117 static unsigned long one_ul = 1;
118 static unsigned long long_max = LONG_MAX;
120 static int ten_thousand = 10000;
122 #ifdef CONFIG_PERF_EVENTS
123 static int six_hundred_forty_kb = 640 * 1024;
126 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
127 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
129 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
130 static int maxolduid = 65535;
131 static int minolduid;
133 static int ngroups_max = NGROUPS_MAX;
134 static const int cap_last_cap = CAP_LAST_CAP;
137 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
138 * and hung_task_check_interval_secs
140 #ifdef CONFIG_DETECT_HUNG_TASK
141 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
144 #ifdef CONFIG_INOTIFY_USER
145 #include <linux/inotify.h>
147 #ifdef CONFIG_FANOTIFY
148 #include <linux/fanotify.h>
151 #ifdef CONFIG_PROC_SYSCTL
154 * enum sysctl_writes_mode - supported sysctl write modes
156 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
157 * to be written, and multiple writes on the same sysctl file descriptor
158 * will rewrite the sysctl value, regardless of file position. No warning
159 * is issued when the initial position is not 0.
160 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
162 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
163 * file position 0 and the value must be fully contained in the buffer
164 * sent to the write syscall. If dealing with strings respect the file
165 * position, but restrict this to the max length of the buffer, anything
166 * passed the max length will be ignored. Multiple writes will append
169 * These write modes control how current file position affects the behavior of
170 * updating sysctl values through the proc interface on each write.
172 enum sysctl_writes_mode {
173 SYSCTL_WRITES_LEGACY = -1,
174 SYSCTL_WRITES_WARN = 0,
175 SYSCTL_WRITES_STRICT = 1,
178 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
179 #endif /* CONFIG_PROC_SYSCTL */
181 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
182 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
183 int sysctl_legacy_va_layout;
186 #ifdef CONFIG_COMPACTION
187 static int min_extfrag_threshold;
188 static int max_extfrag_threshold = 1000;
191 #endif /* CONFIG_SYSCTL */
193 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
194 static int bpf_stats_handler(struct ctl_table *table, int write,
195 void *buffer, size_t *lenp, loff_t *ppos)
197 struct static_key *key = (struct static_key *)table->data;
198 static int saved_val;
200 struct ctl_table tmp = {
202 .maxlen = sizeof(val),
204 .extra1 = SYSCTL_ZERO,
205 .extra2 = SYSCTL_ONE,
208 if (write && !capable(CAP_SYS_ADMIN))
211 mutex_lock(&bpf_stats_enabled_mutex);
213 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
214 if (write && !ret && val != saved_val) {
216 static_key_slow_inc(key);
218 static_key_slow_dec(key);
221 mutex_unlock(&bpf_stats_enabled_mutex);
225 void __weak unpriv_ebpf_notify(int new_state)
229 static int bpf_unpriv_handler(struct ctl_table *table, int write,
230 void *buffer, size_t *lenp, loff_t *ppos)
232 int ret, unpriv_enable = *(int *)table->data;
233 bool locked_state = unpriv_enable == 1;
234 struct ctl_table tmp = *table;
236 if (write && !capable(CAP_SYS_ADMIN))
239 tmp.data = &unpriv_enable;
240 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
242 if (locked_state && unpriv_enable != 1)
244 *(int *)table->data = unpriv_enable;
247 unpriv_ebpf_notify(unpriv_enable);
251 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
257 #ifdef CONFIG_PROC_SYSCTL
259 static int _proc_do_string(char *data, int maxlen, int write,
260 char *buffer, size_t *lenp, loff_t *ppos)
265 if (!data || !maxlen || !*lenp) {
271 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
272 /* Only continue writes not past the end of buffer. */
274 if (len > maxlen - 1)
281 /* Start writing from beginning of buffer. */
287 while ((p - buffer) < *lenp && len < maxlen - 1) {
289 if (c == 0 || c == '\n')
310 memcpy(buffer, data, len);
321 static void warn_sysctl_write(struct ctl_table *table)
323 pr_warn_once("%s wrote to %s when file position was not 0!\n"
324 "This will not be supported in the future. To silence this\n"
325 "warning, set kernel.sysctl_writes_strict = -1\n",
326 current->comm, table->procname);
330 * proc_first_pos_non_zero_ignore - check if first position is allowed
331 * @ppos: file position
332 * @table: the sysctl table
334 * Returns true if the first position is non-zero and the sysctl_writes_strict
335 * mode indicates this is not allowed for numeric input types. String proc
336 * handlers can ignore the return value.
338 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
339 struct ctl_table *table)
344 switch (sysctl_writes_strict) {
345 case SYSCTL_WRITES_STRICT:
347 case SYSCTL_WRITES_WARN:
348 warn_sysctl_write(table);
356 * proc_dostring - read a string sysctl
357 * @table: the sysctl table
358 * @write: %TRUE if this is a write to the sysctl file
359 * @buffer: the user buffer
360 * @lenp: the size of the user buffer
361 * @ppos: file position
363 * Reads/writes a string from/to the user buffer. If the kernel
364 * buffer provided is not large enough to hold the string, the
365 * string is truncated. The copied string is %NULL-terminated.
366 * If the string is being read by the user process, it is copied
367 * and a newline '\n' is added. It is truncated if the buffer is
370 * Returns 0 on success.
372 int proc_dostring(struct ctl_table *table, int write,
373 void *buffer, size_t *lenp, loff_t *ppos)
376 proc_first_pos_non_zero_ignore(ppos, table);
378 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
382 static size_t proc_skip_spaces(char **buf)
385 char *tmp = skip_spaces(*buf);
391 static void proc_skip_char(char **buf, size_t *size, const char v)
402 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
405 * @cp: kernel buffer containing the string to parse
406 * @endp: pointer to store the trailing characters
407 * @base: the base to use
408 * @res: where the parsed integer will be stored
410 * In case of success 0 is returned and @res will contain the parsed integer,
411 * @endp will hold any trailing characters.
412 * This function will fail the parse on overflow. If there wasn't an overflow
413 * the function will defer the decision what characters count as invalid to the
416 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
419 unsigned long long result;
422 cp = _parse_integer_fixup_radix(cp, &base);
423 rv = _parse_integer(cp, base, &result);
424 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
432 *res = (unsigned long)result;
438 * proc_get_long - reads an ASCII formatted integer from a user buffer
440 * @buf: a kernel buffer
441 * @size: size of the kernel buffer
442 * @val: this is where the number will be stored
443 * @neg: set to %TRUE if number is negative
444 * @perm_tr: a vector which contains the allowed trailers
445 * @perm_tr_len: size of the perm_tr vector
446 * @tr: pointer to store the trailer character
448 * In case of success %0 is returned and @buf and @size are updated with
449 * the amount of bytes read. If @tr is non-NULL and a trailing
450 * character exists (size is non-zero after returning from this
451 * function), @tr is updated with the trailing character.
453 static int proc_get_long(char **buf, size_t *size,
454 unsigned long *val, bool *neg,
455 const char *perm_tr, unsigned perm_tr_len, char *tr)
457 char *p, tmp[TMPBUFLEN];
463 if (len > TMPBUFLEN - 1)
466 memcpy(tmp, *buf, len);
470 if (*p == '-' && *size > 1) {
478 if (strtoul_lenient(p, &p, 0, val))
483 /* We don't know if the next char is whitespace thus we may accept
484 * invalid integers (e.g. 1234...a) or two integers instead of one
485 * (e.g. 123...1). So lets not allow such large numbers. */
486 if (len == TMPBUFLEN - 1)
489 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
492 if (tr && (len < *size))
502 * proc_put_long - converts an integer to a decimal ASCII formatted string
504 * @buf: the user buffer
505 * @size: the size of the user buffer
506 * @val: the integer to be converted
507 * @neg: sign of the number, %TRUE for negative
509 * In case of success @buf and @size are updated with the amount of bytes
512 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
515 char tmp[TMPBUFLEN], *p = tmp;
517 sprintf(p, "%s%lu", neg ? "-" : "", val);
521 memcpy(*buf, tmp, len);
527 static void proc_put_char(void **buf, size_t *size, char c)
530 char **buffer = (char **)buf;
539 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
541 int write, void *data)
544 *(bool *)valp = *lvalp;
546 int val = *(bool *)valp;
548 *lvalp = (unsigned long)val;
554 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
556 int write, void *data)
560 if (*lvalp > (unsigned long) INT_MAX + 1)
562 WRITE_ONCE(*valp, -*lvalp);
564 if (*lvalp > (unsigned long) INT_MAX)
566 WRITE_ONCE(*valp, *lvalp);
569 int val = READ_ONCE(*valp);
572 *lvalp = -(unsigned long)val;
575 *lvalp = (unsigned long)val;
581 static int do_proc_douintvec_conv(unsigned long *lvalp,
583 int write, void *data)
586 if (*lvalp > UINT_MAX)
588 WRITE_ONCE(*valp, *lvalp);
590 unsigned int val = READ_ONCE(*valp);
591 *lvalp = (unsigned long)val;
596 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
598 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
599 int write, void *buffer,
600 size_t *lenp, loff_t *ppos,
601 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
602 int write, void *data),
605 int *i, vleft, first = 1, err = 0;
609 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
614 i = (int *) tbl_data;
615 vleft = table->maxlen / sizeof(*i);
619 conv = do_proc_dointvec_conv;
622 if (proc_first_pos_non_zero_ignore(ppos, table))
625 if (left > PAGE_SIZE - 1)
626 left = PAGE_SIZE - 1;
630 for (; left && vleft--; i++, first=0) {
635 left -= proc_skip_spaces(&p);
639 err = proc_get_long(&p, &left, &lval, &neg,
641 sizeof(proc_wspace_sep), NULL);
644 if (conv(&neg, &lval, i, 1, data)) {
649 if (conv(&neg, &lval, i, 0, data)) {
654 proc_put_char(&buffer, &left, '\t');
655 proc_put_long(&buffer, &left, lval, neg);
659 if (!write && !first && left && !err)
660 proc_put_char(&buffer, &left, '\n');
661 if (write && !err && left)
662 left -= proc_skip_spaces(&p);
664 return err ? : -EINVAL;
671 static int do_proc_dointvec(struct ctl_table *table, int write,
672 void *buffer, size_t *lenp, loff_t *ppos,
673 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
674 int write, void *data),
677 return __do_proc_dointvec(table->data, table, write,
678 buffer, lenp, ppos, conv, data);
681 static int do_proc_douintvec_w(unsigned int *tbl_data,
682 struct ctl_table *table,
684 size_t *lenp, loff_t *ppos,
685 int (*conv)(unsigned long *lvalp,
687 int write, void *data),
698 if (proc_first_pos_non_zero_ignore(ppos, table))
701 if (left > PAGE_SIZE - 1)
702 left = PAGE_SIZE - 1;
704 left -= proc_skip_spaces(&p);
710 err = proc_get_long(&p, &left, &lval, &neg,
712 sizeof(proc_wspace_sep), NULL);
718 if (conv(&lval, tbl_data, 1, data)) {
724 left -= proc_skip_spaces(&p);
732 /* This is in keeping with old __do_proc_dointvec() */
738 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
739 size_t *lenp, loff_t *ppos,
740 int (*conv)(unsigned long *lvalp,
742 int write, void *data),
751 if (conv(&lval, tbl_data, 0, data)) {
756 proc_put_long(&buffer, &left, lval, false);
760 proc_put_char(&buffer, &left, '\n');
769 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
770 int write, void *buffer,
771 size_t *lenp, loff_t *ppos,
772 int (*conv)(unsigned long *lvalp,
774 int write, void *data),
777 unsigned int *i, vleft;
779 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
784 i = (unsigned int *) tbl_data;
785 vleft = table->maxlen / sizeof(*i);
788 * Arrays are not supported, keep this simple. *Do not* add
797 conv = do_proc_douintvec_conv;
800 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
802 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
805 static int do_proc_douintvec(struct ctl_table *table, int write,
806 void *buffer, size_t *lenp, loff_t *ppos,
807 int (*conv)(unsigned long *lvalp,
809 int write, void *data),
812 return __do_proc_douintvec(table->data, table, write,
813 buffer, lenp, ppos, conv, data);
817 * proc_dobool - read/write a bool
818 * @table: the sysctl table
819 * @write: %TRUE if this is a write to the sysctl file
820 * @buffer: the user buffer
821 * @lenp: the size of the user buffer
822 * @ppos: file position
824 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
825 * values from/to the user buffer, treated as an ASCII string.
827 * Returns 0 on success.
829 int proc_dobool(struct ctl_table *table, int write, void *buffer,
830 size_t *lenp, loff_t *ppos)
832 return do_proc_dointvec(table, write, buffer, lenp, ppos,
833 do_proc_dobool_conv, NULL);
837 * proc_dointvec - read a vector of integers
838 * @table: the sysctl table
839 * @write: %TRUE if this is a write to the sysctl file
840 * @buffer: the user buffer
841 * @lenp: the size of the user buffer
842 * @ppos: file position
844 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
845 * values from/to the user buffer, treated as an ASCII string.
847 * Returns 0 on success.
849 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
850 size_t *lenp, loff_t *ppos)
852 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
855 #ifdef CONFIG_COMPACTION
856 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
857 int write, void *buffer, size_t *lenp, loff_t *ppos)
861 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
862 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
864 old = *(int *)table->data;
865 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
868 if (old != *(int *)table->data)
869 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
870 table->procname, current->comm,
871 task_pid_nr(current));
877 * proc_douintvec - read a vector of unsigned integers
878 * @table: the sysctl table
879 * @write: %TRUE if this is a write to the sysctl file
880 * @buffer: the user buffer
881 * @lenp: the size of the user buffer
882 * @ppos: file position
884 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
885 * values from/to the user buffer, treated as an ASCII string.
887 * Returns 0 on success.
889 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
890 size_t *lenp, loff_t *ppos)
892 return do_proc_douintvec(table, write, buffer, lenp, ppos,
893 do_proc_douintvec_conv, NULL);
897 * Taint values can only be increased
898 * This means we can safely use a temporary.
900 static int proc_taint(struct ctl_table *table, int write,
901 void *buffer, size_t *lenp, loff_t *ppos)
904 unsigned long tmptaint = get_taint();
907 if (write && !capable(CAP_SYS_ADMIN))
912 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
920 * If we are relying on panic_on_taint not producing
921 * false positives due to userspace input, bail out
922 * before setting the requested taint flags.
924 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
928 * Poor man's atomic or. Not worth adding a primitive
929 * to everyone's atomic.h for this
931 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
932 if ((1UL << i) & tmptaint)
933 add_taint(i, LOCKDEP_STILL_OK);
940 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
941 void *buffer, size_t *lenp, loff_t *ppos)
943 if (write && !capable(CAP_SYS_ADMIN))
946 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
951 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
952 * @min: pointer to minimum allowable value
953 * @max: pointer to maximum allowable value
955 * The do_proc_dointvec_minmax_conv_param structure provides the
956 * minimum and maximum values for doing range checking for those sysctl
957 * parameters that use the proc_dointvec_minmax() handler.
959 struct do_proc_dointvec_minmax_conv_param {
964 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
966 int write, void *data)
969 struct do_proc_dointvec_minmax_conv_param *param = data;
971 * If writing, first do so via a temporary local int so we can
972 * bounds-check it before touching *valp.
974 int *ip = write ? &tmp : valp;
976 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
981 if ((param->min && *param->min > tmp) ||
982 (param->max && *param->max < tmp))
984 WRITE_ONCE(*valp, tmp);
991 * proc_dointvec_minmax - read a vector of integers with min/max values
992 * @table: the sysctl table
993 * @write: %TRUE if this is a write to the sysctl file
994 * @buffer: the user buffer
995 * @lenp: the size of the user buffer
996 * @ppos: file position
998 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
999 * values from/to the user buffer, treated as an ASCII string.
1001 * This routine will ensure the values are within the range specified by
1002 * table->extra1 (min) and table->extra2 (max).
1004 * Returns 0 on success or -EINVAL on write when the range check fails.
1006 int proc_dointvec_minmax(struct ctl_table *table, int write,
1007 void *buffer, size_t *lenp, loff_t *ppos)
1009 struct do_proc_dointvec_minmax_conv_param param = {
1010 .min = (int *) table->extra1,
1011 .max = (int *) table->extra2,
1013 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1014 do_proc_dointvec_minmax_conv, ¶m);
1018 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1019 * @min: pointer to minimum allowable value
1020 * @max: pointer to maximum allowable value
1022 * The do_proc_douintvec_minmax_conv_param structure provides the
1023 * minimum and maximum values for doing range checking for those sysctl
1024 * parameters that use the proc_douintvec_minmax() handler.
1026 struct do_proc_douintvec_minmax_conv_param {
1031 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1033 int write, void *data)
1037 struct do_proc_douintvec_minmax_conv_param *param = data;
1038 /* write via temporary local uint for bounds-checking */
1039 unsigned int *up = write ? &tmp : valp;
1041 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1046 if ((param->min && *param->min > tmp) ||
1047 (param->max && *param->max < tmp))
1050 WRITE_ONCE(*valp, tmp);
1057 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1058 * @table: the sysctl table
1059 * @write: %TRUE if this is a write to the sysctl file
1060 * @buffer: the user buffer
1061 * @lenp: the size of the user buffer
1062 * @ppos: file position
1064 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1065 * values from/to the user buffer, treated as an ASCII string. Negative
1066 * strings are not allowed.
1068 * This routine will ensure the values are within the range specified by
1069 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1070 * check for UINT_MAX to avoid having to support wrap around uses from
1073 * Returns 0 on success or -ERANGE on write when the range check fails.
1075 int proc_douintvec_minmax(struct ctl_table *table, int write,
1076 void *buffer, size_t *lenp, loff_t *ppos)
1078 struct do_proc_douintvec_minmax_conv_param param = {
1079 .min = (unsigned int *) table->extra1,
1080 .max = (unsigned int *) table->extra2,
1082 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1083 do_proc_douintvec_minmax_conv, ¶m);
1087 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1088 * @table: the sysctl table
1089 * @write: %TRUE if this is a write to the sysctl file
1090 * @buffer: the user buffer
1091 * @lenp: the size of the user buffer
1092 * @ppos: file position
1094 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1095 * values from/to the user buffer, treated as an ASCII string. Negative
1096 * strings are not allowed.
1098 * This routine will ensure the values are within the range specified by
1099 * table->extra1 (min) and table->extra2 (max).
1101 * Returns 0 on success or an error on write when the range check fails.
1103 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1104 void *buffer, size_t *lenp, loff_t *ppos)
1106 struct ctl_table tmp;
1107 unsigned int min = 0, max = 255U, val;
1108 u8 *data = table->data;
1109 struct do_proc_douintvec_minmax_conv_param param = {
1115 /* Do not support arrays yet. */
1116 if (table->maxlen != sizeof(u8))
1119 if (table->extra1) {
1120 min = *(unsigned int *) table->extra1;
1124 if (table->extra2) {
1125 max = *(unsigned int *) table->extra2;
1132 tmp.maxlen = sizeof(val);
1134 val = READ_ONCE(*data);
1135 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1136 do_proc_douintvec_minmax_conv, ¶m);
1140 WRITE_ONCE(*data, val);
1143 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1145 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1147 int write, void *data)
1152 val = round_pipe_size(*lvalp);
1158 unsigned int val = *valp;
1159 *lvalp = (unsigned long) val;
1165 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1166 void *buffer, size_t *lenp, loff_t *ppos)
1168 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1169 do_proc_dopipe_max_size_conv, NULL);
1172 static void validate_coredump_safety(void)
1174 #ifdef CONFIG_COREDUMP
1175 if (suid_dumpable == SUID_DUMP_ROOT &&
1176 core_pattern[0] != '/' && core_pattern[0] != '|') {
1178 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1179 "Pipe handler or fully qualified core dump path required.\n"
1180 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1186 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1187 void *buffer, size_t *lenp, loff_t *ppos)
1189 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1191 validate_coredump_safety();
1195 #ifdef CONFIG_COREDUMP
1196 static int proc_dostring_coredump(struct ctl_table *table, int write,
1197 void *buffer, size_t *lenp, loff_t *ppos)
1199 int error = proc_dostring(table, write, buffer, lenp, ppos);
1201 validate_coredump_safety();
1206 #ifdef CONFIG_MAGIC_SYSRQ
1207 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1208 void *buffer, size_t *lenp, loff_t *ppos)
1214 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1215 lenp, ppos, NULL, NULL);
1220 sysrq_toggle_support(tmp);
1226 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1227 int write, void *buffer, size_t *lenp, loff_t *ppos,
1228 unsigned long convmul, unsigned long convdiv)
1230 unsigned long *i, *min, *max;
1231 int vleft, first = 1, err = 0;
1235 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1240 i = (unsigned long *) data;
1241 min = (unsigned long *) table->extra1;
1242 max = (unsigned long *) table->extra2;
1243 vleft = table->maxlen / sizeof(unsigned long);
1247 if (proc_first_pos_non_zero_ignore(ppos, table))
1250 if (left > PAGE_SIZE - 1)
1251 left = PAGE_SIZE - 1;
1255 for (; left && vleft--; i++, first = 0) {
1261 left -= proc_skip_spaces(&p);
1265 err = proc_get_long(&p, &left, &val, &neg,
1267 sizeof(proc_wspace_sep), NULL);
1272 val = convmul * val / convdiv;
1273 if ((min && val < *min) || (max && val > *max)) {
1277 WRITE_ONCE(*i, val);
1279 val = convdiv * READ_ONCE(*i) / convmul;
1281 proc_put_char(&buffer, &left, '\t');
1282 proc_put_long(&buffer, &left, val, false);
1286 if (!write && !first && left && !err)
1287 proc_put_char(&buffer, &left, '\n');
1289 left -= proc_skip_spaces(&p);
1291 return err ? : -EINVAL;
1298 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1299 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1300 unsigned long convdiv)
1302 return __do_proc_doulongvec_minmax(table->data, table, write,
1303 buffer, lenp, ppos, convmul, convdiv);
1307 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1308 * @table: the sysctl table
1309 * @write: %TRUE if this is a write to the sysctl file
1310 * @buffer: the user buffer
1311 * @lenp: the size of the user buffer
1312 * @ppos: file position
1314 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1315 * values from/to the user buffer, treated as an ASCII string.
1317 * This routine will ensure the values are within the range specified by
1318 * table->extra1 (min) and table->extra2 (max).
1320 * Returns 0 on success.
1322 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1323 void *buffer, size_t *lenp, loff_t *ppos)
1325 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1329 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1330 * @table: the sysctl table
1331 * @write: %TRUE if this is a write to the sysctl file
1332 * @buffer: the user buffer
1333 * @lenp: the size of the user buffer
1334 * @ppos: file position
1336 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1337 * values from/to the user buffer, treated as an ASCII string. The values
1338 * are treated as milliseconds, and converted to jiffies when they are stored.
1340 * This routine will ensure the values are within the range specified by
1341 * table->extra1 (min) and table->extra2 (max).
1343 * Returns 0 on success.
1345 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1346 void *buffer, size_t *lenp, loff_t *ppos)
1348 return do_proc_doulongvec_minmax(table, write, buffer,
1349 lenp, ppos, HZ, 1000l);
1353 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1355 int write, void *data)
1358 if (*lvalp > INT_MAX / HZ)
1361 WRITE_ONCE(*valp, -*lvalp * HZ);
1363 WRITE_ONCE(*valp, *lvalp * HZ);
1365 int val = READ_ONCE(*valp);
1369 lval = -(unsigned long)val;
1372 lval = (unsigned long)val;
1379 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1381 int write, void *data)
1384 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1386 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1392 lval = -(unsigned long)val;
1395 lval = (unsigned long)val;
1397 *lvalp = jiffies_to_clock_t(lval);
1402 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1404 int write, void *data)
1407 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1411 WRITE_ONCE(*valp, (int)jif);
1413 int val = READ_ONCE(*valp);
1417 lval = -(unsigned long)val;
1420 lval = (unsigned long)val;
1422 *lvalp = jiffies_to_msecs(lval);
1428 * proc_dointvec_jiffies - read a vector of integers as seconds
1429 * @table: the sysctl table
1430 * @write: %TRUE if this is a write to the sysctl file
1431 * @buffer: the user buffer
1432 * @lenp: the size of the user buffer
1433 * @ppos: file position
1435 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1436 * values from/to the user buffer, treated as an ASCII string.
1437 * The values read are assumed to be in seconds, and are converted into
1440 * Returns 0 on success.
1442 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1443 void *buffer, size_t *lenp, loff_t *ppos)
1445 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1446 do_proc_dointvec_jiffies_conv,NULL);
1450 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1451 * @table: the sysctl table
1452 * @write: %TRUE if this is a write to the sysctl file
1453 * @buffer: the user buffer
1454 * @lenp: the size of the user buffer
1455 * @ppos: pointer to the file position
1457 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1458 * values from/to the user buffer, treated as an ASCII string.
1459 * The values read are assumed to be in 1/USER_HZ seconds, and
1460 * are converted into jiffies.
1462 * Returns 0 on success.
1464 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1465 void *buffer, size_t *lenp, loff_t *ppos)
1467 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1468 do_proc_dointvec_userhz_jiffies_conv,NULL);
1472 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1473 * @table: the sysctl table
1474 * @write: %TRUE if this is a write to the sysctl file
1475 * @buffer: the user buffer
1476 * @lenp: the size of the user buffer
1477 * @ppos: file position
1478 * @ppos: the current position in the file
1480 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1481 * values from/to the user buffer, treated as an ASCII string.
1482 * The values read are assumed to be in 1/1000 seconds, and
1483 * are converted into jiffies.
1485 * Returns 0 on success.
1487 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1488 size_t *lenp, loff_t *ppos)
1490 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1491 do_proc_dointvec_ms_jiffies_conv, NULL);
1494 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1495 size_t *lenp, loff_t *ppos)
1497 struct pid *new_pid;
1501 tmp = pid_vnr(cad_pid);
1503 r = __do_proc_dointvec(&tmp, table, write, buffer,
1504 lenp, ppos, NULL, NULL);
1508 new_pid = find_get_pid(tmp);
1512 put_pid(xchg(&cad_pid, new_pid));
1517 * proc_do_large_bitmap - read/write from/to a large bitmap
1518 * @table: the sysctl table
1519 * @write: %TRUE if this is a write to the sysctl file
1520 * @buffer: the user buffer
1521 * @lenp: the size of the user buffer
1522 * @ppos: file position
1524 * The bitmap is stored at table->data and the bitmap length (in bits)
1527 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1528 * large bitmaps may be represented in a compact manner. Writing into
1529 * the file will clear the bitmap then update it with the given input.
1531 * Returns 0 on success.
1533 int proc_do_large_bitmap(struct ctl_table *table, int write,
1534 void *buffer, size_t *lenp, loff_t *ppos)
1537 size_t left = *lenp;
1538 unsigned long bitmap_len = table->maxlen;
1539 unsigned long *bitmap = *(unsigned long **) table->data;
1540 unsigned long *tmp_bitmap = NULL;
1541 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1543 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1552 if (left > PAGE_SIZE - 1) {
1553 left = PAGE_SIZE - 1;
1554 /* How much of the buffer we'll skip this pass */
1555 skipped = *lenp - left;
1558 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1561 proc_skip_char(&p, &left, '\n');
1562 while (!err && left) {
1563 unsigned long val_a, val_b;
1567 /* In case we stop parsing mid-number, we can reset */
1569 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1572 * If we consumed the entirety of a truncated buffer or
1573 * only one char is left (may be a "-"), then stop here,
1574 * reset, & come back for more.
1576 if ((left <= 1) && skipped) {
1583 if (val_a >= bitmap_len || neg) {
1595 err = proc_get_long(&p, &left, &val_b,
1596 &neg, tr_b, sizeof(tr_b),
1599 * If we consumed all of a truncated buffer or
1600 * then stop here, reset, & come back for more.
1602 if (!left && skipped) {
1609 if (val_b >= bitmap_len || neg ||
1620 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1621 proc_skip_char(&p, &left, '\n');
1625 unsigned long bit_a, bit_b = 0;
1629 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1630 if (bit_a >= bitmap_len)
1632 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1636 proc_put_char(&buffer, &left, ',');
1637 proc_put_long(&buffer, &left, bit_a, false);
1638 if (bit_a != bit_b) {
1639 proc_put_char(&buffer, &left, '-');
1640 proc_put_long(&buffer, &left, bit_b, false);
1645 proc_put_char(&buffer, &left, '\n');
1651 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1653 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1659 bitmap_free(tmp_bitmap);
1663 #else /* CONFIG_PROC_SYSCTL */
1665 int proc_dostring(struct ctl_table *table, int write,
1666 void *buffer, size_t *lenp, loff_t *ppos)
1671 int proc_dobool(struct ctl_table *table, int write,
1672 void *buffer, size_t *lenp, loff_t *ppos)
1677 int proc_dointvec(struct ctl_table *table, int write,
1678 void *buffer, size_t *lenp, loff_t *ppos)
1683 int proc_douintvec(struct ctl_table *table, int write,
1684 void *buffer, size_t *lenp, loff_t *ppos)
1689 int proc_dointvec_minmax(struct ctl_table *table, int write,
1690 void *buffer, size_t *lenp, loff_t *ppos)
1695 int proc_douintvec_minmax(struct ctl_table *table, int write,
1696 void *buffer, size_t *lenp, loff_t *ppos)
1701 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1702 void *buffer, size_t *lenp, loff_t *ppos)
1707 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1708 void *buffer, size_t *lenp, loff_t *ppos)
1713 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1714 void *buffer, size_t *lenp, loff_t *ppos)
1719 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1720 void *buffer, size_t *lenp, loff_t *ppos)
1725 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1726 void *buffer, size_t *lenp, loff_t *ppos)
1731 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1732 void *buffer, size_t *lenp, loff_t *ppos)
1737 int proc_do_large_bitmap(struct ctl_table *table, int write,
1738 void *buffer, size_t *lenp, loff_t *ppos)
1743 #endif /* CONFIG_PROC_SYSCTL */
1745 #if defined(CONFIG_SYSCTL)
1746 int proc_do_static_key(struct ctl_table *table, int write,
1747 void *buffer, size_t *lenp, loff_t *ppos)
1749 struct static_key *key = (struct static_key *)table->data;
1750 static DEFINE_MUTEX(static_key_mutex);
1752 struct ctl_table tmp = {
1754 .maxlen = sizeof(val),
1755 .mode = table->mode,
1756 .extra1 = SYSCTL_ZERO,
1757 .extra2 = SYSCTL_ONE,
1760 if (write && !capable(CAP_SYS_ADMIN))
1763 mutex_lock(&static_key_mutex);
1764 val = static_key_enabled(key);
1765 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1766 if (write && !ret) {
1768 static_key_enable(key);
1770 static_key_disable(key);
1772 mutex_unlock(&static_key_mutex);
1776 static struct ctl_table kern_table[] = {
1778 .procname = "sched_child_runs_first",
1779 .data = &sysctl_sched_child_runs_first,
1780 .maxlen = sizeof(unsigned int),
1782 .proc_handler = proc_dointvec,
1784 #ifdef CONFIG_SCHEDSTATS
1786 .procname = "sched_schedstats",
1788 .maxlen = sizeof(unsigned int),
1790 .proc_handler = sysctl_schedstats,
1791 .extra1 = SYSCTL_ZERO,
1792 .extra2 = SYSCTL_ONE,
1794 #endif /* CONFIG_SCHEDSTATS */
1795 #ifdef CONFIG_TASK_DELAY_ACCT
1797 .procname = "task_delayacct",
1799 .maxlen = sizeof(unsigned int),
1801 .proc_handler = sysctl_delayacct,
1802 .extra1 = SYSCTL_ZERO,
1803 .extra2 = SYSCTL_ONE,
1805 #endif /* CONFIG_TASK_DELAY_ACCT */
1806 #ifdef CONFIG_NUMA_BALANCING
1808 .procname = "numa_balancing",
1809 .data = NULL, /* filled in by handler */
1810 .maxlen = sizeof(unsigned int),
1812 .proc_handler = sysctl_numa_balancing,
1813 .extra1 = SYSCTL_ZERO,
1814 .extra2 = SYSCTL_ONE,
1816 #endif /* CONFIG_NUMA_BALANCING */
1818 .procname = "sched_rt_period_us",
1819 .data = &sysctl_sched_rt_period,
1820 .maxlen = sizeof(unsigned int),
1822 .proc_handler = sched_rt_handler,
1825 .procname = "sched_rt_runtime_us",
1826 .data = &sysctl_sched_rt_runtime,
1827 .maxlen = sizeof(int),
1829 .proc_handler = sched_rt_handler,
1832 .procname = "sched_deadline_period_max_us",
1833 .data = &sysctl_sched_dl_period_max,
1834 .maxlen = sizeof(unsigned int),
1836 .proc_handler = proc_dointvec,
1839 .procname = "sched_deadline_period_min_us",
1840 .data = &sysctl_sched_dl_period_min,
1841 .maxlen = sizeof(unsigned int),
1843 .proc_handler = proc_dointvec,
1846 .procname = "sched_rr_timeslice_ms",
1847 .data = &sysctl_sched_rr_timeslice,
1848 .maxlen = sizeof(int),
1850 .proc_handler = sched_rr_handler,
1852 #ifdef CONFIG_UCLAMP_TASK
1854 .procname = "sched_util_clamp_min",
1855 .data = &sysctl_sched_uclamp_util_min,
1856 .maxlen = sizeof(unsigned int),
1858 .proc_handler = sysctl_sched_uclamp_handler,
1861 .procname = "sched_util_clamp_max",
1862 .data = &sysctl_sched_uclamp_util_max,
1863 .maxlen = sizeof(unsigned int),
1865 .proc_handler = sysctl_sched_uclamp_handler,
1868 .procname = "sched_util_clamp_min_rt_default",
1869 .data = &sysctl_sched_uclamp_util_min_rt_default,
1870 .maxlen = sizeof(unsigned int),
1872 .proc_handler = sysctl_sched_uclamp_handler,
1875 #ifdef CONFIG_SCHED_AUTOGROUP
1877 .procname = "sched_autogroup_enabled",
1878 .data = &sysctl_sched_autogroup_enabled,
1879 .maxlen = sizeof(unsigned int),
1881 .proc_handler = proc_dointvec_minmax,
1882 .extra1 = SYSCTL_ZERO,
1883 .extra2 = SYSCTL_ONE,
1886 #ifdef CONFIG_CFS_BANDWIDTH
1888 .procname = "sched_cfs_bandwidth_slice_us",
1889 .data = &sysctl_sched_cfs_bandwidth_slice,
1890 .maxlen = sizeof(unsigned int),
1892 .proc_handler = proc_dointvec_minmax,
1893 .extra1 = SYSCTL_ONE,
1896 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1898 .procname = "sched_energy_aware",
1899 .data = &sysctl_sched_energy_aware,
1900 .maxlen = sizeof(unsigned int),
1902 .proc_handler = sched_energy_aware_handler,
1903 .extra1 = SYSCTL_ZERO,
1904 .extra2 = SYSCTL_ONE,
1907 #ifdef CONFIG_PROVE_LOCKING
1909 .procname = "prove_locking",
1910 .data = &prove_locking,
1911 .maxlen = sizeof(int),
1913 .proc_handler = proc_dointvec,
1916 #ifdef CONFIG_LOCK_STAT
1918 .procname = "lock_stat",
1920 .maxlen = sizeof(int),
1922 .proc_handler = proc_dointvec,
1926 .procname = "panic",
1927 .data = &panic_timeout,
1928 .maxlen = sizeof(int),
1930 .proc_handler = proc_dointvec,
1932 #ifdef CONFIG_COREDUMP
1934 .procname = "core_uses_pid",
1935 .data = &core_uses_pid,
1936 .maxlen = sizeof(int),
1938 .proc_handler = proc_dointvec,
1941 .procname = "core_pattern",
1942 .data = core_pattern,
1943 .maxlen = CORENAME_MAX_SIZE,
1945 .proc_handler = proc_dostring_coredump,
1948 .procname = "core_pipe_limit",
1949 .data = &core_pipe_limit,
1950 .maxlen = sizeof(unsigned int),
1952 .proc_handler = proc_dointvec,
1955 #ifdef CONFIG_PROC_SYSCTL
1957 .procname = "tainted",
1958 .maxlen = sizeof(long),
1960 .proc_handler = proc_taint,
1963 .procname = "sysctl_writes_strict",
1964 .data = &sysctl_writes_strict,
1965 .maxlen = sizeof(int),
1967 .proc_handler = proc_dointvec_minmax,
1968 .extra1 = SYSCTL_NEG_ONE,
1969 .extra2 = SYSCTL_ONE,
1972 #ifdef CONFIG_LATENCYTOP
1974 .procname = "latencytop",
1975 .data = &latencytop_enabled,
1976 .maxlen = sizeof(int),
1978 .proc_handler = sysctl_latencytop,
1981 #ifdef CONFIG_BLK_DEV_INITRD
1983 .procname = "real-root-dev",
1984 .data = &real_root_dev,
1985 .maxlen = sizeof(int),
1987 .proc_handler = proc_dointvec,
1991 .procname = "print-fatal-signals",
1992 .data = &print_fatal_signals,
1993 .maxlen = sizeof(int),
1995 .proc_handler = proc_dointvec,
1999 .procname = "reboot-cmd",
2000 .data = reboot_command,
2003 .proc_handler = proc_dostring,
2006 .procname = "stop-a",
2007 .data = &stop_a_enabled,
2008 .maxlen = sizeof (int),
2010 .proc_handler = proc_dointvec,
2013 .procname = "scons-poweroff",
2014 .data = &scons_pwroff,
2015 .maxlen = sizeof (int),
2017 .proc_handler = proc_dointvec,
2020 #ifdef CONFIG_SPARC64
2022 .procname = "tsb-ratio",
2023 .data = &sysctl_tsb_ratio,
2024 .maxlen = sizeof (int),
2026 .proc_handler = proc_dointvec,
2029 #ifdef CONFIG_PARISC
2031 .procname = "soft-power",
2032 .data = &pwrsw_enabled,
2033 .maxlen = sizeof (int),
2035 .proc_handler = proc_dointvec,
2038 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2040 .procname = "unaligned-trap",
2041 .data = &unaligned_enabled,
2042 .maxlen = sizeof (int),
2044 .proc_handler = proc_dointvec,
2048 .procname = "ctrl-alt-del",
2050 .maxlen = sizeof(int),
2052 .proc_handler = proc_dointvec,
2054 #ifdef CONFIG_FUNCTION_TRACER
2056 .procname = "ftrace_enabled",
2057 .data = &ftrace_enabled,
2058 .maxlen = sizeof(int),
2060 .proc_handler = ftrace_enable_sysctl,
2063 #ifdef CONFIG_STACK_TRACER
2065 .procname = "stack_tracer_enabled",
2066 .data = &stack_tracer_enabled,
2067 .maxlen = sizeof(int),
2069 .proc_handler = stack_trace_sysctl,
2072 #ifdef CONFIG_TRACING
2074 .procname = "ftrace_dump_on_oops",
2075 .data = &ftrace_dump_on_oops,
2076 .maxlen = sizeof(int),
2078 .proc_handler = proc_dointvec,
2081 .procname = "traceoff_on_warning",
2082 .data = &__disable_trace_on_warning,
2083 .maxlen = sizeof(__disable_trace_on_warning),
2085 .proc_handler = proc_dointvec,
2088 .procname = "tracepoint_printk",
2089 .data = &tracepoint_printk,
2090 .maxlen = sizeof(tracepoint_printk),
2092 .proc_handler = tracepoint_printk_sysctl,
2095 #ifdef CONFIG_KEXEC_CORE
2097 .procname = "kexec_load_disabled",
2098 .data = &kexec_load_disabled,
2099 .maxlen = sizeof(int),
2101 /* only handle a transition from default "0" to "1" */
2102 .proc_handler = proc_dointvec_minmax,
2103 .extra1 = SYSCTL_ONE,
2104 .extra2 = SYSCTL_ONE,
2107 #ifdef CONFIG_MODULES
2109 .procname = "modprobe",
2110 .data = &modprobe_path,
2111 .maxlen = KMOD_PATH_LEN,
2113 .proc_handler = proc_dostring,
2116 .procname = "modules_disabled",
2117 .data = &modules_disabled,
2118 .maxlen = sizeof(int),
2120 /* only handle a transition from default "0" to "1" */
2121 .proc_handler = proc_dointvec_minmax,
2122 .extra1 = SYSCTL_ONE,
2123 .extra2 = SYSCTL_ONE,
2126 #ifdef CONFIG_UEVENT_HELPER
2128 .procname = "hotplug",
2129 .data = &uevent_helper,
2130 .maxlen = UEVENT_HELPER_PATH_LEN,
2132 .proc_handler = proc_dostring,
2135 #ifdef CONFIG_CHR_DEV_SG
2137 .procname = "sg-big-buff",
2138 .data = &sg_big_buff,
2139 .maxlen = sizeof (int),
2141 .proc_handler = proc_dointvec,
2144 #ifdef CONFIG_BSD_PROCESS_ACCT
2148 .maxlen = 3*sizeof(int),
2150 .proc_handler = proc_dointvec,
2153 #ifdef CONFIG_MAGIC_SYSRQ
2155 .procname = "sysrq",
2157 .maxlen = sizeof (int),
2159 .proc_handler = sysrq_sysctl_handler,
2162 #ifdef CONFIG_PROC_SYSCTL
2164 .procname = "cad_pid",
2166 .maxlen = sizeof (int),
2168 .proc_handler = proc_do_cad_pid,
2172 .procname = "threads-max",
2174 .maxlen = sizeof(int),
2176 .proc_handler = sysctl_max_threads,
2179 .procname = "random",
2181 .child = random_table,
2184 .procname = "usermodehelper",
2186 .child = usermodehelper_table,
2188 #ifdef CONFIG_FW_LOADER_USER_HELPER
2190 .procname = "firmware_config",
2192 .child = firmware_config_table,
2196 .procname = "overflowuid",
2197 .data = &overflowuid,
2198 .maxlen = sizeof(int),
2200 .proc_handler = proc_dointvec_minmax,
2201 .extra1 = &minolduid,
2202 .extra2 = &maxolduid,
2205 .procname = "overflowgid",
2206 .data = &overflowgid,
2207 .maxlen = sizeof(int),
2209 .proc_handler = proc_dointvec_minmax,
2210 .extra1 = &minolduid,
2211 .extra2 = &maxolduid,
2215 .procname = "userprocess_debug",
2216 .data = &show_unhandled_signals,
2217 .maxlen = sizeof(int),
2219 .proc_handler = proc_dointvec,
2224 .procname = "oops_all_cpu_backtrace",
2225 .data = &sysctl_oops_all_cpu_backtrace,
2226 .maxlen = sizeof(int),
2228 .proc_handler = proc_dointvec_minmax,
2229 .extra1 = SYSCTL_ZERO,
2230 .extra2 = SYSCTL_ONE,
2232 #endif /* CONFIG_SMP */
2234 .procname = "pid_max",
2236 .maxlen = sizeof (int),
2238 .proc_handler = proc_dointvec_minmax,
2239 .extra1 = &pid_max_min,
2240 .extra2 = &pid_max_max,
2243 .procname = "panic_on_oops",
2244 .data = &panic_on_oops,
2245 .maxlen = sizeof(int),
2247 .proc_handler = proc_dointvec,
2250 .procname = "panic_print",
2251 .data = &panic_print,
2252 .maxlen = sizeof(unsigned long),
2254 .proc_handler = proc_doulongvec_minmax,
2256 #if defined CONFIG_PRINTK
2258 .procname = "printk",
2259 .data = &console_loglevel,
2260 .maxlen = 4*sizeof(int),
2262 .proc_handler = proc_dointvec,
2265 .procname = "printk_ratelimit",
2266 .data = &printk_ratelimit_state.interval,
2267 .maxlen = sizeof(int),
2269 .proc_handler = proc_dointvec_jiffies,
2272 .procname = "printk_ratelimit_burst",
2273 .data = &printk_ratelimit_state.burst,
2274 .maxlen = sizeof(int),
2276 .proc_handler = proc_dointvec,
2279 .procname = "printk_delay",
2280 .data = &printk_delay_msec,
2281 .maxlen = sizeof(int),
2283 .proc_handler = proc_dointvec_minmax,
2284 .extra1 = SYSCTL_ZERO,
2285 .extra2 = &ten_thousand,
2288 .procname = "printk_devkmsg",
2289 .data = devkmsg_log_str,
2290 .maxlen = DEVKMSG_STR_MAX_SIZE,
2292 .proc_handler = devkmsg_sysctl_set_loglvl,
2295 .procname = "dmesg_restrict",
2296 .data = &dmesg_restrict,
2297 .maxlen = sizeof(int),
2299 .proc_handler = proc_dointvec_minmax_sysadmin,
2300 .extra1 = SYSCTL_ZERO,
2301 .extra2 = SYSCTL_ONE,
2304 .procname = "kptr_restrict",
2305 .data = &kptr_restrict,
2306 .maxlen = sizeof(int),
2308 .proc_handler = proc_dointvec_minmax_sysadmin,
2309 .extra1 = SYSCTL_ZERO,
2310 .extra2 = SYSCTL_TWO,
2314 .procname = "ngroups_max",
2315 .data = &ngroups_max,
2316 .maxlen = sizeof (int),
2318 .proc_handler = proc_dointvec,
2321 .procname = "cap_last_cap",
2322 .data = (void *)&cap_last_cap,
2323 .maxlen = sizeof(int),
2325 .proc_handler = proc_dointvec,
2327 #if defined(CONFIG_LOCKUP_DETECTOR)
2329 .procname = "watchdog",
2330 .data = &watchdog_user_enabled,
2331 .maxlen = sizeof(int),
2333 .proc_handler = proc_watchdog,
2334 .extra1 = SYSCTL_ZERO,
2335 .extra2 = SYSCTL_ONE,
2338 .procname = "watchdog_thresh",
2339 .data = &watchdog_thresh,
2340 .maxlen = sizeof(int),
2342 .proc_handler = proc_watchdog_thresh,
2343 .extra1 = SYSCTL_ZERO,
2347 .procname = "nmi_watchdog",
2348 .data = &nmi_watchdog_user_enabled,
2349 .maxlen = sizeof(int),
2350 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2351 .proc_handler = proc_nmi_watchdog,
2352 .extra1 = SYSCTL_ZERO,
2353 .extra2 = SYSCTL_ONE,
2356 .procname = "watchdog_cpumask",
2357 .data = &watchdog_cpumask_bits,
2360 .proc_handler = proc_watchdog_cpumask,
2362 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2364 .procname = "soft_watchdog",
2365 .data = &soft_watchdog_user_enabled,
2366 .maxlen = sizeof(int),
2368 .proc_handler = proc_soft_watchdog,
2369 .extra1 = SYSCTL_ZERO,
2370 .extra2 = SYSCTL_ONE,
2373 .procname = "softlockup_panic",
2374 .data = &softlockup_panic,
2375 .maxlen = sizeof(int),
2377 .proc_handler = proc_dointvec_minmax,
2378 .extra1 = SYSCTL_ZERO,
2379 .extra2 = SYSCTL_ONE,
2383 .procname = "softlockup_all_cpu_backtrace",
2384 .data = &sysctl_softlockup_all_cpu_backtrace,
2385 .maxlen = sizeof(int),
2387 .proc_handler = proc_dointvec_minmax,
2388 .extra1 = SYSCTL_ZERO,
2389 .extra2 = SYSCTL_ONE,
2391 #endif /* CONFIG_SMP */
2393 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2395 .procname = "hardlockup_panic",
2396 .data = &hardlockup_panic,
2397 .maxlen = sizeof(int),
2399 .proc_handler = proc_dointvec_minmax,
2400 .extra1 = SYSCTL_ZERO,
2401 .extra2 = SYSCTL_ONE,
2405 .procname = "hardlockup_all_cpu_backtrace",
2406 .data = &sysctl_hardlockup_all_cpu_backtrace,
2407 .maxlen = sizeof(int),
2409 .proc_handler = proc_dointvec_minmax,
2410 .extra1 = SYSCTL_ZERO,
2411 .extra2 = SYSCTL_ONE,
2413 #endif /* CONFIG_SMP */
2417 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2419 .procname = "unknown_nmi_panic",
2420 .data = &unknown_nmi_panic,
2421 .maxlen = sizeof (int),
2423 .proc_handler = proc_dointvec,
2427 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2428 defined(CONFIG_DEBUG_STACKOVERFLOW)
2430 .procname = "panic_on_stackoverflow",
2431 .data = &sysctl_panic_on_stackoverflow,
2432 .maxlen = sizeof(int),
2434 .proc_handler = proc_dointvec,
2437 #if defined(CONFIG_X86)
2439 .procname = "panic_on_unrecovered_nmi",
2440 .data = &panic_on_unrecovered_nmi,
2441 .maxlen = sizeof(int),
2443 .proc_handler = proc_dointvec,
2446 .procname = "panic_on_io_nmi",
2447 .data = &panic_on_io_nmi,
2448 .maxlen = sizeof(int),
2450 .proc_handler = proc_dointvec,
2453 .procname = "bootloader_type",
2454 .data = &bootloader_type,
2455 .maxlen = sizeof (int),
2457 .proc_handler = proc_dointvec,
2460 .procname = "bootloader_version",
2461 .data = &bootloader_version,
2462 .maxlen = sizeof (int),
2464 .proc_handler = proc_dointvec,
2467 .procname = "io_delay_type",
2468 .data = &io_delay_type,
2469 .maxlen = sizeof(int),
2471 .proc_handler = proc_dointvec,
2474 #if defined(CONFIG_MMU)
2476 .procname = "randomize_va_space",
2477 .data = &randomize_va_space,
2478 .maxlen = sizeof(int),
2480 .proc_handler = proc_dointvec,
2483 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2485 .procname = "spin_retry",
2486 .data = &spin_retry,
2487 .maxlen = sizeof (int),
2489 .proc_handler = proc_dointvec,
2492 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2494 .procname = "acpi_video_flags",
2495 .data = &acpi_realmode_flags,
2496 .maxlen = sizeof (unsigned long),
2498 .proc_handler = proc_doulongvec_minmax,
2501 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2503 .procname = "ignore-unaligned-usertrap",
2504 .data = &no_unaligned_warning,
2505 .maxlen = sizeof (int),
2507 .proc_handler = proc_dointvec,
2512 .procname = "unaligned-dump-stack",
2513 .data = &unaligned_dump_stack,
2514 .maxlen = sizeof (int),
2516 .proc_handler = proc_dointvec,
2519 #ifdef CONFIG_DETECT_HUNG_TASK
2522 .procname = "hung_task_all_cpu_backtrace",
2523 .data = &sysctl_hung_task_all_cpu_backtrace,
2524 .maxlen = sizeof(int),
2526 .proc_handler = proc_dointvec_minmax,
2527 .extra1 = SYSCTL_ZERO,
2528 .extra2 = SYSCTL_ONE,
2530 #endif /* CONFIG_SMP */
2532 .procname = "hung_task_panic",
2533 .data = &sysctl_hung_task_panic,
2534 .maxlen = sizeof(int),
2536 .proc_handler = proc_dointvec_minmax,
2537 .extra1 = SYSCTL_ZERO,
2538 .extra2 = SYSCTL_ONE,
2541 .procname = "hung_task_check_count",
2542 .data = &sysctl_hung_task_check_count,
2543 .maxlen = sizeof(int),
2545 .proc_handler = proc_dointvec_minmax,
2546 .extra1 = SYSCTL_ZERO,
2549 .procname = "hung_task_timeout_secs",
2550 .data = &sysctl_hung_task_timeout_secs,
2551 .maxlen = sizeof(unsigned long),
2553 .proc_handler = proc_dohung_task_timeout_secs,
2554 .extra2 = &hung_task_timeout_max,
2557 .procname = "hung_task_check_interval_secs",
2558 .data = &sysctl_hung_task_check_interval_secs,
2559 .maxlen = sizeof(unsigned long),
2561 .proc_handler = proc_dohung_task_timeout_secs,
2562 .extra2 = &hung_task_timeout_max,
2565 .procname = "hung_task_warnings",
2566 .data = &sysctl_hung_task_warnings,
2567 .maxlen = sizeof(int),
2569 .proc_handler = proc_dointvec_minmax,
2570 .extra1 = SYSCTL_NEG_ONE,
2573 #ifdef CONFIG_RT_MUTEXES
2575 .procname = "max_lock_depth",
2576 .data = &max_lock_depth,
2577 .maxlen = sizeof(int),
2579 .proc_handler = proc_dointvec,
2583 .procname = "poweroff_cmd",
2584 .data = &poweroff_cmd,
2585 .maxlen = POWEROFF_CMD_PATH_LEN,
2587 .proc_handler = proc_dostring,
2593 .child = key_sysctls,
2596 #ifdef CONFIG_PERF_EVENTS
2598 * User-space scripts rely on the existence of this file
2599 * as a feature check for perf_events being enabled.
2601 * So it's an ABI, do not remove!
2604 .procname = "perf_event_paranoid",
2605 .data = &sysctl_perf_event_paranoid,
2606 .maxlen = sizeof(sysctl_perf_event_paranoid),
2608 .proc_handler = proc_dointvec,
2611 .procname = "perf_event_mlock_kb",
2612 .data = &sysctl_perf_event_mlock,
2613 .maxlen = sizeof(sysctl_perf_event_mlock),
2615 .proc_handler = proc_dointvec,
2618 .procname = "perf_event_max_sample_rate",
2619 .data = &sysctl_perf_event_sample_rate,
2620 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2622 .proc_handler = perf_proc_update_handler,
2623 .extra1 = SYSCTL_ONE,
2626 .procname = "perf_cpu_time_max_percent",
2627 .data = &sysctl_perf_cpu_time_max_percent,
2628 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2630 .proc_handler = perf_cpu_time_max_percent_handler,
2631 .extra1 = SYSCTL_ZERO,
2632 .extra2 = SYSCTL_ONE_HUNDRED,
2635 .procname = "perf_event_max_stack",
2636 .data = &sysctl_perf_event_max_stack,
2637 .maxlen = sizeof(sysctl_perf_event_max_stack),
2639 .proc_handler = perf_event_max_stack_handler,
2640 .extra1 = SYSCTL_ZERO,
2641 .extra2 = &six_hundred_forty_kb,
2644 .procname = "perf_event_max_contexts_per_stack",
2645 .data = &sysctl_perf_event_max_contexts_per_stack,
2646 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2648 .proc_handler = perf_event_max_stack_handler,
2649 .extra1 = SYSCTL_ZERO,
2650 .extra2 = SYSCTL_ONE_THOUSAND,
2654 .procname = "panic_on_warn",
2655 .data = &panic_on_warn,
2656 .maxlen = sizeof(int),
2658 .proc_handler = proc_dointvec_minmax,
2659 .extra1 = SYSCTL_ZERO,
2660 .extra2 = SYSCTL_ONE,
2662 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2664 .procname = "timer_migration",
2665 .data = &sysctl_timer_migration,
2666 .maxlen = sizeof(unsigned int),
2668 .proc_handler = timer_migration_handler,
2669 .extra1 = SYSCTL_ZERO,
2670 .extra2 = SYSCTL_ONE,
2673 #ifdef CONFIG_BPF_SYSCALL
2675 .procname = "unprivileged_bpf_disabled",
2676 .data = &sysctl_unprivileged_bpf_disabled,
2677 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2679 .proc_handler = bpf_unpriv_handler,
2680 .extra1 = SYSCTL_ZERO,
2681 .extra2 = SYSCTL_TWO,
2684 .procname = "bpf_stats_enabled",
2685 .data = &bpf_stats_enabled_key.key,
2686 .maxlen = sizeof(bpf_stats_enabled_key),
2688 .proc_handler = bpf_stats_handler,
2691 #if defined(CONFIG_TREE_RCU)
2693 .procname = "panic_on_rcu_stall",
2694 .data = &sysctl_panic_on_rcu_stall,
2695 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2697 .proc_handler = proc_dointvec_minmax,
2698 .extra1 = SYSCTL_ZERO,
2699 .extra2 = SYSCTL_ONE,
2702 #if defined(CONFIG_TREE_RCU)
2704 .procname = "max_rcu_stall_to_panic",
2705 .data = &sysctl_max_rcu_stall_to_panic,
2706 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2708 .proc_handler = proc_dointvec_minmax,
2709 .extra1 = SYSCTL_ONE,
2710 .extra2 = SYSCTL_INT_MAX,
2713 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2715 .procname = "stack_erasing",
2717 .maxlen = sizeof(int),
2719 .proc_handler = stack_erasing_sysctl,
2720 .extra1 = SYSCTL_ZERO,
2721 .extra2 = SYSCTL_ONE,
2727 static struct ctl_table vm_table[] = {
2729 .procname = "overcommit_memory",
2730 .data = &sysctl_overcommit_memory,
2731 .maxlen = sizeof(sysctl_overcommit_memory),
2733 .proc_handler = overcommit_policy_handler,
2734 .extra1 = SYSCTL_ZERO,
2735 .extra2 = SYSCTL_TWO,
2738 .procname = "panic_on_oom",
2739 .data = &sysctl_panic_on_oom,
2740 .maxlen = sizeof(sysctl_panic_on_oom),
2742 .proc_handler = proc_dointvec_minmax,
2743 .extra1 = SYSCTL_ZERO,
2744 .extra2 = SYSCTL_TWO,
2747 .procname = "oom_kill_allocating_task",
2748 .data = &sysctl_oom_kill_allocating_task,
2749 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2751 .proc_handler = proc_dointvec,
2754 .procname = "oom_dump_tasks",
2755 .data = &sysctl_oom_dump_tasks,
2756 .maxlen = sizeof(sysctl_oom_dump_tasks),
2758 .proc_handler = proc_dointvec,
2761 .procname = "overcommit_ratio",
2762 .data = &sysctl_overcommit_ratio,
2763 .maxlen = sizeof(sysctl_overcommit_ratio),
2765 .proc_handler = overcommit_ratio_handler,
2768 .procname = "overcommit_kbytes",
2769 .data = &sysctl_overcommit_kbytes,
2770 .maxlen = sizeof(sysctl_overcommit_kbytes),
2772 .proc_handler = overcommit_kbytes_handler,
2775 .procname = "page-cluster",
2776 .data = &page_cluster,
2777 .maxlen = sizeof(int),
2779 .proc_handler = proc_dointvec_minmax,
2780 .extra1 = SYSCTL_ZERO,
2783 .procname = "dirty_background_ratio",
2784 .data = &dirty_background_ratio,
2785 .maxlen = sizeof(dirty_background_ratio),
2787 .proc_handler = dirty_background_ratio_handler,
2788 .extra1 = SYSCTL_ZERO,
2789 .extra2 = SYSCTL_ONE_HUNDRED,
2792 .procname = "dirty_background_bytes",
2793 .data = &dirty_background_bytes,
2794 .maxlen = sizeof(dirty_background_bytes),
2796 .proc_handler = dirty_background_bytes_handler,
2800 .procname = "dirty_ratio",
2801 .data = &vm_dirty_ratio,
2802 .maxlen = sizeof(vm_dirty_ratio),
2804 .proc_handler = dirty_ratio_handler,
2805 .extra1 = SYSCTL_ZERO,
2806 .extra2 = SYSCTL_ONE_HUNDRED,
2809 .procname = "dirty_bytes",
2810 .data = &vm_dirty_bytes,
2811 .maxlen = sizeof(vm_dirty_bytes),
2813 .proc_handler = dirty_bytes_handler,
2814 .extra1 = &dirty_bytes_min,
2817 .procname = "dirty_writeback_centisecs",
2818 .data = &dirty_writeback_interval,
2819 .maxlen = sizeof(dirty_writeback_interval),
2821 .proc_handler = dirty_writeback_centisecs_handler,
2824 .procname = "dirty_expire_centisecs",
2825 .data = &dirty_expire_interval,
2826 .maxlen = sizeof(dirty_expire_interval),
2828 .proc_handler = proc_dointvec_minmax,
2829 .extra1 = SYSCTL_ZERO,
2832 .procname = "dirtytime_expire_seconds",
2833 .data = &dirtytime_expire_interval,
2834 .maxlen = sizeof(dirtytime_expire_interval),
2836 .proc_handler = dirtytime_interval_handler,
2837 .extra1 = SYSCTL_ZERO,
2840 .procname = "swappiness",
2841 .data = &vm_swappiness,
2842 .maxlen = sizeof(vm_swappiness),
2844 .proc_handler = proc_dointvec_minmax,
2845 .extra1 = SYSCTL_ZERO,
2846 .extra2 = SYSCTL_TWO_HUNDRED,
2850 .procname = "numa_stat",
2851 .data = &sysctl_vm_numa_stat,
2852 .maxlen = sizeof(int),
2854 .proc_handler = sysctl_vm_numa_stat_handler,
2855 .extra1 = SYSCTL_ZERO,
2856 .extra2 = SYSCTL_ONE,
2859 #ifdef CONFIG_HUGETLB_PAGE
2861 .procname = "nr_hugepages",
2863 .maxlen = sizeof(unsigned long),
2865 .proc_handler = hugetlb_sysctl_handler,
2869 .procname = "nr_hugepages_mempolicy",
2871 .maxlen = sizeof(unsigned long),
2873 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2877 .procname = "hugetlb_shm_group",
2878 .data = &sysctl_hugetlb_shm_group,
2879 .maxlen = sizeof(gid_t),
2881 .proc_handler = proc_dointvec,
2884 .procname = "nr_overcommit_hugepages",
2886 .maxlen = sizeof(unsigned long),
2888 .proc_handler = hugetlb_overcommit_handler,
2892 .procname = "lowmem_reserve_ratio",
2893 .data = &sysctl_lowmem_reserve_ratio,
2894 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2896 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2899 .procname = "drop_caches",
2900 .data = &sysctl_drop_caches,
2901 .maxlen = sizeof(int),
2903 .proc_handler = drop_caches_sysctl_handler,
2904 .extra1 = SYSCTL_ONE,
2905 .extra2 = SYSCTL_FOUR,
2907 #ifdef CONFIG_COMPACTION
2909 .procname = "compact_memory",
2911 .maxlen = sizeof(int),
2913 .proc_handler = sysctl_compaction_handler,
2916 .procname = "compaction_proactiveness",
2917 .data = &sysctl_compaction_proactiveness,
2918 .maxlen = sizeof(sysctl_compaction_proactiveness),
2920 .proc_handler = compaction_proactiveness_sysctl_handler,
2921 .extra1 = SYSCTL_ZERO,
2922 .extra2 = SYSCTL_ONE_HUNDRED,
2925 .procname = "extfrag_threshold",
2926 .data = &sysctl_extfrag_threshold,
2927 .maxlen = sizeof(int),
2929 .proc_handler = proc_dointvec_minmax,
2930 .extra1 = &min_extfrag_threshold,
2931 .extra2 = &max_extfrag_threshold,
2934 .procname = "compact_unevictable_allowed",
2935 .data = &sysctl_compact_unevictable_allowed,
2936 .maxlen = sizeof(int),
2938 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2939 .extra1 = SYSCTL_ZERO,
2940 .extra2 = SYSCTL_ONE,
2943 #endif /* CONFIG_COMPACTION */
2945 .procname = "min_free_kbytes",
2946 .data = &min_free_kbytes,
2947 .maxlen = sizeof(min_free_kbytes),
2949 .proc_handler = min_free_kbytes_sysctl_handler,
2950 .extra1 = SYSCTL_ZERO,
2953 .procname = "watermark_boost_factor",
2954 .data = &watermark_boost_factor,
2955 .maxlen = sizeof(watermark_boost_factor),
2957 .proc_handler = proc_dointvec_minmax,
2958 .extra1 = SYSCTL_ZERO,
2961 .procname = "watermark_scale_factor",
2962 .data = &watermark_scale_factor,
2963 .maxlen = sizeof(watermark_scale_factor),
2965 .proc_handler = watermark_scale_factor_sysctl_handler,
2966 .extra1 = SYSCTL_ONE,
2967 .extra2 = SYSCTL_THREE_THOUSAND,
2970 .procname = "percpu_pagelist_high_fraction",
2971 .data = &percpu_pagelist_high_fraction,
2972 .maxlen = sizeof(percpu_pagelist_high_fraction),
2974 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2975 .extra1 = SYSCTL_ZERO,
2978 .procname = "page_lock_unfairness",
2979 .data = &sysctl_page_lock_unfairness,
2980 .maxlen = sizeof(sysctl_page_lock_unfairness),
2982 .proc_handler = proc_dointvec_minmax,
2983 .extra1 = SYSCTL_ZERO,
2987 .procname = "max_map_count",
2988 .data = &sysctl_max_map_count,
2989 .maxlen = sizeof(sysctl_max_map_count),
2991 .proc_handler = proc_dointvec_minmax,
2992 .extra1 = SYSCTL_ZERO,
2996 .procname = "nr_trim_pages",
2997 .data = &sysctl_nr_trim_pages,
2998 .maxlen = sizeof(sysctl_nr_trim_pages),
3000 .proc_handler = proc_dointvec_minmax,
3001 .extra1 = SYSCTL_ZERO,
3005 .procname = "laptop_mode",
3006 .data = &laptop_mode,
3007 .maxlen = sizeof(laptop_mode),
3009 .proc_handler = proc_dointvec_jiffies,
3012 .procname = "vfs_cache_pressure",
3013 .data = &sysctl_vfs_cache_pressure,
3014 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3016 .proc_handler = proc_dointvec_minmax,
3017 .extra1 = SYSCTL_ZERO,
3019 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3020 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3022 .procname = "legacy_va_layout",
3023 .data = &sysctl_legacy_va_layout,
3024 .maxlen = sizeof(sysctl_legacy_va_layout),
3026 .proc_handler = proc_dointvec_minmax,
3027 .extra1 = SYSCTL_ZERO,
3032 .procname = "zone_reclaim_mode",
3033 .data = &node_reclaim_mode,
3034 .maxlen = sizeof(node_reclaim_mode),
3036 .proc_handler = proc_dointvec_minmax,
3037 .extra1 = SYSCTL_ZERO,
3040 .procname = "min_unmapped_ratio",
3041 .data = &sysctl_min_unmapped_ratio,
3042 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3044 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3045 .extra1 = SYSCTL_ZERO,
3046 .extra2 = SYSCTL_ONE_HUNDRED,
3049 .procname = "min_slab_ratio",
3050 .data = &sysctl_min_slab_ratio,
3051 .maxlen = sizeof(sysctl_min_slab_ratio),
3053 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3054 .extra1 = SYSCTL_ZERO,
3055 .extra2 = SYSCTL_ONE_HUNDRED,
3060 .procname = "stat_interval",
3061 .data = &sysctl_stat_interval,
3062 .maxlen = sizeof(sysctl_stat_interval),
3064 .proc_handler = proc_dointvec_jiffies,
3067 .procname = "stat_refresh",
3071 .proc_handler = vmstat_refresh,
3076 .procname = "mmap_min_addr",
3077 .data = &dac_mmap_min_addr,
3078 .maxlen = sizeof(unsigned long),
3080 .proc_handler = mmap_min_addr_handler,
3085 .procname = "numa_zonelist_order",
3086 .data = &numa_zonelist_order,
3087 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3089 .proc_handler = numa_zonelist_order_handler,
3092 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3093 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3095 .procname = "vdso_enabled",
3096 #ifdef CONFIG_X86_32
3097 .data = &vdso32_enabled,
3098 .maxlen = sizeof(vdso32_enabled),
3100 .data = &vdso_enabled,
3101 .maxlen = sizeof(vdso_enabled),
3104 .proc_handler = proc_dointvec,
3105 .extra1 = SYSCTL_ZERO,
3108 #ifdef CONFIG_HIGHMEM
3110 .procname = "highmem_is_dirtyable",
3111 .data = &vm_highmem_is_dirtyable,
3112 .maxlen = sizeof(vm_highmem_is_dirtyable),
3114 .proc_handler = proc_dointvec_minmax,
3115 .extra1 = SYSCTL_ZERO,
3116 .extra2 = SYSCTL_ONE,
3119 #ifdef CONFIG_MEMORY_FAILURE
3121 .procname = "memory_failure_early_kill",
3122 .data = &sysctl_memory_failure_early_kill,
3123 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3125 .proc_handler = proc_dointvec_minmax,
3126 .extra1 = SYSCTL_ZERO,
3127 .extra2 = SYSCTL_ONE,
3130 .procname = "memory_failure_recovery",
3131 .data = &sysctl_memory_failure_recovery,
3132 .maxlen = sizeof(sysctl_memory_failure_recovery),
3134 .proc_handler = proc_dointvec_minmax,
3135 .extra1 = SYSCTL_ZERO,
3136 .extra2 = SYSCTL_ONE,
3140 .procname = "user_reserve_kbytes",
3141 .data = &sysctl_user_reserve_kbytes,
3142 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3144 .proc_handler = proc_doulongvec_minmax,
3147 .procname = "admin_reserve_kbytes",
3148 .data = &sysctl_admin_reserve_kbytes,
3149 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3151 .proc_handler = proc_doulongvec_minmax,
3153 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3155 .procname = "mmap_rnd_bits",
3156 .data = &mmap_rnd_bits,
3157 .maxlen = sizeof(mmap_rnd_bits),
3159 .proc_handler = proc_dointvec_minmax,
3160 .extra1 = (void *)&mmap_rnd_bits_min,
3161 .extra2 = (void *)&mmap_rnd_bits_max,
3164 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3166 .procname = "mmap_rnd_compat_bits",
3167 .data = &mmap_rnd_compat_bits,
3168 .maxlen = sizeof(mmap_rnd_compat_bits),
3170 .proc_handler = proc_dointvec_minmax,
3171 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3172 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3175 #ifdef CONFIG_USERFAULTFD
3177 .procname = "unprivileged_userfaultfd",
3178 .data = &sysctl_unprivileged_userfaultfd,
3179 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3181 .proc_handler = proc_dointvec_minmax,
3182 .extra1 = SYSCTL_ZERO,
3183 .extra2 = SYSCTL_ONE,
3189 static struct ctl_table fs_table[] = {
3191 .procname = "inode-nr",
3192 .data = &inodes_stat,
3193 .maxlen = 2*sizeof(long),
3195 .proc_handler = proc_nr_inodes,
3198 .procname = "inode-state",
3199 .data = &inodes_stat,
3200 .maxlen = 7*sizeof(long),
3202 .proc_handler = proc_nr_inodes,
3205 .procname = "file-nr",
3206 .data = &files_stat,
3207 .maxlen = sizeof(files_stat),
3209 .proc_handler = proc_nr_files,
3212 .procname = "file-max",
3213 .data = &files_stat.max_files,
3214 .maxlen = sizeof(files_stat.max_files),
3216 .proc_handler = proc_doulongvec_minmax,
3218 .extra2 = &long_max,
3221 .procname = "nr_open",
3222 .data = &sysctl_nr_open,
3223 .maxlen = sizeof(unsigned int),
3225 .proc_handler = proc_dointvec_minmax,
3226 .extra1 = &sysctl_nr_open_min,
3227 .extra2 = &sysctl_nr_open_max,
3230 .procname = "dentry-state",
3231 .data = &dentry_stat,
3232 .maxlen = 6*sizeof(long),
3234 .proc_handler = proc_nr_dentry,
3237 .procname = "overflowuid",
3238 .data = &fs_overflowuid,
3239 .maxlen = sizeof(int),
3241 .proc_handler = proc_dointvec_minmax,
3242 .extra1 = &minolduid,
3243 .extra2 = &maxolduid,
3246 .procname = "overflowgid",
3247 .data = &fs_overflowgid,
3248 .maxlen = sizeof(int),
3250 .proc_handler = proc_dointvec_minmax,
3251 .extra1 = &minolduid,
3252 .extra2 = &maxolduid,
3254 #ifdef CONFIG_FILE_LOCKING
3256 .procname = "leases-enable",
3257 .data = &leases_enable,
3258 .maxlen = sizeof(int),
3260 .proc_handler = proc_dointvec,
3263 #ifdef CONFIG_DNOTIFY
3265 .procname = "dir-notify-enable",
3266 .data = &dir_notify_enable,
3267 .maxlen = sizeof(int),
3269 .proc_handler = proc_dointvec,
3273 #ifdef CONFIG_FILE_LOCKING
3275 .procname = "lease-break-time",
3276 .data = &lease_break_time,
3277 .maxlen = sizeof(int),
3279 .proc_handler = proc_dointvec,
3284 .procname = "aio-nr",
3286 .maxlen = sizeof(aio_nr),
3288 .proc_handler = proc_doulongvec_minmax,
3291 .procname = "aio-max-nr",
3292 .data = &aio_max_nr,
3293 .maxlen = sizeof(aio_max_nr),
3295 .proc_handler = proc_doulongvec_minmax,
3297 #endif /* CONFIG_AIO */
3298 #ifdef CONFIG_INOTIFY_USER
3300 .procname = "inotify",
3302 .child = inotify_table,
3305 #ifdef CONFIG_FANOTIFY
3307 .procname = "fanotify",
3309 .child = fanotify_table,
3314 .procname = "epoll",
3316 .child = epoll_table,
3321 .procname = "protected_symlinks",
3322 .data = &sysctl_protected_symlinks,
3323 .maxlen = sizeof(int),
3325 .proc_handler = proc_dointvec_minmax,
3326 .extra1 = SYSCTL_ZERO,
3327 .extra2 = SYSCTL_ONE,
3330 .procname = "protected_hardlinks",
3331 .data = &sysctl_protected_hardlinks,
3332 .maxlen = sizeof(int),
3334 .proc_handler = proc_dointvec_minmax,
3335 .extra1 = SYSCTL_ZERO,
3336 .extra2 = SYSCTL_ONE,
3339 .procname = "protected_fifos",
3340 .data = &sysctl_protected_fifos,
3341 .maxlen = sizeof(int),
3343 .proc_handler = proc_dointvec_minmax,
3344 .extra1 = SYSCTL_ZERO,
3345 .extra2 = SYSCTL_TWO,
3348 .procname = "protected_regular",
3349 .data = &sysctl_protected_regular,
3350 .maxlen = sizeof(int),
3352 .proc_handler = proc_dointvec_minmax,
3353 .extra1 = SYSCTL_ZERO,
3354 .extra2 = SYSCTL_TWO,
3357 .procname = "suid_dumpable",
3358 .data = &suid_dumpable,
3359 .maxlen = sizeof(int),
3361 .proc_handler = proc_dointvec_minmax_coredump,
3362 .extra1 = SYSCTL_ZERO,
3363 .extra2 = SYSCTL_TWO,
3365 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3367 .procname = "binfmt_misc",
3369 .child = sysctl_mount_point,
3373 .procname = "pipe-max-size",
3374 .data = &pipe_max_size,
3375 .maxlen = sizeof(pipe_max_size),
3377 .proc_handler = proc_dopipe_max_size,
3380 .procname = "pipe-user-pages-hard",
3381 .data = &pipe_user_pages_hard,
3382 .maxlen = sizeof(pipe_user_pages_hard),
3384 .proc_handler = proc_doulongvec_minmax,
3387 .procname = "pipe-user-pages-soft",
3388 .data = &pipe_user_pages_soft,
3389 .maxlen = sizeof(pipe_user_pages_soft),
3391 .proc_handler = proc_doulongvec_minmax,
3394 .procname = "mount-max",
3395 .data = &sysctl_mount_max,
3396 .maxlen = sizeof(unsigned int),
3398 .proc_handler = proc_dointvec_minmax,
3399 .extra1 = SYSCTL_ONE,
3404 static struct ctl_table debug_table[] = {
3405 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3407 .procname = "exception-trace",
3408 .data = &show_unhandled_signals,
3409 .maxlen = sizeof(int),
3411 .proc_handler = proc_dointvec
3414 #if defined(CONFIG_OPTPROBES)
3416 .procname = "kprobes-optimization",
3417 .data = &sysctl_kprobes_optimization,
3418 .maxlen = sizeof(int),
3420 .proc_handler = proc_kprobes_optimization_handler,
3421 .extra1 = SYSCTL_ZERO,
3422 .extra2 = SYSCTL_ONE,
3428 static struct ctl_table dev_table[] = {
3432 static struct ctl_table sysctl_base_table[] = {
3434 .procname = "kernel",
3436 .child = kern_table,
3449 .procname = "debug",
3451 .child = debug_table,
3461 int __init sysctl_init(void)
3463 struct ctl_table_header *hdr;
3465 hdr = register_sysctl_table(sysctl_base_table);
3466 kmemleak_not_leak(hdr);
3469 #endif /* CONFIG_SYSCTL */
3471 * No sense putting this after each symbol definition, twice,
3472 * exception granted :-)
3474 EXPORT_SYMBOL(proc_dobool);
3475 EXPORT_SYMBOL(proc_dointvec);
3476 EXPORT_SYMBOL(proc_douintvec);
3477 EXPORT_SYMBOL(proc_dointvec_jiffies);
3478 EXPORT_SYMBOL(proc_dointvec_minmax);
3479 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3480 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3481 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3482 EXPORT_SYMBOL(proc_dostring);
3483 EXPORT_SYMBOL(proc_doulongvec_minmax);
3484 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3485 EXPORT_SYMBOL(proc_do_large_bitmap);