1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/panic.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.h>
34 #include <linux/kmemleak.h>
35 #include <linux/filter.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
39 #include <linux/kobject.h>
40 #include <linux/net.h>
41 #include <linux/sysrq.h>
42 #include <linux/highuid.h>
43 #include <linux/writeback.h>
44 #include <linux/ratelimit.h>
45 #include <linux/compaction.h>
46 #include <linux/hugetlb.h>
47 #include <linux/initrd.h>
48 #include <linux/key.h>
49 #include <linux/times.h>
50 #include <linux/limits.h>
51 #include <linux/dcache.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
69 #include <linux/userfaultfd_k.h>
70 #include <linux/coredump.h>
71 #include <linux/latencytop.h>
72 #include <linux/pid.h>
73 #include <linux/delayacct.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>
98 #if defined(CONFIG_SYSCTL)
100 /* Constants used for minimum and maximum */
103 static const int ten_thousand = 10000;
105 #ifdef CONFIG_PERF_EVENTS
106 static const int six_hundred_forty_kb = 640 * 1024;
109 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
110 static const unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
112 static const int ngroups_max = NGROUPS_MAX;
113 static const int cap_last_cap = CAP_LAST_CAP;
115 #ifdef CONFIG_PROC_SYSCTL
118 * enum sysctl_writes_mode - supported sysctl write modes
120 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
121 * to be written, and multiple writes on the same sysctl file descriptor
122 * will rewrite the sysctl value, regardless of file position. No warning
123 * is issued when the initial position is not 0.
124 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
126 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
127 * file position 0 and the value must be fully contained in the buffer
128 * sent to the write syscall. If dealing with strings respect the file
129 * position, but restrict this to the max length of the buffer, anything
130 * passed the max length will be ignored. Multiple writes will append
133 * These write modes control how current file position affects the behavior of
134 * updating sysctl values through the proc interface on each write.
136 enum sysctl_writes_mode {
137 SYSCTL_WRITES_LEGACY = -1,
138 SYSCTL_WRITES_WARN = 0,
139 SYSCTL_WRITES_STRICT = 1,
142 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
143 #endif /* CONFIG_PROC_SYSCTL */
145 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
146 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
147 int sysctl_legacy_va_layout;
150 #ifdef CONFIG_COMPACTION
151 /* min_extfrag_threshold is SYSCTL_ZERO */;
152 static const int max_extfrag_threshold = 1000;
155 #endif /* CONFIG_SYSCTL */
157 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
158 static int bpf_stats_handler(struct ctl_table *table, int write,
159 void *buffer, size_t *lenp, loff_t *ppos)
161 struct static_key *key = (struct static_key *)table->data;
162 static int saved_val;
164 struct ctl_table tmp = {
166 .maxlen = sizeof(val),
168 .extra1 = SYSCTL_ZERO,
169 .extra2 = SYSCTL_ONE,
172 if (write && !capable(CAP_SYS_ADMIN))
175 mutex_lock(&bpf_stats_enabled_mutex);
177 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
178 if (write && !ret && val != saved_val) {
180 static_key_slow_inc(key);
182 static_key_slow_dec(key);
185 mutex_unlock(&bpf_stats_enabled_mutex);
189 static int bpf_unpriv_handler(struct ctl_table *table, int write,
190 void *buffer, size_t *lenp, loff_t *ppos)
192 int ret, unpriv_enable = *(int *)table->data;
193 bool locked_state = unpriv_enable == 1;
194 struct ctl_table tmp = *table;
196 if (write && !capable(CAP_SYS_ADMIN))
199 tmp.data = &unpriv_enable;
200 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
202 if (locked_state && unpriv_enable != 1)
204 *(int *)table->data = unpriv_enable;
208 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
214 #ifdef CONFIG_PROC_SYSCTL
216 static int _proc_do_string(char *data, int maxlen, int write,
217 char *buffer, size_t *lenp, loff_t *ppos)
222 if (!data || !maxlen || !*lenp) {
228 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
229 /* Only continue writes not past the end of buffer. */
231 if (len > maxlen - 1)
238 /* Start writing from beginning of buffer. */
244 while ((p - buffer) < *lenp && len < maxlen - 1) {
246 if (c == 0 || c == '\n')
267 memcpy(buffer, data, len);
278 static void warn_sysctl_write(struct ctl_table *table)
280 pr_warn_once("%s wrote to %s when file position was not 0!\n"
281 "This will not be supported in the future. To silence this\n"
282 "warning, set kernel.sysctl_writes_strict = -1\n",
283 current->comm, table->procname);
287 * proc_first_pos_non_zero_ignore - check if first position is allowed
288 * @ppos: file position
289 * @table: the sysctl table
291 * Returns true if the first position is non-zero and the sysctl_writes_strict
292 * mode indicates this is not allowed for numeric input types. String proc
293 * handlers can ignore the return value.
295 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
296 struct ctl_table *table)
301 switch (sysctl_writes_strict) {
302 case SYSCTL_WRITES_STRICT:
304 case SYSCTL_WRITES_WARN:
305 warn_sysctl_write(table);
313 * proc_dostring - read a string sysctl
314 * @table: the sysctl table
315 * @write: %TRUE if this is a write to the sysctl file
316 * @buffer: the user buffer
317 * @lenp: the size of the user buffer
318 * @ppos: file position
320 * Reads/writes a string from/to the user buffer. If the kernel
321 * buffer provided is not large enough to hold the string, the
322 * string is truncated. The copied string is %NULL-terminated.
323 * If the string is being read by the user process, it is copied
324 * and a newline '\n' is added. It is truncated if the buffer is
327 * Returns 0 on success.
329 int proc_dostring(struct ctl_table *table, int write,
330 void *buffer, size_t *lenp, loff_t *ppos)
333 proc_first_pos_non_zero_ignore(ppos, table);
335 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
339 static size_t proc_skip_spaces(char **buf)
342 char *tmp = skip_spaces(*buf);
348 static void proc_skip_char(char **buf, size_t *size, const char v)
359 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
362 * @cp: kernel buffer containing the string to parse
363 * @endp: pointer to store the trailing characters
364 * @base: the base to use
365 * @res: where the parsed integer will be stored
367 * In case of success 0 is returned and @res will contain the parsed integer,
368 * @endp will hold any trailing characters.
369 * This function will fail the parse on overflow. If there wasn't an overflow
370 * the function will defer the decision what characters count as invalid to the
373 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
376 unsigned long long result;
379 cp = _parse_integer_fixup_radix(cp, &base);
380 rv = _parse_integer(cp, base, &result);
381 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
389 *res = (unsigned long)result;
395 * proc_get_long - reads an ASCII formatted integer from a user buffer
397 * @buf: a kernel buffer
398 * @size: size of the kernel buffer
399 * @val: this is where the number will be stored
400 * @neg: set to %TRUE if number is negative
401 * @perm_tr: a vector which contains the allowed trailers
402 * @perm_tr_len: size of the perm_tr vector
403 * @tr: pointer to store the trailer character
405 * In case of success %0 is returned and @buf and @size are updated with
406 * the amount of bytes read. If @tr is non-NULL and a trailing
407 * character exists (size is non-zero after returning from this
408 * function), @tr is updated with the trailing character.
410 static int proc_get_long(char **buf, size_t *size,
411 unsigned long *val, bool *neg,
412 const char *perm_tr, unsigned perm_tr_len, char *tr)
415 char *p, tmp[TMPBUFLEN];
421 if (len > TMPBUFLEN - 1)
424 memcpy(tmp, *buf, len);
428 if (*p == '-' && *size > 1) {
436 if (strtoul_lenient(p, &p, 0, val))
441 /* We don't know if the next char is whitespace thus we may accept
442 * invalid integers (e.g. 1234...a) or two integers instead of one
443 * (e.g. 123...1). So lets not allow such large numbers. */
444 if (len == TMPBUFLEN - 1)
447 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
450 if (tr && (len < *size))
460 * proc_put_long - converts an integer to a decimal ASCII formatted string
462 * @buf: the user buffer
463 * @size: the size of the user buffer
464 * @val: the integer to be converted
465 * @neg: sign of the number, %TRUE for negative
467 * In case of success @buf and @size are updated with the amount of bytes
470 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
473 char tmp[TMPBUFLEN], *p = tmp;
475 sprintf(p, "%s%lu", neg ? "-" : "", val);
479 memcpy(*buf, tmp, len);
485 static void proc_put_char(void **buf, size_t *size, char c)
488 char **buffer = (char **)buf;
497 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
499 int write, void *data)
502 *(bool *)valp = *lvalp;
504 int val = *(bool *)valp;
506 *lvalp = (unsigned long)val;
512 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
514 int write, void *data)
518 if (*lvalp > (unsigned long) INT_MAX + 1)
522 if (*lvalp > (unsigned long) INT_MAX)
530 *lvalp = -(unsigned long)val;
533 *lvalp = (unsigned long)val;
539 static int do_proc_douintvec_conv(unsigned long *lvalp,
541 int write, void *data)
544 if (*lvalp > UINT_MAX)
548 unsigned int val = *valp;
549 *lvalp = (unsigned long)val;
554 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
556 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
557 int write, void *buffer,
558 size_t *lenp, loff_t *ppos,
559 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
560 int write, void *data),
563 int *i, vleft, first = 1, err = 0;
567 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
572 i = (int *) tbl_data;
573 vleft = table->maxlen / sizeof(*i);
577 conv = do_proc_dointvec_conv;
580 if (proc_first_pos_non_zero_ignore(ppos, table))
583 if (left > PAGE_SIZE - 1)
584 left = PAGE_SIZE - 1;
588 for (; left && vleft--; i++, first=0) {
593 left -= proc_skip_spaces(&p);
597 err = proc_get_long(&p, &left, &lval, &neg,
599 sizeof(proc_wspace_sep), NULL);
602 if (conv(&neg, &lval, i, 1, data)) {
607 if (conv(&neg, &lval, i, 0, data)) {
612 proc_put_char(&buffer, &left, '\t');
613 proc_put_long(&buffer, &left, lval, neg);
617 if (!write && !first && left && !err)
618 proc_put_char(&buffer, &left, '\n');
619 if (write && !err && left)
620 left -= proc_skip_spaces(&p);
622 return err ? : -EINVAL;
629 static int do_proc_dointvec(struct ctl_table *table, int write,
630 void *buffer, size_t *lenp, loff_t *ppos,
631 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
632 int write, void *data),
635 return __do_proc_dointvec(table->data, table, write,
636 buffer, lenp, ppos, conv, data);
639 static int do_proc_douintvec_w(unsigned int *tbl_data,
640 struct ctl_table *table,
642 size_t *lenp, loff_t *ppos,
643 int (*conv)(unsigned long *lvalp,
645 int write, void *data),
656 if (proc_first_pos_non_zero_ignore(ppos, table))
659 if (left > PAGE_SIZE - 1)
660 left = PAGE_SIZE - 1;
662 left -= proc_skip_spaces(&p);
668 err = proc_get_long(&p, &left, &lval, &neg,
670 sizeof(proc_wspace_sep), NULL);
676 if (conv(&lval, tbl_data, 1, data)) {
682 left -= proc_skip_spaces(&p);
690 /* This is in keeping with old __do_proc_dointvec() */
696 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
697 size_t *lenp, loff_t *ppos,
698 int (*conv)(unsigned long *lvalp,
700 int write, void *data),
709 if (conv(&lval, tbl_data, 0, data)) {
714 proc_put_long(&buffer, &left, lval, false);
718 proc_put_char(&buffer, &left, '\n');
727 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
728 int write, void *buffer,
729 size_t *lenp, loff_t *ppos,
730 int (*conv)(unsigned long *lvalp,
732 int write, void *data),
735 unsigned int *i, vleft;
737 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
742 i = (unsigned int *) tbl_data;
743 vleft = table->maxlen / sizeof(*i);
746 * Arrays are not supported, keep this simple. *Do not* add
755 conv = do_proc_douintvec_conv;
758 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
760 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
763 int do_proc_douintvec(struct ctl_table *table, int write,
764 void *buffer, size_t *lenp, loff_t *ppos,
765 int (*conv)(unsigned long *lvalp,
767 int write, void *data),
770 return __do_proc_douintvec(table->data, table, write,
771 buffer, lenp, ppos, conv, data);
775 * proc_dobool - read/write a bool
776 * @table: the sysctl table
777 * @write: %TRUE if this is a write to the sysctl file
778 * @buffer: the user buffer
779 * @lenp: the size of the user buffer
780 * @ppos: file position
782 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
783 * values from/to the user buffer, treated as an ASCII string.
785 * Returns 0 on success.
787 int proc_dobool(struct ctl_table *table, int write, void *buffer,
788 size_t *lenp, loff_t *ppos)
790 return do_proc_dointvec(table, write, buffer, lenp, ppos,
791 do_proc_dobool_conv, NULL);
795 * proc_dointvec - read a vector of integers
796 * @table: the sysctl table
797 * @write: %TRUE if this is a write to the sysctl file
798 * @buffer: the user buffer
799 * @lenp: the size of the user buffer
800 * @ppos: file position
802 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
803 * values from/to the user buffer, treated as an ASCII string.
805 * Returns 0 on success.
807 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
808 size_t *lenp, loff_t *ppos)
810 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
813 #ifdef CONFIG_COMPACTION
814 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
815 int write, void *buffer, size_t *lenp, loff_t *ppos)
819 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
820 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
822 old = *(int *)table->data;
823 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
826 if (old != *(int *)table->data)
827 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
828 table->procname, current->comm,
829 task_pid_nr(current));
835 * proc_douintvec - read a vector of unsigned integers
836 * @table: the sysctl table
837 * @write: %TRUE if this is a write to the sysctl file
838 * @buffer: the user buffer
839 * @lenp: the size of the user buffer
840 * @ppos: file position
842 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
843 * values from/to the user buffer, treated as an ASCII string.
845 * Returns 0 on success.
847 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
848 size_t *lenp, loff_t *ppos)
850 return do_proc_douintvec(table, write, buffer, lenp, ppos,
851 do_proc_douintvec_conv, NULL);
855 * Taint values can only be increased
856 * This means we can safely use a temporary.
858 static int proc_taint(struct ctl_table *table, int write,
859 void *buffer, size_t *lenp, loff_t *ppos)
862 unsigned long tmptaint = get_taint();
865 if (write && !capable(CAP_SYS_ADMIN))
870 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
878 * If we are relying on panic_on_taint not producing
879 * false positives due to userspace input, bail out
880 * before setting the requested taint flags.
882 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
886 * Poor man's atomic or. Not worth adding a primitive
887 * to everyone's atomic.h for this
889 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
890 if ((1UL << i) & tmptaint)
891 add_taint(i, LOCKDEP_STILL_OK);
898 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
899 * @min: pointer to minimum allowable value
900 * @max: pointer to maximum allowable value
902 * The do_proc_dointvec_minmax_conv_param structure provides the
903 * minimum and maximum values for doing range checking for those sysctl
904 * parameters that use the proc_dointvec_minmax() handler.
906 struct do_proc_dointvec_minmax_conv_param {
911 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
913 int write, void *data)
916 struct do_proc_dointvec_minmax_conv_param *param = data;
918 * If writing, first do so via a temporary local int so we can
919 * bounds-check it before touching *valp.
921 int *ip = write ? &tmp : valp;
923 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
928 if ((param->min && *param->min > tmp) ||
929 (param->max && *param->max < tmp))
938 * proc_dointvec_minmax - read a vector of integers with min/max values
939 * @table: the sysctl table
940 * @write: %TRUE if this is a write to the sysctl file
941 * @buffer: the user buffer
942 * @lenp: the size of the user buffer
943 * @ppos: file position
945 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
946 * values from/to the user buffer, treated as an ASCII string.
948 * This routine will ensure the values are within the range specified by
949 * table->extra1 (min) and table->extra2 (max).
951 * Returns 0 on success or -EINVAL on write when the range check fails.
953 int proc_dointvec_minmax(struct ctl_table *table, int write,
954 void *buffer, size_t *lenp, loff_t *ppos)
956 struct do_proc_dointvec_minmax_conv_param param = {
957 .min = (int *) table->extra1,
958 .max = (int *) table->extra2,
960 return do_proc_dointvec(table, write, buffer, lenp, ppos,
961 do_proc_dointvec_minmax_conv, ¶m);
965 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
966 * @min: pointer to minimum allowable value
967 * @max: pointer to maximum allowable value
969 * The do_proc_douintvec_minmax_conv_param structure provides the
970 * minimum and maximum values for doing range checking for those sysctl
971 * parameters that use the proc_douintvec_minmax() handler.
973 struct do_proc_douintvec_minmax_conv_param {
978 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
980 int write, void *data)
984 struct do_proc_douintvec_minmax_conv_param *param = data;
985 /* write via temporary local uint for bounds-checking */
986 unsigned int *up = write ? &tmp : valp;
988 ret = do_proc_douintvec_conv(lvalp, up, write, data);
993 if ((param->min && *param->min > tmp) ||
994 (param->max && *param->max < tmp))
1004 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1005 * @table: the sysctl table
1006 * @write: %TRUE if this is a write to the sysctl file
1007 * @buffer: the user buffer
1008 * @lenp: the size of the user buffer
1009 * @ppos: file position
1011 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1012 * values from/to the user buffer, treated as an ASCII string. Negative
1013 * strings are not allowed.
1015 * This routine will ensure the values are within the range specified by
1016 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1017 * check for UINT_MAX to avoid having to support wrap around uses from
1020 * Returns 0 on success or -ERANGE on write when the range check fails.
1022 int proc_douintvec_minmax(struct ctl_table *table, int write,
1023 void *buffer, size_t *lenp, loff_t *ppos)
1025 struct do_proc_douintvec_minmax_conv_param param = {
1026 .min = (unsigned int *) table->extra1,
1027 .max = (unsigned int *) table->extra2,
1029 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1030 do_proc_douintvec_minmax_conv, ¶m);
1034 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1035 * @table: the sysctl table
1036 * @write: %TRUE if this is a write to the sysctl file
1037 * @buffer: the user buffer
1038 * @lenp: the size of the user buffer
1039 * @ppos: file position
1041 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1042 * values from/to the user buffer, treated as an ASCII string. Negative
1043 * strings are not allowed.
1045 * This routine will ensure the values are within the range specified by
1046 * table->extra1 (min) and table->extra2 (max).
1048 * Returns 0 on success or an error on write when the range check fails.
1050 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1051 void *buffer, size_t *lenp, loff_t *ppos)
1053 struct ctl_table tmp;
1054 unsigned int min = 0, max = 255U, val;
1055 u8 *data = table->data;
1056 struct do_proc_douintvec_minmax_conv_param param = {
1062 /* Do not support arrays yet. */
1063 if (table->maxlen != sizeof(u8))
1066 if (table->extra1) {
1067 min = *(unsigned int *) table->extra1;
1071 if (table->extra2) {
1072 max = *(unsigned int *) table->extra2;
1079 tmp.maxlen = sizeof(val);
1082 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1083 do_proc_douintvec_minmax_conv, ¶m);
1090 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1092 #ifdef CONFIG_MAGIC_SYSRQ
1093 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1094 void *buffer, size_t *lenp, loff_t *ppos)
1100 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1101 lenp, ppos, NULL, NULL);
1106 sysrq_toggle_support(tmp);
1112 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1113 int write, void *buffer, size_t *lenp, loff_t *ppos,
1114 unsigned long convmul, unsigned long convdiv)
1116 unsigned long *i, *min, *max;
1117 int vleft, first = 1, err = 0;
1121 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1126 i = (unsigned long *) data;
1127 min = (unsigned long *) table->extra1;
1128 max = (unsigned long *) table->extra2;
1129 vleft = table->maxlen / sizeof(unsigned long);
1133 if (proc_first_pos_non_zero_ignore(ppos, table))
1136 if (left > PAGE_SIZE - 1)
1137 left = PAGE_SIZE - 1;
1141 for (; left && vleft--; i++, first = 0) {
1147 left -= proc_skip_spaces(&p);
1151 err = proc_get_long(&p, &left, &val, &neg,
1153 sizeof(proc_wspace_sep), NULL);
1158 val = convmul * val / convdiv;
1159 if ((min && val < *min) || (max && val > *max)) {
1165 val = convdiv * (*i) / convmul;
1167 proc_put_char(&buffer, &left, '\t');
1168 proc_put_long(&buffer, &left, val, false);
1172 if (!write && !first && left && !err)
1173 proc_put_char(&buffer, &left, '\n');
1175 left -= proc_skip_spaces(&p);
1177 return err ? : -EINVAL;
1184 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1185 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1186 unsigned long convdiv)
1188 return __do_proc_doulongvec_minmax(table->data, table, write,
1189 buffer, lenp, ppos, convmul, convdiv);
1193 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1194 * @table: the sysctl table
1195 * @write: %TRUE if this is a write to the sysctl file
1196 * @buffer: the user buffer
1197 * @lenp: the size of the user buffer
1198 * @ppos: file position
1200 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1201 * values from/to the user buffer, treated as an ASCII string.
1203 * This routine will ensure the values are within the range specified by
1204 * table->extra1 (min) and table->extra2 (max).
1206 * Returns 0 on success.
1208 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1209 void *buffer, size_t *lenp, loff_t *ppos)
1211 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1215 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1216 * @table: the sysctl table
1217 * @write: %TRUE if this is a write to the sysctl file
1218 * @buffer: the user buffer
1219 * @lenp: the size of the user buffer
1220 * @ppos: file position
1222 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1223 * values from/to the user buffer, treated as an ASCII string. The values
1224 * are treated as milliseconds, and converted to jiffies when they are stored.
1226 * This routine will ensure the values are within the range specified by
1227 * table->extra1 (min) and table->extra2 (max).
1229 * Returns 0 on success.
1231 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1232 void *buffer, size_t *lenp, loff_t *ppos)
1234 return do_proc_doulongvec_minmax(table, write, buffer,
1235 lenp, ppos, HZ, 1000l);
1239 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1241 int write, void *data)
1244 if (*lvalp > INT_MAX / HZ)
1246 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1252 lval = -(unsigned long)val;
1255 lval = (unsigned long)val;
1262 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1264 int write, void *data)
1267 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1269 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1275 lval = -(unsigned long)val;
1278 lval = (unsigned long)val;
1280 *lvalp = jiffies_to_clock_t(lval);
1285 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1287 int write, void *data)
1290 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1300 lval = -(unsigned long)val;
1303 lval = (unsigned long)val;
1305 *lvalp = jiffies_to_msecs(lval);
1311 * proc_dointvec_jiffies - read a vector of integers as seconds
1312 * @table: the sysctl table
1313 * @write: %TRUE if this is a write to the sysctl file
1314 * @buffer: the user buffer
1315 * @lenp: the size of the user buffer
1316 * @ppos: file position
1318 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1319 * values from/to the user buffer, treated as an ASCII string.
1320 * The values read are assumed to be in seconds, and are converted into
1323 * Returns 0 on success.
1325 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1326 void *buffer, size_t *lenp, loff_t *ppos)
1328 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1329 do_proc_dointvec_jiffies_conv,NULL);
1333 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1334 * @table: the sysctl table
1335 * @write: %TRUE if this is a write to the sysctl file
1336 * @buffer: the user buffer
1337 * @lenp: the size of the user buffer
1338 * @ppos: pointer to the file position
1340 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1341 * values from/to the user buffer, treated as an ASCII string.
1342 * The values read are assumed to be in 1/USER_HZ seconds, and
1343 * are converted into jiffies.
1345 * Returns 0 on success.
1347 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1348 void *buffer, size_t *lenp, loff_t *ppos)
1350 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1351 do_proc_dointvec_userhz_jiffies_conv,NULL);
1355 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1356 * @table: the sysctl table
1357 * @write: %TRUE if this is a write to the sysctl file
1358 * @buffer: the user buffer
1359 * @lenp: the size of the user buffer
1360 * @ppos: file position
1361 * @ppos: the current position in the file
1363 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1364 * values from/to the user buffer, treated as an ASCII string.
1365 * The values read are assumed to be in 1/1000 seconds, and
1366 * are converted into jiffies.
1368 * Returns 0 on success.
1370 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1371 size_t *lenp, loff_t *ppos)
1373 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1374 do_proc_dointvec_ms_jiffies_conv, NULL);
1377 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1378 size_t *lenp, loff_t *ppos)
1380 struct pid *new_pid;
1384 tmp = pid_vnr(cad_pid);
1386 r = __do_proc_dointvec(&tmp, table, write, buffer,
1387 lenp, ppos, NULL, NULL);
1391 new_pid = find_get_pid(tmp);
1395 put_pid(xchg(&cad_pid, new_pid));
1400 * proc_do_large_bitmap - read/write from/to a large bitmap
1401 * @table: the sysctl table
1402 * @write: %TRUE if this is a write to the sysctl file
1403 * @buffer: the user buffer
1404 * @lenp: the size of the user buffer
1405 * @ppos: file position
1407 * The bitmap is stored at table->data and the bitmap length (in bits)
1410 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1411 * large bitmaps may be represented in a compact manner. Writing into
1412 * the file will clear the bitmap then update it with the given input.
1414 * Returns 0 on success.
1416 int proc_do_large_bitmap(struct ctl_table *table, int write,
1417 void *buffer, size_t *lenp, loff_t *ppos)
1420 size_t left = *lenp;
1421 unsigned long bitmap_len = table->maxlen;
1422 unsigned long *bitmap = *(unsigned long **) table->data;
1423 unsigned long *tmp_bitmap = NULL;
1424 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1426 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1435 if (left > PAGE_SIZE - 1) {
1436 left = PAGE_SIZE - 1;
1437 /* How much of the buffer we'll skip this pass */
1438 skipped = *lenp - left;
1441 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1444 proc_skip_char(&p, &left, '\n');
1445 while (!err && left) {
1446 unsigned long val_a, val_b;
1450 /* In case we stop parsing mid-number, we can reset */
1452 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1455 * If we consumed the entirety of a truncated buffer or
1456 * only one char is left (may be a "-"), then stop here,
1457 * reset, & come back for more.
1459 if ((left <= 1) && skipped) {
1466 if (val_a >= bitmap_len || neg) {
1478 err = proc_get_long(&p, &left, &val_b,
1479 &neg, tr_b, sizeof(tr_b),
1482 * If we consumed all of a truncated buffer or
1483 * then stop here, reset, & come back for more.
1485 if (!left && skipped) {
1492 if (val_b >= bitmap_len || neg ||
1503 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1504 proc_skip_char(&p, &left, '\n');
1508 unsigned long bit_a, bit_b = 0;
1512 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1513 if (bit_a >= bitmap_len)
1515 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1519 proc_put_char(&buffer, &left, ',');
1520 proc_put_long(&buffer, &left, bit_a, false);
1521 if (bit_a != bit_b) {
1522 proc_put_char(&buffer, &left, '-');
1523 proc_put_long(&buffer, &left, bit_b, false);
1528 proc_put_char(&buffer, &left, '\n');
1534 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1536 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1542 bitmap_free(tmp_bitmap);
1546 #else /* CONFIG_PROC_SYSCTL */
1548 int proc_dostring(struct ctl_table *table, int write,
1549 void *buffer, size_t *lenp, loff_t *ppos)
1554 int proc_dobool(struct ctl_table *table, int write,
1555 void *buffer, size_t *lenp, loff_t *ppos)
1560 int proc_dointvec(struct ctl_table *table, int write,
1561 void *buffer, size_t *lenp, loff_t *ppos)
1566 int proc_douintvec(struct ctl_table *table, int write,
1567 void *buffer, size_t *lenp, loff_t *ppos)
1572 int proc_dointvec_minmax(struct ctl_table *table, int write,
1573 void *buffer, size_t *lenp, loff_t *ppos)
1578 int proc_douintvec_minmax(struct ctl_table *table, int write,
1579 void *buffer, size_t *lenp, loff_t *ppos)
1584 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1585 void *buffer, size_t *lenp, loff_t *ppos)
1590 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1591 void *buffer, size_t *lenp, loff_t *ppos)
1596 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1597 void *buffer, size_t *lenp, loff_t *ppos)
1602 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1603 void *buffer, size_t *lenp, loff_t *ppos)
1608 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1609 void *buffer, size_t *lenp, loff_t *ppos)
1614 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1615 void *buffer, size_t *lenp, loff_t *ppos)
1620 int proc_do_large_bitmap(struct ctl_table *table, int write,
1621 void *buffer, size_t *lenp, loff_t *ppos)
1626 #endif /* CONFIG_PROC_SYSCTL */
1628 #if defined(CONFIG_SYSCTL)
1629 int proc_do_static_key(struct ctl_table *table, int write,
1630 void *buffer, size_t *lenp, loff_t *ppos)
1632 struct static_key *key = (struct static_key *)table->data;
1633 static DEFINE_MUTEX(static_key_mutex);
1635 struct ctl_table tmp = {
1637 .maxlen = sizeof(val),
1638 .mode = table->mode,
1639 .extra1 = SYSCTL_ZERO,
1640 .extra2 = SYSCTL_ONE,
1643 if (write && !capable(CAP_SYS_ADMIN))
1646 mutex_lock(&static_key_mutex);
1647 val = static_key_enabled(key);
1648 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1649 if (write && !ret) {
1651 static_key_enable(key);
1653 static_key_disable(key);
1655 mutex_unlock(&static_key_mutex);
1659 static struct ctl_table kern_table[] = {
1661 .procname = "sched_child_runs_first",
1662 .data = &sysctl_sched_child_runs_first,
1663 .maxlen = sizeof(unsigned int),
1665 .proc_handler = proc_dointvec,
1667 #ifdef CONFIG_SCHEDSTATS
1669 .procname = "sched_schedstats",
1671 .maxlen = sizeof(unsigned int),
1673 .proc_handler = sysctl_schedstats,
1674 .extra1 = SYSCTL_ZERO,
1675 .extra2 = SYSCTL_ONE,
1677 #endif /* CONFIG_SCHEDSTATS */
1678 #ifdef CONFIG_TASK_DELAY_ACCT
1680 .procname = "task_delayacct",
1682 .maxlen = sizeof(unsigned int),
1684 .proc_handler = sysctl_delayacct,
1685 .extra1 = SYSCTL_ZERO,
1686 .extra2 = SYSCTL_ONE,
1688 #endif /* CONFIG_TASK_DELAY_ACCT */
1689 #ifdef CONFIG_NUMA_BALANCING
1691 .procname = "numa_balancing",
1692 .data = NULL, /* filled in by handler */
1693 .maxlen = sizeof(unsigned int),
1695 .proc_handler = sysctl_numa_balancing,
1696 .extra1 = SYSCTL_ZERO,
1697 .extra2 = SYSCTL_ONE,
1699 #endif /* CONFIG_NUMA_BALANCING */
1701 .procname = "sched_rt_period_us",
1702 .data = &sysctl_sched_rt_period,
1703 .maxlen = sizeof(unsigned int),
1705 .proc_handler = sched_rt_handler,
1708 .procname = "sched_rt_runtime_us",
1709 .data = &sysctl_sched_rt_runtime,
1710 .maxlen = sizeof(int),
1712 .proc_handler = sched_rt_handler,
1715 .procname = "sched_deadline_period_max_us",
1716 .data = &sysctl_sched_dl_period_max,
1717 .maxlen = sizeof(unsigned int),
1719 .proc_handler = proc_dointvec,
1722 .procname = "sched_deadline_period_min_us",
1723 .data = &sysctl_sched_dl_period_min,
1724 .maxlen = sizeof(unsigned int),
1726 .proc_handler = proc_dointvec,
1729 .procname = "sched_rr_timeslice_ms",
1730 .data = &sysctl_sched_rr_timeslice,
1731 .maxlen = sizeof(int),
1733 .proc_handler = sched_rr_handler,
1735 #ifdef CONFIG_UCLAMP_TASK
1737 .procname = "sched_util_clamp_min",
1738 .data = &sysctl_sched_uclamp_util_min,
1739 .maxlen = sizeof(unsigned int),
1741 .proc_handler = sysctl_sched_uclamp_handler,
1744 .procname = "sched_util_clamp_max",
1745 .data = &sysctl_sched_uclamp_util_max,
1746 .maxlen = sizeof(unsigned int),
1748 .proc_handler = sysctl_sched_uclamp_handler,
1751 .procname = "sched_util_clamp_min_rt_default",
1752 .data = &sysctl_sched_uclamp_util_min_rt_default,
1753 .maxlen = sizeof(unsigned int),
1755 .proc_handler = sysctl_sched_uclamp_handler,
1758 #ifdef CONFIG_SCHED_AUTOGROUP
1760 .procname = "sched_autogroup_enabled",
1761 .data = &sysctl_sched_autogroup_enabled,
1762 .maxlen = sizeof(unsigned int),
1764 .proc_handler = proc_dointvec_minmax,
1765 .extra1 = SYSCTL_ZERO,
1766 .extra2 = SYSCTL_ONE,
1769 #ifdef CONFIG_CFS_BANDWIDTH
1771 .procname = "sched_cfs_bandwidth_slice_us",
1772 .data = &sysctl_sched_cfs_bandwidth_slice,
1773 .maxlen = sizeof(unsigned int),
1775 .proc_handler = proc_dointvec_minmax,
1776 .extra1 = SYSCTL_ONE,
1779 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1781 .procname = "sched_energy_aware",
1782 .data = &sysctl_sched_energy_aware,
1783 .maxlen = sizeof(unsigned int),
1785 .proc_handler = sched_energy_aware_handler,
1786 .extra1 = SYSCTL_ZERO,
1787 .extra2 = SYSCTL_ONE,
1790 #ifdef CONFIG_PROVE_LOCKING
1792 .procname = "prove_locking",
1793 .data = &prove_locking,
1794 .maxlen = sizeof(int),
1796 .proc_handler = proc_dointvec,
1799 #ifdef CONFIG_LOCK_STAT
1801 .procname = "lock_stat",
1803 .maxlen = sizeof(int),
1805 .proc_handler = proc_dointvec,
1809 .procname = "panic",
1810 .data = &panic_timeout,
1811 .maxlen = sizeof(int),
1813 .proc_handler = proc_dointvec,
1815 #ifdef CONFIG_PROC_SYSCTL
1817 .procname = "tainted",
1818 .maxlen = sizeof(long),
1820 .proc_handler = proc_taint,
1823 .procname = "sysctl_writes_strict",
1824 .data = &sysctl_writes_strict,
1825 .maxlen = sizeof(int),
1827 .proc_handler = proc_dointvec_minmax,
1828 .extra1 = SYSCTL_NEG_ONE,
1829 .extra2 = SYSCTL_ONE,
1832 #ifdef CONFIG_LATENCYTOP
1834 .procname = "latencytop",
1835 .data = &latencytop_enabled,
1836 .maxlen = sizeof(int),
1838 .proc_handler = sysctl_latencytop,
1841 #ifdef CONFIG_BLK_DEV_INITRD
1843 .procname = "real-root-dev",
1844 .data = &real_root_dev,
1845 .maxlen = sizeof(int),
1847 .proc_handler = proc_dointvec,
1851 .procname = "print-fatal-signals",
1852 .data = &print_fatal_signals,
1853 .maxlen = sizeof(int),
1855 .proc_handler = proc_dointvec,
1859 .procname = "reboot-cmd",
1860 .data = reboot_command,
1863 .proc_handler = proc_dostring,
1866 .procname = "stop-a",
1867 .data = &stop_a_enabled,
1868 .maxlen = sizeof (int),
1870 .proc_handler = proc_dointvec,
1873 .procname = "scons-poweroff",
1874 .data = &scons_pwroff,
1875 .maxlen = sizeof (int),
1877 .proc_handler = proc_dointvec,
1880 #ifdef CONFIG_SPARC64
1882 .procname = "tsb-ratio",
1883 .data = &sysctl_tsb_ratio,
1884 .maxlen = sizeof (int),
1886 .proc_handler = proc_dointvec,
1889 #ifdef CONFIG_PARISC
1891 .procname = "soft-power",
1892 .data = &pwrsw_enabled,
1893 .maxlen = sizeof (int),
1895 .proc_handler = proc_dointvec,
1898 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1900 .procname = "unaligned-trap",
1901 .data = &unaligned_enabled,
1902 .maxlen = sizeof (int),
1904 .proc_handler = proc_dointvec,
1908 .procname = "ctrl-alt-del",
1910 .maxlen = sizeof(int),
1912 .proc_handler = proc_dointvec,
1914 #ifdef CONFIG_FUNCTION_TRACER
1916 .procname = "ftrace_enabled",
1917 .data = &ftrace_enabled,
1918 .maxlen = sizeof(int),
1920 .proc_handler = ftrace_enable_sysctl,
1923 #ifdef CONFIG_STACK_TRACER
1925 .procname = "stack_tracer_enabled",
1926 .data = &stack_tracer_enabled,
1927 .maxlen = sizeof(int),
1929 .proc_handler = stack_trace_sysctl,
1932 #ifdef CONFIG_TRACING
1934 .procname = "ftrace_dump_on_oops",
1935 .data = &ftrace_dump_on_oops,
1936 .maxlen = sizeof(int),
1938 .proc_handler = proc_dointvec,
1941 .procname = "traceoff_on_warning",
1942 .data = &__disable_trace_on_warning,
1943 .maxlen = sizeof(__disable_trace_on_warning),
1945 .proc_handler = proc_dointvec,
1948 .procname = "tracepoint_printk",
1949 .data = &tracepoint_printk,
1950 .maxlen = sizeof(tracepoint_printk),
1952 .proc_handler = tracepoint_printk_sysctl,
1955 #ifdef CONFIG_KEXEC_CORE
1957 .procname = "kexec_load_disabled",
1958 .data = &kexec_load_disabled,
1959 .maxlen = sizeof(int),
1961 /* only handle a transition from default "0" to "1" */
1962 .proc_handler = proc_dointvec_minmax,
1963 .extra1 = SYSCTL_ONE,
1964 .extra2 = SYSCTL_ONE,
1967 #ifdef CONFIG_MODULES
1969 .procname = "modprobe",
1970 .data = &modprobe_path,
1971 .maxlen = KMOD_PATH_LEN,
1973 .proc_handler = proc_dostring,
1976 .procname = "modules_disabled",
1977 .data = &modules_disabled,
1978 .maxlen = sizeof(int),
1980 /* only handle a transition from default "0" to "1" */
1981 .proc_handler = proc_dointvec_minmax,
1982 .extra1 = SYSCTL_ONE,
1983 .extra2 = SYSCTL_ONE,
1986 #ifdef CONFIG_UEVENT_HELPER
1988 .procname = "hotplug",
1989 .data = &uevent_helper,
1990 .maxlen = UEVENT_HELPER_PATH_LEN,
1992 .proc_handler = proc_dostring,
1995 #ifdef CONFIG_BSD_PROCESS_ACCT
1999 .maxlen = 3*sizeof(int),
2001 .proc_handler = proc_dointvec,
2004 #ifdef CONFIG_MAGIC_SYSRQ
2006 .procname = "sysrq",
2008 .maxlen = sizeof (int),
2010 .proc_handler = sysrq_sysctl_handler,
2013 #ifdef CONFIG_PROC_SYSCTL
2015 .procname = "cad_pid",
2017 .maxlen = sizeof (int),
2019 .proc_handler = proc_do_cad_pid,
2023 .procname = "threads-max",
2025 .maxlen = sizeof(int),
2027 .proc_handler = sysctl_max_threads,
2030 .procname = "usermodehelper",
2032 .child = usermodehelper_table,
2035 .procname = "overflowuid",
2036 .data = &overflowuid,
2037 .maxlen = sizeof(int),
2039 .proc_handler = proc_dointvec_minmax,
2040 .extra1 = SYSCTL_ZERO,
2041 .extra2 = SYSCTL_MAXOLDUID,
2044 .procname = "overflowgid",
2045 .data = &overflowgid,
2046 .maxlen = sizeof(int),
2048 .proc_handler = proc_dointvec_minmax,
2049 .extra1 = SYSCTL_ZERO,
2050 .extra2 = SYSCTL_MAXOLDUID,
2054 .procname = "userprocess_debug",
2055 .data = &show_unhandled_signals,
2056 .maxlen = sizeof(int),
2058 .proc_handler = proc_dointvec,
2063 .procname = "oops_all_cpu_backtrace",
2064 .data = &sysctl_oops_all_cpu_backtrace,
2065 .maxlen = sizeof(int),
2067 .proc_handler = proc_dointvec_minmax,
2068 .extra1 = SYSCTL_ZERO,
2069 .extra2 = SYSCTL_ONE,
2071 #endif /* CONFIG_SMP */
2073 .procname = "pid_max",
2075 .maxlen = sizeof (int),
2077 .proc_handler = proc_dointvec_minmax,
2078 .extra1 = &pid_max_min,
2079 .extra2 = &pid_max_max,
2082 .procname = "panic_on_oops",
2083 .data = &panic_on_oops,
2084 .maxlen = sizeof(int),
2086 .proc_handler = proc_dointvec,
2089 .procname = "panic_print",
2090 .data = &panic_print,
2091 .maxlen = sizeof(unsigned long),
2093 .proc_handler = proc_doulongvec_minmax,
2096 .procname = "ngroups_max",
2097 .data = (void *)&ngroups_max,
2098 .maxlen = sizeof (int),
2100 .proc_handler = proc_dointvec,
2103 .procname = "cap_last_cap",
2104 .data = (void *)&cap_last_cap,
2105 .maxlen = sizeof(int),
2107 .proc_handler = proc_dointvec,
2109 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2111 .procname = "unknown_nmi_panic",
2112 .data = &unknown_nmi_panic,
2113 .maxlen = sizeof (int),
2115 .proc_handler = proc_dointvec,
2119 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2120 defined(CONFIG_DEBUG_STACKOVERFLOW)
2122 .procname = "panic_on_stackoverflow",
2123 .data = &sysctl_panic_on_stackoverflow,
2124 .maxlen = sizeof(int),
2126 .proc_handler = proc_dointvec,
2129 #if defined(CONFIG_X86)
2131 .procname = "panic_on_unrecovered_nmi",
2132 .data = &panic_on_unrecovered_nmi,
2133 .maxlen = sizeof(int),
2135 .proc_handler = proc_dointvec,
2138 .procname = "panic_on_io_nmi",
2139 .data = &panic_on_io_nmi,
2140 .maxlen = sizeof(int),
2142 .proc_handler = proc_dointvec,
2145 .procname = "bootloader_type",
2146 .data = &bootloader_type,
2147 .maxlen = sizeof (int),
2149 .proc_handler = proc_dointvec,
2152 .procname = "bootloader_version",
2153 .data = &bootloader_version,
2154 .maxlen = sizeof (int),
2156 .proc_handler = proc_dointvec,
2159 .procname = "io_delay_type",
2160 .data = &io_delay_type,
2161 .maxlen = sizeof(int),
2163 .proc_handler = proc_dointvec,
2166 #if defined(CONFIG_MMU)
2168 .procname = "randomize_va_space",
2169 .data = &randomize_va_space,
2170 .maxlen = sizeof(int),
2172 .proc_handler = proc_dointvec,
2175 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2177 .procname = "spin_retry",
2178 .data = &spin_retry,
2179 .maxlen = sizeof (int),
2181 .proc_handler = proc_dointvec,
2184 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2186 .procname = "acpi_video_flags",
2187 .data = &acpi_realmode_flags,
2188 .maxlen = sizeof (unsigned long),
2190 .proc_handler = proc_doulongvec_minmax,
2193 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2195 .procname = "ignore-unaligned-usertrap",
2196 .data = &no_unaligned_warning,
2197 .maxlen = sizeof (int),
2199 .proc_handler = proc_dointvec,
2204 .procname = "unaligned-dump-stack",
2205 .data = &unaligned_dump_stack,
2206 .maxlen = sizeof (int),
2208 .proc_handler = proc_dointvec,
2211 #ifdef CONFIG_RT_MUTEXES
2213 .procname = "max_lock_depth",
2214 .data = &max_lock_depth,
2215 .maxlen = sizeof(int),
2217 .proc_handler = proc_dointvec,
2221 .procname = "poweroff_cmd",
2222 .data = &poweroff_cmd,
2223 .maxlen = POWEROFF_CMD_PATH_LEN,
2225 .proc_handler = proc_dostring,
2231 .child = key_sysctls,
2234 #ifdef CONFIG_PERF_EVENTS
2236 * User-space scripts rely on the existence of this file
2237 * as a feature check for perf_events being enabled.
2239 * So it's an ABI, do not remove!
2242 .procname = "perf_event_paranoid",
2243 .data = &sysctl_perf_event_paranoid,
2244 .maxlen = sizeof(sysctl_perf_event_paranoid),
2246 .proc_handler = proc_dointvec,
2249 .procname = "perf_event_mlock_kb",
2250 .data = &sysctl_perf_event_mlock,
2251 .maxlen = sizeof(sysctl_perf_event_mlock),
2253 .proc_handler = proc_dointvec,
2256 .procname = "perf_event_max_sample_rate",
2257 .data = &sysctl_perf_event_sample_rate,
2258 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2260 .proc_handler = perf_proc_update_handler,
2261 .extra1 = SYSCTL_ONE,
2264 .procname = "perf_cpu_time_max_percent",
2265 .data = &sysctl_perf_cpu_time_max_percent,
2266 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2268 .proc_handler = perf_cpu_time_max_percent_handler,
2269 .extra1 = SYSCTL_ZERO,
2270 .extra2 = SYSCTL_ONE_HUNDRED,
2273 .procname = "perf_event_max_stack",
2274 .data = &sysctl_perf_event_max_stack,
2275 .maxlen = sizeof(sysctl_perf_event_max_stack),
2277 .proc_handler = perf_event_max_stack_handler,
2278 .extra1 = SYSCTL_ZERO,
2279 .extra2 = (void *)&six_hundred_forty_kb,
2282 .procname = "perf_event_max_contexts_per_stack",
2283 .data = &sysctl_perf_event_max_contexts_per_stack,
2284 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2286 .proc_handler = perf_event_max_stack_handler,
2287 .extra1 = SYSCTL_ZERO,
2288 .extra2 = SYSCTL_ONE_THOUSAND,
2292 .procname = "panic_on_warn",
2293 .data = &panic_on_warn,
2294 .maxlen = sizeof(int),
2296 .proc_handler = proc_dointvec_minmax,
2297 .extra1 = SYSCTL_ZERO,
2298 .extra2 = SYSCTL_ONE,
2300 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2302 .procname = "timer_migration",
2303 .data = &sysctl_timer_migration,
2304 .maxlen = sizeof(unsigned int),
2306 .proc_handler = timer_migration_handler,
2307 .extra1 = SYSCTL_ZERO,
2308 .extra2 = SYSCTL_ONE,
2311 #ifdef CONFIG_BPF_SYSCALL
2313 .procname = "unprivileged_bpf_disabled",
2314 .data = &sysctl_unprivileged_bpf_disabled,
2315 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2317 .proc_handler = bpf_unpriv_handler,
2318 .extra1 = SYSCTL_ZERO,
2319 .extra2 = SYSCTL_TWO,
2322 .procname = "bpf_stats_enabled",
2323 .data = &bpf_stats_enabled_key.key,
2324 .maxlen = sizeof(bpf_stats_enabled_key),
2326 .proc_handler = bpf_stats_handler,
2329 #if defined(CONFIG_TREE_RCU)
2331 .procname = "panic_on_rcu_stall",
2332 .data = &sysctl_panic_on_rcu_stall,
2333 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2335 .proc_handler = proc_dointvec_minmax,
2336 .extra1 = SYSCTL_ZERO,
2337 .extra2 = SYSCTL_ONE,
2340 #if defined(CONFIG_TREE_RCU)
2342 .procname = "max_rcu_stall_to_panic",
2343 .data = &sysctl_max_rcu_stall_to_panic,
2344 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2346 .proc_handler = proc_dointvec_minmax,
2347 .extra1 = SYSCTL_ONE,
2348 .extra2 = SYSCTL_INT_MAX,
2354 static struct ctl_table vm_table[] = {
2356 .procname = "overcommit_memory",
2357 .data = &sysctl_overcommit_memory,
2358 .maxlen = sizeof(sysctl_overcommit_memory),
2360 .proc_handler = overcommit_policy_handler,
2361 .extra1 = SYSCTL_ZERO,
2362 .extra2 = SYSCTL_TWO,
2365 .procname = "panic_on_oom",
2366 .data = &sysctl_panic_on_oom,
2367 .maxlen = sizeof(sysctl_panic_on_oom),
2369 .proc_handler = proc_dointvec_minmax,
2370 .extra1 = SYSCTL_ZERO,
2371 .extra2 = SYSCTL_TWO,
2374 .procname = "oom_kill_allocating_task",
2375 .data = &sysctl_oom_kill_allocating_task,
2376 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2378 .proc_handler = proc_dointvec,
2381 .procname = "oom_dump_tasks",
2382 .data = &sysctl_oom_dump_tasks,
2383 .maxlen = sizeof(sysctl_oom_dump_tasks),
2385 .proc_handler = proc_dointvec,
2388 .procname = "overcommit_ratio",
2389 .data = &sysctl_overcommit_ratio,
2390 .maxlen = sizeof(sysctl_overcommit_ratio),
2392 .proc_handler = overcommit_ratio_handler,
2395 .procname = "overcommit_kbytes",
2396 .data = &sysctl_overcommit_kbytes,
2397 .maxlen = sizeof(sysctl_overcommit_kbytes),
2399 .proc_handler = overcommit_kbytes_handler,
2402 .procname = "page-cluster",
2403 .data = &page_cluster,
2404 .maxlen = sizeof(int),
2406 .proc_handler = proc_dointvec_minmax,
2407 .extra1 = SYSCTL_ZERO,
2410 .procname = "dirty_background_ratio",
2411 .data = &dirty_background_ratio,
2412 .maxlen = sizeof(dirty_background_ratio),
2414 .proc_handler = dirty_background_ratio_handler,
2415 .extra1 = SYSCTL_ZERO,
2416 .extra2 = SYSCTL_ONE_HUNDRED,
2419 .procname = "dirty_background_bytes",
2420 .data = &dirty_background_bytes,
2421 .maxlen = sizeof(dirty_background_bytes),
2423 .proc_handler = dirty_background_bytes_handler,
2424 .extra1 = SYSCTL_LONG_ONE,
2427 .procname = "dirty_ratio",
2428 .data = &vm_dirty_ratio,
2429 .maxlen = sizeof(vm_dirty_ratio),
2431 .proc_handler = dirty_ratio_handler,
2432 .extra1 = SYSCTL_ZERO,
2433 .extra2 = SYSCTL_ONE_HUNDRED,
2436 .procname = "dirty_bytes",
2437 .data = &vm_dirty_bytes,
2438 .maxlen = sizeof(vm_dirty_bytes),
2440 .proc_handler = dirty_bytes_handler,
2441 .extra1 = (void *)&dirty_bytes_min,
2444 .procname = "dirty_writeback_centisecs",
2445 .data = &dirty_writeback_interval,
2446 .maxlen = sizeof(dirty_writeback_interval),
2448 .proc_handler = dirty_writeback_centisecs_handler,
2451 .procname = "dirty_expire_centisecs",
2452 .data = &dirty_expire_interval,
2453 .maxlen = sizeof(dirty_expire_interval),
2455 .proc_handler = proc_dointvec_minmax,
2456 .extra1 = SYSCTL_ZERO,
2459 .procname = "dirtytime_expire_seconds",
2460 .data = &dirtytime_expire_interval,
2461 .maxlen = sizeof(dirtytime_expire_interval),
2463 .proc_handler = dirtytime_interval_handler,
2464 .extra1 = SYSCTL_ZERO,
2467 .procname = "swappiness",
2468 .data = &vm_swappiness,
2469 .maxlen = sizeof(vm_swappiness),
2471 .proc_handler = proc_dointvec_minmax,
2472 .extra1 = SYSCTL_ZERO,
2473 .extra2 = SYSCTL_TWO_HUNDRED,
2475 #ifdef CONFIG_HUGETLB_PAGE
2477 .procname = "nr_hugepages",
2479 .maxlen = sizeof(unsigned long),
2481 .proc_handler = hugetlb_sysctl_handler,
2485 .procname = "nr_hugepages_mempolicy",
2487 .maxlen = sizeof(unsigned long),
2489 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2492 .procname = "numa_stat",
2493 .data = &sysctl_vm_numa_stat,
2494 .maxlen = sizeof(int),
2496 .proc_handler = sysctl_vm_numa_stat_handler,
2497 .extra1 = SYSCTL_ZERO,
2498 .extra2 = SYSCTL_ONE,
2502 .procname = "hugetlb_shm_group",
2503 .data = &sysctl_hugetlb_shm_group,
2504 .maxlen = sizeof(gid_t),
2506 .proc_handler = proc_dointvec,
2509 .procname = "nr_overcommit_hugepages",
2511 .maxlen = sizeof(unsigned long),
2513 .proc_handler = hugetlb_overcommit_handler,
2517 .procname = "lowmem_reserve_ratio",
2518 .data = &sysctl_lowmem_reserve_ratio,
2519 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2521 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2524 .procname = "drop_caches",
2525 .data = &sysctl_drop_caches,
2526 .maxlen = sizeof(int),
2528 .proc_handler = drop_caches_sysctl_handler,
2529 .extra1 = SYSCTL_ONE,
2530 .extra2 = SYSCTL_FOUR,
2532 #ifdef CONFIG_COMPACTION
2534 .procname = "compact_memory",
2536 .maxlen = sizeof(int),
2538 .proc_handler = sysctl_compaction_handler,
2541 .procname = "compaction_proactiveness",
2542 .data = &sysctl_compaction_proactiveness,
2543 .maxlen = sizeof(sysctl_compaction_proactiveness),
2545 .proc_handler = compaction_proactiveness_sysctl_handler,
2546 .extra1 = SYSCTL_ZERO,
2547 .extra2 = SYSCTL_ONE_HUNDRED,
2550 .procname = "extfrag_threshold",
2551 .data = &sysctl_extfrag_threshold,
2552 .maxlen = sizeof(int),
2554 .proc_handler = proc_dointvec_minmax,
2555 .extra1 = SYSCTL_ZERO,
2556 .extra2 = (void *)&max_extfrag_threshold,
2559 .procname = "compact_unevictable_allowed",
2560 .data = &sysctl_compact_unevictable_allowed,
2561 .maxlen = sizeof(int),
2563 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2564 .extra1 = SYSCTL_ZERO,
2565 .extra2 = SYSCTL_ONE,
2568 #endif /* CONFIG_COMPACTION */
2570 .procname = "min_free_kbytes",
2571 .data = &min_free_kbytes,
2572 .maxlen = sizeof(min_free_kbytes),
2574 .proc_handler = min_free_kbytes_sysctl_handler,
2575 .extra1 = SYSCTL_ZERO,
2578 .procname = "watermark_boost_factor",
2579 .data = &watermark_boost_factor,
2580 .maxlen = sizeof(watermark_boost_factor),
2582 .proc_handler = proc_dointvec_minmax,
2583 .extra1 = SYSCTL_ZERO,
2586 .procname = "watermark_scale_factor",
2587 .data = &watermark_scale_factor,
2588 .maxlen = sizeof(watermark_scale_factor),
2590 .proc_handler = watermark_scale_factor_sysctl_handler,
2591 .extra1 = SYSCTL_ONE,
2592 .extra2 = SYSCTL_THREE_THOUSAND,
2595 .procname = "percpu_pagelist_high_fraction",
2596 .data = &percpu_pagelist_high_fraction,
2597 .maxlen = sizeof(percpu_pagelist_high_fraction),
2599 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2600 .extra1 = SYSCTL_ZERO,
2603 .procname = "page_lock_unfairness",
2604 .data = &sysctl_page_lock_unfairness,
2605 .maxlen = sizeof(sysctl_page_lock_unfairness),
2607 .proc_handler = proc_dointvec_minmax,
2608 .extra1 = SYSCTL_ZERO,
2612 .procname = "max_map_count",
2613 .data = &sysctl_max_map_count,
2614 .maxlen = sizeof(sysctl_max_map_count),
2616 .proc_handler = proc_dointvec_minmax,
2617 .extra1 = SYSCTL_ZERO,
2621 .procname = "nr_trim_pages",
2622 .data = &sysctl_nr_trim_pages,
2623 .maxlen = sizeof(sysctl_nr_trim_pages),
2625 .proc_handler = proc_dointvec_minmax,
2626 .extra1 = SYSCTL_ZERO,
2630 .procname = "laptop_mode",
2631 .data = &laptop_mode,
2632 .maxlen = sizeof(laptop_mode),
2634 .proc_handler = proc_dointvec_jiffies,
2637 .procname = "vfs_cache_pressure",
2638 .data = &sysctl_vfs_cache_pressure,
2639 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2641 .proc_handler = proc_dointvec_minmax,
2642 .extra1 = SYSCTL_ZERO,
2644 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2645 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2647 .procname = "legacy_va_layout",
2648 .data = &sysctl_legacy_va_layout,
2649 .maxlen = sizeof(sysctl_legacy_va_layout),
2651 .proc_handler = proc_dointvec_minmax,
2652 .extra1 = SYSCTL_ZERO,
2657 .procname = "zone_reclaim_mode",
2658 .data = &node_reclaim_mode,
2659 .maxlen = sizeof(node_reclaim_mode),
2661 .proc_handler = proc_dointvec_minmax,
2662 .extra1 = SYSCTL_ZERO,
2665 .procname = "min_unmapped_ratio",
2666 .data = &sysctl_min_unmapped_ratio,
2667 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2669 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2670 .extra1 = SYSCTL_ZERO,
2671 .extra2 = SYSCTL_ONE_HUNDRED,
2674 .procname = "min_slab_ratio",
2675 .data = &sysctl_min_slab_ratio,
2676 .maxlen = sizeof(sysctl_min_slab_ratio),
2678 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2679 .extra1 = SYSCTL_ZERO,
2680 .extra2 = SYSCTL_ONE_HUNDRED,
2685 .procname = "stat_interval",
2686 .data = &sysctl_stat_interval,
2687 .maxlen = sizeof(sysctl_stat_interval),
2689 .proc_handler = proc_dointvec_jiffies,
2692 .procname = "stat_refresh",
2696 .proc_handler = vmstat_refresh,
2701 .procname = "mmap_min_addr",
2702 .data = &dac_mmap_min_addr,
2703 .maxlen = sizeof(unsigned long),
2705 .proc_handler = mmap_min_addr_handler,
2710 .procname = "numa_zonelist_order",
2711 .data = &numa_zonelist_order,
2712 .maxlen = NUMA_ZONELIST_ORDER_LEN,
2714 .proc_handler = numa_zonelist_order_handler,
2717 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
2718 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
2720 .procname = "vdso_enabled",
2721 #ifdef CONFIG_X86_32
2722 .data = &vdso32_enabled,
2723 .maxlen = sizeof(vdso32_enabled),
2725 .data = &vdso_enabled,
2726 .maxlen = sizeof(vdso_enabled),
2729 .proc_handler = proc_dointvec,
2730 .extra1 = SYSCTL_ZERO,
2733 #ifdef CONFIG_HIGHMEM
2735 .procname = "highmem_is_dirtyable",
2736 .data = &vm_highmem_is_dirtyable,
2737 .maxlen = sizeof(vm_highmem_is_dirtyable),
2739 .proc_handler = proc_dointvec_minmax,
2740 .extra1 = SYSCTL_ZERO,
2741 .extra2 = SYSCTL_ONE,
2744 #ifdef CONFIG_MEMORY_FAILURE
2746 .procname = "memory_failure_early_kill",
2747 .data = &sysctl_memory_failure_early_kill,
2748 .maxlen = sizeof(sysctl_memory_failure_early_kill),
2750 .proc_handler = proc_dointvec_minmax,
2751 .extra1 = SYSCTL_ZERO,
2752 .extra2 = SYSCTL_ONE,
2755 .procname = "memory_failure_recovery",
2756 .data = &sysctl_memory_failure_recovery,
2757 .maxlen = sizeof(sysctl_memory_failure_recovery),
2759 .proc_handler = proc_dointvec_minmax,
2760 .extra1 = SYSCTL_ZERO,
2761 .extra2 = SYSCTL_ONE,
2765 .procname = "user_reserve_kbytes",
2766 .data = &sysctl_user_reserve_kbytes,
2767 .maxlen = sizeof(sysctl_user_reserve_kbytes),
2769 .proc_handler = proc_doulongvec_minmax,
2772 .procname = "admin_reserve_kbytes",
2773 .data = &sysctl_admin_reserve_kbytes,
2774 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
2776 .proc_handler = proc_doulongvec_minmax,
2778 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
2780 .procname = "mmap_rnd_bits",
2781 .data = &mmap_rnd_bits,
2782 .maxlen = sizeof(mmap_rnd_bits),
2784 .proc_handler = proc_dointvec_minmax,
2785 .extra1 = (void *)&mmap_rnd_bits_min,
2786 .extra2 = (void *)&mmap_rnd_bits_max,
2789 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
2791 .procname = "mmap_rnd_compat_bits",
2792 .data = &mmap_rnd_compat_bits,
2793 .maxlen = sizeof(mmap_rnd_compat_bits),
2795 .proc_handler = proc_dointvec_minmax,
2796 .extra1 = (void *)&mmap_rnd_compat_bits_min,
2797 .extra2 = (void *)&mmap_rnd_compat_bits_max,
2800 #ifdef CONFIG_USERFAULTFD
2802 .procname = "unprivileged_userfaultfd",
2803 .data = &sysctl_unprivileged_userfaultfd,
2804 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
2806 .proc_handler = proc_dointvec_minmax,
2807 .extra1 = SYSCTL_ZERO,
2808 .extra2 = SYSCTL_ONE,
2814 static struct ctl_table debug_table[] = {
2815 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
2817 .procname = "exception-trace",
2818 .data = &show_unhandled_signals,
2819 .maxlen = sizeof(int),
2821 .proc_handler = proc_dointvec
2824 #if defined(CONFIG_OPTPROBES)
2826 .procname = "kprobes-optimization",
2827 .data = &sysctl_kprobes_optimization,
2828 .maxlen = sizeof(int),
2830 .proc_handler = proc_kprobes_optimization_handler,
2831 .extra1 = SYSCTL_ZERO,
2832 .extra2 = SYSCTL_ONE,
2838 static struct ctl_table dev_table[] = {
2842 DECLARE_SYSCTL_BASE(kernel, kern_table);
2843 DECLARE_SYSCTL_BASE(vm, vm_table);
2844 DECLARE_SYSCTL_BASE(debug, debug_table);
2845 DECLARE_SYSCTL_BASE(dev, dev_table);
2847 int __init sysctl_init(void)
2849 register_sysctl_base(kernel);
2850 register_sysctl_base(vm);
2851 register_sysctl_base(debug);
2852 register_sysctl_base(dev);
2856 #endif /* CONFIG_SYSCTL */
2858 * No sense putting this after each symbol definition, twice,
2859 * exception granted :-)
2861 EXPORT_SYMBOL(proc_dobool);
2862 EXPORT_SYMBOL(proc_dointvec);
2863 EXPORT_SYMBOL(proc_douintvec);
2864 EXPORT_SYMBOL(proc_dointvec_jiffies);
2865 EXPORT_SYMBOL(proc_dointvec_minmax);
2866 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
2867 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2868 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2869 EXPORT_SYMBOL(proc_dostring);
2870 EXPORT_SYMBOL(proc_doulongvec_minmax);
2871 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2872 EXPORT_SYMBOL(proc_do_large_bitmap);