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 void proc_skip_spaces(char **buf, size_t *size)
392 static void proc_skip_char(char **buf, size_t *size, const char v)
403 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
406 * @cp: kernel buffer containing the string to parse
407 * @endp: pointer to store the trailing characters
408 * @base: the base to use
409 * @res: where the parsed integer will be stored
411 * In case of success 0 is returned and @res will contain the parsed integer,
412 * @endp will hold any trailing characters.
413 * This function will fail the parse on overflow. If there wasn't an overflow
414 * the function will defer the decision what characters count as invalid to the
417 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
420 unsigned long long result;
423 cp = _parse_integer_fixup_radix(cp, &base);
424 rv = _parse_integer(cp, base, &result);
425 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
433 *res = (unsigned long)result;
439 * proc_get_long - reads an ASCII formatted integer from a user buffer
441 * @buf: a kernel buffer
442 * @size: size of the kernel buffer
443 * @val: this is where the number will be stored
444 * @neg: set to %TRUE if number is negative
445 * @perm_tr: a vector which contains the allowed trailers
446 * @perm_tr_len: size of the perm_tr vector
447 * @tr: pointer to store the trailer character
449 * In case of success %0 is returned and @buf and @size are updated with
450 * the amount of bytes read. If @tr is non-NULL and a trailing
451 * character exists (size is non-zero after returning from this
452 * function), @tr is updated with the trailing character.
454 static int proc_get_long(char **buf, size_t *size,
455 unsigned long *val, bool *neg,
456 const char *perm_tr, unsigned perm_tr_len, char *tr)
458 char *p, tmp[TMPBUFLEN];
464 if (len > TMPBUFLEN - 1)
467 memcpy(tmp, *buf, len);
471 if (*p == '-' && *size > 1) {
479 if (strtoul_lenient(p, &p, 0, val))
484 /* We don't know if the next char is whitespace thus we may accept
485 * invalid integers (e.g. 1234...a) or two integers instead of one
486 * (e.g. 123...1). So lets not allow such large numbers. */
487 if (len == TMPBUFLEN - 1)
490 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
493 if (tr && (len < *size))
503 * proc_put_long - converts an integer to a decimal ASCII formatted string
505 * @buf: the user buffer
506 * @size: the size of the user buffer
507 * @val: the integer to be converted
508 * @neg: sign of the number, %TRUE for negative
510 * In case of success @buf and @size are updated with the amount of bytes
513 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
516 char tmp[TMPBUFLEN], *p = tmp;
518 sprintf(p, "%s%lu", neg ? "-" : "", val);
522 memcpy(*buf, tmp, len);
528 static void proc_put_char(void **buf, size_t *size, char c)
531 char **buffer = (char **)buf;
540 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
542 int write, void *data)
545 *(bool *)valp = *lvalp;
547 int val = *(bool *)valp;
549 *lvalp = (unsigned long)val;
555 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
557 int write, void *data)
561 if (*lvalp > (unsigned long) INT_MAX + 1)
563 WRITE_ONCE(*valp, -*lvalp);
565 if (*lvalp > (unsigned long) INT_MAX)
567 WRITE_ONCE(*valp, *lvalp);
570 int val = READ_ONCE(*valp);
573 *lvalp = -(unsigned long)val;
576 *lvalp = (unsigned long)val;
582 static int do_proc_douintvec_conv(unsigned long *lvalp,
584 int write, void *data)
587 if (*lvalp > UINT_MAX)
589 WRITE_ONCE(*valp, *lvalp);
591 unsigned int val = READ_ONCE(*valp);
592 *lvalp = (unsigned long)val;
597 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
599 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
600 int write, void *buffer,
601 size_t *lenp, loff_t *ppos,
602 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
603 int write, void *data),
606 int *i, vleft, first = 1, err = 0;
610 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
615 i = (int *) tbl_data;
616 vleft = table->maxlen / sizeof(*i);
620 conv = do_proc_dointvec_conv;
623 if (proc_first_pos_non_zero_ignore(ppos, table))
626 if (left > PAGE_SIZE - 1)
627 left = PAGE_SIZE - 1;
631 for (; left && vleft--; i++, first=0) {
636 proc_skip_spaces(&p, &left);
640 err = proc_get_long(&p, &left, &lval, &neg,
642 sizeof(proc_wspace_sep), NULL);
645 if (conv(&neg, &lval, i, 1, data)) {
650 if (conv(&neg, &lval, i, 0, data)) {
655 proc_put_char(&buffer, &left, '\t');
656 proc_put_long(&buffer, &left, lval, neg);
660 if (!write && !first && left && !err)
661 proc_put_char(&buffer, &left, '\n');
662 if (write && !err && left)
663 proc_skip_spaces(&p, &left);
665 return err ? : -EINVAL;
672 static int do_proc_dointvec(struct ctl_table *table, int write,
673 void *buffer, size_t *lenp, loff_t *ppos,
674 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
675 int write, void *data),
678 return __do_proc_dointvec(table->data, table, write,
679 buffer, lenp, ppos, conv, data);
682 static int do_proc_douintvec_w(unsigned int *tbl_data,
683 struct ctl_table *table,
685 size_t *lenp, loff_t *ppos,
686 int (*conv)(unsigned long *lvalp,
688 int write, void *data),
699 if (proc_first_pos_non_zero_ignore(ppos, table))
702 if (left > PAGE_SIZE - 1)
703 left = PAGE_SIZE - 1;
705 proc_skip_spaces(&p, &left);
711 err = proc_get_long(&p, &left, &lval, &neg,
713 sizeof(proc_wspace_sep), NULL);
719 if (conv(&lval, tbl_data, 1, data)) {
725 proc_skip_spaces(&p, &left);
733 /* This is in keeping with old __do_proc_dointvec() */
739 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
740 size_t *lenp, loff_t *ppos,
741 int (*conv)(unsigned long *lvalp,
743 int write, void *data),
752 if (conv(&lval, tbl_data, 0, data)) {
757 proc_put_long(&buffer, &left, lval, false);
761 proc_put_char(&buffer, &left, '\n');
770 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
771 int write, void *buffer,
772 size_t *lenp, loff_t *ppos,
773 int (*conv)(unsigned long *lvalp,
775 int write, void *data),
778 unsigned int *i, vleft;
780 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
785 i = (unsigned int *) tbl_data;
786 vleft = table->maxlen / sizeof(*i);
789 * Arrays are not supported, keep this simple. *Do not* add
798 conv = do_proc_douintvec_conv;
801 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
803 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
806 static int do_proc_douintvec(struct ctl_table *table, int write,
807 void *buffer, size_t *lenp, loff_t *ppos,
808 int (*conv)(unsigned long *lvalp,
810 int write, void *data),
813 return __do_proc_douintvec(table->data, table, write,
814 buffer, lenp, ppos, conv, data);
818 * proc_dobool - read/write a bool
819 * @table: the sysctl table
820 * @write: %TRUE if this is a write to the sysctl file
821 * @buffer: the user buffer
822 * @lenp: the size of the user buffer
823 * @ppos: file position
825 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
826 * values from/to the user buffer, treated as an ASCII string.
828 * Returns 0 on success.
830 int proc_dobool(struct ctl_table *table, int write, void *buffer,
831 size_t *lenp, loff_t *ppos)
833 return do_proc_dointvec(table, write, buffer, lenp, ppos,
834 do_proc_dobool_conv, NULL);
838 * proc_dointvec - read a vector of integers
839 * @table: the sysctl table
840 * @write: %TRUE if this is a write to the sysctl file
841 * @buffer: the user buffer
842 * @lenp: the size of the user buffer
843 * @ppos: file position
845 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
846 * values from/to the user buffer, treated as an ASCII string.
848 * Returns 0 on success.
850 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
851 size_t *lenp, loff_t *ppos)
853 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
856 #ifdef CONFIG_COMPACTION
857 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
858 int write, void *buffer, size_t *lenp, loff_t *ppos)
862 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
863 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
865 old = *(int *)table->data;
866 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
869 if (old != *(int *)table->data)
870 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
871 table->procname, current->comm,
872 task_pid_nr(current));
878 * proc_douintvec - read a vector of unsigned integers
879 * @table: the sysctl table
880 * @write: %TRUE if this is a write to the sysctl file
881 * @buffer: the user buffer
882 * @lenp: the size of the user buffer
883 * @ppos: file position
885 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
886 * values from/to the user buffer, treated as an ASCII string.
888 * Returns 0 on success.
890 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
891 size_t *lenp, loff_t *ppos)
893 return do_proc_douintvec(table, write, buffer, lenp, ppos,
894 do_proc_douintvec_conv, NULL);
898 * Taint values can only be increased
899 * This means we can safely use a temporary.
901 static int proc_taint(struct ctl_table *table, int write,
902 void *buffer, size_t *lenp, loff_t *ppos)
905 unsigned long tmptaint = get_taint();
908 if (write && !capable(CAP_SYS_ADMIN))
913 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
921 * If we are relying on panic_on_taint not producing
922 * false positives due to userspace input, bail out
923 * before setting the requested taint flags.
925 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
929 * Poor man's atomic or. Not worth adding a primitive
930 * to everyone's atomic.h for this
932 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
933 if ((1UL << i) & tmptaint)
934 add_taint(i, LOCKDEP_STILL_OK);
941 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
942 void *buffer, size_t *lenp, loff_t *ppos)
944 if (write && !capable(CAP_SYS_ADMIN))
947 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
952 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
953 * @min: pointer to minimum allowable value
954 * @max: pointer to maximum allowable value
956 * The do_proc_dointvec_minmax_conv_param structure provides the
957 * minimum and maximum values for doing range checking for those sysctl
958 * parameters that use the proc_dointvec_minmax() handler.
960 struct do_proc_dointvec_minmax_conv_param {
965 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
967 int write, void *data)
970 struct do_proc_dointvec_minmax_conv_param *param = data;
972 * If writing, first do so via a temporary local int so we can
973 * bounds-check it before touching *valp.
975 int *ip = write ? &tmp : valp;
977 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
982 if ((param->min && *param->min > tmp) ||
983 (param->max && *param->max < tmp))
985 WRITE_ONCE(*valp, tmp);
992 * proc_dointvec_minmax - read a vector of integers with min/max values
993 * @table: the sysctl table
994 * @write: %TRUE if this is a write to the sysctl file
995 * @buffer: the user buffer
996 * @lenp: the size of the user buffer
997 * @ppos: file position
999 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1000 * values from/to the user buffer, treated as an ASCII string.
1002 * This routine will ensure the values are within the range specified by
1003 * table->extra1 (min) and table->extra2 (max).
1005 * Returns 0 on success or -EINVAL on write when the range check fails.
1007 int proc_dointvec_minmax(struct ctl_table *table, int write,
1008 void *buffer, size_t *lenp, loff_t *ppos)
1010 struct do_proc_dointvec_minmax_conv_param param = {
1011 .min = (int *) table->extra1,
1012 .max = (int *) table->extra2,
1014 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1015 do_proc_dointvec_minmax_conv, ¶m);
1019 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1020 * @min: pointer to minimum allowable value
1021 * @max: pointer to maximum allowable value
1023 * The do_proc_douintvec_minmax_conv_param structure provides the
1024 * minimum and maximum values for doing range checking for those sysctl
1025 * parameters that use the proc_douintvec_minmax() handler.
1027 struct do_proc_douintvec_minmax_conv_param {
1032 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1034 int write, void *data)
1038 struct do_proc_douintvec_minmax_conv_param *param = data;
1039 /* write via temporary local uint for bounds-checking */
1040 unsigned int *up = write ? &tmp : valp;
1042 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1047 if ((param->min && *param->min > tmp) ||
1048 (param->max && *param->max < tmp))
1051 WRITE_ONCE(*valp, tmp);
1058 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1059 * @table: the sysctl table
1060 * @write: %TRUE if this is a write to the sysctl file
1061 * @buffer: the user buffer
1062 * @lenp: the size of the user buffer
1063 * @ppos: file position
1065 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1066 * values from/to the user buffer, treated as an ASCII string. Negative
1067 * strings are not allowed.
1069 * This routine will ensure the values are within the range specified by
1070 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1071 * check for UINT_MAX to avoid having to support wrap around uses from
1074 * Returns 0 on success or -ERANGE on write when the range check fails.
1076 int proc_douintvec_minmax(struct ctl_table *table, int write,
1077 void *buffer, size_t *lenp, loff_t *ppos)
1079 struct do_proc_douintvec_minmax_conv_param param = {
1080 .min = (unsigned int *) table->extra1,
1081 .max = (unsigned int *) table->extra2,
1083 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1084 do_proc_douintvec_minmax_conv, ¶m);
1088 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1089 * @table: the sysctl table
1090 * @write: %TRUE if this is a write to the sysctl file
1091 * @buffer: the user buffer
1092 * @lenp: the size of the user buffer
1093 * @ppos: file position
1095 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1096 * values from/to the user buffer, treated as an ASCII string. Negative
1097 * strings are not allowed.
1099 * This routine will ensure the values are within the range specified by
1100 * table->extra1 (min) and table->extra2 (max).
1102 * Returns 0 on success or an error on write when the range check fails.
1104 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1105 void *buffer, size_t *lenp, loff_t *ppos)
1107 struct ctl_table tmp;
1108 unsigned int min = 0, max = 255U, val;
1109 u8 *data = table->data;
1110 struct do_proc_douintvec_minmax_conv_param param = {
1116 /* Do not support arrays yet. */
1117 if (table->maxlen != sizeof(u8))
1120 if (table->extra1) {
1121 min = *(unsigned int *) table->extra1;
1125 if (table->extra2) {
1126 max = *(unsigned int *) table->extra2;
1133 tmp.maxlen = sizeof(val);
1135 val = READ_ONCE(*data);
1136 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1137 do_proc_douintvec_minmax_conv, ¶m);
1141 WRITE_ONCE(*data, val);
1144 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1146 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1148 int write, void *data)
1153 val = round_pipe_size(*lvalp);
1159 unsigned int val = *valp;
1160 *lvalp = (unsigned long) val;
1166 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1167 void *buffer, size_t *lenp, loff_t *ppos)
1169 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1170 do_proc_dopipe_max_size_conv, NULL);
1173 static void validate_coredump_safety(void)
1175 #ifdef CONFIG_COREDUMP
1176 if (suid_dumpable == SUID_DUMP_ROOT &&
1177 core_pattern[0] != '/' && core_pattern[0] != '|') {
1179 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1180 "Pipe handler or fully qualified core dump path required.\n"
1181 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1187 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1188 void *buffer, size_t *lenp, loff_t *ppos)
1190 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1192 validate_coredump_safety();
1196 #ifdef CONFIG_COREDUMP
1197 static int proc_dostring_coredump(struct ctl_table *table, int write,
1198 void *buffer, size_t *lenp, loff_t *ppos)
1200 int error = proc_dostring(table, write, buffer, lenp, ppos);
1202 validate_coredump_safety();
1207 #ifdef CONFIG_MAGIC_SYSRQ
1208 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1209 void *buffer, size_t *lenp, loff_t *ppos)
1215 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1216 lenp, ppos, NULL, NULL);
1221 sysrq_toggle_support(tmp);
1227 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1228 int write, void *buffer, size_t *lenp, loff_t *ppos,
1229 unsigned long convmul, unsigned long convdiv)
1231 unsigned long *i, *min, *max;
1232 int vleft, first = 1, err = 0;
1236 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1241 i = (unsigned long *) data;
1242 min = (unsigned long *) table->extra1;
1243 max = (unsigned long *) table->extra2;
1244 vleft = table->maxlen / sizeof(unsigned long);
1248 if (proc_first_pos_non_zero_ignore(ppos, table))
1251 if (left > PAGE_SIZE - 1)
1252 left = PAGE_SIZE - 1;
1256 for (; left && vleft--; i++, first = 0) {
1262 proc_skip_spaces(&p, &left);
1266 err = proc_get_long(&p, &left, &val, &neg,
1268 sizeof(proc_wspace_sep), NULL);
1273 val = convmul * val / convdiv;
1274 if ((min && val < *min) || (max && val > *max)) {
1278 WRITE_ONCE(*i, val);
1280 val = convdiv * READ_ONCE(*i) / convmul;
1282 proc_put_char(&buffer, &left, '\t');
1283 proc_put_long(&buffer, &left, val, false);
1287 if (!write && !first && left && !err)
1288 proc_put_char(&buffer, &left, '\n');
1290 proc_skip_spaces(&p, &left);
1292 return err ? : -EINVAL;
1299 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1300 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1301 unsigned long convdiv)
1303 return __do_proc_doulongvec_minmax(table->data, table, write,
1304 buffer, lenp, ppos, convmul, convdiv);
1308 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1309 * @table: the sysctl table
1310 * @write: %TRUE if this is a write to the sysctl file
1311 * @buffer: the user buffer
1312 * @lenp: the size of the user buffer
1313 * @ppos: file position
1315 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1316 * values from/to the user buffer, treated as an ASCII string.
1318 * This routine will ensure the values are within the range specified by
1319 * table->extra1 (min) and table->extra2 (max).
1321 * Returns 0 on success.
1323 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1324 void *buffer, size_t *lenp, loff_t *ppos)
1326 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1330 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1331 * @table: the sysctl table
1332 * @write: %TRUE if this is a write to the sysctl file
1333 * @buffer: the user buffer
1334 * @lenp: the size of the user buffer
1335 * @ppos: file position
1337 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1338 * values from/to the user buffer, treated as an ASCII string. The values
1339 * are treated as milliseconds, and converted to jiffies when they are stored.
1341 * This routine will ensure the values are within the range specified by
1342 * table->extra1 (min) and table->extra2 (max).
1344 * Returns 0 on success.
1346 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1347 void *buffer, size_t *lenp, loff_t *ppos)
1349 return do_proc_doulongvec_minmax(table, write, buffer,
1350 lenp, ppos, HZ, 1000l);
1354 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1356 int write, void *data)
1359 if (*lvalp > INT_MAX / HZ)
1362 WRITE_ONCE(*valp, -*lvalp * HZ);
1364 WRITE_ONCE(*valp, *lvalp * HZ);
1366 int val = READ_ONCE(*valp);
1370 lval = -(unsigned long)val;
1373 lval = (unsigned long)val;
1380 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1382 int write, void *data)
1385 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1387 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1393 lval = -(unsigned long)val;
1396 lval = (unsigned long)val;
1398 *lvalp = jiffies_to_clock_t(lval);
1403 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1405 int write, void *data)
1408 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1412 WRITE_ONCE(*valp, (int)jif);
1414 int val = READ_ONCE(*valp);
1418 lval = -(unsigned long)val;
1421 lval = (unsigned long)val;
1423 *lvalp = jiffies_to_msecs(lval);
1429 * proc_dointvec_jiffies - read a vector of integers as seconds
1430 * @table: the sysctl table
1431 * @write: %TRUE if this is a write to the sysctl file
1432 * @buffer: the user buffer
1433 * @lenp: the size of the user buffer
1434 * @ppos: file position
1436 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1437 * values from/to the user buffer, treated as an ASCII string.
1438 * The values read are assumed to be in seconds, and are converted into
1441 * Returns 0 on success.
1443 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1444 void *buffer, size_t *lenp, loff_t *ppos)
1446 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1447 do_proc_dointvec_jiffies_conv,NULL);
1451 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1452 * @table: the sysctl table
1453 * @write: %TRUE if this is a write to the sysctl file
1454 * @buffer: the user buffer
1455 * @lenp: the size of the user buffer
1456 * @ppos: pointer to the file position
1458 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1459 * values from/to the user buffer, treated as an ASCII string.
1460 * The values read are assumed to be in 1/USER_HZ seconds, and
1461 * are converted into jiffies.
1463 * Returns 0 on success.
1465 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1466 void *buffer, size_t *lenp, loff_t *ppos)
1468 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1469 do_proc_dointvec_userhz_jiffies_conv,NULL);
1473 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1474 * @table: the sysctl table
1475 * @write: %TRUE if this is a write to the sysctl file
1476 * @buffer: the user buffer
1477 * @lenp: the size of the user buffer
1478 * @ppos: file position
1479 * @ppos: the current position in the file
1481 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1482 * values from/to the user buffer, treated as an ASCII string.
1483 * The values read are assumed to be in 1/1000 seconds, and
1484 * are converted into jiffies.
1486 * Returns 0 on success.
1488 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1489 size_t *lenp, loff_t *ppos)
1491 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1492 do_proc_dointvec_ms_jiffies_conv, NULL);
1495 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1496 size_t *lenp, loff_t *ppos)
1498 struct pid *new_pid;
1502 tmp = pid_vnr(cad_pid);
1504 r = __do_proc_dointvec(&tmp, table, write, buffer,
1505 lenp, ppos, NULL, NULL);
1509 new_pid = find_get_pid(tmp);
1513 put_pid(xchg(&cad_pid, new_pid));
1518 * proc_do_large_bitmap - read/write from/to a large bitmap
1519 * @table: the sysctl table
1520 * @write: %TRUE if this is a write to the sysctl file
1521 * @buffer: the user buffer
1522 * @lenp: the size of the user buffer
1523 * @ppos: file position
1525 * The bitmap is stored at table->data and the bitmap length (in bits)
1528 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1529 * large bitmaps may be represented in a compact manner. Writing into
1530 * the file will clear the bitmap then update it with the given input.
1532 * Returns 0 on success.
1534 int proc_do_large_bitmap(struct ctl_table *table, int write,
1535 void *buffer, size_t *lenp, loff_t *ppos)
1538 size_t left = *lenp;
1539 unsigned long bitmap_len = table->maxlen;
1540 unsigned long *bitmap = *(unsigned long **) table->data;
1541 unsigned long *tmp_bitmap = NULL;
1542 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1544 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1553 if (left > PAGE_SIZE - 1) {
1554 left = PAGE_SIZE - 1;
1555 /* How much of the buffer we'll skip this pass */
1556 skipped = *lenp - left;
1559 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1562 proc_skip_char(&p, &left, '\n');
1563 while (!err && left) {
1564 unsigned long val_a, val_b;
1568 /* In case we stop parsing mid-number, we can reset */
1570 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1573 * If we consumed the entirety of a truncated buffer or
1574 * only one char is left (may be a "-"), then stop here,
1575 * reset, & come back for more.
1577 if ((left <= 1) && skipped) {
1584 if (val_a >= bitmap_len || neg) {
1596 err = proc_get_long(&p, &left, &val_b,
1597 &neg, tr_b, sizeof(tr_b),
1600 * If we consumed all of a truncated buffer or
1601 * then stop here, reset, & come back for more.
1603 if (!left && skipped) {
1610 if (val_b >= bitmap_len || neg ||
1621 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1622 proc_skip_char(&p, &left, '\n');
1626 unsigned long bit_a, bit_b = 0;
1630 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1631 if (bit_a >= bitmap_len)
1633 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1637 proc_put_char(&buffer, &left, ',');
1638 proc_put_long(&buffer, &left, bit_a, false);
1639 if (bit_a != bit_b) {
1640 proc_put_char(&buffer, &left, '-');
1641 proc_put_long(&buffer, &left, bit_b, false);
1646 proc_put_char(&buffer, &left, '\n');
1652 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1654 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1660 bitmap_free(tmp_bitmap);
1664 #else /* CONFIG_PROC_SYSCTL */
1666 int proc_dostring(struct ctl_table *table, int write,
1667 void *buffer, size_t *lenp, loff_t *ppos)
1672 int proc_dobool(struct ctl_table *table, int write,
1673 void *buffer, size_t *lenp, loff_t *ppos)
1678 int proc_dointvec(struct ctl_table *table, int write,
1679 void *buffer, size_t *lenp, loff_t *ppos)
1684 int proc_douintvec(struct ctl_table *table, int write,
1685 void *buffer, size_t *lenp, loff_t *ppos)
1690 int proc_dointvec_minmax(struct ctl_table *table, int write,
1691 void *buffer, size_t *lenp, loff_t *ppos)
1696 int proc_douintvec_minmax(struct ctl_table *table, int write,
1697 void *buffer, size_t *lenp, loff_t *ppos)
1702 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1703 void *buffer, size_t *lenp, loff_t *ppos)
1708 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1709 void *buffer, size_t *lenp, loff_t *ppos)
1714 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1715 void *buffer, size_t *lenp, loff_t *ppos)
1720 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1721 void *buffer, size_t *lenp, loff_t *ppos)
1726 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1727 void *buffer, size_t *lenp, loff_t *ppos)
1732 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1733 void *buffer, size_t *lenp, loff_t *ppos)
1738 int proc_do_large_bitmap(struct ctl_table *table, int write,
1739 void *buffer, size_t *lenp, loff_t *ppos)
1744 #endif /* CONFIG_PROC_SYSCTL */
1746 #if defined(CONFIG_SYSCTL)
1747 int proc_do_static_key(struct ctl_table *table, int write,
1748 void *buffer, size_t *lenp, loff_t *ppos)
1750 struct static_key *key = (struct static_key *)table->data;
1751 static DEFINE_MUTEX(static_key_mutex);
1753 struct ctl_table tmp = {
1755 .maxlen = sizeof(val),
1756 .mode = table->mode,
1757 .extra1 = SYSCTL_ZERO,
1758 .extra2 = SYSCTL_ONE,
1761 if (write && !capable(CAP_SYS_ADMIN))
1764 mutex_lock(&static_key_mutex);
1765 val = static_key_enabled(key);
1766 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1767 if (write && !ret) {
1769 static_key_enable(key);
1771 static_key_disable(key);
1773 mutex_unlock(&static_key_mutex);
1777 static struct ctl_table kern_table[] = {
1779 .procname = "sched_child_runs_first",
1780 .data = &sysctl_sched_child_runs_first,
1781 .maxlen = sizeof(unsigned int),
1783 .proc_handler = proc_dointvec,
1785 #ifdef CONFIG_SCHEDSTATS
1787 .procname = "sched_schedstats",
1789 .maxlen = sizeof(unsigned int),
1791 .proc_handler = sysctl_schedstats,
1792 .extra1 = SYSCTL_ZERO,
1793 .extra2 = SYSCTL_ONE,
1795 #endif /* CONFIG_SCHEDSTATS */
1796 #ifdef CONFIG_TASK_DELAY_ACCT
1798 .procname = "task_delayacct",
1800 .maxlen = sizeof(unsigned int),
1802 .proc_handler = sysctl_delayacct,
1803 .extra1 = SYSCTL_ZERO,
1804 .extra2 = SYSCTL_ONE,
1806 #endif /* CONFIG_TASK_DELAY_ACCT */
1807 #ifdef CONFIG_NUMA_BALANCING
1809 .procname = "numa_balancing",
1810 .data = NULL, /* filled in by handler */
1811 .maxlen = sizeof(unsigned int),
1813 .proc_handler = sysctl_numa_balancing,
1814 .extra1 = SYSCTL_ZERO,
1815 .extra2 = SYSCTL_ONE,
1817 #endif /* CONFIG_NUMA_BALANCING */
1819 .procname = "sched_rt_period_us",
1820 .data = &sysctl_sched_rt_period,
1821 .maxlen = sizeof(unsigned int),
1823 .proc_handler = sched_rt_handler,
1826 .procname = "sched_rt_runtime_us",
1827 .data = &sysctl_sched_rt_runtime,
1828 .maxlen = sizeof(int),
1830 .proc_handler = sched_rt_handler,
1833 .procname = "sched_deadline_period_max_us",
1834 .data = &sysctl_sched_dl_period_max,
1835 .maxlen = sizeof(unsigned int),
1837 .proc_handler = proc_dointvec,
1840 .procname = "sched_deadline_period_min_us",
1841 .data = &sysctl_sched_dl_period_min,
1842 .maxlen = sizeof(unsigned int),
1844 .proc_handler = proc_dointvec,
1847 .procname = "sched_rr_timeslice_ms",
1848 .data = &sysctl_sched_rr_timeslice,
1849 .maxlen = sizeof(int),
1851 .proc_handler = sched_rr_handler,
1853 #ifdef CONFIG_UCLAMP_TASK
1855 .procname = "sched_util_clamp_min",
1856 .data = &sysctl_sched_uclamp_util_min,
1857 .maxlen = sizeof(unsigned int),
1859 .proc_handler = sysctl_sched_uclamp_handler,
1862 .procname = "sched_util_clamp_max",
1863 .data = &sysctl_sched_uclamp_util_max,
1864 .maxlen = sizeof(unsigned int),
1866 .proc_handler = sysctl_sched_uclamp_handler,
1869 .procname = "sched_util_clamp_min_rt_default",
1870 .data = &sysctl_sched_uclamp_util_min_rt_default,
1871 .maxlen = sizeof(unsigned int),
1873 .proc_handler = sysctl_sched_uclamp_handler,
1876 #ifdef CONFIG_SCHED_AUTOGROUP
1878 .procname = "sched_autogroup_enabled",
1879 .data = &sysctl_sched_autogroup_enabled,
1880 .maxlen = sizeof(unsigned int),
1882 .proc_handler = proc_dointvec_minmax,
1883 .extra1 = SYSCTL_ZERO,
1884 .extra2 = SYSCTL_ONE,
1887 #ifdef CONFIG_CFS_BANDWIDTH
1889 .procname = "sched_cfs_bandwidth_slice_us",
1890 .data = &sysctl_sched_cfs_bandwidth_slice,
1891 .maxlen = sizeof(unsigned int),
1893 .proc_handler = proc_dointvec_minmax,
1894 .extra1 = SYSCTL_ONE,
1897 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1899 .procname = "sched_energy_aware",
1900 .data = &sysctl_sched_energy_aware,
1901 .maxlen = sizeof(unsigned int),
1903 .proc_handler = sched_energy_aware_handler,
1904 .extra1 = SYSCTL_ZERO,
1905 .extra2 = SYSCTL_ONE,
1908 #ifdef CONFIG_PROVE_LOCKING
1910 .procname = "prove_locking",
1911 .data = &prove_locking,
1912 .maxlen = sizeof(int),
1914 .proc_handler = proc_dointvec,
1917 #ifdef CONFIG_LOCK_STAT
1919 .procname = "lock_stat",
1921 .maxlen = sizeof(int),
1923 .proc_handler = proc_dointvec,
1927 .procname = "panic",
1928 .data = &panic_timeout,
1929 .maxlen = sizeof(int),
1931 .proc_handler = proc_dointvec,
1933 #ifdef CONFIG_COREDUMP
1935 .procname = "core_uses_pid",
1936 .data = &core_uses_pid,
1937 .maxlen = sizeof(int),
1939 .proc_handler = proc_dointvec,
1942 .procname = "core_pattern",
1943 .data = core_pattern,
1944 .maxlen = CORENAME_MAX_SIZE,
1946 .proc_handler = proc_dostring_coredump,
1949 .procname = "core_pipe_limit",
1950 .data = &core_pipe_limit,
1951 .maxlen = sizeof(unsigned int),
1953 .proc_handler = proc_dointvec,
1956 #ifdef CONFIG_PROC_SYSCTL
1958 .procname = "tainted",
1959 .maxlen = sizeof(long),
1961 .proc_handler = proc_taint,
1964 .procname = "sysctl_writes_strict",
1965 .data = &sysctl_writes_strict,
1966 .maxlen = sizeof(int),
1968 .proc_handler = proc_dointvec_minmax,
1969 .extra1 = SYSCTL_NEG_ONE,
1970 .extra2 = SYSCTL_ONE,
1973 #ifdef CONFIG_LATENCYTOP
1975 .procname = "latencytop",
1976 .data = &latencytop_enabled,
1977 .maxlen = sizeof(int),
1979 .proc_handler = sysctl_latencytop,
1982 #ifdef CONFIG_BLK_DEV_INITRD
1984 .procname = "real-root-dev",
1985 .data = &real_root_dev,
1986 .maxlen = sizeof(int),
1988 .proc_handler = proc_dointvec,
1992 .procname = "print-fatal-signals",
1993 .data = &print_fatal_signals,
1994 .maxlen = sizeof(int),
1996 .proc_handler = proc_dointvec,
2000 .procname = "reboot-cmd",
2001 .data = reboot_command,
2004 .proc_handler = proc_dostring,
2007 .procname = "stop-a",
2008 .data = &stop_a_enabled,
2009 .maxlen = sizeof (int),
2011 .proc_handler = proc_dointvec,
2014 .procname = "scons-poweroff",
2015 .data = &scons_pwroff,
2016 .maxlen = sizeof (int),
2018 .proc_handler = proc_dointvec,
2021 #ifdef CONFIG_SPARC64
2023 .procname = "tsb-ratio",
2024 .data = &sysctl_tsb_ratio,
2025 .maxlen = sizeof (int),
2027 .proc_handler = proc_dointvec,
2030 #ifdef CONFIG_PARISC
2032 .procname = "soft-power",
2033 .data = &pwrsw_enabled,
2034 .maxlen = sizeof (int),
2036 .proc_handler = proc_dointvec,
2039 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2041 .procname = "unaligned-trap",
2042 .data = &unaligned_enabled,
2043 .maxlen = sizeof (int),
2045 .proc_handler = proc_dointvec,
2049 .procname = "ctrl-alt-del",
2051 .maxlen = sizeof(int),
2053 .proc_handler = proc_dointvec,
2055 #ifdef CONFIG_FUNCTION_TRACER
2057 .procname = "ftrace_enabled",
2058 .data = &ftrace_enabled,
2059 .maxlen = sizeof(int),
2061 .proc_handler = ftrace_enable_sysctl,
2064 #ifdef CONFIG_STACK_TRACER
2066 .procname = "stack_tracer_enabled",
2067 .data = &stack_tracer_enabled,
2068 .maxlen = sizeof(int),
2070 .proc_handler = stack_trace_sysctl,
2073 #ifdef CONFIG_TRACING
2075 .procname = "ftrace_dump_on_oops",
2076 .data = &ftrace_dump_on_oops,
2077 .maxlen = sizeof(int),
2079 .proc_handler = proc_dointvec,
2082 .procname = "traceoff_on_warning",
2083 .data = &__disable_trace_on_warning,
2084 .maxlen = sizeof(__disable_trace_on_warning),
2086 .proc_handler = proc_dointvec,
2089 .procname = "tracepoint_printk",
2090 .data = &tracepoint_printk,
2091 .maxlen = sizeof(tracepoint_printk),
2093 .proc_handler = tracepoint_printk_sysctl,
2096 #ifdef CONFIG_KEXEC_CORE
2098 .procname = "kexec_load_disabled",
2099 .data = &kexec_load_disabled,
2100 .maxlen = sizeof(int),
2102 /* only handle a transition from default "0" to "1" */
2103 .proc_handler = proc_dointvec_minmax,
2104 .extra1 = SYSCTL_ONE,
2105 .extra2 = SYSCTL_ONE,
2108 #ifdef CONFIG_MODULES
2110 .procname = "modprobe",
2111 .data = &modprobe_path,
2112 .maxlen = KMOD_PATH_LEN,
2114 .proc_handler = proc_dostring,
2117 .procname = "modules_disabled",
2118 .data = &modules_disabled,
2119 .maxlen = sizeof(int),
2121 /* only handle a transition from default "0" to "1" */
2122 .proc_handler = proc_dointvec_minmax,
2123 .extra1 = SYSCTL_ONE,
2124 .extra2 = SYSCTL_ONE,
2127 #ifdef CONFIG_UEVENT_HELPER
2129 .procname = "hotplug",
2130 .data = &uevent_helper,
2131 .maxlen = UEVENT_HELPER_PATH_LEN,
2133 .proc_handler = proc_dostring,
2136 #ifdef CONFIG_CHR_DEV_SG
2138 .procname = "sg-big-buff",
2139 .data = &sg_big_buff,
2140 .maxlen = sizeof (int),
2142 .proc_handler = proc_dointvec,
2145 #ifdef CONFIG_BSD_PROCESS_ACCT
2149 .maxlen = 3*sizeof(int),
2151 .proc_handler = proc_dointvec,
2154 #ifdef CONFIG_MAGIC_SYSRQ
2156 .procname = "sysrq",
2158 .maxlen = sizeof (int),
2160 .proc_handler = sysrq_sysctl_handler,
2163 #ifdef CONFIG_PROC_SYSCTL
2165 .procname = "cad_pid",
2167 .maxlen = sizeof (int),
2169 .proc_handler = proc_do_cad_pid,
2173 .procname = "threads-max",
2175 .maxlen = sizeof(int),
2177 .proc_handler = sysctl_max_threads,
2180 .procname = "random",
2182 .child = random_table,
2185 .procname = "usermodehelper",
2187 .child = usermodehelper_table,
2189 #ifdef CONFIG_FW_LOADER_USER_HELPER
2191 .procname = "firmware_config",
2193 .child = firmware_config_table,
2197 .procname = "overflowuid",
2198 .data = &overflowuid,
2199 .maxlen = sizeof(int),
2201 .proc_handler = proc_dointvec_minmax,
2202 .extra1 = &minolduid,
2203 .extra2 = &maxolduid,
2206 .procname = "overflowgid",
2207 .data = &overflowgid,
2208 .maxlen = sizeof(int),
2210 .proc_handler = proc_dointvec_minmax,
2211 .extra1 = &minolduid,
2212 .extra2 = &maxolduid,
2216 .procname = "userprocess_debug",
2217 .data = &show_unhandled_signals,
2218 .maxlen = sizeof(int),
2220 .proc_handler = proc_dointvec,
2224 .procname = "pid_max",
2226 .maxlen = sizeof (int),
2228 .proc_handler = proc_dointvec_minmax,
2229 .extra1 = &pid_max_min,
2230 .extra2 = &pid_max_max,
2233 .procname = "panic_on_oops",
2234 .data = &panic_on_oops,
2235 .maxlen = sizeof(int),
2237 .proc_handler = proc_dointvec,
2240 .procname = "panic_print",
2241 .data = &panic_print,
2242 .maxlen = sizeof(unsigned long),
2244 .proc_handler = proc_doulongvec_minmax,
2246 #if defined CONFIG_PRINTK
2248 .procname = "printk",
2249 .data = &console_loglevel,
2250 .maxlen = 4*sizeof(int),
2252 .proc_handler = proc_dointvec,
2255 .procname = "printk_ratelimit",
2256 .data = &printk_ratelimit_state.interval,
2257 .maxlen = sizeof(int),
2259 .proc_handler = proc_dointvec_jiffies,
2262 .procname = "printk_ratelimit_burst",
2263 .data = &printk_ratelimit_state.burst,
2264 .maxlen = sizeof(int),
2266 .proc_handler = proc_dointvec,
2269 .procname = "printk_delay",
2270 .data = &printk_delay_msec,
2271 .maxlen = sizeof(int),
2273 .proc_handler = proc_dointvec_minmax,
2274 .extra1 = SYSCTL_ZERO,
2275 .extra2 = &ten_thousand,
2278 .procname = "printk_devkmsg",
2279 .data = devkmsg_log_str,
2280 .maxlen = DEVKMSG_STR_MAX_SIZE,
2282 .proc_handler = devkmsg_sysctl_set_loglvl,
2285 .procname = "dmesg_restrict",
2286 .data = &dmesg_restrict,
2287 .maxlen = sizeof(int),
2289 .proc_handler = proc_dointvec_minmax_sysadmin,
2290 .extra1 = SYSCTL_ZERO,
2291 .extra2 = SYSCTL_ONE,
2294 .procname = "kptr_restrict",
2295 .data = &kptr_restrict,
2296 .maxlen = sizeof(int),
2298 .proc_handler = proc_dointvec_minmax_sysadmin,
2299 .extra1 = SYSCTL_ZERO,
2300 .extra2 = SYSCTL_TWO,
2304 .procname = "ngroups_max",
2305 .data = &ngroups_max,
2306 .maxlen = sizeof (int),
2308 .proc_handler = proc_dointvec,
2311 .procname = "cap_last_cap",
2312 .data = (void *)&cap_last_cap,
2313 .maxlen = sizeof(int),
2315 .proc_handler = proc_dointvec,
2317 #if defined(CONFIG_LOCKUP_DETECTOR)
2319 .procname = "watchdog",
2320 .data = &watchdog_user_enabled,
2321 .maxlen = sizeof(int),
2323 .proc_handler = proc_watchdog,
2324 .extra1 = SYSCTL_ZERO,
2325 .extra2 = SYSCTL_ONE,
2328 .procname = "watchdog_thresh",
2329 .data = &watchdog_thresh,
2330 .maxlen = sizeof(int),
2332 .proc_handler = proc_watchdog_thresh,
2333 .extra1 = SYSCTL_ZERO,
2337 .procname = "nmi_watchdog",
2338 .data = &nmi_watchdog_user_enabled,
2339 .maxlen = sizeof(int),
2340 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2341 .proc_handler = proc_nmi_watchdog,
2342 .extra1 = SYSCTL_ZERO,
2343 .extra2 = SYSCTL_ONE,
2346 .procname = "watchdog_cpumask",
2347 .data = &watchdog_cpumask_bits,
2350 .proc_handler = proc_watchdog_cpumask,
2352 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2354 .procname = "soft_watchdog",
2355 .data = &soft_watchdog_user_enabled,
2356 .maxlen = sizeof(int),
2358 .proc_handler = proc_soft_watchdog,
2359 .extra1 = SYSCTL_ZERO,
2360 .extra2 = SYSCTL_ONE,
2363 .procname = "softlockup_panic",
2364 .data = &softlockup_panic,
2365 .maxlen = sizeof(int),
2367 .proc_handler = proc_dointvec_minmax,
2368 .extra1 = SYSCTL_ZERO,
2369 .extra2 = SYSCTL_ONE,
2373 .procname = "softlockup_all_cpu_backtrace",
2374 .data = &sysctl_softlockup_all_cpu_backtrace,
2375 .maxlen = sizeof(int),
2377 .proc_handler = proc_dointvec_minmax,
2378 .extra1 = SYSCTL_ZERO,
2379 .extra2 = SYSCTL_ONE,
2381 #endif /* CONFIG_SMP */
2383 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2385 .procname = "hardlockup_panic",
2386 .data = &hardlockup_panic,
2387 .maxlen = sizeof(int),
2389 .proc_handler = proc_dointvec_minmax,
2390 .extra1 = SYSCTL_ZERO,
2391 .extra2 = SYSCTL_ONE,
2395 .procname = "hardlockup_all_cpu_backtrace",
2396 .data = &sysctl_hardlockup_all_cpu_backtrace,
2397 .maxlen = sizeof(int),
2399 .proc_handler = proc_dointvec_minmax,
2400 .extra1 = SYSCTL_ZERO,
2401 .extra2 = SYSCTL_ONE,
2403 #endif /* CONFIG_SMP */
2407 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2409 .procname = "unknown_nmi_panic",
2410 .data = &unknown_nmi_panic,
2411 .maxlen = sizeof (int),
2413 .proc_handler = proc_dointvec,
2417 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2418 defined(CONFIG_DEBUG_STACKOVERFLOW)
2420 .procname = "panic_on_stackoverflow",
2421 .data = &sysctl_panic_on_stackoverflow,
2422 .maxlen = sizeof(int),
2424 .proc_handler = proc_dointvec,
2427 #if defined(CONFIG_X86)
2429 .procname = "panic_on_unrecovered_nmi",
2430 .data = &panic_on_unrecovered_nmi,
2431 .maxlen = sizeof(int),
2433 .proc_handler = proc_dointvec,
2436 .procname = "panic_on_io_nmi",
2437 .data = &panic_on_io_nmi,
2438 .maxlen = sizeof(int),
2440 .proc_handler = proc_dointvec,
2443 .procname = "bootloader_type",
2444 .data = &bootloader_type,
2445 .maxlen = sizeof (int),
2447 .proc_handler = proc_dointvec,
2450 .procname = "bootloader_version",
2451 .data = &bootloader_version,
2452 .maxlen = sizeof (int),
2454 .proc_handler = proc_dointvec,
2457 .procname = "io_delay_type",
2458 .data = &io_delay_type,
2459 .maxlen = sizeof(int),
2461 .proc_handler = proc_dointvec,
2464 #if defined(CONFIG_MMU)
2466 .procname = "randomize_va_space",
2467 .data = &randomize_va_space,
2468 .maxlen = sizeof(int),
2470 .proc_handler = proc_dointvec,
2473 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2475 .procname = "spin_retry",
2476 .data = &spin_retry,
2477 .maxlen = sizeof (int),
2479 .proc_handler = proc_dointvec,
2482 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2484 .procname = "acpi_video_flags",
2485 .data = &acpi_realmode_flags,
2486 .maxlen = sizeof (unsigned long),
2488 .proc_handler = proc_doulongvec_minmax,
2491 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2493 .procname = "ignore-unaligned-usertrap",
2494 .data = &no_unaligned_warning,
2495 .maxlen = sizeof (int),
2497 .proc_handler = proc_dointvec,
2502 .procname = "unaligned-dump-stack",
2503 .data = &unaligned_dump_stack,
2504 .maxlen = sizeof (int),
2506 .proc_handler = proc_dointvec,
2509 #ifdef CONFIG_DETECT_HUNG_TASK
2512 .procname = "hung_task_all_cpu_backtrace",
2513 .data = &sysctl_hung_task_all_cpu_backtrace,
2514 .maxlen = sizeof(int),
2516 .proc_handler = proc_dointvec_minmax,
2517 .extra1 = SYSCTL_ZERO,
2518 .extra2 = SYSCTL_ONE,
2520 #endif /* CONFIG_SMP */
2522 .procname = "hung_task_panic",
2523 .data = &sysctl_hung_task_panic,
2524 .maxlen = sizeof(int),
2526 .proc_handler = proc_dointvec_minmax,
2527 .extra1 = SYSCTL_ZERO,
2528 .extra2 = SYSCTL_ONE,
2531 .procname = "hung_task_check_count",
2532 .data = &sysctl_hung_task_check_count,
2533 .maxlen = sizeof(int),
2535 .proc_handler = proc_dointvec_minmax,
2536 .extra1 = SYSCTL_ZERO,
2539 .procname = "hung_task_timeout_secs",
2540 .data = &sysctl_hung_task_timeout_secs,
2541 .maxlen = sizeof(unsigned long),
2543 .proc_handler = proc_dohung_task_timeout_secs,
2544 .extra2 = &hung_task_timeout_max,
2547 .procname = "hung_task_check_interval_secs",
2548 .data = &sysctl_hung_task_check_interval_secs,
2549 .maxlen = sizeof(unsigned long),
2551 .proc_handler = proc_dohung_task_timeout_secs,
2552 .extra2 = &hung_task_timeout_max,
2555 .procname = "hung_task_warnings",
2556 .data = &sysctl_hung_task_warnings,
2557 .maxlen = sizeof(int),
2559 .proc_handler = proc_dointvec_minmax,
2560 .extra1 = SYSCTL_NEG_ONE,
2563 #ifdef CONFIG_RT_MUTEXES
2565 .procname = "max_lock_depth",
2566 .data = &max_lock_depth,
2567 .maxlen = sizeof(int),
2569 .proc_handler = proc_dointvec,
2573 .procname = "poweroff_cmd",
2574 .data = &poweroff_cmd,
2575 .maxlen = POWEROFF_CMD_PATH_LEN,
2577 .proc_handler = proc_dostring,
2583 .child = key_sysctls,
2586 #ifdef CONFIG_PERF_EVENTS
2588 * User-space scripts rely on the existence of this file
2589 * as a feature check for perf_events being enabled.
2591 * So it's an ABI, do not remove!
2594 .procname = "perf_event_paranoid",
2595 .data = &sysctl_perf_event_paranoid,
2596 .maxlen = sizeof(sysctl_perf_event_paranoid),
2598 .proc_handler = proc_dointvec,
2601 .procname = "perf_event_mlock_kb",
2602 .data = &sysctl_perf_event_mlock,
2603 .maxlen = sizeof(sysctl_perf_event_mlock),
2605 .proc_handler = proc_dointvec,
2608 .procname = "perf_event_max_sample_rate",
2609 .data = &sysctl_perf_event_sample_rate,
2610 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2612 .proc_handler = perf_proc_update_handler,
2613 .extra1 = SYSCTL_ONE,
2616 .procname = "perf_cpu_time_max_percent",
2617 .data = &sysctl_perf_cpu_time_max_percent,
2618 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2620 .proc_handler = perf_cpu_time_max_percent_handler,
2621 .extra1 = SYSCTL_ZERO,
2622 .extra2 = SYSCTL_ONE_HUNDRED,
2625 .procname = "perf_event_max_stack",
2626 .data = &sysctl_perf_event_max_stack,
2627 .maxlen = sizeof(sysctl_perf_event_max_stack),
2629 .proc_handler = perf_event_max_stack_handler,
2630 .extra1 = SYSCTL_ZERO,
2631 .extra2 = &six_hundred_forty_kb,
2634 .procname = "perf_event_max_contexts_per_stack",
2635 .data = &sysctl_perf_event_max_contexts_per_stack,
2636 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2638 .proc_handler = perf_event_max_stack_handler,
2639 .extra1 = SYSCTL_ZERO,
2640 .extra2 = SYSCTL_ONE_THOUSAND,
2644 .procname = "panic_on_warn",
2645 .data = &panic_on_warn,
2646 .maxlen = sizeof(int),
2648 .proc_handler = proc_dointvec_minmax,
2649 .extra1 = SYSCTL_ZERO,
2650 .extra2 = SYSCTL_ONE,
2652 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2654 .procname = "timer_migration",
2655 .data = &sysctl_timer_migration,
2656 .maxlen = sizeof(unsigned int),
2658 .proc_handler = timer_migration_handler,
2659 .extra1 = SYSCTL_ZERO,
2660 .extra2 = SYSCTL_ONE,
2663 #ifdef CONFIG_BPF_SYSCALL
2665 .procname = "unprivileged_bpf_disabled",
2666 .data = &sysctl_unprivileged_bpf_disabled,
2667 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2669 .proc_handler = bpf_unpriv_handler,
2670 .extra1 = SYSCTL_ZERO,
2671 .extra2 = SYSCTL_TWO,
2674 .procname = "bpf_stats_enabled",
2675 .data = &bpf_stats_enabled_key.key,
2676 .maxlen = sizeof(bpf_stats_enabled_key),
2678 .proc_handler = bpf_stats_handler,
2681 #if defined(CONFIG_TREE_RCU)
2683 .procname = "panic_on_rcu_stall",
2684 .data = &sysctl_panic_on_rcu_stall,
2685 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2687 .proc_handler = proc_dointvec_minmax,
2688 .extra1 = SYSCTL_ZERO,
2689 .extra2 = SYSCTL_ONE,
2692 #if defined(CONFIG_TREE_RCU)
2694 .procname = "max_rcu_stall_to_panic",
2695 .data = &sysctl_max_rcu_stall_to_panic,
2696 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2698 .proc_handler = proc_dointvec_minmax,
2699 .extra1 = SYSCTL_ONE,
2700 .extra2 = SYSCTL_INT_MAX,
2703 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2705 .procname = "stack_erasing",
2707 .maxlen = sizeof(int),
2709 .proc_handler = stack_erasing_sysctl,
2710 .extra1 = SYSCTL_ZERO,
2711 .extra2 = SYSCTL_ONE,
2717 static struct ctl_table vm_table[] = {
2719 .procname = "overcommit_memory",
2720 .data = &sysctl_overcommit_memory,
2721 .maxlen = sizeof(sysctl_overcommit_memory),
2723 .proc_handler = overcommit_policy_handler,
2724 .extra1 = SYSCTL_ZERO,
2725 .extra2 = SYSCTL_TWO,
2728 .procname = "panic_on_oom",
2729 .data = &sysctl_panic_on_oom,
2730 .maxlen = sizeof(sysctl_panic_on_oom),
2732 .proc_handler = proc_dointvec_minmax,
2733 .extra1 = SYSCTL_ZERO,
2734 .extra2 = SYSCTL_TWO,
2737 .procname = "oom_kill_allocating_task",
2738 .data = &sysctl_oom_kill_allocating_task,
2739 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2741 .proc_handler = proc_dointvec,
2744 .procname = "oom_dump_tasks",
2745 .data = &sysctl_oom_dump_tasks,
2746 .maxlen = sizeof(sysctl_oom_dump_tasks),
2748 .proc_handler = proc_dointvec,
2751 .procname = "overcommit_ratio",
2752 .data = &sysctl_overcommit_ratio,
2753 .maxlen = sizeof(sysctl_overcommit_ratio),
2755 .proc_handler = overcommit_ratio_handler,
2758 .procname = "overcommit_kbytes",
2759 .data = &sysctl_overcommit_kbytes,
2760 .maxlen = sizeof(sysctl_overcommit_kbytes),
2762 .proc_handler = overcommit_kbytes_handler,
2765 .procname = "page-cluster",
2766 .data = &page_cluster,
2767 .maxlen = sizeof(int),
2769 .proc_handler = proc_dointvec_minmax,
2770 .extra1 = SYSCTL_ZERO,
2773 .procname = "dirty_background_ratio",
2774 .data = &dirty_background_ratio,
2775 .maxlen = sizeof(dirty_background_ratio),
2777 .proc_handler = dirty_background_ratio_handler,
2778 .extra1 = SYSCTL_ZERO,
2779 .extra2 = SYSCTL_ONE_HUNDRED,
2782 .procname = "dirty_background_bytes",
2783 .data = &dirty_background_bytes,
2784 .maxlen = sizeof(dirty_background_bytes),
2786 .proc_handler = dirty_background_bytes_handler,
2790 .procname = "dirty_ratio",
2791 .data = &vm_dirty_ratio,
2792 .maxlen = sizeof(vm_dirty_ratio),
2794 .proc_handler = dirty_ratio_handler,
2795 .extra1 = SYSCTL_ZERO,
2796 .extra2 = SYSCTL_ONE_HUNDRED,
2799 .procname = "dirty_bytes",
2800 .data = &vm_dirty_bytes,
2801 .maxlen = sizeof(vm_dirty_bytes),
2803 .proc_handler = dirty_bytes_handler,
2804 .extra1 = &dirty_bytes_min,
2807 .procname = "dirty_writeback_centisecs",
2808 .data = &dirty_writeback_interval,
2809 .maxlen = sizeof(dirty_writeback_interval),
2811 .proc_handler = dirty_writeback_centisecs_handler,
2814 .procname = "dirty_expire_centisecs",
2815 .data = &dirty_expire_interval,
2816 .maxlen = sizeof(dirty_expire_interval),
2818 .proc_handler = proc_dointvec_minmax,
2819 .extra1 = SYSCTL_ZERO,
2822 .procname = "dirtytime_expire_seconds",
2823 .data = &dirtytime_expire_interval,
2824 .maxlen = sizeof(dirtytime_expire_interval),
2826 .proc_handler = dirtytime_interval_handler,
2827 .extra1 = SYSCTL_ZERO,
2830 .procname = "swappiness",
2831 .data = &vm_swappiness,
2832 .maxlen = sizeof(vm_swappiness),
2834 .proc_handler = proc_dointvec_minmax,
2835 .extra1 = SYSCTL_ZERO,
2836 .extra2 = SYSCTL_TWO_HUNDRED,
2840 .procname = "numa_stat",
2841 .data = &sysctl_vm_numa_stat,
2842 .maxlen = sizeof(int),
2844 .proc_handler = sysctl_vm_numa_stat_handler,
2845 .extra1 = SYSCTL_ZERO,
2846 .extra2 = SYSCTL_ONE,
2849 #ifdef CONFIG_HUGETLB_PAGE
2851 .procname = "nr_hugepages",
2853 .maxlen = sizeof(unsigned long),
2855 .proc_handler = hugetlb_sysctl_handler,
2859 .procname = "nr_hugepages_mempolicy",
2861 .maxlen = sizeof(unsigned long),
2863 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2867 .procname = "hugetlb_shm_group",
2868 .data = &sysctl_hugetlb_shm_group,
2869 .maxlen = sizeof(gid_t),
2871 .proc_handler = proc_dointvec,
2874 .procname = "nr_overcommit_hugepages",
2876 .maxlen = sizeof(unsigned long),
2878 .proc_handler = hugetlb_overcommit_handler,
2882 .procname = "lowmem_reserve_ratio",
2883 .data = &sysctl_lowmem_reserve_ratio,
2884 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2886 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2889 .procname = "drop_caches",
2890 .data = &sysctl_drop_caches,
2891 .maxlen = sizeof(int),
2893 .proc_handler = drop_caches_sysctl_handler,
2894 .extra1 = SYSCTL_ONE,
2895 .extra2 = SYSCTL_FOUR,
2897 #ifdef CONFIG_COMPACTION
2899 .procname = "compact_memory",
2901 .maxlen = sizeof(int),
2903 .proc_handler = sysctl_compaction_handler,
2906 .procname = "compaction_proactiveness",
2907 .data = &sysctl_compaction_proactiveness,
2908 .maxlen = sizeof(sysctl_compaction_proactiveness),
2910 .proc_handler = compaction_proactiveness_sysctl_handler,
2911 .extra1 = SYSCTL_ZERO,
2912 .extra2 = SYSCTL_ONE_HUNDRED,
2915 .procname = "extfrag_threshold",
2916 .data = &sysctl_extfrag_threshold,
2917 .maxlen = sizeof(int),
2919 .proc_handler = proc_dointvec_minmax,
2920 .extra1 = &min_extfrag_threshold,
2921 .extra2 = &max_extfrag_threshold,
2924 .procname = "compact_unevictable_allowed",
2925 .data = &sysctl_compact_unevictable_allowed,
2926 .maxlen = sizeof(int),
2928 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2929 .extra1 = SYSCTL_ZERO,
2930 .extra2 = SYSCTL_ONE,
2933 #endif /* CONFIG_COMPACTION */
2935 .procname = "min_free_kbytes",
2936 .data = &min_free_kbytes,
2937 .maxlen = sizeof(min_free_kbytes),
2939 .proc_handler = min_free_kbytes_sysctl_handler,
2940 .extra1 = SYSCTL_ZERO,
2943 .procname = "watermark_boost_factor",
2944 .data = &watermark_boost_factor,
2945 .maxlen = sizeof(watermark_boost_factor),
2947 .proc_handler = proc_dointvec_minmax,
2948 .extra1 = SYSCTL_ZERO,
2951 .procname = "watermark_scale_factor",
2952 .data = &watermark_scale_factor,
2953 .maxlen = sizeof(watermark_scale_factor),
2955 .proc_handler = watermark_scale_factor_sysctl_handler,
2956 .extra1 = SYSCTL_ONE,
2957 .extra2 = SYSCTL_THREE_THOUSAND,
2960 .procname = "percpu_pagelist_high_fraction",
2961 .data = &percpu_pagelist_high_fraction,
2962 .maxlen = sizeof(percpu_pagelist_high_fraction),
2964 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2965 .extra1 = SYSCTL_ZERO,
2968 .procname = "page_lock_unfairness",
2969 .data = &sysctl_page_lock_unfairness,
2970 .maxlen = sizeof(sysctl_page_lock_unfairness),
2972 .proc_handler = proc_dointvec_minmax,
2973 .extra1 = SYSCTL_ZERO,
2977 .procname = "max_map_count",
2978 .data = &sysctl_max_map_count,
2979 .maxlen = sizeof(sysctl_max_map_count),
2981 .proc_handler = proc_dointvec_minmax,
2982 .extra1 = SYSCTL_ZERO,
2986 .procname = "nr_trim_pages",
2987 .data = &sysctl_nr_trim_pages,
2988 .maxlen = sizeof(sysctl_nr_trim_pages),
2990 .proc_handler = proc_dointvec_minmax,
2991 .extra1 = SYSCTL_ZERO,
2995 .procname = "laptop_mode",
2996 .data = &laptop_mode,
2997 .maxlen = sizeof(laptop_mode),
2999 .proc_handler = proc_dointvec_jiffies,
3002 .procname = "vfs_cache_pressure",
3003 .data = &sysctl_vfs_cache_pressure,
3004 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3006 .proc_handler = proc_dointvec_minmax,
3007 .extra1 = SYSCTL_ZERO,
3009 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3010 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3012 .procname = "legacy_va_layout",
3013 .data = &sysctl_legacy_va_layout,
3014 .maxlen = sizeof(sysctl_legacy_va_layout),
3016 .proc_handler = proc_dointvec_minmax,
3017 .extra1 = SYSCTL_ZERO,
3022 .procname = "zone_reclaim_mode",
3023 .data = &node_reclaim_mode,
3024 .maxlen = sizeof(node_reclaim_mode),
3026 .proc_handler = proc_dointvec_minmax,
3027 .extra1 = SYSCTL_ZERO,
3030 .procname = "min_unmapped_ratio",
3031 .data = &sysctl_min_unmapped_ratio,
3032 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3034 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3035 .extra1 = SYSCTL_ZERO,
3036 .extra2 = SYSCTL_ONE_HUNDRED,
3039 .procname = "min_slab_ratio",
3040 .data = &sysctl_min_slab_ratio,
3041 .maxlen = sizeof(sysctl_min_slab_ratio),
3043 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3044 .extra1 = SYSCTL_ZERO,
3045 .extra2 = SYSCTL_ONE_HUNDRED,
3050 .procname = "stat_interval",
3051 .data = &sysctl_stat_interval,
3052 .maxlen = sizeof(sysctl_stat_interval),
3054 .proc_handler = proc_dointvec_jiffies,
3057 .procname = "stat_refresh",
3061 .proc_handler = vmstat_refresh,
3066 .procname = "mmap_min_addr",
3067 .data = &dac_mmap_min_addr,
3068 .maxlen = sizeof(unsigned long),
3070 .proc_handler = mmap_min_addr_handler,
3075 .procname = "numa_zonelist_order",
3076 .data = &numa_zonelist_order,
3077 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3079 .proc_handler = numa_zonelist_order_handler,
3082 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3083 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3085 .procname = "vdso_enabled",
3086 #ifdef CONFIG_X86_32
3087 .data = &vdso32_enabled,
3088 .maxlen = sizeof(vdso32_enabled),
3090 .data = &vdso_enabled,
3091 .maxlen = sizeof(vdso_enabled),
3094 .proc_handler = proc_dointvec,
3095 .extra1 = SYSCTL_ZERO,
3098 #ifdef CONFIG_HIGHMEM
3100 .procname = "highmem_is_dirtyable",
3101 .data = &vm_highmem_is_dirtyable,
3102 .maxlen = sizeof(vm_highmem_is_dirtyable),
3104 .proc_handler = proc_dointvec_minmax,
3105 .extra1 = SYSCTL_ZERO,
3106 .extra2 = SYSCTL_ONE,
3109 #ifdef CONFIG_MEMORY_FAILURE
3111 .procname = "memory_failure_early_kill",
3112 .data = &sysctl_memory_failure_early_kill,
3113 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3115 .proc_handler = proc_dointvec_minmax,
3116 .extra1 = SYSCTL_ZERO,
3117 .extra2 = SYSCTL_ONE,
3120 .procname = "memory_failure_recovery",
3121 .data = &sysctl_memory_failure_recovery,
3122 .maxlen = sizeof(sysctl_memory_failure_recovery),
3124 .proc_handler = proc_dointvec_minmax,
3125 .extra1 = SYSCTL_ZERO,
3126 .extra2 = SYSCTL_ONE,
3130 .procname = "user_reserve_kbytes",
3131 .data = &sysctl_user_reserve_kbytes,
3132 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3134 .proc_handler = proc_doulongvec_minmax,
3137 .procname = "admin_reserve_kbytes",
3138 .data = &sysctl_admin_reserve_kbytes,
3139 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3141 .proc_handler = proc_doulongvec_minmax,
3143 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3145 .procname = "mmap_rnd_bits",
3146 .data = &mmap_rnd_bits,
3147 .maxlen = sizeof(mmap_rnd_bits),
3149 .proc_handler = proc_dointvec_minmax,
3150 .extra1 = (void *)&mmap_rnd_bits_min,
3151 .extra2 = (void *)&mmap_rnd_bits_max,
3154 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3156 .procname = "mmap_rnd_compat_bits",
3157 .data = &mmap_rnd_compat_bits,
3158 .maxlen = sizeof(mmap_rnd_compat_bits),
3160 .proc_handler = proc_dointvec_minmax,
3161 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3162 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3165 #ifdef CONFIG_USERFAULTFD
3167 .procname = "unprivileged_userfaultfd",
3168 .data = &sysctl_unprivileged_userfaultfd,
3169 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3171 .proc_handler = proc_dointvec_minmax,
3172 .extra1 = SYSCTL_ZERO,
3173 .extra2 = SYSCTL_ONE,
3179 static struct ctl_table fs_table[] = {
3181 .procname = "inode-nr",
3182 .data = &inodes_stat,
3183 .maxlen = 2*sizeof(long),
3185 .proc_handler = proc_nr_inodes,
3188 .procname = "inode-state",
3189 .data = &inodes_stat,
3190 .maxlen = 7*sizeof(long),
3192 .proc_handler = proc_nr_inodes,
3195 .procname = "file-nr",
3196 .data = &files_stat,
3197 .maxlen = sizeof(files_stat),
3199 .proc_handler = proc_nr_files,
3202 .procname = "file-max",
3203 .data = &files_stat.max_files,
3204 .maxlen = sizeof(files_stat.max_files),
3206 .proc_handler = proc_doulongvec_minmax,
3208 .extra2 = &long_max,
3211 .procname = "nr_open",
3212 .data = &sysctl_nr_open,
3213 .maxlen = sizeof(unsigned int),
3215 .proc_handler = proc_dointvec_minmax,
3216 .extra1 = &sysctl_nr_open_min,
3217 .extra2 = &sysctl_nr_open_max,
3220 .procname = "dentry-state",
3221 .data = &dentry_stat,
3222 .maxlen = 6*sizeof(long),
3224 .proc_handler = proc_nr_dentry,
3227 .procname = "overflowuid",
3228 .data = &fs_overflowuid,
3229 .maxlen = sizeof(int),
3231 .proc_handler = proc_dointvec_minmax,
3232 .extra1 = &minolduid,
3233 .extra2 = &maxolduid,
3236 .procname = "overflowgid",
3237 .data = &fs_overflowgid,
3238 .maxlen = sizeof(int),
3240 .proc_handler = proc_dointvec_minmax,
3241 .extra1 = &minolduid,
3242 .extra2 = &maxolduid,
3244 #ifdef CONFIG_FILE_LOCKING
3246 .procname = "leases-enable",
3247 .data = &leases_enable,
3248 .maxlen = sizeof(int),
3250 .proc_handler = proc_dointvec,
3253 #ifdef CONFIG_DNOTIFY
3255 .procname = "dir-notify-enable",
3256 .data = &dir_notify_enable,
3257 .maxlen = sizeof(int),
3259 .proc_handler = proc_dointvec,
3263 #ifdef CONFIG_FILE_LOCKING
3265 .procname = "lease-break-time",
3266 .data = &lease_break_time,
3267 .maxlen = sizeof(int),
3269 .proc_handler = proc_dointvec,
3274 .procname = "aio-nr",
3276 .maxlen = sizeof(aio_nr),
3278 .proc_handler = proc_doulongvec_minmax,
3281 .procname = "aio-max-nr",
3282 .data = &aio_max_nr,
3283 .maxlen = sizeof(aio_max_nr),
3285 .proc_handler = proc_doulongvec_minmax,
3287 #endif /* CONFIG_AIO */
3288 #ifdef CONFIG_INOTIFY_USER
3290 .procname = "inotify",
3292 .child = inotify_table,
3295 #ifdef CONFIG_FANOTIFY
3297 .procname = "fanotify",
3299 .child = fanotify_table,
3304 .procname = "epoll",
3306 .child = epoll_table,
3311 .procname = "protected_symlinks",
3312 .data = &sysctl_protected_symlinks,
3313 .maxlen = sizeof(int),
3315 .proc_handler = proc_dointvec_minmax,
3316 .extra1 = SYSCTL_ZERO,
3317 .extra2 = SYSCTL_ONE,
3320 .procname = "protected_hardlinks",
3321 .data = &sysctl_protected_hardlinks,
3322 .maxlen = sizeof(int),
3324 .proc_handler = proc_dointvec_minmax,
3325 .extra1 = SYSCTL_ZERO,
3326 .extra2 = SYSCTL_ONE,
3329 .procname = "protected_fifos",
3330 .data = &sysctl_protected_fifos,
3331 .maxlen = sizeof(int),
3333 .proc_handler = proc_dointvec_minmax,
3334 .extra1 = SYSCTL_ZERO,
3335 .extra2 = SYSCTL_TWO,
3338 .procname = "protected_regular",
3339 .data = &sysctl_protected_regular,
3340 .maxlen = sizeof(int),
3342 .proc_handler = proc_dointvec_minmax,
3343 .extra1 = SYSCTL_ZERO,
3344 .extra2 = SYSCTL_TWO,
3347 .procname = "suid_dumpable",
3348 .data = &suid_dumpable,
3349 .maxlen = sizeof(int),
3351 .proc_handler = proc_dointvec_minmax_coredump,
3352 .extra1 = SYSCTL_ZERO,
3353 .extra2 = SYSCTL_TWO,
3355 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3357 .procname = "binfmt_misc",
3359 .child = sysctl_mount_point,
3363 .procname = "pipe-max-size",
3364 .data = &pipe_max_size,
3365 .maxlen = sizeof(pipe_max_size),
3367 .proc_handler = proc_dopipe_max_size,
3370 .procname = "pipe-user-pages-hard",
3371 .data = &pipe_user_pages_hard,
3372 .maxlen = sizeof(pipe_user_pages_hard),
3374 .proc_handler = proc_doulongvec_minmax,
3377 .procname = "pipe-user-pages-soft",
3378 .data = &pipe_user_pages_soft,
3379 .maxlen = sizeof(pipe_user_pages_soft),
3381 .proc_handler = proc_doulongvec_minmax,
3384 .procname = "mount-max",
3385 .data = &sysctl_mount_max,
3386 .maxlen = sizeof(unsigned int),
3388 .proc_handler = proc_dointvec_minmax,
3389 .extra1 = SYSCTL_ONE,
3394 static struct ctl_table debug_table[] = {
3395 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3397 .procname = "exception-trace",
3398 .data = &show_unhandled_signals,
3399 .maxlen = sizeof(int),
3401 .proc_handler = proc_dointvec
3404 #if defined(CONFIG_OPTPROBES)
3406 .procname = "kprobes-optimization",
3407 .data = &sysctl_kprobes_optimization,
3408 .maxlen = sizeof(int),
3410 .proc_handler = proc_kprobes_optimization_handler,
3411 .extra1 = SYSCTL_ZERO,
3412 .extra2 = SYSCTL_ONE,
3418 static struct ctl_table dev_table[] = {
3422 static struct ctl_table sysctl_base_table[] = {
3424 .procname = "kernel",
3426 .child = kern_table,
3439 .procname = "debug",
3441 .child = debug_table,
3451 int __init sysctl_init(void)
3453 struct ctl_table_header *hdr;
3455 hdr = register_sysctl_table(sysctl_base_table);
3456 kmemleak_not_leak(hdr);
3459 #endif /* CONFIG_SYSCTL */
3461 * No sense putting this after each symbol definition, twice,
3462 * exception granted :-)
3464 EXPORT_SYMBOL(proc_dobool);
3465 EXPORT_SYMBOL(proc_dointvec);
3466 EXPORT_SYMBOL(proc_douintvec);
3467 EXPORT_SYMBOL(proc_dointvec_jiffies);
3468 EXPORT_SYMBOL(proc_dointvec_minmax);
3469 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3470 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3471 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3472 EXPORT_SYMBOL(proc_dostring);
3473 EXPORT_SYMBOL(proc_doulongvec_minmax);
3474 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3475 EXPORT_SYMBOL(proc_do_large_bitmap);