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 int __maybe_unused neg_one = -1;
117 static int __maybe_unused two = 2;
118 static int __maybe_unused four = 4;
119 static unsigned long zero_ul;
120 static unsigned long one_ul = 1;
121 static unsigned long long_max = LONG_MAX;
122 static int one_hundred = 100;
123 static int two_hundred = 200;
124 static int one_thousand = 1000;
126 static int ten_thousand = 10000;
128 #ifdef CONFIG_PERF_EVENTS
129 static int six_hundred_forty_kb = 640 * 1024;
132 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
133 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
135 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
136 static int maxolduid = 65535;
137 static int minolduid;
139 static int ngroups_max = NGROUPS_MAX;
140 static const int cap_last_cap = CAP_LAST_CAP;
143 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
144 * and hung_task_check_interval_secs
146 #ifdef CONFIG_DETECT_HUNG_TASK
147 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150 #ifdef CONFIG_INOTIFY_USER
151 #include <linux/inotify.h>
153 #ifdef CONFIG_FANOTIFY
154 #include <linux/fanotify.h>
157 #ifdef CONFIG_PROC_SYSCTL
160 * enum sysctl_writes_mode - supported sysctl write modes
162 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
163 * to be written, and multiple writes on the same sysctl file descriptor
164 * will rewrite the sysctl value, regardless of file position. No warning
165 * is issued when the initial position is not 0.
166 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
168 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
169 * file position 0 and the value must be fully contained in the buffer
170 * sent to the write syscall. If dealing with strings respect the file
171 * position, but restrict this to the max length of the buffer, anything
172 * passed the max length will be ignored. Multiple writes will append
175 * These write modes control how current file position affects the behavior of
176 * updating sysctl values through the proc interface on each write.
178 enum sysctl_writes_mode {
179 SYSCTL_WRITES_LEGACY = -1,
180 SYSCTL_WRITES_WARN = 0,
181 SYSCTL_WRITES_STRICT = 1,
184 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
185 #endif /* CONFIG_PROC_SYSCTL */
187 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
188 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
189 int sysctl_legacy_va_layout;
192 #ifdef CONFIG_COMPACTION
193 static int min_extfrag_threshold;
194 static int max_extfrag_threshold = 1000;
197 #endif /* CONFIG_SYSCTL */
199 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
200 static int bpf_stats_handler(struct ctl_table *table, int write,
201 void *buffer, size_t *lenp, loff_t *ppos)
203 struct static_key *key = (struct static_key *)table->data;
204 static int saved_val;
206 struct ctl_table tmp = {
208 .maxlen = sizeof(val),
210 .extra1 = SYSCTL_ZERO,
211 .extra2 = SYSCTL_ONE,
214 if (write && !capable(CAP_SYS_ADMIN))
217 mutex_lock(&bpf_stats_enabled_mutex);
219 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
220 if (write && !ret && val != saved_val) {
222 static_key_slow_inc(key);
224 static_key_slow_dec(key);
227 mutex_unlock(&bpf_stats_enabled_mutex);
231 static int bpf_unpriv_handler(struct ctl_table *table, int write,
232 void *buffer, size_t *lenp, loff_t *ppos)
234 int ret, unpriv_enable = *(int *)table->data;
235 bool locked_state = unpriv_enable == 1;
236 struct ctl_table tmp = *table;
238 if (write && !capable(CAP_SYS_ADMIN))
241 tmp.data = &unpriv_enable;
242 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
244 if (locked_state && unpriv_enable != 1)
246 *(int *)table->data = unpriv_enable;
250 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
256 #ifdef CONFIG_PROC_SYSCTL
258 static int _proc_do_string(char *data, int maxlen, int write,
259 char *buffer, size_t *lenp, loff_t *ppos)
264 if (!data || !maxlen || !*lenp) {
270 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
271 /* Only continue writes not past the end of buffer. */
273 if (len > maxlen - 1)
280 /* Start writing from beginning of buffer. */
286 while ((p - buffer) < *lenp && len < maxlen - 1) {
288 if (c == 0 || c == '\n')
309 memcpy(buffer, data, len);
320 static void warn_sysctl_write(struct ctl_table *table)
322 pr_warn_once("%s wrote to %s when file position was not 0!\n"
323 "This will not be supported in the future. To silence this\n"
324 "warning, set kernel.sysctl_writes_strict = -1\n",
325 current->comm, table->procname);
329 * proc_first_pos_non_zero_ignore - check if first position is allowed
330 * @ppos: file position
331 * @table: the sysctl table
333 * Returns true if the first position is non-zero and the sysctl_writes_strict
334 * mode indicates this is not allowed for numeric input types. String proc
335 * handlers can ignore the return value.
337 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
338 struct ctl_table *table)
343 switch (sysctl_writes_strict) {
344 case SYSCTL_WRITES_STRICT:
346 case SYSCTL_WRITES_WARN:
347 warn_sysctl_write(table);
355 * proc_dostring - read a string sysctl
356 * @table: the sysctl table
357 * @write: %TRUE if this is a write to the sysctl file
358 * @buffer: the user buffer
359 * @lenp: the size of the user buffer
360 * @ppos: file position
362 * Reads/writes a string from/to the user buffer. If the kernel
363 * buffer provided is not large enough to hold the string, the
364 * string is truncated. The copied string is %NULL-terminated.
365 * If the string is being read by the user process, it is copied
366 * and a newline '\n' is added. It is truncated if the buffer is
369 * Returns 0 on success.
371 int proc_dostring(struct ctl_table *table, int write,
372 void *buffer, size_t *lenp, loff_t *ppos)
375 proc_first_pos_non_zero_ignore(ppos, table);
377 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
381 static size_t proc_skip_spaces(char **buf)
384 char *tmp = skip_spaces(*buf);
390 static void proc_skip_char(char **buf, size_t *size, const char v)
401 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
404 * @cp: kernel buffer containing the string to parse
405 * @endp: pointer to store the trailing characters
406 * @base: the base to use
407 * @res: where the parsed integer will be stored
409 * In case of success 0 is returned and @res will contain the parsed integer,
410 * @endp will hold any trailing characters.
411 * This function will fail the parse on overflow. If there wasn't an overflow
412 * the function will defer the decision what characters count as invalid to the
415 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
418 unsigned long long result;
421 cp = _parse_integer_fixup_radix(cp, &base);
422 rv = _parse_integer(cp, base, &result);
423 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
431 *res = (unsigned long)result;
437 * proc_get_long - reads an ASCII formatted integer from a user buffer
439 * @buf: a kernel buffer
440 * @size: size of the kernel buffer
441 * @val: this is where the number will be stored
442 * @neg: set to %TRUE if number is negative
443 * @perm_tr: a vector which contains the allowed trailers
444 * @perm_tr_len: size of the perm_tr vector
445 * @tr: pointer to store the trailer character
447 * In case of success %0 is returned and @buf and @size are updated with
448 * the amount of bytes read. If @tr is non-NULL and a trailing
449 * character exists (size is non-zero after returning from this
450 * function), @tr is updated with the trailing character.
452 static int proc_get_long(char **buf, size_t *size,
453 unsigned long *val, bool *neg,
454 const char *perm_tr, unsigned perm_tr_len, char *tr)
457 char *p, tmp[TMPBUFLEN];
463 if (len > TMPBUFLEN - 1)
466 memcpy(tmp, *buf, len);
470 if (*p == '-' && *size > 1) {
478 if (strtoul_lenient(p, &p, 0, val))
483 /* We don't know if the next char is whitespace thus we may accept
484 * invalid integers (e.g. 1234...a) or two integers instead of one
485 * (e.g. 123...1). So lets not allow such large numbers. */
486 if (len == TMPBUFLEN - 1)
489 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
492 if (tr && (len < *size))
502 * proc_put_long - converts an integer to a decimal ASCII formatted string
504 * @buf: the user buffer
505 * @size: the size of the user buffer
506 * @val: the integer to be converted
507 * @neg: sign of the number, %TRUE for negative
509 * In case of success @buf and @size are updated with the amount of bytes
512 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
515 char tmp[TMPBUFLEN], *p = tmp;
517 sprintf(p, "%s%lu", neg ? "-" : "", val);
521 memcpy(*buf, tmp, len);
527 static void proc_put_char(void **buf, size_t *size, char c)
530 char **buffer = (char **)buf;
539 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
541 int write, void *data)
544 *(bool *)valp = *lvalp;
546 int val = *(bool *)valp;
548 *lvalp = (unsigned long)val;
554 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
556 int write, void *data)
560 if (*lvalp > (unsigned long) INT_MAX + 1)
564 if (*lvalp > (unsigned long) INT_MAX)
572 *lvalp = -(unsigned long)val;
575 *lvalp = (unsigned long)val;
581 static int do_proc_douintvec_conv(unsigned long *lvalp,
583 int write, void *data)
586 if (*lvalp > UINT_MAX)
590 unsigned int val = *valp;
591 *lvalp = (unsigned long)val;
596 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
598 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
599 int write, void *buffer,
600 size_t *lenp, loff_t *ppos,
601 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
602 int write, void *data),
605 int *i, vleft, first = 1, err = 0;
609 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
614 i = (int *) tbl_data;
615 vleft = table->maxlen / sizeof(*i);
619 conv = do_proc_dointvec_conv;
622 if (proc_first_pos_non_zero_ignore(ppos, table))
625 if (left > PAGE_SIZE - 1)
626 left = PAGE_SIZE - 1;
630 for (; left && vleft--; i++, first=0) {
635 left -= proc_skip_spaces(&p);
639 err = proc_get_long(&p, &left, &lval, &neg,
641 sizeof(proc_wspace_sep), NULL);
644 if (conv(&neg, &lval, i, 1, data)) {
649 if (conv(&neg, &lval, i, 0, data)) {
654 proc_put_char(&buffer, &left, '\t');
655 proc_put_long(&buffer, &left, lval, neg);
659 if (!write && !first && left && !err)
660 proc_put_char(&buffer, &left, '\n');
661 if (write && !err && left)
662 left -= proc_skip_spaces(&p);
664 return err ? : -EINVAL;
671 static int do_proc_dointvec(struct ctl_table *table, int write,
672 void *buffer, size_t *lenp, loff_t *ppos,
673 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
674 int write, void *data),
677 return __do_proc_dointvec(table->data, table, write,
678 buffer, lenp, ppos, conv, data);
681 static int do_proc_douintvec_w(unsigned int *tbl_data,
682 struct ctl_table *table,
684 size_t *lenp, loff_t *ppos,
685 int (*conv)(unsigned long *lvalp,
687 int write, void *data),
698 if (proc_first_pos_non_zero_ignore(ppos, table))
701 if (left > PAGE_SIZE - 1)
702 left = PAGE_SIZE - 1;
704 left -= proc_skip_spaces(&p);
710 err = proc_get_long(&p, &left, &lval, &neg,
712 sizeof(proc_wspace_sep), NULL);
718 if (conv(&lval, tbl_data, 1, data)) {
724 left -= proc_skip_spaces(&p);
732 /* This is in keeping with old __do_proc_dointvec() */
738 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
739 size_t *lenp, loff_t *ppos,
740 int (*conv)(unsigned long *lvalp,
742 int write, void *data),
751 if (conv(&lval, tbl_data, 0, data)) {
756 proc_put_long(&buffer, &left, lval, false);
760 proc_put_char(&buffer, &left, '\n');
769 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
770 int write, void *buffer,
771 size_t *lenp, loff_t *ppos,
772 int (*conv)(unsigned long *lvalp,
774 int write, void *data),
777 unsigned int *i, vleft;
779 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
784 i = (unsigned int *) tbl_data;
785 vleft = table->maxlen / sizeof(*i);
788 * Arrays are not supported, keep this simple. *Do not* add
797 conv = do_proc_douintvec_conv;
800 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
802 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
805 static int do_proc_douintvec(struct ctl_table *table, int write,
806 void *buffer, size_t *lenp, loff_t *ppos,
807 int (*conv)(unsigned long *lvalp,
809 int write, void *data),
812 return __do_proc_douintvec(table->data, table, write,
813 buffer, lenp, ppos, conv, data);
817 * proc_dobool - read/write a bool
818 * @table: the sysctl table
819 * @write: %TRUE if this is a write to the sysctl file
820 * @buffer: the user buffer
821 * @lenp: the size of the user buffer
822 * @ppos: file position
824 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
825 * values from/to the user buffer, treated as an ASCII string.
827 * Returns 0 on success.
829 int proc_dobool(struct ctl_table *table, int write, void *buffer,
830 size_t *lenp, loff_t *ppos)
832 return do_proc_dointvec(table, write, buffer, lenp, ppos,
833 do_proc_dobool_conv, NULL);
837 * proc_dointvec - read a vector of integers
838 * @table: the sysctl table
839 * @write: %TRUE if this is a write to the sysctl file
840 * @buffer: the user buffer
841 * @lenp: the size of the user buffer
842 * @ppos: file position
844 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
845 * values from/to the user buffer, treated as an ASCII string.
847 * Returns 0 on success.
849 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
850 size_t *lenp, loff_t *ppos)
852 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
855 #ifdef CONFIG_COMPACTION
856 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
857 int write, void *buffer, size_t *lenp, loff_t *ppos)
861 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
862 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
864 old = *(int *)table->data;
865 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
868 if (old != *(int *)table->data)
869 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
870 table->procname, current->comm,
871 task_pid_nr(current));
877 * proc_douintvec - read a vector of unsigned integers
878 * @table: the sysctl table
879 * @write: %TRUE if this is a write to the sysctl file
880 * @buffer: the user buffer
881 * @lenp: the size of the user buffer
882 * @ppos: file position
884 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
885 * values from/to the user buffer, treated as an ASCII string.
887 * Returns 0 on success.
889 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
890 size_t *lenp, loff_t *ppos)
892 return do_proc_douintvec(table, write, buffer, lenp, ppos,
893 do_proc_douintvec_conv, NULL);
897 * Taint values can only be increased
898 * This means we can safely use a temporary.
900 static int proc_taint(struct ctl_table *table, int write,
901 void *buffer, size_t *lenp, loff_t *ppos)
904 unsigned long tmptaint = get_taint();
907 if (write && !capable(CAP_SYS_ADMIN))
912 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
920 * If we are relying on panic_on_taint not producing
921 * false positives due to userspace input, bail out
922 * before setting the requested taint flags.
924 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
928 * Poor man's atomic or. Not worth adding a primitive
929 * to everyone's atomic.h for this
931 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
932 if ((1UL << i) & tmptaint)
933 add_taint(i, LOCKDEP_STILL_OK);
940 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
941 void *buffer, size_t *lenp, loff_t *ppos)
943 if (write && !capable(CAP_SYS_ADMIN))
946 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
951 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
952 * @min: pointer to minimum allowable value
953 * @max: pointer to maximum allowable value
955 * The do_proc_dointvec_minmax_conv_param structure provides the
956 * minimum and maximum values for doing range checking for those sysctl
957 * parameters that use the proc_dointvec_minmax() handler.
959 struct do_proc_dointvec_minmax_conv_param {
964 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
966 int write, void *data)
969 struct do_proc_dointvec_minmax_conv_param *param = data;
971 * If writing, first do so via a temporary local int so we can
972 * bounds-check it before touching *valp.
974 int *ip = write ? &tmp : valp;
976 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
981 if ((param->min && *param->min > tmp) ||
982 (param->max && *param->max < tmp))
991 * proc_dointvec_minmax - read a vector of integers with min/max values
992 * @table: the sysctl table
993 * @write: %TRUE if this is a write to the sysctl file
994 * @buffer: the user buffer
995 * @lenp: the size of the user buffer
996 * @ppos: file position
998 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
999 * values from/to the user buffer, treated as an ASCII string.
1001 * This routine will ensure the values are within the range specified by
1002 * table->extra1 (min) and table->extra2 (max).
1004 * Returns 0 on success or -EINVAL on write when the range check fails.
1006 int proc_dointvec_minmax(struct ctl_table *table, int write,
1007 void *buffer, size_t *lenp, loff_t *ppos)
1009 struct do_proc_dointvec_minmax_conv_param param = {
1010 .min = (int *) table->extra1,
1011 .max = (int *) table->extra2,
1013 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1014 do_proc_dointvec_minmax_conv, ¶m);
1018 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1019 * @min: pointer to minimum allowable value
1020 * @max: pointer to maximum allowable value
1022 * The do_proc_douintvec_minmax_conv_param structure provides the
1023 * minimum and maximum values for doing range checking for those sysctl
1024 * parameters that use the proc_douintvec_minmax() handler.
1026 struct do_proc_douintvec_minmax_conv_param {
1031 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1033 int write, void *data)
1037 struct do_proc_douintvec_minmax_conv_param *param = data;
1038 /* write via temporary local uint for bounds-checking */
1039 unsigned int *up = write ? &tmp : valp;
1041 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1046 if ((param->min && *param->min > tmp) ||
1047 (param->max && *param->max < tmp))
1057 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1058 * @table: the sysctl table
1059 * @write: %TRUE if this is a write to the sysctl file
1060 * @buffer: the user buffer
1061 * @lenp: the size of the user buffer
1062 * @ppos: file position
1064 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1065 * values from/to the user buffer, treated as an ASCII string. Negative
1066 * strings are not allowed.
1068 * This routine will ensure the values are within the range specified by
1069 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1070 * check for UINT_MAX to avoid having to support wrap around uses from
1073 * Returns 0 on success or -ERANGE on write when the range check fails.
1075 int proc_douintvec_minmax(struct ctl_table *table, int write,
1076 void *buffer, size_t *lenp, loff_t *ppos)
1078 struct do_proc_douintvec_minmax_conv_param param = {
1079 .min = (unsigned int *) table->extra1,
1080 .max = (unsigned int *) table->extra2,
1082 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1083 do_proc_douintvec_minmax_conv, ¶m);
1087 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1088 * @table: the sysctl table
1089 * @write: %TRUE if this is a write to the sysctl file
1090 * @buffer: the user buffer
1091 * @lenp: the size of the user buffer
1092 * @ppos: file position
1094 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1095 * values from/to the user buffer, treated as an ASCII string. Negative
1096 * strings are not allowed.
1098 * This routine will ensure the values are within the range specified by
1099 * table->extra1 (min) and table->extra2 (max).
1101 * Returns 0 on success or an error on write when the range check fails.
1103 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1104 void *buffer, size_t *lenp, loff_t *ppos)
1106 struct ctl_table tmp;
1107 unsigned int min = 0, max = 255U, val;
1108 u8 *data = table->data;
1109 struct do_proc_douintvec_minmax_conv_param param = {
1115 /* Do not support arrays yet. */
1116 if (table->maxlen != sizeof(u8))
1119 if (table->extra1) {
1120 min = *(unsigned int *) table->extra1;
1124 if (table->extra2) {
1125 max = *(unsigned int *) table->extra2;
1132 tmp.maxlen = sizeof(val);
1135 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1136 do_proc_douintvec_minmax_conv, ¶m);
1143 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1145 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1147 int write, void *data)
1152 val = round_pipe_size(*lvalp);
1158 unsigned int val = *valp;
1159 *lvalp = (unsigned long) val;
1165 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1166 void *buffer, size_t *lenp, loff_t *ppos)
1168 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1169 do_proc_dopipe_max_size_conv, NULL);
1172 static void validate_coredump_safety(void)
1174 #ifdef CONFIG_COREDUMP
1175 if (suid_dumpable == SUID_DUMP_ROOT &&
1176 core_pattern[0] != '/' && core_pattern[0] != '|') {
1178 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1179 "Pipe handler or fully qualified core dump path required.\n"
1180 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1186 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1187 void *buffer, size_t *lenp, loff_t *ppos)
1189 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1191 validate_coredump_safety();
1195 #ifdef CONFIG_COREDUMP
1196 static int proc_dostring_coredump(struct ctl_table *table, int write,
1197 void *buffer, size_t *lenp, loff_t *ppos)
1199 int error = proc_dostring(table, write, buffer, lenp, ppos);
1201 validate_coredump_safety();
1206 #ifdef CONFIG_MAGIC_SYSRQ
1207 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1208 void *buffer, size_t *lenp, loff_t *ppos)
1214 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1215 lenp, ppos, NULL, NULL);
1220 sysrq_toggle_support(tmp);
1226 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1227 int write, void *buffer, size_t *lenp, loff_t *ppos,
1228 unsigned long convmul, unsigned long convdiv)
1230 unsigned long *i, *min, *max;
1231 int vleft, first = 1, err = 0;
1235 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1240 i = (unsigned long *) data;
1241 min = (unsigned long *) table->extra1;
1242 max = (unsigned long *) table->extra2;
1243 vleft = table->maxlen / sizeof(unsigned long);
1247 if (proc_first_pos_non_zero_ignore(ppos, table))
1250 if (left > PAGE_SIZE - 1)
1251 left = PAGE_SIZE - 1;
1255 for (; left && vleft--; i++, first = 0) {
1261 left -= proc_skip_spaces(&p);
1265 err = proc_get_long(&p, &left, &val, &neg,
1267 sizeof(proc_wspace_sep), NULL);
1272 val = convmul * val / convdiv;
1273 if ((min && val < *min) || (max && val > *max)) {
1279 val = convdiv * (*i) / convmul;
1281 proc_put_char(&buffer, &left, '\t');
1282 proc_put_long(&buffer, &left, val, false);
1286 if (!write && !first && left && !err)
1287 proc_put_char(&buffer, &left, '\n');
1289 left -= proc_skip_spaces(&p);
1291 return err ? : -EINVAL;
1298 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1299 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1300 unsigned long convdiv)
1302 return __do_proc_doulongvec_minmax(table->data, table, write,
1303 buffer, lenp, ppos, convmul, convdiv);
1307 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1308 * @table: the sysctl table
1309 * @write: %TRUE if this is a write to the sysctl file
1310 * @buffer: the user buffer
1311 * @lenp: the size of the user buffer
1312 * @ppos: file position
1314 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1315 * values from/to the user buffer, treated as an ASCII string.
1317 * This routine will ensure the values are within the range specified by
1318 * table->extra1 (min) and table->extra2 (max).
1320 * Returns 0 on success.
1322 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1323 void *buffer, size_t *lenp, loff_t *ppos)
1325 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1329 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1330 * @table: the sysctl table
1331 * @write: %TRUE if this is a write to the sysctl file
1332 * @buffer: the user buffer
1333 * @lenp: the size of the user buffer
1334 * @ppos: file position
1336 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1337 * values from/to the user buffer, treated as an ASCII string. The values
1338 * are treated as milliseconds, and converted to jiffies when they are stored.
1340 * This routine will ensure the values are within the range specified by
1341 * table->extra1 (min) and table->extra2 (max).
1343 * Returns 0 on success.
1345 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1346 void *buffer, size_t *lenp, loff_t *ppos)
1348 return do_proc_doulongvec_minmax(table, write, buffer,
1349 lenp, ppos, HZ, 1000l);
1353 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1355 int write, void *data)
1358 if (*lvalp > INT_MAX / HZ)
1360 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1366 lval = -(unsigned long)val;
1369 lval = (unsigned long)val;
1376 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1378 int write, void *data)
1381 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1383 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1389 lval = -(unsigned long)val;
1392 lval = (unsigned long)val;
1394 *lvalp = jiffies_to_clock_t(lval);
1399 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1401 int write, void *data)
1404 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1414 lval = -(unsigned long)val;
1417 lval = (unsigned long)val;
1419 *lvalp = jiffies_to_msecs(lval);
1425 * proc_dointvec_jiffies - read a vector of integers as seconds
1426 * @table: the sysctl table
1427 * @write: %TRUE if this is a write to the sysctl file
1428 * @buffer: the user buffer
1429 * @lenp: the size of the user buffer
1430 * @ppos: file position
1432 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1433 * values from/to the user buffer, treated as an ASCII string.
1434 * The values read are assumed to be in seconds, and are converted into
1437 * Returns 0 on success.
1439 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1440 void *buffer, size_t *lenp, loff_t *ppos)
1442 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1443 do_proc_dointvec_jiffies_conv,NULL);
1447 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1448 * @table: the sysctl table
1449 * @write: %TRUE if this is a write to the sysctl file
1450 * @buffer: the user buffer
1451 * @lenp: the size of the user buffer
1452 * @ppos: pointer to the file position
1454 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1455 * values from/to the user buffer, treated as an ASCII string.
1456 * The values read are assumed to be in 1/USER_HZ seconds, and
1457 * are converted into jiffies.
1459 * Returns 0 on success.
1461 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1462 void *buffer, size_t *lenp, loff_t *ppos)
1464 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1465 do_proc_dointvec_userhz_jiffies_conv,NULL);
1469 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1470 * @table: the sysctl table
1471 * @write: %TRUE if this is a write to the sysctl file
1472 * @buffer: the user buffer
1473 * @lenp: the size of the user buffer
1474 * @ppos: file position
1475 * @ppos: the current position in the file
1477 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1478 * values from/to the user buffer, treated as an ASCII string.
1479 * The values read are assumed to be in 1/1000 seconds, and
1480 * are converted into jiffies.
1482 * Returns 0 on success.
1484 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1485 size_t *lenp, loff_t *ppos)
1487 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1488 do_proc_dointvec_ms_jiffies_conv, NULL);
1491 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1492 size_t *lenp, loff_t *ppos)
1494 struct pid *new_pid;
1498 tmp = pid_vnr(cad_pid);
1500 r = __do_proc_dointvec(&tmp, table, write, buffer,
1501 lenp, ppos, NULL, NULL);
1505 new_pid = find_get_pid(tmp);
1509 put_pid(xchg(&cad_pid, new_pid));
1514 * proc_do_large_bitmap - read/write from/to a large bitmap
1515 * @table: the sysctl table
1516 * @write: %TRUE if this is a write to the sysctl file
1517 * @buffer: the user buffer
1518 * @lenp: the size of the user buffer
1519 * @ppos: file position
1521 * The bitmap is stored at table->data and the bitmap length (in bits)
1524 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1525 * large bitmaps may be represented in a compact manner. Writing into
1526 * the file will clear the bitmap then update it with the given input.
1528 * Returns 0 on success.
1530 int proc_do_large_bitmap(struct ctl_table *table, int write,
1531 void *buffer, size_t *lenp, loff_t *ppos)
1534 size_t left = *lenp;
1535 unsigned long bitmap_len = table->maxlen;
1536 unsigned long *bitmap = *(unsigned long **) table->data;
1537 unsigned long *tmp_bitmap = NULL;
1538 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1540 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1549 if (left > PAGE_SIZE - 1) {
1550 left = PAGE_SIZE - 1;
1551 /* How much of the buffer we'll skip this pass */
1552 skipped = *lenp - left;
1555 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1558 proc_skip_char(&p, &left, '\n');
1559 while (!err && left) {
1560 unsigned long val_a, val_b;
1564 /* In case we stop parsing mid-number, we can reset */
1566 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1569 * If we consumed the entirety of a truncated buffer or
1570 * only one char is left (may be a "-"), then stop here,
1571 * reset, & come back for more.
1573 if ((left <= 1) && skipped) {
1580 if (val_a >= bitmap_len || neg) {
1592 err = proc_get_long(&p, &left, &val_b,
1593 &neg, tr_b, sizeof(tr_b),
1596 * If we consumed all of a truncated buffer or
1597 * then stop here, reset, & come back for more.
1599 if (!left && skipped) {
1606 if (val_b >= bitmap_len || neg ||
1617 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1618 proc_skip_char(&p, &left, '\n');
1622 unsigned long bit_a, bit_b = 0;
1626 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1627 if (bit_a >= bitmap_len)
1629 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1633 proc_put_char(&buffer, &left, ',');
1634 proc_put_long(&buffer, &left, bit_a, false);
1635 if (bit_a != bit_b) {
1636 proc_put_char(&buffer, &left, '-');
1637 proc_put_long(&buffer, &left, bit_b, false);
1642 proc_put_char(&buffer, &left, '\n');
1648 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1650 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1656 bitmap_free(tmp_bitmap);
1660 #else /* CONFIG_PROC_SYSCTL */
1662 int proc_dostring(struct ctl_table *table, int write,
1663 void *buffer, size_t *lenp, loff_t *ppos)
1668 int proc_dobool(struct ctl_table *table, int write,
1669 void *buffer, size_t *lenp, loff_t *ppos)
1674 int proc_dointvec(struct ctl_table *table, int write,
1675 void *buffer, size_t *lenp, loff_t *ppos)
1680 int proc_douintvec(struct ctl_table *table, int write,
1681 void *buffer, size_t *lenp, loff_t *ppos)
1686 int proc_dointvec_minmax(struct ctl_table *table, int write,
1687 void *buffer, size_t *lenp, loff_t *ppos)
1692 int proc_douintvec_minmax(struct ctl_table *table, int write,
1693 void *buffer, size_t *lenp, loff_t *ppos)
1698 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1699 void *buffer, size_t *lenp, loff_t *ppos)
1704 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1705 void *buffer, size_t *lenp, loff_t *ppos)
1710 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1711 void *buffer, size_t *lenp, loff_t *ppos)
1716 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1717 void *buffer, size_t *lenp, loff_t *ppos)
1722 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1723 void *buffer, size_t *lenp, loff_t *ppos)
1728 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1729 void *buffer, size_t *lenp, loff_t *ppos)
1734 int proc_do_large_bitmap(struct ctl_table *table, int write,
1735 void *buffer, size_t *lenp, loff_t *ppos)
1740 #endif /* CONFIG_PROC_SYSCTL */
1742 #if defined(CONFIG_SYSCTL)
1743 int proc_do_static_key(struct ctl_table *table, int write,
1744 void *buffer, size_t *lenp, loff_t *ppos)
1746 struct static_key *key = (struct static_key *)table->data;
1747 static DEFINE_MUTEX(static_key_mutex);
1749 struct ctl_table tmp = {
1751 .maxlen = sizeof(val),
1752 .mode = table->mode,
1753 .extra1 = SYSCTL_ZERO,
1754 .extra2 = SYSCTL_ONE,
1757 if (write && !capable(CAP_SYS_ADMIN))
1760 mutex_lock(&static_key_mutex);
1761 val = static_key_enabled(key);
1762 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1763 if (write && !ret) {
1765 static_key_enable(key);
1767 static_key_disable(key);
1769 mutex_unlock(&static_key_mutex);
1773 static struct ctl_table kern_table[] = {
1775 .procname = "sched_child_runs_first",
1776 .data = &sysctl_sched_child_runs_first,
1777 .maxlen = sizeof(unsigned int),
1779 .proc_handler = proc_dointvec,
1781 #ifdef CONFIG_SCHEDSTATS
1783 .procname = "sched_schedstats",
1785 .maxlen = sizeof(unsigned int),
1787 .proc_handler = sysctl_schedstats,
1788 .extra1 = SYSCTL_ZERO,
1789 .extra2 = SYSCTL_ONE,
1791 #endif /* CONFIG_SCHEDSTATS */
1792 #ifdef CONFIG_TASK_DELAY_ACCT
1794 .procname = "task_delayacct",
1796 .maxlen = sizeof(unsigned int),
1798 .proc_handler = sysctl_delayacct,
1799 .extra1 = SYSCTL_ZERO,
1800 .extra2 = SYSCTL_ONE,
1802 #endif /* CONFIG_TASK_DELAY_ACCT */
1803 #ifdef CONFIG_NUMA_BALANCING
1805 .procname = "numa_balancing",
1806 .data = NULL, /* filled in by handler */
1807 .maxlen = sizeof(unsigned int),
1809 .proc_handler = sysctl_numa_balancing,
1810 .extra1 = SYSCTL_ZERO,
1811 .extra2 = SYSCTL_ONE,
1813 #endif /* CONFIG_NUMA_BALANCING */
1815 .procname = "sched_rt_period_us",
1816 .data = &sysctl_sched_rt_period,
1817 .maxlen = sizeof(unsigned int),
1819 .proc_handler = sched_rt_handler,
1822 .procname = "sched_rt_runtime_us",
1823 .data = &sysctl_sched_rt_runtime,
1824 .maxlen = sizeof(int),
1826 .proc_handler = sched_rt_handler,
1829 .procname = "sched_deadline_period_max_us",
1830 .data = &sysctl_sched_dl_period_max,
1831 .maxlen = sizeof(unsigned int),
1833 .proc_handler = proc_dointvec,
1836 .procname = "sched_deadline_period_min_us",
1837 .data = &sysctl_sched_dl_period_min,
1838 .maxlen = sizeof(unsigned int),
1840 .proc_handler = proc_dointvec,
1843 .procname = "sched_rr_timeslice_ms",
1844 .data = &sysctl_sched_rr_timeslice,
1845 .maxlen = sizeof(int),
1847 .proc_handler = sched_rr_handler,
1849 #ifdef CONFIG_UCLAMP_TASK
1851 .procname = "sched_util_clamp_min",
1852 .data = &sysctl_sched_uclamp_util_min,
1853 .maxlen = sizeof(unsigned int),
1855 .proc_handler = sysctl_sched_uclamp_handler,
1858 .procname = "sched_util_clamp_max",
1859 .data = &sysctl_sched_uclamp_util_max,
1860 .maxlen = sizeof(unsigned int),
1862 .proc_handler = sysctl_sched_uclamp_handler,
1865 .procname = "sched_util_clamp_min_rt_default",
1866 .data = &sysctl_sched_uclamp_util_min_rt_default,
1867 .maxlen = sizeof(unsigned int),
1869 .proc_handler = sysctl_sched_uclamp_handler,
1872 #ifdef CONFIG_SCHED_AUTOGROUP
1874 .procname = "sched_autogroup_enabled",
1875 .data = &sysctl_sched_autogroup_enabled,
1876 .maxlen = sizeof(unsigned int),
1878 .proc_handler = proc_dointvec_minmax,
1879 .extra1 = SYSCTL_ZERO,
1880 .extra2 = SYSCTL_ONE,
1883 #ifdef CONFIG_CFS_BANDWIDTH
1885 .procname = "sched_cfs_bandwidth_slice_us",
1886 .data = &sysctl_sched_cfs_bandwidth_slice,
1887 .maxlen = sizeof(unsigned int),
1889 .proc_handler = proc_dointvec_minmax,
1890 .extra1 = SYSCTL_ONE,
1893 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1895 .procname = "sched_energy_aware",
1896 .data = &sysctl_sched_energy_aware,
1897 .maxlen = sizeof(unsigned int),
1899 .proc_handler = sched_energy_aware_handler,
1900 .extra1 = SYSCTL_ZERO,
1901 .extra2 = SYSCTL_ONE,
1904 #ifdef CONFIG_PROVE_LOCKING
1906 .procname = "prove_locking",
1907 .data = &prove_locking,
1908 .maxlen = sizeof(int),
1910 .proc_handler = proc_dointvec,
1913 #ifdef CONFIG_LOCK_STAT
1915 .procname = "lock_stat",
1917 .maxlen = sizeof(int),
1919 .proc_handler = proc_dointvec,
1923 .procname = "panic",
1924 .data = &panic_timeout,
1925 .maxlen = sizeof(int),
1927 .proc_handler = proc_dointvec,
1929 #ifdef CONFIG_COREDUMP
1931 .procname = "core_uses_pid",
1932 .data = &core_uses_pid,
1933 .maxlen = sizeof(int),
1935 .proc_handler = proc_dointvec,
1938 .procname = "core_pattern",
1939 .data = core_pattern,
1940 .maxlen = CORENAME_MAX_SIZE,
1942 .proc_handler = proc_dostring_coredump,
1945 .procname = "core_pipe_limit",
1946 .data = &core_pipe_limit,
1947 .maxlen = sizeof(unsigned int),
1949 .proc_handler = proc_dointvec,
1952 #ifdef CONFIG_PROC_SYSCTL
1954 .procname = "tainted",
1955 .maxlen = sizeof(long),
1957 .proc_handler = proc_taint,
1960 .procname = "sysctl_writes_strict",
1961 .data = &sysctl_writes_strict,
1962 .maxlen = sizeof(int),
1964 .proc_handler = proc_dointvec_minmax,
1966 .extra2 = SYSCTL_ONE,
1969 #ifdef CONFIG_LATENCYTOP
1971 .procname = "latencytop",
1972 .data = &latencytop_enabled,
1973 .maxlen = sizeof(int),
1975 .proc_handler = sysctl_latencytop,
1978 #ifdef CONFIG_BLK_DEV_INITRD
1980 .procname = "real-root-dev",
1981 .data = &real_root_dev,
1982 .maxlen = sizeof(int),
1984 .proc_handler = proc_dointvec,
1988 .procname = "print-fatal-signals",
1989 .data = &print_fatal_signals,
1990 .maxlen = sizeof(int),
1992 .proc_handler = proc_dointvec,
1996 .procname = "reboot-cmd",
1997 .data = reboot_command,
2000 .proc_handler = proc_dostring,
2003 .procname = "stop-a",
2004 .data = &stop_a_enabled,
2005 .maxlen = sizeof (int),
2007 .proc_handler = proc_dointvec,
2010 .procname = "scons-poweroff",
2011 .data = &scons_pwroff,
2012 .maxlen = sizeof (int),
2014 .proc_handler = proc_dointvec,
2017 #ifdef CONFIG_SPARC64
2019 .procname = "tsb-ratio",
2020 .data = &sysctl_tsb_ratio,
2021 .maxlen = sizeof (int),
2023 .proc_handler = proc_dointvec,
2026 #ifdef CONFIG_PARISC
2028 .procname = "soft-power",
2029 .data = &pwrsw_enabled,
2030 .maxlen = sizeof (int),
2032 .proc_handler = proc_dointvec,
2035 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2037 .procname = "unaligned-trap",
2038 .data = &unaligned_enabled,
2039 .maxlen = sizeof (int),
2041 .proc_handler = proc_dointvec,
2045 .procname = "ctrl-alt-del",
2047 .maxlen = sizeof(int),
2049 .proc_handler = proc_dointvec,
2051 #ifdef CONFIG_FUNCTION_TRACER
2053 .procname = "ftrace_enabled",
2054 .data = &ftrace_enabled,
2055 .maxlen = sizeof(int),
2057 .proc_handler = ftrace_enable_sysctl,
2060 #ifdef CONFIG_STACK_TRACER
2062 .procname = "stack_tracer_enabled",
2063 .data = &stack_tracer_enabled,
2064 .maxlen = sizeof(int),
2066 .proc_handler = stack_trace_sysctl,
2069 #ifdef CONFIG_TRACING
2071 .procname = "ftrace_dump_on_oops",
2072 .data = &ftrace_dump_on_oops,
2073 .maxlen = sizeof(int),
2075 .proc_handler = proc_dointvec,
2078 .procname = "traceoff_on_warning",
2079 .data = &__disable_trace_on_warning,
2080 .maxlen = sizeof(__disable_trace_on_warning),
2082 .proc_handler = proc_dointvec,
2085 .procname = "tracepoint_printk",
2086 .data = &tracepoint_printk,
2087 .maxlen = sizeof(tracepoint_printk),
2089 .proc_handler = tracepoint_printk_sysctl,
2092 #ifdef CONFIG_KEXEC_CORE
2094 .procname = "kexec_load_disabled",
2095 .data = &kexec_load_disabled,
2096 .maxlen = sizeof(int),
2098 /* only handle a transition from default "0" to "1" */
2099 .proc_handler = proc_dointvec_minmax,
2100 .extra1 = SYSCTL_ONE,
2101 .extra2 = SYSCTL_ONE,
2104 #ifdef CONFIG_MODULES
2106 .procname = "modprobe",
2107 .data = &modprobe_path,
2108 .maxlen = KMOD_PATH_LEN,
2110 .proc_handler = proc_dostring,
2113 .procname = "modules_disabled",
2114 .data = &modules_disabled,
2115 .maxlen = sizeof(int),
2117 /* only handle a transition from default "0" to "1" */
2118 .proc_handler = proc_dointvec_minmax,
2119 .extra1 = SYSCTL_ONE,
2120 .extra2 = SYSCTL_ONE,
2123 #ifdef CONFIG_UEVENT_HELPER
2125 .procname = "hotplug",
2126 .data = &uevent_helper,
2127 .maxlen = UEVENT_HELPER_PATH_LEN,
2129 .proc_handler = proc_dostring,
2132 #ifdef CONFIG_CHR_DEV_SG
2134 .procname = "sg-big-buff",
2135 .data = &sg_big_buff,
2136 .maxlen = sizeof (int),
2138 .proc_handler = proc_dointvec,
2141 #ifdef CONFIG_BSD_PROCESS_ACCT
2145 .maxlen = 3*sizeof(int),
2147 .proc_handler = proc_dointvec,
2150 #ifdef CONFIG_MAGIC_SYSRQ
2152 .procname = "sysrq",
2154 .maxlen = sizeof (int),
2156 .proc_handler = sysrq_sysctl_handler,
2159 #ifdef CONFIG_PROC_SYSCTL
2161 .procname = "cad_pid",
2163 .maxlen = sizeof (int),
2165 .proc_handler = proc_do_cad_pid,
2169 .procname = "threads-max",
2171 .maxlen = sizeof(int),
2173 .proc_handler = sysctl_max_threads,
2176 .procname = "random",
2178 .child = random_table,
2181 .procname = "usermodehelper",
2183 .child = usermodehelper_table,
2185 #ifdef CONFIG_FW_LOADER_USER_HELPER
2187 .procname = "firmware_config",
2189 .child = firmware_config_table,
2193 .procname = "overflowuid",
2194 .data = &overflowuid,
2195 .maxlen = sizeof(int),
2197 .proc_handler = proc_dointvec_minmax,
2198 .extra1 = &minolduid,
2199 .extra2 = &maxolduid,
2202 .procname = "overflowgid",
2203 .data = &overflowgid,
2204 .maxlen = sizeof(int),
2206 .proc_handler = proc_dointvec_minmax,
2207 .extra1 = &minolduid,
2208 .extra2 = &maxolduid,
2212 .procname = "userprocess_debug",
2213 .data = &show_unhandled_signals,
2214 .maxlen = sizeof(int),
2216 .proc_handler = proc_dointvec,
2221 .procname = "oops_all_cpu_backtrace",
2222 .data = &sysctl_oops_all_cpu_backtrace,
2223 .maxlen = sizeof(int),
2225 .proc_handler = proc_dointvec_minmax,
2226 .extra1 = SYSCTL_ZERO,
2227 .extra2 = SYSCTL_ONE,
2229 #endif /* CONFIG_SMP */
2231 .procname = "pid_max",
2233 .maxlen = sizeof (int),
2235 .proc_handler = proc_dointvec_minmax,
2236 .extra1 = &pid_max_min,
2237 .extra2 = &pid_max_max,
2240 .procname = "panic_on_oops",
2241 .data = &panic_on_oops,
2242 .maxlen = sizeof(int),
2244 .proc_handler = proc_dointvec,
2247 .procname = "panic_print",
2248 .data = &panic_print,
2249 .maxlen = sizeof(unsigned long),
2251 .proc_handler = proc_doulongvec_minmax,
2253 #if defined CONFIG_PRINTK
2255 .procname = "printk",
2256 .data = &console_loglevel,
2257 .maxlen = 4*sizeof(int),
2259 .proc_handler = proc_dointvec,
2262 .procname = "printk_ratelimit",
2263 .data = &printk_ratelimit_state.interval,
2264 .maxlen = sizeof(int),
2266 .proc_handler = proc_dointvec_jiffies,
2269 .procname = "printk_ratelimit_burst",
2270 .data = &printk_ratelimit_state.burst,
2271 .maxlen = sizeof(int),
2273 .proc_handler = proc_dointvec,
2276 .procname = "printk_delay",
2277 .data = &printk_delay_msec,
2278 .maxlen = sizeof(int),
2280 .proc_handler = proc_dointvec_minmax,
2281 .extra1 = SYSCTL_ZERO,
2282 .extra2 = &ten_thousand,
2285 .procname = "printk_devkmsg",
2286 .data = devkmsg_log_str,
2287 .maxlen = DEVKMSG_STR_MAX_SIZE,
2289 .proc_handler = devkmsg_sysctl_set_loglvl,
2292 .procname = "dmesg_restrict",
2293 .data = &dmesg_restrict,
2294 .maxlen = sizeof(int),
2296 .proc_handler = proc_dointvec_minmax_sysadmin,
2297 .extra1 = SYSCTL_ZERO,
2298 .extra2 = SYSCTL_ONE,
2301 .procname = "kptr_restrict",
2302 .data = &kptr_restrict,
2303 .maxlen = sizeof(int),
2305 .proc_handler = proc_dointvec_minmax_sysadmin,
2306 .extra1 = SYSCTL_ZERO,
2311 .procname = "ngroups_max",
2312 .data = &ngroups_max,
2313 .maxlen = sizeof (int),
2315 .proc_handler = proc_dointvec,
2318 .procname = "cap_last_cap",
2319 .data = (void *)&cap_last_cap,
2320 .maxlen = sizeof(int),
2322 .proc_handler = proc_dointvec,
2324 #if defined(CONFIG_LOCKUP_DETECTOR)
2326 .procname = "watchdog",
2327 .data = &watchdog_user_enabled,
2328 .maxlen = sizeof(int),
2330 .proc_handler = proc_watchdog,
2331 .extra1 = SYSCTL_ZERO,
2332 .extra2 = SYSCTL_ONE,
2335 .procname = "watchdog_thresh",
2336 .data = &watchdog_thresh,
2337 .maxlen = sizeof(int),
2339 .proc_handler = proc_watchdog_thresh,
2340 .extra1 = SYSCTL_ZERO,
2344 .procname = "nmi_watchdog",
2345 .data = &nmi_watchdog_user_enabled,
2346 .maxlen = sizeof(int),
2347 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2348 .proc_handler = proc_nmi_watchdog,
2349 .extra1 = SYSCTL_ZERO,
2350 .extra2 = SYSCTL_ONE,
2353 .procname = "watchdog_cpumask",
2354 .data = &watchdog_cpumask_bits,
2357 .proc_handler = proc_watchdog_cpumask,
2359 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2361 .procname = "soft_watchdog",
2362 .data = &soft_watchdog_user_enabled,
2363 .maxlen = sizeof(int),
2365 .proc_handler = proc_soft_watchdog,
2366 .extra1 = SYSCTL_ZERO,
2367 .extra2 = SYSCTL_ONE,
2370 .procname = "softlockup_panic",
2371 .data = &softlockup_panic,
2372 .maxlen = sizeof(int),
2374 .proc_handler = proc_dointvec_minmax,
2375 .extra1 = SYSCTL_ZERO,
2376 .extra2 = SYSCTL_ONE,
2380 .procname = "softlockup_all_cpu_backtrace",
2381 .data = &sysctl_softlockup_all_cpu_backtrace,
2382 .maxlen = sizeof(int),
2384 .proc_handler = proc_dointvec_minmax,
2385 .extra1 = SYSCTL_ZERO,
2386 .extra2 = SYSCTL_ONE,
2388 #endif /* CONFIG_SMP */
2390 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2392 .procname = "hardlockup_panic",
2393 .data = &hardlockup_panic,
2394 .maxlen = sizeof(int),
2396 .proc_handler = proc_dointvec_minmax,
2397 .extra1 = SYSCTL_ZERO,
2398 .extra2 = SYSCTL_ONE,
2402 .procname = "hardlockup_all_cpu_backtrace",
2403 .data = &sysctl_hardlockup_all_cpu_backtrace,
2404 .maxlen = sizeof(int),
2406 .proc_handler = proc_dointvec_minmax,
2407 .extra1 = SYSCTL_ZERO,
2408 .extra2 = SYSCTL_ONE,
2410 #endif /* CONFIG_SMP */
2414 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2416 .procname = "unknown_nmi_panic",
2417 .data = &unknown_nmi_panic,
2418 .maxlen = sizeof (int),
2420 .proc_handler = proc_dointvec,
2424 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2425 defined(CONFIG_DEBUG_STACKOVERFLOW)
2427 .procname = "panic_on_stackoverflow",
2428 .data = &sysctl_panic_on_stackoverflow,
2429 .maxlen = sizeof(int),
2431 .proc_handler = proc_dointvec,
2434 #if defined(CONFIG_X86)
2436 .procname = "panic_on_unrecovered_nmi",
2437 .data = &panic_on_unrecovered_nmi,
2438 .maxlen = sizeof(int),
2440 .proc_handler = proc_dointvec,
2443 .procname = "panic_on_io_nmi",
2444 .data = &panic_on_io_nmi,
2445 .maxlen = sizeof(int),
2447 .proc_handler = proc_dointvec,
2450 .procname = "bootloader_type",
2451 .data = &bootloader_type,
2452 .maxlen = sizeof (int),
2454 .proc_handler = proc_dointvec,
2457 .procname = "bootloader_version",
2458 .data = &bootloader_version,
2459 .maxlen = sizeof (int),
2461 .proc_handler = proc_dointvec,
2464 .procname = "io_delay_type",
2465 .data = &io_delay_type,
2466 .maxlen = sizeof(int),
2468 .proc_handler = proc_dointvec,
2471 #if defined(CONFIG_MMU)
2473 .procname = "randomize_va_space",
2474 .data = &randomize_va_space,
2475 .maxlen = sizeof(int),
2477 .proc_handler = proc_dointvec,
2480 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2482 .procname = "spin_retry",
2483 .data = &spin_retry,
2484 .maxlen = sizeof (int),
2486 .proc_handler = proc_dointvec,
2489 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2491 .procname = "acpi_video_flags",
2492 .data = &acpi_realmode_flags,
2493 .maxlen = sizeof (unsigned long),
2495 .proc_handler = proc_doulongvec_minmax,
2498 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2500 .procname = "ignore-unaligned-usertrap",
2501 .data = &no_unaligned_warning,
2502 .maxlen = sizeof (int),
2504 .proc_handler = proc_dointvec,
2509 .procname = "unaligned-dump-stack",
2510 .data = &unaligned_dump_stack,
2511 .maxlen = sizeof (int),
2513 .proc_handler = proc_dointvec,
2516 #ifdef CONFIG_DETECT_HUNG_TASK
2519 .procname = "hung_task_all_cpu_backtrace",
2520 .data = &sysctl_hung_task_all_cpu_backtrace,
2521 .maxlen = sizeof(int),
2523 .proc_handler = proc_dointvec_minmax,
2524 .extra1 = SYSCTL_ZERO,
2525 .extra2 = SYSCTL_ONE,
2527 #endif /* CONFIG_SMP */
2529 .procname = "hung_task_panic",
2530 .data = &sysctl_hung_task_panic,
2531 .maxlen = sizeof(int),
2533 .proc_handler = proc_dointvec_minmax,
2534 .extra1 = SYSCTL_ZERO,
2535 .extra2 = SYSCTL_ONE,
2538 .procname = "hung_task_check_count",
2539 .data = &sysctl_hung_task_check_count,
2540 .maxlen = sizeof(int),
2542 .proc_handler = proc_dointvec_minmax,
2543 .extra1 = SYSCTL_ZERO,
2546 .procname = "hung_task_timeout_secs",
2547 .data = &sysctl_hung_task_timeout_secs,
2548 .maxlen = sizeof(unsigned long),
2550 .proc_handler = proc_dohung_task_timeout_secs,
2551 .extra2 = &hung_task_timeout_max,
2554 .procname = "hung_task_check_interval_secs",
2555 .data = &sysctl_hung_task_check_interval_secs,
2556 .maxlen = sizeof(unsigned long),
2558 .proc_handler = proc_dohung_task_timeout_secs,
2559 .extra2 = &hung_task_timeout_max,
2562 .procname = "hung_task_warnings",
2563 .data = &sysctl_hung_task_warnings,
2564 .maxlen = sizeof(int),
2566 .proc_handler = proc_dointvec_minmax,
2570 #ifdef CONFIG_RT_MUTEXES
2572 .procname = "max_lock_depth",
2573 .data = &max_lock_depth,
2574 .maxlen = sizeof(int),
2576 .proc_handler = proc_dointvec,
2580 .procname = "poweroff_cmd",
2581 .data = &poweroff_cmd,
2582 .maxlen = POWEROFF_CMD_PATH_LEN,
2584 .proc_handler = proc_dostring,
2590 .child = key_sysctls,
2593 #ifdef CONFIG_PERF_EVENTS
2595 * User-space scripts rely on the existence of this file
2596 * as a feature check for perf_events being enabled.
2598 * So it's an ABI, do not remove!
2601 .procname = "perf_event_paranoid",
2602 .data = &sysctl_perf_event_paranoid,
2603 .maxlen = sizeof(sysctl_perf_event_paranoid),
2605 .proc_handler = proc_dointvec,
2608 .procname = "perf_event_mlock_kb",
2609 .data = &sysctl_perf_event_mlock,
2610 .maxlen = sizeof(sysctl_perf_event_mlock),
2612 .proc_handler = proc_dointvec,
2615 .procname = "perf_event_max_sample_rate",
2616 .data = &sysctl_perf_event_sample_rate,
2617 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2619 .proc_handler = perf_proc_update_handler,
2620 .extra1 = SYSCTL_ONE,
2623 .procname = "perf_cpu_time_max_percent",
2624 .data = &sysctl_perf_cpu_time_max_percent,
2625 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2627 .proc_handler = perf_cpu_time_max_percent_handler,
2628 .extra1 = SYSCTL_ZERO,
2629 .extra2 = &one_hundred,
2632 .procname = "perf_event_max_stack",
2633 .data = &sysctl_perf_event_max_stack,
2634 .maxlen = sizeof(sysctl_perf_event_max_stack),
2636 .proc_handler = perf_event_max_stack_handler,
2637 .extra1 = SYSCTL_ZERO,
2638 .extra2 = &six_hundred_forty_kb,
2641 .procname = "perf_event_max_contexts_per_stack",
2642 .data = &sysctl_perf_event_max_contexts_per_stack,
2643 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2645 .proc_handler = perf_event_max_stack_handler,
2646 .extra1 = SYSCTL_ZERO,
2647 .extra2 = &one_thousand,
2651 .procname = "panic_on_warn",
2652 .data = &panic_on_warn,
2653 .maxlen = sizeof(int),
2655 .proc_handler = proc_dointvec_minmax,
2656 .extra1 = SYSCTL_ZERO,
2657 .extra2 = SYSCTL_ONE,
2659 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2661 .procname = "timer_migration",
2662 .data = &sysctl_timer_migration,
2663 .maxlen = sizeof(unsigned int),
2665 .proc_handler = timer_migration_handler,
2666 .extra1 = SYSCTL_ZERO,
2667 .extra2 = SYSCTL_ONE,
2670 #ifdef CONFIG_BPF_SYSCALL
2672 .procname = "unprivileged_bpf_disabled",
2673 .data = &sysctl_unprivileged_bpf_disabled,
2674 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2676 .proc_handler = bpf_unpriv_handler,
2677 .extra1 = SYSCTL_ZERO,
2681 .procname = "bpf_stats_enabled",
2682 .data = &bpf_stats_enabled_key.key,
2683 .maxlen = sizeof(bpf_stats_enabled_key),
2685 .proc_handler = bpf_stats_handler,
2688 #if defined(CONFIG_TREE_RCU)
2690 .procname = "panic_on_rcu_stall",
2691 .data = &sysctl_panic_on_rcu_stall,
2692 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2694 .proc_handler = proc_dointvec_minmax,
2695 .extra1 = SYSCTL_ZERO,
2696 .extra2 = SYSCTL_ONE,
2699 #if defined(CONFIG_TREE_RCU)
2701 .procname = "max_rcu_stall_to_panic",
2702 .data = &sysctl_max_rcu_stall_to_panic,
2703 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2705 .proc_handler = proc_dointvec_minmax,
2706 .extra1 = SYSCTL_ONE,
2707 .extra2 = SYSCTL_INT_MAX,
2710 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2712 .procname = "stack_erasing",
2714 .maxlen = sizeof(int),
2716 .proc_handler = stack_erasing_sysctl,
2717 .extra1 = SYSCTL_ZERO,
2718 .extra2 = SYSCTL_ONE,
2724 static struct ctl_table vm_table[] = {
2726 .procname = "overcommit_memory",
2727 .data = &sysctl_overcommit_memory,
2728 .maxlen = sizeof(sysctl_overcommit_memory),
2730 .proc_handler = overcommit_policy_handler,
2731 .extra1 = SYSCTL_ZERO,
2735 .procname = "panic_on_oom",
2736 .data = &sysctl_panic_on_oom,
2737 .maxlen = sizeof(sysctl_panic_on_oom),
2739 .proc_handler = proc_dointvec_minmax,
2740 .extra1 = SYSCTL_ZERO,
2744 .procname = "oom_kill_allocating_task",
2745 .data = &sysctl_oom_kill_allocating_task,
2746 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2748 .proc_handler = proc_dointvec,
2751 .procname = "oom_dump_tasks",
2752 .data = &sysctl_oom_dump_tasks,
2753 .maxlen = sizeof(sysctl_oom_dump_tasks),
2755 .proc_handler = proc_dointvec,
2758 .procname = "overcommit_ratio",
2759 .data = &sysctl_overcommit_ratio,
2760 .maxlen = sizeof(sysctl_overcommit_ratio),
2762 .proc_handler = overcommit_ratio_handler,
2765 .procname = "overcommit_kbytes",
2766 .data = &sysctl_overcommit_kbytes,
2767 .maxlen = sizeof(sysctl_overcommit_kbytes),
2769 .proc_handler = overcommit_kbytes_handler,
2772 .procname = "page-cluster",
2773 .data = &page_cluster,
2774 .maxlen = sizeof(int),
2776 .proc_handler = proc_dointvec_minmax,
2777 .extra1 = SYSCTL_ZERO,
2780 .procname = "dirty_background_ratio",
2781 .data = &dirty_background_ratio,
2782 .maxlen = sizeof(dirty_background_ratio),
2784 .proc_handler = dirty_background_ratio_handler,
2785 .extra1 = SYSCTL_ZERO,
2786 .extra2 = &one_hundred,
2789 .procname = "dirty_background_bytes",
2790 .data = &dirty_background_bytes,
2791 .maxlen = sizeof(dirty_background_bytes),
2793 .proc_handler = dirty_background_bytes_handler,
2797 .procname = "dirty_ratio",
2798 .data = &vm_dirty_ratio,
2799 .maxlen = sizeof(vm_dirty_ratio),
2801 .proc_handler = dirty_ratio_handler,
2802 .extra1 = SYSCTL_ZERO,
2803 .extra2 = &one_hundred,
2806 .procname = "dirty_bytes",
2807 .data = &vm_dirty_bytes,
2808 .maxlen = sizeof(vm_dirty_bytes),
2810 .proc_handler = dirty_bytes_handler,
2811 .extra1 = &dirty_bytes_min,
2814 .procname = "dirty_writeback_centisecs",
2815 .data = &dirty_writeback_interval,
2816 .maxlen = sizeof(dirty_writeback_interval),
2818 .proc_handler = dirty_writeback_centisecs_handler,
2821 .procname = "dirty_expire_centisecs",
2822 .data = &dirty_expire_interval,
2823 .maxlen = sizeof(dirty_expire_interval),
2825 .proc_handler = proc_dointvec_minmax,
2826 .extra1 = SYSCTL_ZERO,
2829 .procname = "dirtytime_expire_seconds",
2830 .data = &dirtytime_expire_interval,
2831 .maxlen = sizeof(dirtytime_expire_interval),
2833 .proc_handler = dirtytime_interval_handler,
2834 .extra1 = SYSCTL_ZERO,
2837 .procname = "swappiness",
2838 .data = &vm_swappiness,
2839 .maxlen = sizeof(vm_swappiness),
2841 .proc_handler = proc_dointvec_minmax,
2842 .extra1 = SYSCTL_ZERO,
2843 .extra2 = &two_hundred,
2845 #ifdef CONFIG_HUGETLB_PAGE
2847 .procname = "nr_hugepages",
2849 .maxlen = sizeof(unsigned long),
2851 .proc_handler = hugetlb_sysctl_handler,
2855 .procname = "nr_hugepages_mempolicy",
2857 .maxlen = sizeof(unsigned long),
2859 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2862 .procname = "numa_stat",
2863 .data = &sysctl_vm_numa_stat,
2864 .maxlen = sizeof(int),
2866 .proc_handler = sysctl_vm_numa_stat_handler,
2867 .extra1 = SYSCTL_ZERO,
2868 .extra2 = SYSCTL_ONE,
2872 .procname = "hugetlb_shm_group",
2873 .data = &sysctl_hugetlb_shm_group,
2874 .maxlen = sizeof(gid_t),
2876 .proc_handler = proc_dointvec,
2879 .procname = "nr_overcommit_hugepages",
2881 .maxlen = sizeof(unsigned long),
2883 .proc_handler = hugetlb_overcommit_handler,
2887 .procname = "lowmem_reserve_ratio",
2888 .data = &sysctl_lowmem_reserve_ratio,
2889 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2891 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2894 .procname = "drop_caches",
2895 .data = &sysctl_drop_caches,
2896 .maxlen = sizeof(int),
2898 .proc_handler = drop_caches_sysctl_handler,
2899 .extra1 = SYSCTL_ONE,
2902 #ifdef CONFIG_COMPACTION
2904 .procname = "compact_memory",
2906 .maxlen = sizeof(int),
2908 .proc_handler = sysctl_compaction_handler,
2911 .procname = "compaction_proactiveness",
2912 .data = &sysctl_compaction_proactiveness,
2913 .maxlen = sizeof(sysctl_compaction_proactiveness),
2915 .proc_handler = compaction_proactiveness_sysctl_handler,
2916 .extra1 = SYSCTL_ZERO,
2917 .extra2 = &one_hundred,
2920 .procname = "extfrag_threshold",
2921 .data = &sysctl_extfrag_threshold,
2922 .maxlen = sizeof(int),
2924 .proc_handler = proc_dointvec_minmax,
2925 .extra1 = &min_extfrag_threshold,
2926 .extra2 = &max_extfrag_threshold,
2929 .procname = "compact_unevictable_allowed",
2930 .data = &sysctl_compact_unevictable_allowed,
2931 .maxlen = sizeof(int),
2933 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2934 .extra1 = SYSCTL_ZERO,
2935 .extra2 = SYSCTL_ONE,
2938 #endif /* CONFIG_COMPACTION */
2940 .procname = "min_free_kbytes",
2941 .data = &min_free_kbytes,
2942 .maxlen = sizeof(min_free_kbytes),
2944 .proc_handler = min_free_kbytes_sysctl_handler,
2945 .extra1 = SYSCTL_ZERO,
2948 .procname = "watermark_boost_factor",
2949 .data = &watermark_boost_factor,
2950 .maxlen = sizeof(watermark_boost_factor),
2952 .proc_handler = proc_dointvec_minmax,
2953 .extra1 = SYSCTL_ZERO,
2956 .procname = "watermark_scale_factor",
2957 .data = &watermark_scale_factor,
2958 .maxlen = sizeof(watermark_scale_factor),
2960 .proc_handler = watermark_scale_factor_sysctl_handler,
2961 .extra1 = SYSCTL_ONE,
2962 .extra2 = &one_thousand,
2965 .procname = "percpu_pagelist_high_fraction",
2966 .data = &percpu_pagelist_high_fraction,
2967 .maxlen = sizeof(percpu_pagelist_high_fraction),
2969 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2970 .extra1 = SYSCTL_ZERO,
2973 .procname = "page_lock_unfairness",
2974 .data = &sysctl_page_lock_unfairness,
2975 .maxlen = sizeof(sysctl_page_lock_unfairness),
2977 .proc_handler = proc_dointvec_minmax,
2978 .extra1 = SYSCTL_ZERO,
2982 .procname = "max_map_count",
2983 .data = &sysctl_max_map_count,
2984 .maxlen = sizeof(sysctl_max_map_count),
2986 .proc_handler = proc_dointvec_minmax,
2987 .extra1 = SYSCTL_ZERO,
2991 .procname = "nr_trim_pages",
2992 .data = &sysctl_nr_trim_pages,
2993 .maxlen = sizeof(sysctl_nr_trim_pages),
2995 .proc_handler = proc_dointvec_minmax,
2996 .extra1 = SYSCTL_ZERO,
3000 .procname = "laptop_mode",
3001 .data = &laptop_mode,
3002 .maxlen = sizeof(laptop_mode),
3004 .proc_handler = proc_dointvec_jiffies,
3007 .procname = "vfs_cache_pressure",
3008 .data = &sysctl_vfs_cache_pressure,
3009 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3011 .proc_handler = proc_dointvec_minmax,
3012 .extra1 = SYSCTL_ZERO,
3014 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3015 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3017 .procname = "legacy_va_layout",
3018 .data = &sysctl_legacy_va_layout,
3019 .maxlen = sizeof(sysctl_legacy_va_layout),
3021 .proc_handler = proc_dointvec_minmax,
3022 .extra1 = SYSCTL_ZERO,
3027 .procname = "zone_reclaim_mode",
3028 .data = &node_reclaim_mode,
3029 .maxlen = sizeof(node_reclaim_mode),
3031 .proc_handler = proc_dointvec_minmax,
3032 .extra1 = SYSCTL_ZERO,
3035 .procname = "min_unmapped_ratio",
3036 .data = &sysctl_min_unmapped_ratio,
3037 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3039 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3040 .extra1 = SYSCTL_ZERO,
3041 .extra2 = &one_hundred,
3044 .procname = "min_slab_ratio",
3045 .data = &sysctl_min_slab_ratio,
3046 .maxlen = sizeof(sysctl_min_slab_ratio),
3048 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3049 .extra1 = SYSCTL_ZERO,
3050 .extra2 = &one_hundred,
3055 .procname = "stat_interval",
3056 .data = &sysctl_stat_interval,
3057 .maxlen = sizeof(sysctl_stat_interval),
3059 .proc_handler = proc_dointvec_jiffies,
3062 .procname = "stat_refresh",
3066 .proc_handler = vmstat_refresh,
3071 .procname = "mmap_min_addr",
3072 .data = &dac_mmap_min_addr,
3073 .maxlen = sizeof(unsigned long),
3075 .proc_handler = mmap_min_addr_handler,
3080 .procname = "numa_zonelist_order",
3081 .data = &numa_zonelist_order,
3082 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3084 .proc_handler = numa_zonelist_order_handler,
3087 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3088 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3090 .procname = "vdso_enabled",
3091 #ifdef CONFIG_X86_32
3092 .data = &vdso32_enabled,
3093 .maxlen = sizeof(vdso32_enabled),
3095 .data = &vdso_enabled,
3096 .maxlen = sizeof(vdso_enabled),
3099 .proc_handler = proc_dointvec,
3100 .extra1 = SYSCTL_ZERO,
3103 #ifdef CONFIG_HIGHMEM
3105 .procname = "highmem_is_dirtyable",
3106 .data = &vm_highmem_is_dirtyable,
3107 .maxlen = sizeof(vm_highmem_is_dirtyable),
3109 .proc_handler = proc_dointvec_minmax,
3110 .extra1 = SYSCTL_ZERO,
3111 .extra2 = SYSCTL_ONE,
3114 #ifdef CONFIG_MEMORY_FAILURE
3116 .procname = "memory_failure_early_kill",
3117 .data = &sysctl_memory_failure_early_kill,
3118 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3120 .proc_handler = proc_dointvec_minmax,
3121 .extra1 = SYSCTL_ZERO,
3122 .extra2 = SYSCTL_ONE,
3125 .procname = "memory_failure_recovery",
3126 .data = &sysctl_memory_failure_recovery,
3127 .maxlen = sizeof(sysctl_memory_failure_recovery),
3129 .proc_handler = proc_dointvec_minmax,
3130 .extra1 = SYSCTL_ZERO,
3131 .extra2 = SYSCTL_ONE,
3135 .procname = "user_reserve_kbytes",
3136 .data = &sysctl_user_reserve_kbytes,
3137 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3139 .proc_handler = proc_doulongvec_minmax,
3142 .procname = "admin_reserve_kbytes",
3143 .data = &sysctl_admin_reserve_kbytes,
3144 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3146 .proc_handler = proc_doulongvec_minmax,
3148 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3150 .procname = "mmap_rnd_bits",
3151 .data = &mmap_rnd_bits,
3152 .maxlen = sizeof(mmap_rnd_bits),
3154 .proc_handler = proc_dointvec_minmax,
3155 .extra1 = (void *)&mmap_rnd_bits_min,
3156 .extra2 = (void *)&mmap_rnd_bits_max,
3159 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3161 .procname = "mmap_rnd_compat_bits",
3162 .data = &mmap_rnd_compat_bits,
3163 .maxlen = sizeof(mmap_rnd_compat_bits),
3165 .proc_handler = proc_dointvec_minmax,
3166 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3167 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3170 #ifdef CONFIG_USERFAULTFD
3172 .procname = "unprivileged_userfaultfd",
3173 .data = &sysctl_unprivileged_userfaultfd,
3174 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3176 .proc_handler = proc_dointvec_minmax,
3177 .extra1 = SYSCTL_ZERO,
3178 .extra2 = SYSCTL_ONE,
3184 static struct ctl_table fs_table[] = {
3186 .procname = "inode-nr",
3187 .data = &inodes_stat,
3188 .maxlen = 2*sizeof(long),
3190 .proc_handler = proc_nr_inodes,
3193 .procname = "inode-state",
3194 .data = &inodes_stat,
3195 .maxlen = 7*sizeof(long),
3197 .proc_handler = proc_nr_inodes,
3200 .procname = "file-nr",
3201 .data = &files_stat,
3202 .maxlen = sizeof(files_stat),
3204 .proc_handler = proc_nr_files,
3207 .procname = "file-max",
3208 .data = &files_stat.max_files,
3209 .maxlen = sizeof(files_stat.max_files),
3211 .proc_handler = proc_doulongvec_minmax,
3213 .extra2 = &long_max,
3216 .procname = "nr_open",
3217 .data = &sysctl_nr_open,
3218 .maxlen = sizeof(unsigned int),
3220 .proc_handler = proc_dointvec_minmax,
3221 .extra1 = &sysctl_nr_open_min,
3222 .extra2 = &sysctl_nr_open_max,
3225 .procname = "dentry-state",
3226 .data = &dentry_stat,
3227 .maxlen = 6*sizeof(long),
3229 .proc_handler = proc_nr_dentry,
3232 .procname = "overflowuid",
3233 .data = &fs_overflowuid,
3234 .maxlen = sizeof(int),
3236 .proc_handler = proc_dointvec_minmax,
3237 .extra1 = &minolduid,
3238 .extra2 = &maxolduid,
3241 .procname = "overflowgid",
3242 .data = &fs_overflowgid,
3243 .maxlen = sizeof(int),
3245 .proc_handler = proc_dointvec_minmax,
3246 .extra1 = &minolduid,
3247 .extra2 = &maxolduid,
3249 #ifdef CONFIG_FILE_LOCKING
3251 .procname = "leases-enable",
3252 .data = &leases_enable,
3253 .maxlen = sizeof(int),
3255 .proc_handler = proc_dointvec,
3258 #ifdef CONFIG_DNOTIFY
3260 .procname = "dir-notify-enable",
3261 .data = &dir_notify_enable,
3262 .maxlen = sizeof(int),
3264 .proc_handler = proc_dointvec,
3268 #ifdef CONFIG_FILE_LOCKING
3270 .procname = "lease-break-time",
3271 .data = &lease_break_time,
3272 .maxlen = sizeof(int),
3274 .proc_handler = proc_dointvec,
3279 .procname = "aio-nr",
3281 .maxlen = sizeof(aio_nr),
3283 .proc_handler = proc_doulongvec_minmax,
3286 .procname = "aio-max-nr",
3287 .data = &aio_max_nr,
3288 .maxlen = sizeof(aio_max_nr),
3290 .proc_handler = proc_doulongvec_minmax,
3292 #endif /* CONFIG_AIO */
3293 #ifdef CONFIG_INOTIFY_USER
3295 .procname = "inotify",
3297 .child = inotify_table,
3300 #ifdef CONFIG_FANOTIFY
3302 .procname = "fanotify",
3304 .child = fanotify_table,
3309 .procname = "epoll",
3311 .child = epoll_table,
3316 .procname = "protected_symlinks",
3317 .data = &sysctl_protected_symlinks,
3318 .maxlen = sizeof(int),
3320 .proc_handler = proc_dointvec_minmax,
3321 .extra1 = SYSCTL_ZERO,
3322 .extra2 = SYSCTL_ONE,
3325 .procname = "protected_hardlinks",
3326 .data = &sysctl_protected_hardlinks,
3327 .maxlen = sizeof(int),
3329 .proc_handler = proc_dointvec_minmax,
3330 .extra1 = SYSCTL_ZERO,
3331 .extra2 = SYSCTL_ONE,
3334 .procname = "protected_fifos",
3335 .data = &sysctl_protected_fifos,
3336 .maxlen = sizeof(int),
3338 .proc_handler = proc_dointvec_minmax,
3339 .extra1 = SYSCTL_ZERO,
3343 .procname = "protected_regular",
3344 .data = &sysctl_protected_regular,
3345 .maxlen = sizeof(int),
3347 .proc_handler = proc_dointvec_minmax,
3348 .extra1 = SYSCTL_ZERO,
3352 .procname = "suid_dumpable",
3353 .data = &suid_dumpable,
3354 .maxlen = sizeof(int),
3356 .proc_handler = proc_dointvec_minmax_coredump,
3357 .extra1 = SYSCTL_ZERO,
3360 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3362 .procname = "binfmt_misc",
3364 .child = sysctl_mount_point,
3368 .procname = "pipe-max-size",
3369 .data = &pipe_max_size,
3370 .maxlen = sizeof(pipe_max_size),
3372 .proc_handler = proc_dopipe_max_size,
3375 .procname = "pipe-user-pages-hard",
3376 .data = &pipe_user_pages_hard,
3377 .maxlen = sizeof(pipe_user_pages_hard),
3379 .proc_handler = proc_doulongvec_minmax,
3382 .procname = "pipe-user-pages-soft",
3383 .data = &pipe_user_pages_soft,
3384 .maxlen = sizeof(pipe_user_pages_soft),
3386 .proc_handler = proc_doulongvec_minmax,
3389 .procname = "mount-max",
3390 .data = &sysctl_mount_max,
3391 .maxlen = sizeof(unsigned int),
3393 .proc_handler = proc_dointvec_minmax,
3394 .extra1 = SYSCTL_ONE,
3399 static struct ctl_table debug_table[] = {
3400 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3402 .procname = "exception-trace",
3403 .data = &show_unhandled_signals,
3404 .maxlen = sizeof(int),
3406 .proc_handler = proc_dointvec
3409 #if defined(CONFIG_OPTPROBES)
3411 .procname = "kprobes-optimization",
3412 .data = &sysctl_kprobes_optimization,
3413 .maxlen = sizeof(int),
3415 .proc_handler = proc_kprobes_optimization_handler,
3416 .extra1 = SYSCTL_ZERO,
3417 .extra2 = SYSCTL_ONE,
3423 static struct ctl_table dev_table[] = {
3427 static struct ctl_table sysctl_base_table[] = {
3429 .procname = "kernel",
3431 .child = kern_table,
3444 .procname = "debug",
3446 .child = debug_table,
3456 int __init sysctl_init(void)
3458 struct ctl_table_header *hdr;
3460 hdr = register_sysctl_table(sysctl_base_table);
3461 kmemleak_not_leak(hdr);
3464 #endif /* CONFIG_SYSCTL */
3466 * No sense putting this after each symbol definition, twice,
3467 * exception granted :-)
3469 EXPORT_SYMBOL(proc_dobool);
3470 EXPORT_SYMBOL(proc_dointvec);
3471 EXPORT_SYMBOL(proc_douintvec);
3472 EXPORT_SYMBOL(proc_dointvec_jiffies);
3473 EXPORT_SYMBOL(proc_dointvec_minmax);
3474 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3475 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3476 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3477 EXPORT_SYMBOL(proc_dostring);
3478 EXPORT_SYMBOL(proc_doulongvec_minmax);
3479 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3480 EXPORT_SYMBOL(proc_do_large_bitmap);