1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/sched/coredump.h>
67 #include <linux/kexec.h>
68 #include <linux/bpf.h>
69 #include <linux/mount.h>
70 #include <linux/userfaultfd_k.h>
71 #include <linux/coredump.h>
72 #include <linux/latencytop.h>
73 #include <linux/pid.h>
75 #include "../lib/kstrtox.h"
77 #include <linux/uaccess.h>
78 #include <asm/processor.h>
82 #include <asm/stacktrace.h>
86 #include <asm/setup.h>
88 #ifdef CONFIG_BSD_PROCESS_ACCT
89 #include <linux/acct.h>
91 #ifdef CONFIG_RT_MUTEXES
92 #include <linux/rtmutex.h>
94 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
95 #include <linux/lockdep.h>
97 #ifdef CONFIG_CHR_DEV_SG
100 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101 #include <linux/stackleak.h>
103 #ifdef CONFIG_LOCKUP_DETECTOR
104 #include <linux/nmi.h>
107 #if defined(CONFIG_SYSCTL)
109 /* Constants used for minimum and maximum */
110 #ifdef CONFIG_LOCKUP_DETECTOR
111 static int sixty = 60;
114 static int __maybe_unused neg_one = -1;
115 static int __maybe_unused two = 2;
116 static int __maybe_unused four = 4;
117 static unsigned long zero_ul;
118 static unsigned long one_ul = 1;
119 static unsigned long long_max = LONG_MAX;
120 static int one_hundred = 100;
121 static int two_hundred = 200;
122 static int one_thousand = 1000;
124 static int ten_thousand = 10000;
126 #ifdef CONFIG_PERF_EVENTS
127 static int six_hundred_forty_kb = 640 * 1024;
130 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
131 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
133 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
134 static int maxolduid = 65535;
135 static int minolduid;
137 static int ngroups_max = NGROUPS_MAX;
138 static const int cap_last_cap = CAP_LAST_CAP;
141 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
142 * and hung_task_check_interval_secs
144 #ifdef CONFIG_DETECT_HUNG_TASK
145 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
148 #ifdef CONFIG_INOTIFY_USER
149 #include <linux/inotify.h>
152 #ifdef CONFIG_PROC_SYSCTL
155 * enum sysctl_writes_mode - supported sysctl write modes
157 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
158 * to be written, and multiple writes on the same sysctl file descriptor
159 * will rewrite the sysctl value, regardless of file position. No warning
160 * is issued when the initial position is not 0.
161 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
163 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
164 * file position 0 and the value must be fully contained in the buffer
165 * sent to the write syscall. If dealing with strings respect the file
166 * position, but restrict this to the max length of the buffer, anything
167 * passed the max length will be ignored. Multiple writes will append
170 * These write modes control how current file position affects the behavior of
171 * updating sysctl values through the proc interface on each write.
173 enum sysctl_writes_mode {
174 SYSCTL_WRITES_LEGACY = -1,
175 SYSCTL_WRITES_WARN = 0,
176 SYSCTL_WRITES_STRICT = 1,
179 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
180 #endif /* CONFIG_PROC_SYSCTL */
182 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
183 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
184 int sysctl_legacy_va_layout;
187 #ifdef CONFIG_SCHED_DEBUG
188 static int min_sched_granularity_ns = 100000; /* 100 usecs */
189 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
190 static int min_wakeup_granularity_ns; /* 0 usecs */
191 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
193 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
194 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
195 #endif /* CONFIG_SMP */
196 #endif /* CONFIG_SCHED_DEBUG */
198 #ifdef CONFIG_COMPACTION
199 static int min_extfrag_threshold;
200 static int max_extfrag_threshold = 1000;
203 #endif /* CONFIG_SYSCTL */
205 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
206 static int bpf_stats_handler(struct ctl_table *table, int write,
207 void *buffer, size_t *lenp, loff_t *ppos)
209 struct static_key *key = (struct static_key *)table->data;
210 static int saved_val;
212 struct ctl_table tmp = {
214 .maxlen = sizeof(val),
216 .extra1 = SYSCTL_ZERO,
217 .extra2 = SYSCTL_ONE,
220 if (write && !capable(CAP_SYS_ADMIN))
223 mutex_lock(&bpf_stats_enabled_mutex);
225 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
226 if (write && !ret && val != saved_val) {
228 static_key_slow_inc(key);
230 static_key_slow_dec(key);
233 mutex_unlock(&bpf_stats_enabled_mutex);
237 static int bpf_unpriv_handler(struct ctl_table *table, int write,
238 void *buffer, size_t *lenp, loff_t *ppos)
240 int ret, unpriv_enable = *(int *)table->data;
241 bool locked_state = unpriv_enable == 1;
242 struct ctl_table tmp = *table;
244 if (write && !capable(CAP_SYS_ADMIN))
247 tmp.data = &unpriv_enable;
248 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
250 if (locked_state && unpriv_enable != 1)
252 *(int *)table->data = unpriv_enable;
256 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
262 #ifdef CONFIG_PROC_SYSCTL
264 static int _proc_do_string(char *data, int maxlen, int write,
265 char *buffer, size_t *lenp, loff_t *ppos)
270 if (!data || !maxlen || !*lenp) {
276 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
277 /* Only continue writes not past the end of buffer. */
279 if (len > maxlen - 1)
286 /* Start writing from beginning of buffer. */
292 while ((p - buffer) < *lenp && len < maxlen - 1) {
294 if (c == 0 || c == '\n')
315 memcpy(buffer, data, len);
326 static void warn_sysctl_write(struct ctl_table *table)
328 pr_warn_once("%s wrote to %s when file position was not 0!\n"
329 "This will not be supported in the future. To silence this\n"
330 "warning, set kernel.sysctl_writes_strict = -1\n",
331 current->comm, table->procname);
335 * proc_first_pos_non_zero_ignore - check if first position is allowed
336 * @ppos: file position
337 * @table: the sysctl table
339 * Returns true if the first position is non-zero and the sysctl_writes_strict
340 * mode indicates this is not allowed for numeric input types. String proc
341 * handlers can ignore the return value.
343 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
344 struct ctl_table *table)
349 switch (sysctl_writes_strict) {
350 case SYSCTL_WRITES_STRICT:
352 case SYSCTL_WRITES_WARN:
353 warn_sysctl_write(table);
361 * proc_dostring - read a string sysctl
362 * @table: the sysctl table
363 * @write: %TRUE if this is a write to the sysctl file
364 * @buffer: the user buffer
365 * @lenp: the size of the user buffer
366 * @ppos: file position
368 * Reads/writes a string from/to the user buffer. If the kernel
369 * buffer provided is not large enough to hold the string, the
370 * string is truncated. The copied string is %NULL-terminated.
371 * If the string is being read by the user process, it is copied
372 * and a newline '\n' is added. It is truncated if the buffer is
375 * Returns 0 on success.
377 int proc_dostring(struct ctl_table *table, int write,
378 void *buffer, size_t *lenp, loff_t *ppos)
381 proc_first_pos_non_zero_ignore(ppos, table);
383 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
387 static size_t proc_skip_spaces(char **buf)
390 char *tmp = skip_spaces(*buf);
396 static void proc_skip_char(char **buf, size_t *size, const char v)
407 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
410 * @cp: kernel buffer containing the string to parse
411 * @endp: pointer to store the trailing characters
412 * @base: the base to use
413 * @res: where the parsed integer will be stored
415 * In case of success 0 is returned and @res will contain the parsed integer,
416 * @endp will hold any trailing characters.
417 * This function will fail the parse on overflow. If there wasn't an overflow
418 * the function will defer the decision what characters count as invalid to the
421 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
424 unsigned long long result;
427 cp = _parse_integer_fixup_radix(cp, &base);
428 rv = _parse_integer(cp, base, &result);
429 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
437 *res = (unsigned long)result;
443 * proc_get_long - reads an ASCII formatted integer from a user buffer
445 * @buf: a kernel buffer
446 * @size: size of the kernel buffer
447 * @val: this is where the number will be stored
448 * @neg: set to %TRUE if number is negative
449 * @perm_tr: a vector which contains the allowed trailers
450 * @perm_tr_len: size of the perm_tr vector
451 * @tr: pointer to store the trailer character
453 * In case of success %0 is returned and @buf and @size are updated with
454 * the amount of bytes read. If @tr is non-NULL and a trailing
455 * character exists (size is non-zero after returning from this
456 * function), @tr is updated with the trailing character.
458 static int proc_get_long(char **buf, size_t *size,
459 unsigned long *val, bool *neg,
460 const char *perm_tr, unsigned perm_tr_len, char *tr)
463 char *p, tmp[TMPBUFLEN];
469 if (len > TMPBUFLEN - 1)
472 memcpy(tmp, *buf, len);
476 if (*p == '-' && *size > 1) {
484 if (strtoul_lenient(p, &p, 0, val))
489 /* We don't know if the next char is whitespace thus we may accept
490 * invalid integers (e.g. 1234...a) or two integers instead of one
491 * (e.g. 123...1). So lets not allow such large numbers. */
492 if (len == TMPBUFLEN - 1)
495 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
498 if (tr && (len < *size))
508 * proc_put_long - converts an integer to a decimal ASCII formatted string
510 * @buf: the user buffer
511 * @size: the size of the user buffer
512 * @val: the integer to be converted
513 * @neg: sign of the number, %TRUE for negative
515 * In case of success @buf and @size are updated with the amount of bytes
518 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
521 char tmp[TMPBUFLEN], *p = tmp;
523 sprintf(p, "%s%lu", neg ? "-" : "", val);
527 memcpy(*buf, tmp, len);
533 static void proc_put_char(void **buf, size_t *size, char c)
536 char **buffer = (char **)buf;
545 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
547 int write, void *data)
551 if (*lvalp > (unsigned long) INT_MAX + 1)
555 if (*lvalp > (unsigned long) INT_MAX)
563 *lvalp = -(unsigned long)val;
566 *lvalp = (unsigned long)val;
572 static int do_proc_douintvec_conv(unsigned long *lvalp,
574 int write, void *data)
577 if (*lvalp > UINT_MAX)
581 unsigned int val = *valp;
582 *lvalp = (unsigned long)val;
587 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
589 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
590 int write, void *buffer,
591 size_t *lenp, loff_t *ppos,
592 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
593 int write, void *data),
596 int *i, vleft, first = 1, err = 0;
600 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
605 i = (int *) tbl_data;
606 vleft = table->maxlen / sizeof(*i);
610 conv = do_proc_dointvec_conv;
613 if (proc_first_pos_non_zero_ignore(ppos, table))
616 if (left > PAGE_SIZE - 1)
617 left = PAGE_SIZE - 1;
621 for (; left && vleft--; i++, first=0) {
626 left -= proc_skip_spaces(&p);
630 err = proc_get_long(&p, &left, &lval, &neg,
632 sizeof(proc_wspace_sep), NULL);
635 if (conv(&neg, &lval, i, 1, data)) {
640 if (conv(&neg, &lval, i, 0, data)) {
645 proc_put_char(&buffer, &left, '\t');
646 proc_put_long(&buffer, &left, lval, neg);
650 if (!write && !first && left && !err)
651 proc_put_char(&buffer, &left, '\n');
652 if (write && !err && left)
653 left -= proc_skip_spaces(&p);
655 return err ? : -EINVAL;
662 static int do_proc_dointvec(struct ctl_table *table, int write,
663 void *buffer, size_t *lenp, loff_t *ppos,
664 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
665 int write, void *data),
668 return __do_proc_dointvec(table->data, table, write,
669 buffer, lenp, ppos, conv, data);
672 static int do_proc_douintvec_w(unsigned int *tbl_data,
673 struct ctl_table *table,
675 size_t *lenp, loff_t *ppos,
676 int (*conv)(unsigned long *lvalp,
678 int write, void *data),
689 if (proc_first_pos_non_zero_ignore(ppos, table))
692 if (left > PAGE_SIZE - 1)
693 left = PAGE_SIZE - 1;
695 left -= proc_skip_spaces(&p);
701 err = proc_get_long(&p, &left, &lval, &neg,
703 sizeof(proc_wspace_sep), NULL);
709 if (conv(&lval, tbl_data, 1, data)) {
715 left -= proc_skip_spaces(&p);
723 /* This is in keeping with old __do_proc_dointvec() */
729 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
730 size_t *lenp, loff_t *ppos,
731 int (*conv)(unsigned long *lvalp,
733 int write, void *data),
742 if (conv(&lval, tbl_data, 0, data)) {
747 proc_put_long(&buffer, &left, lval, false);
751 proc_put_char(&buffer, &left, '\n');
760 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
761 int write, void *buffer,
762 size_t *lenp, loff_t *ppos,
763 int (*conv)(unsigned long *lvalp,
765 int write, void *data),
768 unsigned int *i, vleft;
770 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
775 i = (unsigned int *) tbl_data;
776 vleft = table->maxlen / sizeof(*i);
779 * Arrays are not supported, keep this simple. *Do not* add
788 conv = do_proc_douintvec_conv;
791 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
793 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
796 static int do_proc_douintvec(struct ctl_table *table, int write,
797 void *buffer, size_t *lenp, loff_t *ppos,
798 int (*conv)(unsigned long *lvalp,
800 int write, void *data),
803 return __do_proc_douintvec(table->data, table, write,
804 buffer, lenp, ppos, conv, data);
808 * proc_dointvec - read a vector of integers
809 * @table: the sysctl table
810 * @write: %TRUE if this is a write to the sysctl file
811 * @buffer: the user buffer
812 * @lenp: the size of the user buffer
813 * @ppos: file position
815 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
816 * values from/to the user buffer, treated as an ASCII string.
818 * Returns 0 on success.
820 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
821 size_t *lenp, loff_t *ppos)
823 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
826 #ifdef CONFIG_COMPACTION
827 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
828 int write, void *buffer, size_t *lenp, loff_t *ppos)
832 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
833 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
835 old = *(int *)table->data;
836 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
839 if (old != *(int *)table->data)
840 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
841 table->procname, current->comm,
842 task_pid_nr(current));
848 * proc_douintvec - read a vector of unsigned integers
849 * @table: the sysctl table
850 * @write: %TRUE if this is a write to the sysctl file
851 * @buffer: the user buffer
852 * @lenp: the size of the user buffer
853 * @ppos: file position
855 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
856 * values from/to the user buffer, treated as an ASCII string.
858 * Returns 0 on success.
860 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
861 size_t *lenp, loff_t *ppos)
863 return do_proc_douintvec(table, write, buffer, lenp, ppos,
864 do_proc_douintvec_conv, NULL);
868 * Taint values can only be increased
869 * This means we can safely use a temporary.
871 static int proc_taint(struct ctl_table *table, int write,
872 void *buffer, size_t *lenp, loff_t *ppos)
875 unsigned long tmptaint = get_taint();
878 if (write && !capable(CAP_SYS_ADMIN))
883 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
891 * If we are relying on panic_on_taint not producing
892 * false positives due to userspace input, bail out
893 * before setting the requested taint flags.
895 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
899 * Poor man's atomic or. Not worth adding a primitive
900 * to everyone's atomic.h for this
902 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
903 if ((1UL << i) & tmptaint)
904 add_taint(i, LOCKDEP_STILL_OK);
911 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
912 void *buffer, size_t *lenp, loff_t *ppos)
914 if (write && !capable(CAP_SYS_ADMIN))
917 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
922 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
923 * @min: pointer to minimum allowable value
924 * @max: pointer to maximum allowable value
926 * The do_proc_dointvec_minmax_conv_param structure provides the
927 * minimum and maximum values for doing range checking for those sysctl
928 * parameters that use the proc_dointvec_minmax() handler.
930 struct do_proc_dointvec_minmax_conv_param {
935 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
937 int write, void *data)
940 struct do_proc_dointvec_minmax_conv_param *param = data;
942 * If writing, first do so via a temporary local int so we can
943 * bounds-check it before touching *valp.
945 int *ip = write ? &tmp : valp;
947 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
952 if ((param->min && *param->min > tmp) ||
953 (param->max && *param->max < tmp))
962 * proc_dointvec_minmax - read a vector of integers with min/max values
963 * @table: the sysctl table
964 * @write: %TRUE if this is a write to the sysctl file
965 * @buffer: the user buffer
966 * @lenp: the size of the user buffer
967 * @ppos: file position
969 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
970 * values from/to the user buffer, treated as an ASCII string.
972 * This routine will ensure the values are within the range specified by
973 * table->extra1 (min) and table->extra2 (max).
975 * Returns 0 on success or -EINVAL on write when the range check fails.
977 int proc_dointvec_minmax(struct ctl_table *table, int write,
978 void *buffer, size_t *lenp, loff_t *ppos)
980 struct do_proc_dointvec_minmax_conv_param param = {
981 .min = (int *) table->extra1,
982 .max = (int *) table->extra2,
984 return do_proc_dointvec(table, write, buffer, lenp, ppos,
985 do_proc_dointvec_minmax_conv, ¶m);
989 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
990 * @min: pointer to minimum allowable value
991 * @max: pointer to maximum allowable value
993 * The do_proc_douintvec_minmax_conv_param structure provides the
994 * minimum and maximum values for doing range checking for those sysctl
995 * parameters that use the proc_douintvec_minmax() handler.
997 struct do_proc_douintvec_minmax_conv_param {
1002 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1004 int write, void *data)
1008 struct do_proc_douintvec_minmax_conv_param *param = data;
1009 /* write via temporary local uint for bounds-checking */
1010 unsigned int *up = write ? &tmp : valp;
1012 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1017 if ((param->min && *param->min > tmp) ||
1018 (param->max && *param->max < tmp))
1028 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1029 * @table: the sysctl table
1030 * @write: %TRUE if this is a write to the sysctl file
1031 * @buffer: the user buffer
1032 * @lenp: the size of the user buffer
1033 * @ppos: file position
1035 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1036 * values from/to the user buffer, treated as an ASCII string. Negative
1037 * strings are not allowed.
1039 * This routine will ensure the values are within the range specified by
1040 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1041 * check for UINT_MAX to avoid having to support wrap around uses from
1044 * Returns 0 on success or -ERANGE on write when the range check fails.
1046 int proc_douintvec_minmax(struct ctl_table *table, int write,
1047 void *buffer, size_t *lenp, loff_t *ppos)
1049 struct do_proc_douintvec_minmax_conv_param param = {
1050 .min = (unsigned int *) table->extra1,
1051 .max = (unsigned int *) table->extra2,
1053 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1054 do_proc_douintvec_minmax_conv, ¶m);
1057 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1059 int write, void *data)
1064 val = round_pipe_size(*lvalp);
1070 unsigned int val = *valp;
1071 *lvalp = (unsigned long) val;
1077 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1078 void *buffer, size_t *lenp, loff_t *ppos)
1080 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1081 do_proc_dopipe_max_size_conv, NULL);
1084 static void validate_coredump_safety(void)
1086 #ifdef CONFIG_COREDUMP
1087 if (suid_dumpable == SUID_DUMP_ROOT &&
1088 core_pattern[0] != '/' && core_pattern[0] != '|') {
1090 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1091 "Pipe handler or fully qualified core dump path required.\n"
1092 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1098 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1099 void *buffer, size_t *lenp, loff_t *ppos)
1101 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1103 validate_coredump_safety();
1107 #ifdef CONFIG_COREDUMP
1108 static int proc_dostring_coredump(struct ctl_table *table, int write,
1109 void *buffer, size_t *lenp, loff_t *ppos)
1111 int error = proc_dostring(table, write, buffer, lenp, ppos);
1113 validate_coredump_safety();
1118 #ifdef CONFIG_MAGIC_SYSRQ
1119 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1120 void *buffer, size_t *lenp, loff_t *ppos)
1126 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1127 lenp, ppos, NULL, NULL);
1132 sysrq_toggle_support(tmp);
1138 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1139 int write, void *buffer, size_t *lenp, loff_t *ppos,
1140 unsigned long convmul, unsigned long convdiv)
1142 unsigned long *i, *min, *max;
1143 int vleft, first = 1, err = 0;
1147 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1152 i = (unsigned long *) data;
1153 min = (unsigned long *) table->extra1;
1154 max = (unsigned long *) table->extra2;
1155 vleft = table->maxlen / sizeof(unsigned long);
1159 if (proc_first_pos_non_zero_ignore(ppos, table))
1162 if (left > PAGE_SIZE - 1)
1163 left = PAGE_SIZE - 1;
1167 for (; left && vleft--; i++, first = 0) {
1173 left -= proc_skip_spaces(&p);
1177 err = proc_get_long(&p, &left, &val, &neg,
1179 sizeof(proc_wspace_sep), NULL);
1184 val = convmul * val / convdiv;
1185 if ((min && val < *min) || (max && val > *max)) {
1191 val = convdiv * (*i) / convmul;
1193 proc_put_char(&buffer, &left, '\t');
1194 proc_put_long(&buffer, &left, val, false);
1198 if (!write && !first && left && !err)
1199 proc_put_char(&buffer, &left, '\n');
1201 left -= proc_skip_spaces(&p);
1203 return err ? : -EINVAL;
1210 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1211 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1212 unsigned long convdiv)
1214 return __do_proc_doulongvec_minmax(table->data, table, write,
1215 buffer, lenp, ppos, convmul, convdiv);
1219 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1220 * @table: the sysctl table
1221 * @write: %TRUE if this is a write to the sysctl file
1222 * @buffer: the user buffer
1223 * @lenp: the size of the user buffer
1224 * @ppos: file position
1226 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1227 * values from/to the user buffer, treated as an ASCII string.
1229 * This routine will ensure the values are within the range specified by
1230 * table->extra1 (min) and table->extra2 (max).
1232 * Returns 0 on success.
1234 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1235 void *buffer, size_t *lenp, loff_t *ppos)
1237 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1241 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1242 * @table: the sysctl table
1243 * @write: %TRUE if this is a write to the sysctl file
1244 * @buffer: the user buffer
1245 * @lenp: the size of the user buffer
1246 * @ppos: file position
1248 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1249 * values from/to the user buffer, treated as an ASCII string. The values
1250 * are treated as milliseconds, and converted to jiffies when they are stored.
1252 * This routine will ensure the values are within the range specified by
1253 * table->extra1 (min) and table->extra2 (max).
1255 * Returns 0 on success.
1257 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1258 void *buffer, size_t *lenp, loff_t *ppos)
1260 return do_proc_doulongvec_minmax(table, write, buffer,
1261 lenp, ppos, HZ, 1000l);
1265 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1267 int write, void *data)
1270 if (*lvalp > INT_MAX / HZ)
1272 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1278 lval = -(unsigned long)val;
1281 lval = (unsigned long)val;
1288 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1290 int write, void *data)
1293 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1295 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1301 lval = -(unsigned long)val;
1304 lval = (unsigned long)val;
1306 *lvalp = jiffies_to_clock_t(lval);
1311 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1313 int write, void *data)
1316 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1326 lval = -(unsigned long)val;
1329 lval = (unsigned long)val;
1331 *lvalp = jiffies_to_msecs(lval);
1337 * proc_dointvec_jiffies - read a vector of integers as seconds
1338 * @table: the sysctl table
1339 * @write: %TRUE if this is a write to the sysctl file
1340 * @buffer: the user buffer
1341 * @lenp: the size of the user buffer
1342 * @ppos: file position
1344 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1345 * values from/to the user buffer, treated as an ASCII string.
1346 * The values read are assumed to be in seconds, and are converted into
1349 * Returns 0 on success.
1351 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1352 void *buffer, size_t *lenp, loff_t *ppos)
1354 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1355 do_proc_dointvec_jiffies_conv,NULL);
1359 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1360 * @table: the sysctl table
1361 * @write: %TRUE if this is a write to the sysctl file
1362 * @buffer: the user buffer
1363 * @lenp: the size of the user buffer
1364 * @ppos: pointer to the file position
1366 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1367 * values from/to the user buffer, treated as an ASCII string.
1368 * The values read are assumed to be in 1/USER_HZ seconds, and
1369 * are converted into jiffies.
1371 * Returns 0 on success.
1373 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1374 void *buffer, size_t *lenp, loff_t *ppos)
1376 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1377 do_proc_dointvec_userhz_jiffies_conv,NULL);
1381 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1382 * @table: the sysctl table
1383 * @write: %TRUE if this is a write to the sysctl file
1384 * @buffer: the user buffer
1385 * @lenp: the size of the user buffer
1386 * @ppos: file position
1387 * @ppos: the current position in the file
1389 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1390 * values from/to the user buffer, treated as an ASCII string.
1391 * The values read are assumed to be in 1/1000 seconds, and
1392 * are converted into jiffies.
1394 * Returns 0 on success.
1396 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1397 size_t *lenp, loff_t *ppos)
1399 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1400 do_proc_dointvec_ms_jiffies_conv, NULL);
1403 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1404 size_t *lenp, loff_t *ppos)
1406 struct pid *new_pid;
1410 tmp = pid_vnr(cad_pid);
1412 r = __do_proc_dointvec(&tmp, table, write, buffer,
1413 lenp, ppos, NULL, NULL);
1417 new_pid = find_get_pid(tmp);
1421 put_pid(xchg(&cad_pid, new_pid));
1426 * proc_do_large_bitmap - read/write from/to a large bitmap
1427 * @table: the sysctl table
1428 * @write: %TRUE if this is a write to the sysctl file
1429 * @buffer: the user buffer
1430 * @lenp: the size of the user buffer
1431 * @ppos: file position
1433 * The bitmap is stored at table->data and the bitmap length (in bits)
1436 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1437 * large bitmaps may be represented in a compact manner. Writing into
1438 * the file will clear the bitmap then update it with the given input.
1440 * Returns 0 on success.
1442 int proc_do_large_bitmap(struct ctl_table *table, int write,
1443 void *buffer, size_t *lenp, loff_t *ppos)
1447 size_t left = *lenp;
1448 unsigned long bitmap_len = table->maxlen;
1449 unsigned long *bitmap = *(unsigned long **) table->data;
1450 unsigned long *tmp_bitmap = NULL;
1451 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1453 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1462 if (left > PAGE_SIZE - 1) {
1463 left = PAGE_SIZE - 1;
1464 /* How much of the buffer we'll skip this pass */
1465 skipped = *lenp - left;
1468 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1471 proc_skip_char(&p, &left, '\n');
1472 while (!err && left) {
1473 unsigned long val_a, val_b;
1477 /* In case we stop parsing mid-number, we can reset */
1479 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1482 * If we consumed the entirety of a truncated buffer or
1483 * only one char is left (may be a "-"), then stop here,
1484 * reset, & come back for more.
1486 if ((left <= 1) && skipped) {
1493 if (val_a >= bitmap_len || neg) {
1505 err = proc_get_long(&p, &left, &val_b,
1506 &neg, tr_b, sizeof(tr_b),
1509 * If we consumed all of a truncated buffer or
1510 * then stop here, reset, & come back for more.
1512 if (!left && skipped) {
1519 if (val_b >= bitmap_len || neg ||
1530 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1532 proc_skip_char(&p, &left, '\n');
1536 unsigned long bit_a, bit_b = 0;
1539 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1540 if (bit_a >= bitmap_len)
1542 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1546 proc_put_char(&buffer, &left, ',');
1547 proc_put_long(&buffer, &left, bit_a, false);
1548 if (bit_a != bit_b) {
1549 proc_put_char(&buffer, &left, '-');
1550 proc_put_long(&buffer, &left, bit_b, false);
1555 proc_put_char(&buffer, &left, '\n');
1561 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1563 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1569 bitmap_free(tmp_bitmap);
1573 #else /* CONFIG_PROC_SYSCTL */
1575 int proc_dostring(struct ctl_table *table, int write,
1576 void *buffer, size_t *lenp, loff_t *ppos)
1581 int proc_dointvec(struct ctl_table *table, int write,
1582 void *buffer, size_t *lenp, loff_t *ppos)
1587 int proc_douintvec(struct ctl_table *table, int write,
1588 void *buffer, size_t *lenp, loff_t *ppos)
1593 int proc_dointvec_minmax(struct ctl_table *table, int write,
1594 void *buffer, size_t *lenp, loff_t *ppos)
1599 int proc_douintvec_minmax(struct ctl_table *table, int write,
1600 void *buffer, size_t *lenp, loff_t *ppos)
1605 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1606 void *buffer, size_t *lenp, loff_t *ppos)
1611 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1612 void *buffer, size_t *lenp, loff_t *ppos)
1617 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1618 void *buffer, size_t *lenp, loff_t *ppos)
1623 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1624 void *buffer, size_t *lenp, loff_t *ppos)
1629 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1630 void *buffer, size_t *lenp, loff_t *ppos)
1635 int proc_do_large_bitmap(struct ctl_table *table, int write,
1636 void *buffer, size_t *lenp, loff_t *ppos)
1641 #endif /* CONFIG_PROC_SYSCTL */
1643 #if defined(CONFIG_SYSCTL)
1644 int proc_do_static_key(struct ctl_table *table, int write,
1645 void *buffer, size_t *lenp, loff_t *ppos)
1647 struct static_key *key = (struct static_key *)table->data;
1648 static DEFINE_MUTEX(static_key_mutex);
1650 struct ctl_table tmp = {
1652 .maxlen = sizeof(val),
1653 .mode = table->mode,
1654 .extra1 = SYSCTL_ZERO,
1655 .extra2 = SYSCTL_ONE,
1658 if (write && !capable(CAP_SYS_ADMIN))
1661 mutex_lock(&static_key_mutex);
1662 val = static_key_enabled(key);
1663 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1664 if (write && !ret) {
1666 static_key_enable(key);
1668 static_key_disable(key);
1670 mutex_unlock(&static_key_mutex);
1674 static struct ctl_table kern_table[] = {
1676 .procname = "sched_child_runs_first",
1677 .data = &sysctl_sched_child_runs_first,
1678 .maxlen = sizeof(unsigned int),
1680 .proc_handler = proc_dointvec,
1682 #ifdef CONFIG_SCHED_DEBUG
1684 .procname = "sched_min_granularity_ns",
1685 .data = &sysctl_sched_min_granularity,
1686 .maxlen = sizeof(unsigned int),
1688 .proc_handler = sched_proc_update_handler,
1689 .extra1 = &min_sched_granularity_ns,
1690 .extra2 = &max_sched_granularity_ns,
1693 .procname = "sched_latency_ns",
1694 .data = &sysctl_sched_latency,
1695 .maxlen = sizeof(unsigned int),
1697 .proc_handler = sched_proc_update_handler,
1698 .extra1 = &min_sched_granularity_ns,
1699 .extra2 = &max_sched_granularity_ns,
1702 .procname = "sched_wakeup_granularity_ns",
1703 .data = &sysctl_sched_wakeup_granularity,
1704 .maxlen = sizeof(unsigned int),
1706 .proc_handler = sched_proc_update_handler,
1707 .extra1 = &min_wakeup_granularity_ns,
1708 .extra2 = &max_wakeup_granularity_ns,
1712 .procname = "sched_tunable_scaling",
1713 .data = &sysctl_sched_tunable_scaling,
1714 .maxlen = sizeof(enum sched_tunable_scaling),
1716 .proc_handler = sched_proc_update_handler,
1717 .extra1 = &min_sched_tunable_scaling,
1718 .extra2 = &max_sched_tunable_scaling,
1721 .procname = "sched_migration_cost_ns",
1722 .data = &sysctl_sched_migration_cost,
1723 .maxlen = sizeof(unsigned int),
1725 .proc_handler = proc_dointvec,
1728 .procname = "sched_nr_migrate",
1729 .data = &sysctl_sched_nr_migrate,
1730 .maxlen = sizeof(unsigned int),
1732 .proc_handler = proc_dointvec,
1734 #ifdef CONFIG_SCHEDSTATS
1736 .procname = "sched_schedstats",
1738 .maxlen = sizeof(unsigned int),
1740 .proc_handler = sysctl_schedstats,
1741 .extra1 = SYSCTL_ZERO,
1742 .extra2 = SYSCTL_ONE,
1744 #endif /* CONFIG_SCHEDSTATS */
1745 #endif /* CONFIG_SMP */
1746 #ifdef CONFIG_NUMA_BALANCING
1748 .procname = "numa_balancing_scan_delay_ms",
1749 .data = &sysctl_numa_balancing_scan_delay,
1750 .maxlen = sizeof(unsigned int),
1752 .proc_handler = proc_dointvec,
1755 .procname = "numa_balancing_scan_period_min_ms",
1756 .data = &sysctl_numa_balancing_scan_period_min,
1757 .maxlen = sizeof(unsigned int),
1759 .proc_handler = proc_dointvec,
1762 .procname = "numa_balancing_scan_period_max_ms",
1763 .data = &sysctl_numa_balancing_scan_period_max,
1764 .maxlen = sizeof(unsigned int),
1766 .proc_handler = proc_dointvec,
1769 .procname = "numa_balancing_scan_size_mb",
1770 .data = &sysctl_numa_balancing_scan_size,
1771 .maxlen = sizeof(unsigned int),
1773 .proc_handler = proc_dointvec_minmax,
1774 .extra1 = SYSCTL_ONE,
1777 .procname = "numa_balancing",
1778 .data = NULL, /* filled in by handler */
1779 .maxlen = sizeof(unsigned int),
1781 .proc_handler = sysctl_numa_balancing,
1782 .extra1 = SYSCTL_ZERO,
1783 .extra2 = SYSCTL_ONE,
1785 #endif /* CONFIG_NUMA_BALANCING */
1786 #endif /* CONFIG_SCHED_DEBUG */
1788 .procname = "sched_rt_period_us",
1789 .data = &sysctl_sched_rt_period,
1790 .maxlen = sizeof(unsigned int),
1792 .proc_handler = sched_rt_handler,
1795 .procname = "sched_rt_runtime_us",
1796 .data = &sysctl_sched_rt_runtime,
1797 .maxlen = sizeof(int),
1799 .proc_handler = sched_rt_handler,
1802 .procname = "sched_deadline_period_max_us",
1803 .data = &sysctl_sched_dl_period_max,
1804 .maxlen = sizeof(unsigned int),
1806 .proc_handler = proc_dointvec,
1809 .procname = "sched_deadline_period_min_us",
1810 .data = &sysctl_sched_dl_period_min,
1811 .maxlen = sizeof(unsigned int),
1813 .proc_handler = proc_dointvec,
1816 .procname = "sched_rr_timeslice_ms",
1817 .data = &sysctl_sched_rr_timeslice,
1818 .maxlen = sizeof(int),
1820 .proc_handler = sched_rr_handler,
1822 #ifdef CONFIG_UCLAMP_TASK
1824 .procname = "sched_util_clamp_min",
1825 .data = &sysctl_sched_uclamp_util_min,
1826 .maxlen = sizeof(unsigned int),
1828 .proc_handler = sysctl_sched_uclamp_handler,
1831 .procname = "sched_util_clamp_max",
1832 .data = &sysctl_sched_uclamp_util_max,
1833 .maxlen = sizeof(unsigned int),
1835 .proc_handler = sysctl_sched_uclamp_handler,
1838 .procname = "sched_util_clamp_min_rt_default",
1839 .data = &sysctl_sched_uclamp_util_min_rt_default,
1840 .maxlen = sizeof(unsigned int),
1842 .proc_handler = sysctl_sched_uclamp_handler,
1845 #ifdef CONFIG_SCHED_AUTOGROUP
1847 .procname = "sched_autogroup_enabled",
1848 .data = &sysctl_sched_autogroup_enabled,
1849 .maxlen = sizeof(unsigned int),
1851 .proc_handler = proc_dointvec_minmax,
1852 .extra1 = SYSCTL_ZERO,
1853 .extra2 = SYSCTL_ONE,
1856 #ifdef CONFIG_CFS_BANDWIDTH
1858 .procname = "sched_cfs_bandwidth_slice_us",
1859 .data = &sysctl_sched_cfs_bandwidth_slice,
1860 .maxlen = sizeof(unsigned int),
1862 .proc_handler = proc_dointvec_minmax,
1863 .extra1 = SYSCTL_ONE,
1866 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1868 .procname = "sched_energy_aware",
1869 .data = &sysctl_sched_energy_aware,
1870 .maxlen = sizeof(unsigned int),
1872 .proc_handler = sched_energy_aware_handler,
1873 .extra1 = SYSCTL_ZERO,
1874 .extra2 = SYSCTL_ONE,
1877 #ifdef CONFIG_PROVE_LOCKING
1879 .procname = "prove_locking",
1880 .data = &prove_locking,
1881 .maxlen = sizeof(int),
1883 .proc_handler = proc_dointvec,
1886 #ifdef CONFIG_LOCK_STAT
1888 .procname = "lock_stat",
1890 .maxlen = sizeof(int),
1892 .proc_handler = proc_dointvec,
1896 .procname = "panic",
1897 .data = &panic_timeout,
1898 .maxlen = sizeof(int),
1900 .proc_handler = proc_dointvec,
1902 #ifdef CONFIG_COREDUMP
1904 .procname = "core_uses_pid",
1905 .data = &core_uses_pid,
1906 .maxlen = sizeof(int),
1908 .proc_handler = proc_dointvec,
1911 .procname = "core_pattern",
1912 .data = core_pattern,
1913 .maxlen = CORENAME_MAX_SIZE,
1915 .proc_handler = proc_dostring_coredump,
1918 .procname = "core_pipe_limit",
1919 .data = &core_pipe_limit,
1920 .maxlen = sizeof(unsigned int),
1922 .proc_handler = proc_dointvec,
1925 #ifdef CONFIG_PROC_SYSCTL
1927 .procname = "tainted",
1928 .maxlen = sizeof(long),
1930 .proc_handler = proc_taint,
1933 .procname = "sysctl_writes_strict",
1934 .data = &sysctl_writes_strict,
1935 .maxlen = sizeof(int),
1937 .proc_handler = proc_dointvec_minmax,
1939 .extra2 = SYSCTL_ONE,
1942 #ifdef CONFIG_LATENCYTOP
1944 .procname = "latencytop",
1945 .data = &latencytop_enabled,
1946 .maxlen = sizeof(int),
1948 .proc_handler = sysctl_latencytop,
1951 #ifdef CONFIG_BLK_DEV_INITRD
1953 .procname = "real-root-dev",
1954 .data = &real_root_dev,
1955 .maxlen = sizeof(int),
1957 .proc_handler = proc_dointvec,
1961 .procname = "print-fatal-signals",
1962 .data = &print_fatal_signals,
1963 .maxlen = sizeof(int),
1965 .proc_handler = proc_dointvec,
1969 .procname = "reboot-cmd",
1970 .data = reboot_command,
1973 .proc_handler = proc_dostring,
1976 .procname = "stop-a",
1977 .data = &stop_a_enabled,
1978 .maxlen = sizeof (int),
1980 .proc_handler = proc_dointvec,
1983 .procname = "scons-poweroff",
1984 .data = &scons_pwroff,
1985 .maxlen = sizeof (int),
1987 .proc_handler = proc_dointvec,
1990 #ifdef CONFIG_SPARC64
1992 .procname = "tsb-ratio",
1993 .data = &sysctl_tsb_ratio,
1994 .maxlen = sizeof (int),
1996 .proc_handler = proc_dointvec,
1999 #ifdef CONFIG_PARISC
2001 .procname = "soft-power",
2002 .data = &pwrsw_enabled,
2003 .maxlen = sizeof (int),
2005 .proc_handler = proc_dointvec,
2008 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2010 .procname = "unaligned-trap",
2011 .data = &unaligned_enabled,
2012 .maxlen = sizeof (int),
2014 .proc_handler = proc_dointvec,
2018 .procname = "ctrl-alt-del",
2020 .maxlen = sizeof(int),
2022 .proc_handler = proc_dointvec,
2024 #ifdef CONFIG_FUNCTION_TRACER
2026 .procname = "ftrace_enabled",
2027 .data = &ftrace_enabled,
2028 .maxlen = sizeof(int),
2030 .proc_handler = ftrace_enable_sysctl,
2033 #ifdef CONFIG_STACK_TRACER
2035 .procname = "stack_tracer_enabled",
2036 .data = &stack_tracer_enabled,
2037 .maxlen = sizeof(int),
2039 .proc_handler = stack_trace_sysctl,
2042 #ifdef CONFIG_TRACING
2044 .procname = "ftrace_dump_on_oops",
2045 .data = &ftrace_dump_on_oops,
2046 .maxlen = sizeof(int),
2048 .proc_handler = proc_dointvec,
2051 .procname = "traceoff_on_warning",
2052 .data = &__disable_trace_on_warning,
2053 .maxlen = sizeof(__disable_trace_on_warning),
2055 .proc_handler = proc_dointvec,
2058 .procname = "tracepoint_printk",
2059 .data = &tracepoint_printk,
2060 .maxlen = sizeof(tracepoint_printk),
2062 .proc_handler = tracepoint_printk_sysctl,
2065 #ifdef CONFIG_KEXEC_CORE
2067 .procname = "kexec_load_disabled",
2068 .data = &kexec_load_disabled,
2069 .maxlen = sizeof(int),
2071 /* only handle a transition from default "0" to "1" */
2072 .proc_handler = proc_dointvec_minmax,
2073 .extra1 = SYSCTL_ONE,
2074 .extra2 = SYSCTL_ONE,
2077 #ifdef CONFIG_MODULES
2079 .procname = "modprobe",
2080 .data = &modprobe_path,
2081 .maxlen = KMOD_PATH_LEN,
2083 .proc_handler = proc_dostring,
2086 .procname = "modules_disabled",
2087 .data = &modules_disabled,
2088 .maxlen = sizeof(int),
2090 /* only handle a transition from default "0" to "1" */
2091 .proc_handler = proc_dointvec_minmax,
2092 .extra1 = SYSCTL_ONE,
2093 .extra2 = SYSCTL_ONE,
2096 #ifdef CONFIG_UEVENT_HELPER
2098 .procname = "hotplug",
2099 .data = &uevent_helper,
2100 .maxlen = UEVENT_HELPER_PATH_LEN,
2102 .proc_handler = proc_dostring,
2105 #ifdef CONFIG_CHR_DEV_SG
2107 .procname = "sg-big-buff",
2108 .data = &sg_big_buff,
2109 .maxlen = sizeof (int),
2111 .proc_handler = proc_dointvec,
2114 #ifdef CONFIG_BSD_PROCESS_ACCT
2118 .maxlen = 3*sizeof(int),
2120 .proc_handler = proc_dointvec,
2123 #ifdef CONFIG_MAGIC_SYSRQ
2125 .procname = "sysrq",
2127 .maxlen = sizeof (int),
2129 .proc_handler = sysrq_sysctl_handler,
2132 #ifdef CONFIG_PROC_SYSCTL
2134 .procname = "cad_pid",
2136 .maxlen = sizeof (int),
2138 .proc_handler = proc_do_cad_pid,
2142 .procname = "threads-max",
2144 .maxlen = sizeof(int),
2146 .proc_handler = sysctl_max_threads,
2149 .procname = "random",
2151 .child = random_table,
2154 .procname = "usermodehelper",
2156 .child = usermodehelper_table,
2158 #ifdef CONFIG_FW_LOADER_USER_HELPER
2160 .procname = "firmware_config",
2162 .child = firmware_config_table,
2166 .procname = "overflowuid",
2167 .data = &overflowuid,
2168 .maxlen = sizeof(int),
2170 .proc_handler = proc_dointvec_minmax,
2171 .extra1 = &minolduid,
2172 .extra2 = &maxolduid,
2175 .procname = "overflowgid",
2176 .data = &overflowgid,
2177 .maxlen = sizeof(int),
2179 .proc_handler = proc_dointvec_minmax,
2180 .extra1 = &minolduid,
2181 .extra2 = &maxolduid,
2185 .procname = "userprocess_debug",
2186 .data = &show_unhandled_signals,
2187 .maxlen = sizeof(int),
2189 .proc_handler = proc_dointvec,
2194 .procname = "oops_all_cpu_backtrace",
2195 .data = &sysctl_oops_all_cpu_backtrace,
2196 .maxlen = sizeof(int),
2198 .proc_handler = proc_dointvec_minmax,
2199 .extra1 = SYSCTL_ZERO,
2200 .extra2 = SYSCTL_ONE,
2202 #endif /* CONFIG_SMP */
2204 .procname = "pid_max",
2206 .maxlen = sizeof (int),
2208 .proc_handler = proc_dointvec_minmax,
2209 .extra1 = &pid_max_min,
2210 .extra2 = &pid_max_max,
2213 .procname = "panic_on_oops",
2214 .data = &panic_on_oops,
2215 .maxlen = sizeof(int),
2217 .proc_handler = proc_dointvec,
2220 .procname = "panic_print",
2221 .data = &panic_print,
2222 .maxlen = sizeof(unsigned long),
2224 .proc_handler = proc_doulongvec_minmax,
2226 #if defined CONFIG_PRINTK
2228 .procname = "printk",
2229 .data = &console_loglevel,
2230 .maxlen = 4*sizeof(int),
2232 .proc_handler = proc_dointvec,
2235 .procname = "printk_ratelimit",
2236 .data = &printk_ratelimit_state.interval,
2237 .maxlen = sizeof(int),
2239 .proc_handler = proc_dointvec_jiffies,
2242 .procname = "printk_ratelimit_burst",
2243 .data = &printk_ratelimit_state.burst,
2244 .maxlen = sizeof(int),
2246 .proc_handler = proc_dointvec,
2249 .procname = "printk_delay",
2250 .data = &printk_delay_msec,
2251 .maxlen = sizeof(int),
2253 .proc_handler = proc_dointvec_minmax,
2254 .extra1 = SYSCTL_ZERO,
2255 .extra2 = &ten_thousand,
2258 .procname = "printk_devkmsg",
2259 .data = devkmsg_log_str,
2260 .maxlen = DEVKMSG_STR_MAX_SIZE,
2262 .proc_handler = devkmsg_sysctl_set_loglvl,
2265 .procname = "dmesg_restrict",
2266 .data = &dmesg_restrict,
2267 .maxlen = sizeof(int),
2269 .proc_handler = proc_dointvec_minmax_sysadmin,
2270 .extra1 = SYSCTL_ZERO,
2271 .extra2 = SYSCTL_ONE,
2274 .procname = "kptr_restrict",
2275 .data = &kptr_restrict,
2276 .maxlen = sizeof(int),
2278 .proc_handler = proc_dointvec_minmax_sysadmin,
2279 .extra1 = SYSCTL_ZERO,
2284 .procname = "ngroups_max",
2285 .data = &ngroups_max,
2286 .maxlen = sizeof (int),
2288 .proc_handler = proc_dointvec,
2291 .procname = "cap_last_cap",
2292 .data = (void *)&cap_last_cap,
2293 .maxlen = sizeof(int),
2295 .proc_handler = proc_dointvec,
2297 #if defined(CONFIG_LOCKUP_DETECTOR)
2299 .procname = "watchdog",
2300 .data = &watchdog_user_enabled,
2301 .maxlen = sizeof(int),
2303 .proc_handler = proc_watchdog,
2304 .extra1 = SYSCTL_ZERO,
2305 .extra2 = SYSCTL_ONE,
2308 .procname = "watchdog_thresh",
2309 .data = &watchdog_thresh,
2310 .maxlen = sizeof(int),
2312 .proc_handler = proc_watchdog_thresh,
2313 .extra1 = SYSCTL_ZERO,
2317 .procname = "nmi_watchdog",
2318 .data = &nmi_watchdog_user_enabled,
2319 .maxlen = sizeof(int),
2320 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2321 .proc_handler = proc_nmi_watchdog,
2322 .extra1 = SYSCTL_ZERO,
2323 .extra2 = SYSCTL_ONE,
2326 .procname = "watchdog_cpumask",
2327 .data = &watchdog_cpumask_bits,
2330 .proc_handler = proc_watchdog_cpumask,
2332 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2334 .procname = "soft_watchdog",
2335 .data = &soft_watchdog_user_enabled,
2336 .maxlen = sizeof(int),
2338 .proc_handler = proc_soft_watchdog,
2339 .extra1 = SYSCTL_ZERO,
2340 .extra2 = SYSCTL_ONE,
2343 .procname = "softlockup_panic",
2344 .data = &softlockup_panic,
2345 .maxlen = sizeof(int),
2347 .proc_handler = proc_dointvec_minmax,
2348 .extra1 = SYSCTL_ZERO,
2349 .extra2 = SYSCTL_ONE,
2353 .procname = "softlockup_all_cpu_backtrace",
2354 .data = &sysctl_softlockup_all_cpu_backtrace,
2355 .maxlen = sizeof(int),
2357 .proc_handler = proc_dointvec_minmax,
2358 .extra1 = SYSCTL_ZERO,
2359 .extra2 = SYSCTL_ONE,
2361 #endif /* CONFIG_SMP */
2363 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2365 .procname = "hardlockup_panic",
2366 .data = &hardlockup_panic,
2367 .maxlen = sizeof(int),
2369 .proc_handler = proc_dointvec_minmax,
2370 .extra1 = SYSCTL_ZERO,
2371 .extra2 = SYSCTL_ONE,
2375 .procname = "hardlockup_all_cpu_backtrace",
2376 .data = &sysctl_hardlockup_all_cpu_backtrace,
2377 .maxlen = sizeof(int),
2379 .proc_handler = proc_dointvec_minmax,
2380 .extra1 = SYSCTL_ZERO,
2381 .extra2 = SYSCTL_ONE,
2383 #endif /* CONFIG_SMP */
2387 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2389 .procname = "unknown_nmi_panic",
2390 .data = &unknown_nmi_panic,
2391 .maxlen = sizeof (int),
2393 .proc_handler = proc_dointvec,
2397 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2398 defined(CONFIG_DEBUG_STACKOVERFLOW)
2400 .procname = "panic_on_stackoverflow",
2401 .data = &sysctl_panic_on_stackoverflow,
2402 .maxlen = sizeof(int),
2404 .proc_handler = proc_dointvec,
2407 #if defined(CONFIG_X86)
2409 .procname = "panic_on_unrecovered_nmi",
2410 .data = &panic_on_unrecovered_nmi,
2411 .maxlen = sizeof(int),
2413 .proc_handler = proc_dointvec,
2416 .procname = "panic_on_io_nmi",
2417 .data = &panic_on_io_nmi,
2418 .maxlen = sizeof(int),
2420 .proc_handler = proc_dointvec,
2423 .procname = "bootloader_type",
2424 .data = &bootloader_type,
2425 .maxlen = sizeof (int),
2427 .proc_handler = proc_dointvec,
2430 .procname = "bootloader_version",
2431 .data = &bootloader_version,
2432 .maxlen = sizeof (int),
2434 .proc_handler = proc_dointvec,
2437 .procname = "io_delay_type",
2438 .data = &io_delay_type,
2439 .maxlen = sizeof(int),
2441 .proc_handler = proc_dointvec,
2444 #if defined(CONFIG_MMU)
2446 .procname = "randomize_va_space",
2447 .data = &randomize_va_space,
2448 .maxlen = sizeof(int),
2450 .proc_handler = proc_dointvec,
2453 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2455 .procname = "spin_retry",
2456 .data = &spin_retry,
2457 .maxlen = sizeof (int),
2459 .proc_handler = proc_dointvec,
2462 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2464 .procname = "acpi_video_flags",
2465 .data = &acpi_realmode_flags,
2466 .maxlen = sizeof (unsigned long),
2468 .proc_handler = proc_doulongvec_minmax,
2471 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2473 .procname = "ignore-unaligned-usertrap",
2474 .data = &no_unaligned_warning,
2475 .maxlen = sizeof (int),
2477 .proc_handler = proc_dointvec,
2482 .procname = "unaligned-dump-stack",
2483 .data = &unaligned_dump_stack,
2484 .maxlen = sizeof (int),
2486 .proc_handler = proc_dointvec,
2489 #ifdef CONFIG_DETECT_HUNG_TASK
2492 .procname = "hung_task_all_cpu_backtrace",
2493 .data = &sysctl_hung_task_all_cpu_backtrace,
2494 .maxlen = sizeof(int),
2496 .proc_handler = proc_dointvec_minmax,
2497 .extra1 = SYSCTL_ZERO,
2498 .extra2 = SYSCTL_ONE,
2500 #endif /* CONFIG_SMP */
2502 .procname = "hung_task_panic",
2503 .data = &sysctl_hung_task_panic,
2504 .maxlen = sizeof(int),
2506 .proc_handler = proc_dointvec_minmax,
2507 .extra1 = SYSCTL_ZERO,
2508 .extra2 = SYSCTL_ONE,
2511 .procname = "hung_task_check_count",
2512 .data = &sysctl_hung_task_check_count,
2513 .maxlen = sizeof(int),
2515 .proc_handler = proc_dointvec_minmax,
2516 .extra1 = SYSCTL_ZERO,
2519 .procname = "hung_task_timeout_secs",
2520 .data = &sysctl_hung_task_timeout_secs,
2521 .maxlen = sizeof(unsigned long),
2523 .proc_handler = proc_dohung_task_timeout_secs,
2524 .extra2 = &hung_task_timeout_max,
2527 .procname = "hung_task_check_interval_secs",
2528 .data = &sysctl_hung_task_check_interval_secs,
2529 .maxlen = sizeof(unsigned long),
2531 .proc_handler = proc_dohung_task_timeout_secs,
2532 .extra2 = &hung_task_timeout_max,
2535 .procname = "hung_task_warnings",
2536 .data = &sysctl_hung_task_warnings,
2537 .maxlen = sizeof(int),
2539 .proc_handler = proc_dointvec_minmax,
2543 #ifdef CONFIG_RT_MUTEXES
2545 .procname = "max_lock_depth",
2546 .data = &max_lock_depth,
2547 .maxlen = sizeof(int),
2549 .proc_handler = proc_dointvec,
2553 .procname = "poweroff_cmd",
2554 .data = &poweroff_cmd,
2555 .maxlen = POWEROFF_CMD_PATH_LEN,
2557 .proc_handler = proc_dostring,
2563 .child = key_sysctls,
2566 #ifdef CONFIG_PERF_EVENTS
2568 * User-space scripts rely on the existence of this file
2569 * as a feature check for perf_events being enabled.
2571 * So it's an ABI, do not remove!
2574 .procname = "perf_event_paranoid",
2575 .data = &sysctl_perf_event_paranoid,
2576 .maxlen = sizeof(sysctl_perf_event_paranoid),
2578 .proc_handler = proc_dointvec,
2581 .procname = "perf_event_mlock_kb",
2582 .data = &sysctl_perf_event_mlock,
2583 .maxlen = sizeof(sysctl_perf_event_mlock),
2585 .proc_handler = proc_dointvec,
2588 .procname = "perf_event_max_sample_rate",
2589 .data = &sysctl_perf_event_sample_rate,
2590 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2592 .proc_handler = perf_proc_update_handler,
2593 .extra1 = SYSCTL_ONE,
2596 .procname = "perf_cpu_time_max_percent",
2597 .data = &sysctl_perf_cpu_time_max_percent,
2598 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2600 .proc_handler = perf_cpu_time_max_percent_handler,
2601 .extra1 = SYSCTL_ZERO,
2602 .extra2 = &one_hundred,
2605 .procname = "perf_event_max_stack",
2606 .data = &sysctl_perf_event_max_stack,
2607 .maxlen = sizeof(sysctl_perf_event_max_stack),
2609 .proc_handler = perf_event_max_stack_handler,
2610 .extra1 = SYSCTL_ZERO,
2611 .extra2 = &six_hundred_forty_kb,
2614 .procname = "perf_event_max_contexts_per_stack",
2615 .data = &sysctl_perf_event_max_contexts_per_stack,
2616 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2618 .proc_handler = perf_event_max_stack_handler,
2619 .extra1 = SYSCTL_ZERO,
2620 .extra2 = &one_thousand,
2624 .procname = "panic_on_warn",
2625 .data = &panic_on_warn,
2626 .maxlen = sizeof(int),
2628 .proc_handler = proc_dointvec_minmax,
2629 .extra1 = SYSCTL_ZERO,
2630 .extra2 = SYSCTL_ONE,
2632 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2634 .procname = "timer_migration",
2635 .data = &sysctl_timer_migration,
2636 .maxlen = sizeof(unsigned int),
2638 .proc_handler = timer_migration_handler,
2639 .extra1 = SYSCTL_ZERO,
2640 .extra2 = SYSCTL_ONE,
2643 #ifdef CONFIG_BPF_SYSCALL
2645 .procname = "unprivileged_bpf_disabled",
2646 .data = &sysctl_unprivileged_bpf_disabled,
2647 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2649 .proc_handler = bpf_unpriv_handler,
2650 .extra1 = SYSCTL_ZERO,
2654 .procname = "bpf_stats_enabled",
2655 .data = &bpf_stats_enabled_key.key,
2656 .maxlen = sizeof(bpf_stats_enabled_key),
2658 .proc_handler = bpf_stats_handler,
2661 #if defined(CONFIG_TREE_RCU)
2663 .procname = "panic_on_rcu_stall",
2664 .data = &sysctl_panic_on_rcu_stall,
2665 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2667 .proc_handler = proc_dointvec_minmax,
2668 .extra1 = SYSCTL_ZERO,
2669 .extra2 = SYSCTL_ONE,
2672 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2674 .procname = "stack_erasing",
2676 .maxlen = sizeof(int),
2678 .proc_handler = stack_erasing_sysctl,
2679 .extra1 = SYSCTL_ZERO,
2680 .extra2 = SYSCTL_ONE,
2686 static struct ctl_table vm_table[] = {
2688 .procname = "overcommit_memory",
2689 .data = &sysctl_overcommit_memory,
2690 .maxlen = sizeof(sysctl_overcommit_memory),
2692 .proc_handler = overcommit_policy_handler,
2693 .extra1 = SYSCTL_ZERO,
2697 .procname = "panic_on_oom",
2698 .data = &sysctl_panic_on_oom,
2699 .maxlen = sizeof(sysctl_panic_on_oom),
2701 .proc_handler = proc_dointvec_minmax,
2702 .extra1 = SYSCTL_ZERO,
2706 .procname = "oom_kill_allocating_task",
2707 .data = &sysctl_oom_kill_allocating_task,
2708 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2710 .proc_handler = proc_dointvec,
2713 .procname = "oom_dump_tasks",
2714 .data = &sysctl_oom_dump_tasks,
2715 .maxlen = sizeof(sysctl_oom_dump_tasks),
2717 .proc_handler = proc_dointvec,
2720 .procname = "overcommit_ratio",
2721 .data = &sysctl_overcommit_ratio,
2722 .maxlen = sizeof(sysctl_overcommit_ratio),
2724 .proc_handler = overcommit_ratio_handler,
2727 .procname = "overcommit_kbytes",
2728 .data = &sysctl_overcommit_kbytes,
2729 .maxlen = sizeof(sysctl_overcommit_kbytes),
2731 .proc_handler = overcommit_kbytes_handler,
2734 .procname = "page-cluster",
2735 .data = &page_cluster,
2736 .maxlen = sizeof(int),
2738 .proc_handler = proc_dointvec_minmax,
2739 .extra1 = SYSCTL_ZERO,
2742 .procname = "dirty_background_ratio",
2743 .data = &dirty_background_ratio,
2744 .maxlen = sizeof(dirty_background_ratio),
2746 .proc_handler = dirty_background_ratio_handler,
2747 .extra1 = SYSCTL_ZERO,
2748 .extra2 = &one_hundred,
2751 .procname = "dirty_background_bytes",
2752 .data = &dirty_background_bytes,
2753 .maxlen = sizeof(dirty_background_bytes),
2755 .proc_handler = dirty_background_bytes_handler,
2759 .procname = "dirty_ratio",
2760 .data = &vm_dirty_ratio,
2761 .maxlen = sizeof(vm_dirty_ratio),
2763 .proc_handler = dirty_ratio_handler,
2764 .extra1 = SYSCTL_ZERO,
2765 .extra2 = &one_hundred,
2768 .procname = "dirty_bytes",
2769 .data = &vm_dirty_bytes,
2770 .maxlen = sizeof(vm_dirty_bytes),
2772 .proc_handler = dirty_bytes_handler,
2773 .extra1 = &dirty_bytes_min,
2776 .procname = "dirty_writeback_centisecs",
2777 .data = &dirty_writeback_interval,
2778 .maxlen = sizeof(dirty_writeback_interval),
2780 .proc_handler = dirty_writeback_centisecs_handler,
2783 .procname = "dirty_expire_centisecs",
2784 .data = &dirty_expire_interval,
2785 .maxlen = sizeof(dirty_expire_interval),
2787 .proc_handler = proc_dointvec_minmax,
2788 .extra1 = SYSCTL_ZERO,
2791 .procname = "dirtytime_expire_seconds",
2792 .data = &dirtytime_expire_interval,
2793 .maxlen = sizeof(dirtytime_expire_interval),
2795 .proc_handler = dirtytime_interval_handler,
2796 .extra1 = SYSCTL_ZERO,
2799 .procname = "swappiness",
2800 .data = &vm_swappiness,
2801 .maxlen = sizeof(vm_swappiness),
2803 .proc_handler = proc_dointvec_minmax,
2804 .extra1 = SYSCTL_ZERO,
2805 .extra2 = &two_hundred,
2807 #ifdef CONFIG_HUGETLB_PAGE
2809 .procname = "nr_hugepages",
2811 .maxlen = sizeof(unsigned long),
2813 .proc_handler = hugetlb_sysctl_handler,
2817 .procname = "nr_hugepages_mempolicy",
2819 .maxlen = sizeof(unsigned long),
2821 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2824 .procname = "numa_stat",
2825 .data = &sysctl_vm_numa_stat,
2826 .maxlen = sizeof(int),
2828 .proc_handler = sysctl_vm_numa_stat_handler,
2829 .extra1 = SYSCTL_ZERO,
2830 .extra2 = SYSCTL_ONE,
2834 .procname = "hugetlb_shm_group",
2835 .data = &sysctl_hugetlb_shm_group,
2836 .maxlen = sizeof(gid_t),
2838 .proc_handler = proc_dointvec,
2841 .procname = "nr_overcommit_hugepages",
2843 .maxlen = sizeof(unsigned long),
2845 .proc_handler = hugetlb_overcommit_handler,
2849 .procname = "lowmem_reserve_ratio",
2850 .data = &sysctl_lowmem_reserve_ratio,
2851 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2853 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2856 .procname = "drop_caches",
2857 .data = &sysctl_drop_caches,
2858 .maxlen = sizeof(int),
2860 .proc_handler = drop_caches_sysctl_handler,
2861 .extra1 = SYSCTL_ONE,
2864 #ifdef CONFIG_COMPACTION
2866 .procname = "compact_memory",
2867 .data = &sysctl_compact_memory,
2868 .maxlen = sizeof(int),
2870 .proc_handler = sysctl_compaction_handler,
2873 .procname = "compaction_proactiveness",
2874 .data = &sysctl_compaction_proactiveness,
2875 .maxlen = sizeof(sysctl_compaction_proactiveness),
2877 .proc_handler = proc_dointvec_minmax,
2878 .extra1 = SYSCTL_ZERO,
2879 .extra2 = &one_hundred,
2882 .procname = "extfrag_threshold",
2883 .data = &sysctl_extfrag_threshold,
2884 .maxlen = sizeof(int),
2886 .proc_handler = proc_dointvec_minmax,
2887 .extra1 = &min_extfrag_threshold,
2888 .extra2 = &max_extfrag_threshold,
2891 .procname = "compact_unevictable_allowed",
2892 .data = &sysctl_compact_unevictable_allowed,
2893 .maxlen = sizeof(int),
2895 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2896 .extra1 = SYSCTL_ZERO,
2897 .extra2 = SYSCTL_ONE,
2900 #endif /* CONFIG_COMPACTION */
2902 .procname = "min_free_kbytes",
2903 .data = &min_free_kbytes,
2904 .maxlen = sizeof(min_free_kbytes),
2906 .proc_handler = min_free_kbytes_sysctl_handler,
2907 .extra1 = SYSCTL_ZERO,
2910 .procname = "watermark_boost_factor",
2911 .data = &watermark_boost_factor,
2912 .maxlen = sizeof(watermark_boost_factor),
2914 .proc_handler = proc_dointvec_minmax,
2915 .extra1 = SYSCTL_ZERO,
2918 .procname = "watermark_scale_factor",
2919 .data = &watermark_scale_factor,
2920 .maxlen = sizeof(watermark_scale_factor),
2922 .proc_handler = watermark_scale_factor_sysctl_handler,
2923 .extra1 = SYSCTL_ONE,
2924 .extra2 = &one_thousand,
2927 .procname = "percpu_pagelist_fraction",
2928 .data = &percpu_pagelist_fraction,
2929 .maxlen = sizeof(percpu_pagelist_fraction),
2931 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2932 .extra1 = SYSCTL_ZERO,
2935 .procname = "page_lock_unfairness",
2936 .data = &sysctl_page_lock_unfairness,
2937 .maxlen = sizeof(sysctl_page_lock_unfairness),
2939 .proc_handler = proc_dointvec_minmax,
2940 .extra1 = SYSCTL_ZERO,
2944 .procname = "max_map_count",
2945 .data = &sysctl_max_map_count,
2946 .maxlen = sizeof(sysctl_max_map_count),
2948 .proc_handler = proc_dointvec_minmax,
2949 .extra1 = SYSCTL_ZERO,
2953 .procname = "nr_trim_pages",
2954 .data = &sysctl_nr_trim_pages,
2955 .maxlen = sizeof(sysctl_nr_trim_pages),
2957 .proc_handler = proc_dointvec_minmax,
2958 .extra1 = SYSCTL_ZERO,
2962 .procname = "laptop_mode",
2963 .data = &laptop_mode,
2964 .maxlen = sizeof(laptop_mode),
2966 .proc_handler = proc_dointvec_jiffies,
2969 .procname = "block_dump",
2970 .data = &block_dump,
2971 .maxlen = sizeof(block_dump),
2973 .proc_handler = proc_dointvec_minmax,
2974 .extra1 = SYSCTL_ZERO,
2977 .procname = "vfs_cache_pressure",
2978 .data = &sysctl_vfs_cache_pressure,
2979 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2981 .proc_handler = proc_dointvec_minmax,
2982 .extra1 = SYSCTL_ZERO,
2984 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2985 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2987 .procname = "legacy_va_layout",
2988 .data = &sysctl_legacy_va_layout,
2989 .maxlen = sizeof(sysctl_legacy_va_layout),
2991 .proc_handler = proc_dointvec_minmax,
2992 .extra1 = SYSCTL_ZERO,
2997 .procname = "zone_reclaim_mode",
2998 .data = &node_reclaim_mode,
2999 .maxlen = sizeof(node_reclaim_mode),
3001 .proc_handler = proc_dointvec_minmax,
3002 .extra1 = SYSCTL_ZERO,
3005 .procname = "min_unmapped_ratio",
3006 .data = &sysctl_min_unmapped_ratio,
3007 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3009 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3010 .extra1 = SYSCTL_ZERO,
3011 .extra2 = &one_hundred,
3014 .procname = "min_slab_ratio",
3015 .data = &sysctl_min_slab_ratio,
3016 .maxlen = sizeof(sysctl_min_slab_ratio),
3018 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3019 .extra1 = SYSCTL_ZERO,
3020 .extra2 = &one_hundred,
3025 .procname = "stat_interval",
3026 .data = &sysctl_stat_interval,
3027 .maxlen = sizeof(sysctl_stat_interval),
3029 .proc_handler = proc_dointvec_jiffies,
3032 .procname = "stat_refresh",
3036 .proc_handler = vmstat_refresh,
3041 .procname = "mmap_min_addr",
3042 .data = &dac_mmap_min_addr,
3043 .maxlen = sizeof(unsigned long),
3045 .proc_handler = mmap_min_addr_handler,
3050 .procname = "numa_zonelist_order",
3051 .data = &numa_zonelist_order,
3052 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3054 .proc_handler = numa_zonelist_order_handler,
3057 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3058 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3060 .procname = "vdso_enabled",
3061 #ifdef CONFIG_X86_32
3062 .data = &vdso32_enabled,
3063 .maxlen = sizeof(vdso32_enabled),
3065 .data = &vdso_enabled,
3066 .maxlen = sizeof(vdso_enabled),
3069 .proc_handler = proc_dointvec,
3070 .extra1 = SYSCTL_ZERO,
3073 #ifdef CONFIG_HIGHMEM
3075 .procname = "highmem_is_dirtyable",
3076 .data = &vm_highmem_is_dirtyable,
3077 .maxlen = sizeof(vm_highmem_is_dirtyable),
3079 .proc_handler = proc_dointvec_minmax,
3080 .extra1 = SYSCTL_ZERO,
3081 .extra2 = SYSCTL_ONE,
3084 #ifdef CONFIG_MEMORY_FAILURE
3086 .procname = "memory_failure_early_kill",
3087 .data = &sysctl_memory_failure_early_kill,
3088 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3090 .proc_handler = proc_dointvec_minmax,
3091 .extra1 = SYSCTL_ZERO,
3092 .extra2 = SYSCTL_ONE,
3095 .procname = "memory_failure_recovery",
3096 .data = &sysctl_memory_failure_recovery,
3097 .maxlen = sizeof(sysctl_memory_failure_recovery),
3099 .proc_handler = proc_dointvec_minmax,
3100 .extra1 = SYSCTL_ZERO,
3101 .extra2 = SYSCTL_ONE,
3105 .procname = "user_reserve_kbytes",
3106 .data = &sysctl_user_reserve_kbytes,
3107 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3109 .proc_handler = proc_doulongvec_minmax,
3112 .procname = "admin_reserve_kbytes",
3113 .data = &sysctl_admin_reserve_kbytes,
3114 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3116 .proc_handler = proc_doulongvec_minmax,
3118 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3120 .procname = "mmap_rnd_bits",
3121 .data = &mmap_rnd_bits,
3122 .maxlen = sizeof(mmap_rnd_bits),
3124 .proc_handler = proc_dointvec_minmax,
3125 .extra1 = (void *)&mmap_rnd_bits_min,
3126 .extra2 = (void *)&mmap_rnd_bits_max,
3129 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3131 .procname = "mmap_rnd_compat_bits",
3132 .data = &mmap_rnd_compat_bits,
3133 .maxlen = sizeof(mmap_rnd_compat_bits),
3135 .proc_handler = proc_dointvec_minmax,
3136 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3137 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3140 #ifdef CONFIG_USERFAULTFD
3142 .procname = "unprivileged_userfaultfd",
3143 .data = &sysctl_unprivileged_userfaultfd,
3144 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3146 .proc_handler = proc_dointvec_minmax,
3147 .extra1 = SYSCTL_ZERO,
3148 .extra2 = SYSCTL_ONE,
3154 static struct ctl_table fs_table[] = {
3156 .procname = "inode-nr",
3157 .data = &inodes_stat,
3158 .maxlen = 2*sizeof(long),
3160 .proc_handler = proc_nr_inodes,
3163 .procname = "inode-state",
3164 .data = &inodes_stat,
3165 .maxlen = 7*sizeof(long),
3167 .proc_handler = proc_nr_inodes,
3170 .procname = "file-nr",
3171 .data = &files_stat,
3172 .maxlen = sizeof(files_stat),
3174 .proc_handler = proc_nr_files,
3177 .procname = "file-max",
3178 .data = &files_stat.max_files,
3179 .maxlen = sizeof(files_stat.max_files),
3181 .proc_handler = proc_doulongvec_minmax,
3183 .extra2 = &long_max,
3186 .procname = "nr_open",
3187 .data = &sysctl_nr_open,
3188 .maxlen = sizeof(unsigned int),
3190 .proc_handler = proc_dointvec_minmax,
3191 .extra1 = &sysctl_nr_open_min,
3192 .extra2 = &sysctl_nr_open_max,
3195 .procname = "dentry-state",
3196 .data = &dentry_stat,
3197 .maxlen = 6*sizeof(long),
3199 .proc_handler = proc_nr_dentry,
3202 .procname = "overflowuid",
3203 .data = &fs_overflowuid,
3204 .maxlen = sizeof(int),
3206 .proc_handler = proc_dointvec_minmax,
3207 .extra1 = &minolduid,
3208 .extra2 = &maxolduid,
3211 .procname = "overflowgid",
3212 .data = &fs_overflowgid,
3213 .maxlen = sizeof(int),
3215 .proc_handler = proc_dointvec_minmax,
3216 .extra1 = &minolduid,
3217 .extra2 = &maxolduid,
3219 #ifdef CONFIG_FILE_LOCKING
3221 .procname = "leases-enable",
3222 .data = &leases_enable,
3223 .maxlen = sizeof(int),
3225 .proc_handler = proc_dointvec,
3228 #ifdef CONFIG_DNOTIFY
3230 .procname = "dir-notify-enable",
3231 .data = &dir_notify_enable,
3232 .maxlen = sizeof(int),
3234 .proc_handler = proc_dointvec,
3238 #ifdef CONFIG_FILE_LOCKING
3240 .procname = "lease-break-time",
3241 .data = &lease_break_time,
3242 .maxlen = sizeof(int),
3244 .proc_handler = proc_dointvec,
3249 .procname = "aio-nr",
3251 .maxlen = sizeof(aio_nr),
3253 .proc_handler = proc_doulongvec_minmax,
3256 .procname = "aio-max-nr",
3257 .data = &aio_max_nr,
3258 .maxlen = sizeof(aio_max_nr),
3260 .proc_handler = proc_doulongvec_minmax,
3262 #endif /* CONFIG_AIO */
3263 #ifdef CONFIG_INOTIFY_USER
3265 .procname = "inotify",
3267 .child = inotify_table,
3272 .procname = "epoll",
3274 .child = epoll_table,
3279 .procname = "protected_symlinks",
3280 .data = &sysctl_protected_symlinks,
3281 .maxlen = sizeof(int),
3283 .proc_handler = proc_dointvec_minmax,
3284 .extra1 = SYSCTL_ZERO,
3285 .extra2 = SYSCTL_ONE,
3288 .procname = "protected_hardlinks",
3289 .data = &sysctl_protected_hardlinks,
3290 .maxlen = sizeof(int),
3292 .proc_handler = proc_dointvec_minmax,
3293 .extra1 = SYSCTL_ZERO,
3294 .extra2 = SYSCTL_ONE,
3297 .procname = "protected_fifos",
3298 .data = &sysctl_protected_fifos,
3299 .maxlen = sizeof(int),
3301 .proc_handler = proc_dointvec_minmax,
3302 .extra1 = SYSCTL_ZERO,
3306 .procname = "protected_regular",
3307 .data = &sysctl_protected_regular,
3308 .maxlen = sizeof(int),
3310 .proc_handler = proc_dointvec_minmax,
3311 .extra1 = SYSCTL_ZERO,
3315 .procname = "suid_dumpable",
3316 .data = &suid_dumpable,
3317 .maxlen = sizeof(int),
3319 .proc_handler = proc_dointvec_minmax_coredump,
3320 .extra1 = SYSCTL_ZERO,
3323 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3325 .procname = "binfmt_misc",
3327 .child = sysctl_mount_point,
3331 .procname = "pipe-max-size",
3332 .data = &pipe_max_size,
3333 .maxlen = sizeof(pipe_max_size),
3335 .proc_handler = proc_dopipe_max_size,
3338 .procname = "pipe-user-pages-hard",
3339 .data = &pipe_user_pages_hard,
3340 .maxlen = sizeof(pipe_user_pages_hard),
3342 .proc_handler = proc_doulongvec_minmax,
3345 .procname = "pipe-user-pages-soft",
3346 .data = &pipe_user_pages_soft,
3347 .maxlen = sizeof(pipe_user_pages_soft),
3349 .proc_handler = proc_doulongvec_minmax,
3352 .procname = "mount-max",
3353 .data = &sysctl_mount_max,
3354 .maxlen = sizeof(unsigned int),
3356 .proc_handler = proc_dointvec_minmax,
3357 .extra1 = SYSCTL_ONE,
3362 static struct ctl_table debug_table[] = {
3363 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3365 .procname = "exception-trace",
3366 .data = &show_unhandled_signals,
3367 .maxlen = sizeof(int),
3369 .proc_handler = proc_dointvec
3372 #if defined(CONFIG_OPTPROBES)
3374 .procname = "kprobes-optimization",
3375 .data = &sysctl_kprobes_optimization,
3376 .maxlen = sizeof(int),
3378 .proc_handler = proc_kprobes_optimization_handler,
3379 .extra1 = SYSCTL_ZERO,
3380 .extra2 = SYSCTL_ONE,
3386 static struct ctl_table dev_table[] = {
3390 static struct ctl_table sysctl_base_table[] = {
3392 .procname = "kernel",
3394 .child = kern_table,
3407 .procname = "debug",
3409 .child = debug_table,
3419 int __init sysctl_init(void)
3421 struct ctl_table_header *hdr;
3423 hdr = register_sysctl_table(sysctl_base_table);
3424 kmemleak_not_leak(hdr);
3427 #endif /* CONFIG_SYSCTL */
3429 * No sense putting this after each symbol definition, twice,
3430 * exception granted :-)
3432 EXPORT_SYMBOL(proc_dointvec);
3433 EXPORT_SYMBOL(proc_douintvec);
3434 EXPORT_SYMBOL(proc_dointvec_jiffies);
3435 EXPORT_SYMBOL(proc_dointvec_minmax);
3436 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3437 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3438 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3439 EXPORT_SYMBOL(proc_dostring);
3440 EXPORT_SYMBOL(proc_doulongvec_minmax);
3441 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3442 EXPORT_SYMBOL(proc_do_large_bitmap);