Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sysctl.c: General linux system control interface |
| 3 | * |
| 4 | * Begun 24 March 1995, Stephen Tweedie |
| 5 | * Added /proc support, Dec 1995 |
| 6 | * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. |
| 7 | * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. |
| 8 | * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. |
| 9 | * Dynamic registration fixes, Stephen Tweedie. |
| 10 | * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. |
| 11 | * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris |
| 12 | * Horn. |
| 13 | * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. |
| 14 | * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. |
| 15 | * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill |
| 16 | * Wendling. |
| 17 | * The list_for_each() macro wasn't appropriate for the sysctl loop. |
| 18 | * Removed it and replaced it with older style, 03/23/00, Bill Wendling |
| 19 | */ |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
Christoph Hellwig | e2e40f2 | 2015-02-22 08:58:50 -0800 | [diff] [blame] | 22 | #include <linux/aio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/mm.h> |
| 24 | #include <linux/swap.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/sysctl.h> |
Akinobu Mita | 5a04cca | 2012-03-28 14:42:50 -0700 | [diff] [blame] | 27 | #include <linux/bitmap.h> |
Dave Young | d33ed52 | 2010-03-10 15:23:59 -0800 | [diff] [blame] | 28 | #include <linux/signal.h> |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 29 | #include <linux/printk.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/proc_fs.h> |
Andrew Morgan | 72c2d58 | 2007-10-18 03:05:59 -0700 | [diff] [blame] | 31 | #include <linux/security.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/ctype.h> |
Steven Rostedt | fd4b616 | 2012-07-30 14:42:48 -0700 | [diff] [blame] | 33 | #include <linux/kmemleak.h> |
Adrian Bunk | 62239ac | 2007-07-17 04:03:45 -0700 | [diff] [blame] | 34 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/init.h> |
| 36 | #include <linux/kernel.h> |
Kay Sievers | 0296b22 | 2005-11-11 05:33:52 +0100 | [diff] [blame] | 37 | #include <linux/kobject.h> |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 38 | #include <linux/net.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <linux/sysrq.h> |
| 40 | #include <linux/highuid.h> |
| 41 | #include <linux/writeback.h> |
Ingo Molnar | 3fff4c4 | 2009-09-22 16:18:09 +0200 | [diff] [blame] | 42 | #include <linux/ratelimit.h> |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 43 | #include <linux/compaction.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <linux/hugetlb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <linux/initrd.h> |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 46 | #include <linux/key.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/times.h> |
| 48 | #include <linux/limits.h> |
| 49 | #include <linux/dcache.h> |
Alexey Dobriyan | 6e00670 | 2010-01-20 22:27:56 +0200 | [diff] [blame] | 50 | #include <linux/dnotify.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <linux/syscalls.h> |
Adrian Bunk | c748e13 | 2008-07-23 21:27:03 -0700 | [diff] [blame] | 52 | #include <linux/vmstat.h> |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 53 | #include <linux/nfs_fs.h> |
| 54 | #include <linux/acpi.h> |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 55 | #include <linux/reboot.h> |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 56 | #include <linux/ftrace.h> |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 57 | #include <linux/perf_event.h> |
Masami Hiramatsu | b2be84d | 2010-02-25 08:34:15 -0500 | [diff] [blame] | 58 | #include <linux/kprobes.h> |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 59 | #include <linux/pipe_fs_i.h> |
David Rientjes | 8e4228e | 2010-08-09 17:18:56 -0700 | [diff] [blame] | 60 | #include <linux/oom.h> |
Eric Paris | 17f60a7 | 2011-04-01 17:07:50 -0400 | [diff] [blame] | 61 | #include <linux/kmod.h> |
Dan Ballard | 73efc03 | 2011-10-31 17:11:20 -0700 | [diff] [blame] | 62 | #include <linux/capability.h> |
Al Viro | 4040153 | 2012-02-13 03:58:52 +0000 | [diff] [blame] | 63 | #include <linux/binfmts.h> |
Clark Williams | cf4aebc2 | 2013-02-07 09:46:59 -0600 | [diff] [blame] | 64 | #include <linux/sched/sysctl.h> |
Ingo Molnar | f7ccbae | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 65 | #include <linux/sched/coredump.h> |
Kees Cook | 7984754 | 2014-01-23 15:55:59 -0800 | [diff] [blame] | 66 | #include <linux/kexec.h> |
Alexei Starovoitov | 1be7f75 | 2015-10-07 22:23:21 -0700 | [diff] [blame] | 67 | #include <linux/bpf.h> |
Eric W. Biederman | d292168 | 2016-09-28 00:27:17 -0500 | [diff] [blame] | 68 | #include <linux/mount.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Christian Brauner | 7f2923c | 2019-03-07 16:29:40 -0800 | [diff] [blame] | 70 | #include "../lib/kstrtox.h" |
| 71 | |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 72 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #include <asm/processor.h> |
| 74 | |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 75 | #ifdef CONFIG_X86 |
| 76 | #include <asm/nmi.h> |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 77 | #include <asm/stacktrace.h> |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 78 | #include <asm/io.h> |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 79 | #endif |
David Howells | d550bbd | 2012-03-28 18:30:03 +0100 | [diff] [blame] | 80 | #ifdef CONFIG_SPARC |
| 81 | #include <asm/setup.h> |
| 82 | #endif |
Dave Young | c55b7c3 | 2010-03-10 15:24:08 -0800 | [diff] [blame] | 83 | #ifdef CONFIG_BSD_PROCESS_ACCT |
| 84 | #include <linux/acct.h> |
| 85 | #endif |
Dave Young | 4f0e056 | 2010-03-10 15:24:09 -0800 | [diff] [blame] | 86 | #ifdef CONFIG_RT_MUTEXES |
| 87 | #include <linux/rtmutex.h> |
| 88 | #endif |
Dave Young | 2edf5e4 | 2010-03-10 15:24:10 -0800 | [diff] [blame] | 89 | #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) |
| 90 | #include <linux/lockdep.h> |
| 91 | #endif |
Dave Young | 15485a4 | 2010-03-10 15:24:07 -0800 | [diff] [blame] | 92 | #ifdef CONFIG_CHR_DEV_SG |
| 93 | #include <scsi/sg.h> |
| 94 | #endif |
Alexander Popov | 964c9df | 2018-08-17 01:17:03 +0300 | [diff] [blame] | 95 | #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE |
| 96 | #include <linux/stackleak.h> |
| 97 | #endif |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 98 | #ifdef CONFIG_LOCKUP_DETECTOR |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 99 | #include <linux/nmi.h> |
| 100 | #endif |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #if defined(CONFIG_SYSCTL) |
| 103 | |
| 104 | /* External variables not in a header file. */ |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 105 | extern int suid_dumpable; |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 106 | #ifdef CONFIG_COREDUMP |
| 107 | extern int core_uses_pid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | extern char core_pattern[]; |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 109 | extern unsigned int core_pipe_limit; |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 110 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | extern int pid_max; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | extern int pid_max_min, pid_max_max; |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 113 | extern int percpu_pagelist_fraction; |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 114 | extern int latencytop_enabled; |
Alexey Dobriyan | 9b80a18 | 2016-09-02 00:38:52 +0300 | [diff] [blame] | 115 | extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max; |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 116 | #ifndef CONFIG_MMU |
| 117 | extern int sysctl_nr_trim_pages; |
| 118 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 120 | /* Constants used for minimum and maximum */ |
Don Zickus | 2508ce1 | 2010-05-07 17:11:46 -0400 | [diff] [blame] | 121 | #ifdef CONFIG_LOCKUP_DETECTOR |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 122 | static int sixty = 60; |
| 123 | #endif |
| 124 | |
Aaron Tomlin | 270750db | 2014-01-20 17:34:13 +0000 | [diff] [blame] | 125 | static int __maybe_unused neg_one = -1; |
| 126 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 127 | static int zero; |
Linus Torvalds | cd5f9a4 | 2009-04-06 13:38:46 -0700 | [diff] [blame] | 128 | static int __maybe_unused one = 1; |
| 129 | static int __maybe_unused two = 2; |
Dave Hansen | 5509a5d | 2014-04-03 14:48:19 -0700 | [diff] [blame] | 130 | static int __maybe_unused four = 4; |
Sven Wegener | fc3501d | 2009-02-11 13:04:23 -0800 | [diff] [blame] | 131 | static unsigned long one_ul = 1; |
Christian Brauner | 32a5ad9 | 2019-03-07 16:29:43 -0800 | [diff] [blame^] | 132 | static unsigned long long_max = LONG_MAX; |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 133 | static int one_hundred = 100; |
Johannes Weiner | 795ae7a | 2016-03-17 14:19:14 -0700 | [diff] [blame] | 134 | static int one_thousand = 1000; |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 135 | #ifdef CONFIG_PRINTK |
| 136 | static int ten_thousand = 10000; |
| 137 | #endif |
Arnaldo Carvalho de Melo | c5dfd78 | 2016-04-21 12:28:50 -0300 | [diff] [blame] | 138 | #ifdef CONFIG_PERF_EVENTS |
| 139 | static int six_hundred_forty_kb = 640 * 1024; |
| 140 | #endif |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 141 | |
Andrea Righi | 9e4a5bd | 2009-04-30 15:08:57 -0700 | [diff] [blame] | 142 | /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ |
| 143 | static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ |
| 146 | static int maxolduid = 65535; |
| 147 | static int minolduid; |
| 148 | |
| 149 | static int ngroups_max = NGROUPS_MAX; |
Dan Ballard | 73efc03 | 2011-10-31 17:11:20 -0700 | [diff] [blame] | 150 | static const int cap_last_cap = CAP_LAST_CAP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
Dmitry Vyukov | a2e5144 | 2018-08-21 21:55:52 -0700 | [diff] [blame] | 152 | /* |
| 153 | * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs |
| 154 | * and hung_task_check_interval_secs |
| 155 | */ |
Liu Hua | 80df284 | 2014-04-07 15:38:57 -0700 | [diff] [blame] | 156 | #ifdef CONFIG_DETECT_HUNG_TASK |
| 157 | static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); |
| 158 | #endif |
| 159 | |
Dave Young | d14f172 | 2010-02-25 20:28:57 -0500 | [diff] [blame] | 160 | #ifdef CONFIG_INOTIFY_USER |
| 161 | #include <linux/inotify.h> |
| 162 | #endif |
David S. Miller | 72c57ed | 2008-09-11 23:29:54 -0700 | [diff] [blame] | 163 | #ifdef CONFIG_SPARC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | #endif |
| 165 | |
| 166 | #ifdef __hppa__ |
| 167 | extern int pwrsw_enabled; |
Vineet Gupta | bf14e3b | 2013-01-18 15:12:24 +0530 | [diff] [blame] | 168 | #endif |
| 169 | |
| 170 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | extern int unaligned_enabled; |
| 172 | #endif |
| 173 | |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 174 | #ifdef CONFIG_IA64 |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 175 | extern int unaligned_dump_stack; |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 176 | #endif |
| 177 | |
Vineet Gupta | b6fca72 | 2013-01-09 20:06:28 +0530 | [diff] [blame] | 178 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN |
| 179 | extern int no_unaligned_warning; |
| 180 | #endif |
| 181 | |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 182 | #ifdef CONFIG_PROC_SYSCTL |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 183 | |
Luis R. Rodriguez | a19ac33 | 2017-07-12 14:33:30 -0700 | [diff] [blame] | 184 | /** |
| 185 | * enum sysctl_writes_mode - supported sysctl write modes |
| 186 | * |
| 187 | * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value |
| 188 | * to be written, and multiple writes on the same sysctl file descriptor |
| 189 | * will rewrite the sysctl value, regardless of file position. No warning |
| 190 | * is issued when the initial position is not 0. |
| 191 | * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is |
| 192 | * not 0. |
| 193 | * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at |
| 194 | * file position 0 and the value must be fully contained in the buffer |
| 195 | * sent to the write syscall. If dealing with strings respect the file |
| 196 | * position, but restrict this to the max length of the buffer, anything |
| 197 | * passed the max lenght will be ignored. Multiple writes will append |
| 198 | * to the buffer. |
| 199 | * |
| 200 | * These write modes control how current file position affects the behavior of |
| 201 | * updating sysctl values through the proc interface on each write. |
| 202 | */ |
| 203 | enum sysctl_writes_mode { |
| 204 | SYSCTL_WRITES_LEGACY = -1, |
| 205 | SYSCTL_WRITES_WARN = 0, |
| 206 | SYSCTL_WRITES_STRICT = 1, |
| 207 | }; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 208 | |
Luis R. Rodriguez | a19ac33 | 2017-07-12 14:33:30 -0700 | [diff] [blame] | 209 | static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 210 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 211 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 212 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 213 | static int proc_taint(struct ctl_table *table, int write, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 214 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 215 | #endif |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 216 | |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 217 | #ifdef CONFIG_PRINTK |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 218 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 219 | void __user *buffer, size_t *lenp, loff_t *ppos); |
| 220 | #endif |
| 221 | |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 222 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, |
| 223 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 224 | #ifdef CONFIG_COREDUMP |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 225 | static int proc_dostring_coredump(struct ctl_table *table, int write, |
| 226 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 227 | #endif |
Eric Biggers | 319e0a2 | 2018-02-06 15:41:49 -0800 | [diff] [blame] | 228 | static int proc_dopipe_max_size(struct ctl_table *table, int write, |
| 229 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alexei Starovoitov | 3fcc553 | 2019-02-27 18:30:44 -0800 | [diff] [blame] | 230 | #ifdef CONFIG_BPF_SYSCALL |
Alexei Starovoitov | 492ecee | 2019-02-25 14:28:39 -0800 | [diff] [blame] | 231 | static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write, |
| 232 | void __user *buffer, size_t *lenp, |
| 233 | loff_t *ppos); |
Alexei Starovoitov | 3fcc553 | 2019-02-27 18:30:44 -0800 | [diff] [blame] | 234 | #endif |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 235 | |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 236 | #ifdef CONFIG_MAGIC_SYSRQ |
Randy Dunlap | 5f733e8 | 2018-08-21 22:01:06 -0700 | [diff] [blame] | 237 | /* Note: sysrq code uses its own private copy */ |
Ben Hutchings | 8eaede4 | 2013-10-07 01:05:46 +0100 | [diff] [blame] | 238 | static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 239 | |
Joe Perches | 6f8fd1d | 2014-06-06 14:38:08 -0700 | [diff] [blame] | 240 | static int sysrq_sysctl_handler(struct ctl_table *table, int write, |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 241 | void __user *buffer, size_t *lenp, |
| 242 | loff_t *ppos) |
| 243 | { |
| 244 | int error; |
| 245 | |
| 246 | error = proc_dointvec(table, write, buffer, lenp, ppos); |
| 247 | if (error) |
| 248 | return error; |
| 249 | |
| 250 | if (write) |
| 251 | sysrq_toggle_support(__sysrq_enabled); |
| 252 | |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | #endif |
| 257 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 258 | static struct ctl_table kern_table[]; |
| 259 | static struct ctl_table vm_table[]; |
| 260 | static struct ctl_table fs_table[]; |
| 261 | static struct ctl_table debug_table[]; |
| 262 | static struct ctl_table dev_table[]; |
| 263 | extern struct ctl_table random_table[]; |
Davide Libenzi | 7ef9964 | 2008-12-01 13:13:55 -0800 | [diff] [blame] | 264 | #ifdef CONFIG_EPOLL |
| 265 | extern struct ctl_table epoll_table[]; |
| 266 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
Luis R. Rodriguez | ceb1813 | 2018-03-10 06:14:51 -0800 | [diff] [blame] | 268 | #ifdef CONFIG_FW_LOADER_USER_HELPER |
| 269 | extern struct ctl_table firmware_config_table[]; |
| 270 | #endif |
| 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
| 273 | int sysctl_legacy_va_layout; |
| 274 | #endif |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* The default sysctl tables: */ |
| 277 | |
Eric W. Biederman | de4e83bd | 2012-01-06 03:34:20 -0800 | [diff] [blame] | 278 | static struct ctl_table sysctl_base_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | .procname = "kernel", |
| 281 | .mode = 0555, |
| 282 | .child = kern_table, |
| 283 | }, |
| 284 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | .procname = "vm", |
| 286 | .mode = 0555, |
| 287 | .child = vm_table, |
| 288 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | .procname = "fs", |
| 291 | .mode = 0555, |
| 292 | .child = fs_table, |
| 293 | }, |
| 294 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | .procname = "debug", |
| 296 | .mode = 0555, |
| 297 | .child = debug_table, |
| 298 | }, |
| 299 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | .procname = "dev", |
| 301 | .mode = 0555, |
| 302 | .child = dev_table, |
| 303 | }, |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 304 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | }; |
| 306 | |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 307 | #ifdef CONFIG_SCHED_DEBUG |
Eric Dumazet | 73c4efd | 2007-12-18 15:21:13 +0100 | [diff] [blame] | 308 | static int min_sched_granularity_ns = 100000; /* 100 usecs */ |
| 309 | static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
| 310 | static int min_wakeup_granularity_ns; /* 0 usecs */ |
| 311 | static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 312 | #ifdef CONFIG_SMP |
Christian Ehrhardt | 1983a92 | 2009-11-30 12:16:47 +0100 | [diff] [blame] | 313 | static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; |
| 314 | static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 315 | #endif /* CONFIG_SMP */ |
| 316 | #endif /* CONFIG_SCHED_DEBUG */ |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 317 | |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 318 | #ifdef CONFIG_COMPACTION |
| 319 | static int min_extfrag_threshold; |
| 320 | static int max_extfrag_threshold = 1000; |
| 321 | #endif |
| 322 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 323 | static struct ctl_table kern_table[] = { |
Mike Galbraith | 2bba22c | 2009-09-09 15:41:37 +0200 | [diff] [blame] | 324 | { |
Mike Galbraith | 2bba22c | 2009-09-09 15:41:37 +0200 | [diff] [blame] | 325 | .procname = "sched_child_runs_first", |
| 326 | .data = &sysctl_sched_child_runs_first, |
| 327 | .maxlen = sizeof(unsigned int), |
| 328 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 329 | .proc_handler = proc_dointvec, |
Mike Galbraith | 2bba22c | 2009-09-09 15:41:37 +0200 | [diff] [blame] | 330 | }, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 331 | #ifdef CONFIG_SCHED_DEBUG |
| 332 | { |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 333 | .procname = "sched_min_granularity_ns", |
| 334 | .data = &sysctl_sched_min_granularity, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 335 | .maxlen = sizeof(unsigned int), |
| 336 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 337 | .proc_handler = sched_proc_update_handler, |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 338 | .extra1 = &min_sched_granularity_ns, |
| 339 | .extra2 = &max_sched_granularity_ns, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 340 | }, |
| 341 | { |
Peter Zijlstra | 2180508 | 2007-08-25 18:41:53 +0200 | [diff] [blame] | 342 | .procname = "sched_latency_ns", |
| 343 | .data = &sysctl_sched_latency, |
| 344 | .maxlen = sizeof(unsigned int), |
| 345 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 346 | .proc_handler = sched_proc_update_handler, |
Peter Zijlstra | 2180508 | 2007-08-25 18:41:53 +0200 | [diff] [blame] | 347 | .extra1 = &min_sched_granularity_ns, |
| 348 | .extra2 = &max_sched_granularity_ns, |
| 349 | }, |
| 350 | { |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 351 | .procname = "sched_wakeup_granularity_ns", |
| 352 | .data = &sysctl_sched_wakeup_granularity, |
| 353 | .maxlen = sizeof(unsigned int), |
| 354 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 355 | .proc_handler = sched_proc_update_handler, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 356 | .extra1 = &min_wakeup_granularity_ns, |
| 357 | .extra2 = &max_wakeup_granularity_ns, |
| 358 | }, |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 359 | #ifdef CONFIG_SMP |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 360 | { |
Christian Ehrhardt | 1983a92 | 2009-11-30 12:16:47 +0100 | [diff] [blame] | 361 | .procname = "sched_tunable_scaling", |
| 362 | .data = &sysctl_sched_tunable_scaling, |
| 363 | .maxlen = sizeof(enum sched_tunable_scaling), |
| 364 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 365 | .proc_handler = sched_proc_update_handler, |
Christian Ehrhardt | 1983a92 | 2009-11-30 12:16:47 +0100 | [diff] [blame] | 366 | .extra1 = &min_sched_tunable_scaling, |
| 367 | .extra2 = &max_sched_tunable_scaling, |
Peter Zijlstra | 2398f2c | 2008-06-27 13:41:35 +0200 | [diff] [blame] | 368 | }, |
| 369 | { |
Namhyung Kim | d00535d | 2012-08-16 11:15:30 +0900 | [diff] [blame] | 370 | .procname = "sched_migration_cost_ns", |
Ingo Molnar | da84d96 | 2007-10-15 17:00:18 +0200 | [diff] [blame] | 371 | .data = &sysctl_sched_migration_cost, |
| 372 | .maxlen = sizeof(unsigned int), |
| 373 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 374 | .proc_handler = proc_dointvec, |
Ingo Molnar | da84d96 | 2007-10-15 17:00:18 +0200 | [diff] [blame] | 375 | }, |
Peter Zijlstra | b82d9fd | 2007-11-09 22:39:39 +0100 | [diff] [blame] | 376 | { |
Peter Zijlstra | b82d9fd | 2007-11-09 22:39:39 +0100 | [diff] [blame] | 377 | .procname = "sched_nr_migrate", |
| 378 | .data = &sysctl_sched_nr_migrate, |
| 379 | .maxlen = sizeof(unsigned int), |
Peter Zijlstra | fa85ae2 | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 380 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 381 | .proc_handler = proc_dointvec, |
Peter Zijlstra | fa85ae2 | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 382 | }, |
Mel Gorman | cb25176 | 2016-02-05 09:08:36 +0000 | [diff] [blame] | 383 | #ifdef CONFIG_SCHEDSTATS |
| 384 | { |
| 385 | .procname = "sched_schedstats", |
| 386 | .data = NULL, |
| 387 | .maxlen = sizeof(unsigned int), |
| 388 | .mode = 0644, |
| 389 | .proc_handler = sysctl_schedstats, |
| 390 | .extra1 = &zero, |
| 391 | .extra2 = &one, |
| 392 | }, |
| 393 | #endif /* CONFIG_SCHEDSTATS */ |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 394 | #endif /* CONFIG_SMP */ |
| 395 | #ifdef CONFIG_NUMA_BALANCING |
| 396 | { |
Peter Zijlstra | 4b96a29 | 2012-10-25 14:16:47 +0200 | [diff] [blame] | 397 | .procname = "numa_balancing_scan_delay_ms", |
| 398 | .data = &sysctl_numa_balancing_scan_delay, |
| 399 | .maxlen = sizeof(unsigned int), |
| 400 | .mode = 0644, |
| 401 | .proc_handler = proc_dointvec, |
| 402 | }, |
| 403 | { |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 404 | .procname = "numa_balancing_scan_period_min_ms", |
| 405 | .data = &sysctl_numa_balancing_scan_period_min, |
| 406 | .maxlen = sizeof(unsigned int), |
| 407 | .mode = 0644, |
| 408 | .proc_handler = proc_dointvec, |
| 409 | }, |
| 410 | { |
| 411 | .procname = "numa_balancing_scan_period_max_ms", |
| 412 | .data = &sysctl_numa_balancing_scan_period_max, |
| 413 | .maxlen = sizeof(unsigned int), |
| 414 | .mode = 0644, |
| 415 | .proc_handler = proc_dointvec, |
| 416 | }, |
Peter Zijlstra | 6e5fb22 | 2012-10-25 14:16:45 +0200 | [diff] [blame] | 417 | { |
| 418 | .procname = "numa_balancing_scan_size_mb", |
| 419 | .data = &sysctl_numa_balancing_scan_size, |
| 420 | .maxlen = sizeof(unsigned int), |
| 421 | .mode = 0644, |
Kirill Tkhai | 6419265 | 2014-10-16 14:39:37 +0400 | [diff] [blame] | 422 | .proc_handler = proc_dointvec_minmax, |
| 423 | .extra1 = &one, |
Peter Zijlstra | 6e5fb22 | 2012-10-25 14:16:45 +0200 | [diff] [blame] | 424 | }, |
Mel Gorman | 3a7053b | 2013-10-07 11:29:00 +0100 | [diff] [blame] | 425 | { |
Andi Kleen | 54a43d5 | 2014-01-23 15:53:13 -0800 | [diff] [blame] | 426 | .procname = "numa_balancing", |
| 427 | .data = NULL, /* filled in by handler */ |
| 428 | .maxlen = sizeof(unsigned int), |
| 429 | .mode = 0644, |
| 430 | .proc_handler = sysctl_numa_balancing, |
| 431 | .extra1 = &zero, |
| 432 | .extra2 = &one, |
| 433 | }, |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 434 | #endif /* CONFIG_NUMA_BALANCING */ |
| 435 | #endif /* CONFIG_SCHED_DEBUG */ |
Ingo Molnar | 1799e35 | 2007-09-19 23:34:46 +0200 | [diff] [blame] | 436 | { |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 437 | .procname = "sched_rt_period_us", |
| 438 | .data = &sysctl_sched_rt_period, |
| 439 | .maxlen = sizeof(unsigned int), |
| 440 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 441 | .proc_handler = sched_rt_handler, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 442 | }, |
| 443 | { |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 444 | .procname = "sched_rt_runtime_us", |
| 445 | .data = &sysctl_sched_rt_runtime, |
| 446 | .maxlen = sizeof(int), |
| 447 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 448 | .proc_handler = sched_rt_handler, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 449 | }, |
Clark Williams | ce0dbbb | 2013-02-07 09:47:04 -0600 | [diff] [blame] | 450 | { |
| 451 | .procname = "sched_rr_timeslice_ms", |
Shile Zhang | 975e155 | 2017-01-28 22:00:49 +0800 | [diff] [blame] | 452 | .data = &sysctl_sched_rr_timeslice, |
Clark Williams | ce0dbbb | 2013-02-07 09:47:04 -0600 | [diff] [blame] | 453 | .maxlen = sizeof(int), |
| 454 | .mode = 0644, |
| 455 | .proc_handler = sched_rr_handler, |
| 456 | }, |
Mike Galbraith | 5091faa | 2010-11-30 14:18:03 +0100 | [diff] [blame] | 457 | #ifdef CONFIG_SCHED_AUTOGROUP |
| 458 | { |
| 459 | .procname = "sched_autogroup_enabled", |
| 460 | .data = &sysctl_sched_autogroup_enabled, |
| 461 | .maxlen = sizeof(unsigned int), |
| 462 | .mode = 0644, |
Yong Zhang | 1747b21 | 2011-02-20 15:08:12 +0800 | [diff] [blame] | 463 | .proc_handler = proc_dointvec_minmax, |
Mike Galbraith | 5091faa | 2010-11-30 14:18:03 +0100 | [diff] [blame] | 464 | .extra1 = &zero, |
| 465 | .extra2 = &one, |
| 466 | }, |
| 467 | #endif |
Paul Turner | ec12cb7 | 2011-07-21 09:43:30 -0700 | [diff] [blame] | 468 | #ifdef CONFIG_CFS_BANDWIDTH |
| 469 | { |
| 470 | .procname = "sched_cfs_bandwidth_slice_us", |
| 471 | .data = &sysctl_sched_cfs_bandwidth_slice, |
| 472 | .maxlen = sizeof(unsigned int), |
| 473 | .mode = 0644, |
| 474 | .proc_handler = proc_dointvec_minmax, |
| 475 | .extra1 = &one, |
| 476 | }, |
| 477 | #endif |
Quentin Perret | 8d5d0cf | 2018-12-03 09:56:23 +0000 | [diff] [blame] | 478 | #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) |
| 479 | { |
| 480 | .procname = "sched_energy_aware", |
| 481 | .data = &sysctl_sched_energy_aware, |
| 482 | .maxlen = sizeof(unsigned int), |
| 483 | .mode = 0644, |
| 484 | .proc_handler = sched_energy_aware_handler, |
| 485 | .extra1 = &zero, |
| 486 | .extra2 = &one, |
| 487 | }, |
| 488 | #endif |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 489 | #ifdef CONFIG_PROVE_LOCKING |
| 490 | { |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 491 | .procname = "prove_locking", |
| 492 | .data = &prove_locking, |
| 493 | .maxlen = sizeof(int), |
| 494 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 495 | .proc_handler = proc_dointvec, |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 496 | }, |
| 497 | #endif |
| 498 | #ifdef CONFIG_LOCK_STAT |
| 499 | { |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 500 | .procname = "lock_stat", |
| 501 | .data = &lock_stat, |
| 502 | .maxlen = sizeof(int), |
| 503 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 504 | .proc_handler = proc_dointvec, |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 505 | }, |
| 506 | #endif |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 507 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | .procname = "panic", |
| 509 | .data = &panic_timeout, |
| 510 | .maxlen = sizeof(int), |
| 511 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 512 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | }, |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 514 | #ifdef CONFIG_COREDUMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | .procname = "core_uses_pid", |
| 517 | .data = &core_uses_pid, |
| 518 | .maxlen = sizeof(int), |
| 519 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 520 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | }, |
| 522 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | .procname = "core_pattern", |
| 524 | .data = core_pattern, |
Dan Aloni | 71ce92f | 2007-05-16 22:11:16 -0700 | [diff] [blame] | 525 | .maxlen = CORENAME_MAX_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | .mode = 0644, |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 527 | .proc_handler = proc_dostring_coredump, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | }, |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 529 | { |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 530 | .procname = "core_pipe_limit", |
| 531 | .data = &core_pipe_limit, |
| 532 | .maxlen = sizeof(unsigned int), |
| 533 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 534 | .proc_handler = proc_dointvec, |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 535 | }, |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 536 | #endif |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 537 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | .procname = "tainted", |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 540 | .maxlen = sizeof(long), |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 541 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 542 | .proc_handler = proc_taint, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | }, |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 544 | { |
| 545 | .procname = "sysctl_writes_strict", |
| 546 | .data = &sysctl_writes_strict, |
| 547 | .maxlen = sizeof(int), |
| 548 | .mode = 0644, |
| 549 | .proc_handler = proc_dointvec_minmax, |
| 550 | .extra1 = &neg_one, |
| 551 | .extra2 = &one, |
| 552 | }, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 553 | #endif |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 554 | #ifdef CONFIG_LATENCYTOP |
| 555 | { |
| 556 | .procname = "latencytop", |
| 557 | .data = &latencytop_enabled, |
| 558 | .maxlen = sizeof(int), |
| 559 | .mode = 0644, |
Mel Gorman | cb25176 | 2016-02-05 09:08:36 +0000 | [diff] [blame] | 560 | .proc_handler = sysctl_latencytop, |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 561 | }, |
| 562 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | #ifdef CONFIG_BLK_DEV_INITRD |
| 564 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | .procname = "real-root-dev", |
| 566 | .data = &real_root_dev, |
| 567 | .maxlen = sizeof(int), |
| 568 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 569 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | }, |
| 571 | #endif |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 572 | { |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 573 | .procname = "print-fatal-signals", |
| 574 | .data = &print_fatal_signals, |
| 575 | .maxlen = sizeof(int), |
| 576 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 577 | .proc_handler = proc_dointvec, |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 578 | }, |
David S. Miller | 72c57ed | 2008-09-11 23:29:54 -0700 | [diff] [blame] | 579 | #ifdef CONFIG_SPARC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | .procname = "reboot-cmd", |
| 582 | .data = reboot_command, |
| 583 | .maxlen = 256, |
| 584 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 585 | .proc_handler = proc_dostring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | }, |
| 587 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | .procname = "stop-a", |
| 589 | .data = &stop_a_enabled, |
| 590 | .maxlen = sizeof (int), |
| 591 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 592 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | }, |
| 594 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | .procname = "scons-poweroff", |
| 596 | .data = &scons_pwroff, |
| 597 | .maxlen = sizeof (int), |
| 598 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 599 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | }, |
| 601 | #endif |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 602 | #ifdef CONFIG_SPARC64 |
| 603 | { |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 604 | .procname = "tsb-ratio", |
| 605 | .data = &sysctl_tsb_ratio, |
| 606 | .maxlen = sizeof (int), |
| 607 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 608 | .proc_handler = proc_dointvec, |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 609 | }, |
| 610 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | #ifdef __hppa__ |
| 612 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | .procname = "soft-power", |
| 614 | .data = &pwrsw_enabled, |
| 615 | .maxlen = sizeof (int), |
| 616 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 617 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | }, |
Vineet Gupta | bf14e3b | 2013-01-18 15:12:24 +0530 | [diff] [blame] | 619 | #endif |
| 620 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | .procname = "unaligned-trap", |
| 623 | .data = &unaligned_enabled, |
| 624 | .maxlen = sizeof (int), |
| 625 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 626 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | }, |
| 628 | #endif |
| 629 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | .procname = "ctrl-alt-del", |
| 631 | .data = &C_A_D, |
| 632 | .maxlen = sizeof(int), |
| 633 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 634 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | }, |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 636 | #ifdef CONFIG_FUNCTION_TRACER |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 637 | { |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 638 | .procname = "ftrace_enabled", |
| 639 | .data = &ftrace_enabled, |
| 640 | .maxlen = sizeof(int), |
| 641 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 642 | .proc_handler = ftrace_enable_sysctl, |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 643 | }, |
| 644 | #endif |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 645 | #ifdef CONFIG_STACK_TRACER |
| 646 | { |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 647 | .procname = "stack_tracer_enabled", |
| 648 | .data = &stack_tracer_enabled, |
| 649 | .maxlen = sizeof(int), |
| 650 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 651 | .proc_handler = stack_trace_sysctl, |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 652 | }, |
| 653 | #endif |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 654 | #ifdef CONFIG_TRACING |
| 655 | { |
Peter Zijlstra | 3299b4d | 2008-11-04 11:58:21 +0100 | [diff] [blame] | 656 | .procname = "ftrace_dump_on_oops", |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 657 | .data = &ftrace_dump_on_oops, |
| 658 | .maxlen = sizeof(int), |
| 659 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 660 | .proc_handler = proc_dointvec, |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 661 | }, |
Steven Rostedt (Red Hat) | de7edd3 | 2013-06-14 16:21:43 -0400 | [diff] [blame] | 662 | { |
| 663 | .procname = "traceoff_on_warning", |
| 664 | .data = &__disable_trace_on_warning, |
| 665 | .maxlen = sizeof(__disable_trace_on_warning), |
| 666 | .mode = 0644, |
| 667 | .proc_handler = proc_dointvec, |
| 668 | }, |
Steven Rostedt (Red Hat) | 0daa2302 | 2014-12-12 22:27:10 -0500 | [diff] [blame] | 669 | { |
| 670 | .procname = "tracepoint_printk", |
| 671 | .data = &tracepoint_printk, |
| 672 | .maxlen = sizeof(tracepoint_printk), |
| 673 | .mode = 0644, |
Steven Rostedt (Red Hat) | 42391745 | 2016-11-23 15:52:45 -0500 | [diff] [blame] | 674 | .proc_handler = tracepoint_printk_sysctl, |
Steven Rostedt (Red Hat) | 0daa2302 | 2014-12-12 22:27:10 -0500 | [diff] [blame] | 675 | }, |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 676 | #endif |
Dave Young | 2965faa | 2015-09-09 15:38:55 -0700 | [diff] [blame] | 677 | #ifdef CONFIG_KEXEC_CORE |
Kees Cook | 7984754 | 2014-01-23 15:55:59 -0800 | [diff] [blame] | 678 | { |
| 679 | .procname = "kexec_load_disabled", |
| 680 | .data = &kexec_load_disabled, |
| 681 | .maxlen = sizeof(int), |
| 682 | .mode = 0644, |
| 683 | /* only handle a transition from default "0" to "1" */ |
| 684 | .proc_handler = proc_dointvec_minmax, |
| 685 | .extra1 = &one, |
| 686 | .extra2 = &one, |
| 687 | }, |
| 688 | #endif |
Johannes Berg | a1ef5ad | 2008-07-08 19:00:17 +0200 | [diff] [blame] | 689 | #ifdef CONFIG_MODULES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | .procname = "modprobe", |
| 692 | .data = &modprobe_path, |
| 693 | .maxlen = KMOD_PATH_LEN, |
| 694 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 695 | .proc_handler = proc_dostring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | }, |
Kees Cook | 3d43321 | 2009-04-02 15:49:29 -0700 | [diff] [blame] | 697 | { |
Kees Cook | 3d43321 | 2009-04-02 15:49:29 -0700 | [diff] [blame] | 698 | .procname = "modules_disabled", |
| 699 | .data = &modules_disabled, |
| 700 | .maxlen = sizeof(int), |
| 701 | .mode = 0644, |
| 702 | /* only handle a transition from default "0" to "1" */ |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 703 | .proc_handler = proc_dointvec_minmax, |
Kees Cook | 3d43321 | 2009-04-02 15:49:29 -0700 | [diff] [blame] | 704 | .extra1 = &one, |
| 705 | .extra2 = &one, |
| 706 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | #endif |
Michael Marineau | 86d5613 | 2014-04-10 14:09:31 -0700 | [diff] [blame] | 708 | #ifdef CONFIG_UEVENT_HELPER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | .procname = "hotplug", |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 711 | .data = &uevent_helper, |
| 712 | .maxlen = UEVENT_HELPER_PATH_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 714 | .proc_handler = proc_dostring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | }, |
Michael Marineau | 86d5613 | 2014-04-10 14:09:31 -0700 | [diff] [blame] | 716 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | #ifdef CONFIG_CHR_DEV_SG |
| 718 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | .procname = "sg-big-buff", |
| 720 | .data = &sg_big_buff, |
| 721 | .maxlen = sizeof (int), |
| 722 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 723 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | }, |
| 725 | #endif |
| 726 | #ifdef CONFIG_BSD_PROCESS_ACCT |
| 727 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | .procname = "acct", |
| 729 | .data = &acct_parm, |
| 730 | .maxlen = 3*sizeof(int), |
| 731 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 732 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | }, |
| 734 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | #ifdef CONFIG_MAGIC_SYSRQ |
| 736 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | .procname = "sysrq", |
Ingo Molnar | 5d6f647 | 2006-12-13 00:34:36 -0800 | [diff] [blame] | 738 | .data = &__sysrq_enabled, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | .maxlen = sizeof (int), |
| 740 | .mode = 0644, |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 741 | .proc_handler = sysrq_sysctl_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | }, |
| 743 | #endif |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 744 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | .procname = "cad_pid", |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 747 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | .maxlen = sizeof (int), |
| 749 | .mode = 0600, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 750 | .proc_handler = proc_do_cad_pid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | }, |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 752 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | .procname = "threads-max", |
Heinrich Schuchardt | 16db3d3 | 2015-04-16 12:47:50 -0700 | [diff] [blame] | 755 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | .maxlen = sizeof(int), |
| 757 | .mode = 0644, |
Heinrich Schuchardt | 16db3d3 | 2015-04-16 12:47:50 -0700 | [diff] [blame] | 758 | .proc_handler = sysctl_max_threads, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | }, |
| 760 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | .procname = "random", |
| 762 | .mode = 0555, |
| 763 | .child = random_table, |
| 764 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | { |
Eric Paris | 17f60a7 | 2011-04-01 17:07:50 -0400 | [diff] [blame] | 766 | .procname = "usermodehelper", |
| 767 | .mode = 0555, |
| 768 | .child = usermodehelper_table, |
| 769 | }, |
Luis R. Rodriguez | ceb1813 | 2018-03-10 06:14:51 -0800 | [diff] [blame] | 770 | #ifdef CONFIG_FW_LOADER_USER_HELPER |
| 771 | { |
| 772 | .procname = "firmware_config", |
| 773 | .mode = 0555, |
| 774 | .child = firmware_config_table, |
| 775 | }, |
| 776 | #endif |
Eric Paris | 17f60a7 | 2011-04-01 17:07:50 -0400 | [diff] [blame] | 777 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | .procname = "overflowuid", |
| 779 | .data = &overflowuid, |
| 780 | .maxlen = sizeof(int), |
| 781 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 782 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | .extra1 = &minolduid, |
| 784 | .extra2 = &maxolduid, |
| 785 | }, |
| 786 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | .procname = "overflowgid", |
| 788 | .data = &overflowgid, |
| 789 | .maxlen = sizeof(int), |
| 790 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 791 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | .extra1 = &minolduid, |
| 793 | .extra2 = &maxolduid, |
| 794 | }, |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 795 | #ifdef CONFIG_S390 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | #ifdef CONFIG_MATHEMU |
| 797 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | .procname = "ieee_emulation_warnings", |
| 799 | .data = &sysctl_ieee_emulation_warnings, |
| 800 | .maxlen = sizeof(int), |
| 801 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 802 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | }, |
| 804 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | .procname = "userprocess_debug", |
Heiko Carstens | ab3c68e | 2010-05-17 10:00:21 +0200 | [diff] [blame] | 807 | .data = &show_unhandled_signals, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | .maxlen = sizeof(int), |
| 809 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 810 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | }, |
| 812 | #endif |
| 813 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | .procname = "pid_max", |
| 815 | .data = &pid_max, |
| 816 | .maxlen = sizeof (int), |
| 817 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 818 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | .extra1 = &pid_max_min, |
| 820 | .extra2 = &pid_max_max, |
| 821 | }, |
| 822 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | .procname = "panic_on_oops", |
| 824 | .data = &panic_on_oops, |
| 825 | .maxlen = sizeof(int), |
| 826 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 827 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | }, |
Feng Tang | 81c9d43 | 2019-01-03 15:28:20 -0800 | [diff] [blame] | 829 | { |
| 830 | .procname = "panic_print", |
| 831 | .data = &panic_print, |
| 832 | .maxlen = sizeof(unsigned long), |
| 833 | .mode = 0644, |
| 834 | .proc_handler = proc_doulongvec_minmax, |
| 835 | }, |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 836 | #if defined CONFIG_PRINTK |
| 837 | { |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 838 | .procname = "printk", |
| 839 | .data = &console_loglevel, |
| 840 | .maxlen = 4*sizeof(int), |
| 841 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 842 | .proc_handler = proc_dointvec, |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 843 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | .procname = "printk_ratelimit", |
Dave Young | 717115e | 2008-07-25 01:45:58 -0700 | [diff] [blame] | 846 | .data = &printk_ratelimit_state.interval, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | .maxlen = sizeof(int), |
| 848 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 849 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | }, |
| 851 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | .procname = "printk_ratelimit_burst", |
Dave Young | 717115e | 2008-07-25 01:45:58 -0700 | [diff] [blame] | 853 | .data = &printk_ratelimit_state.burst, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | .maxlen = sizeof(int), |
| 855 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 856 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | }, |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 858 | { |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 859 | .procname = "printk_delay", |
| 860 | .data = &printk_delay_msec, |
| 861 | .maxlen = sizeof(int), |
| 862 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 863 | .proc_handler = proc_dointvec_minmax, |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 864 | .extra1 = &zero, |
| 865 | .extra2 = &ten_thousand, |
| 866 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | { |
Borislav Petkov | 750afe7 | 2016-08-02 14:04:07 -0700 | [diff] [blame] | 868 | .procname = "printk_devkmsg", |
| 869 | .data = devkmsg_log_str, |
| 870 | .maxlen = DEVKMSG_STR_MAX_SIZE, |
| 871 | .mode = 0644, |
| 872 | .proc_handler = devkmsg_sysctl_set_loglvl, |
| 873 | }, |
| 874 | { |
Dan Rosenberg | eaf06b2 | 2010-11-11 14:05:18 -0800 | [diff] [blame] | 875 | .procname = "dmesg_restrict", |
| 876 | .data = &dmesg_restrict, |
| 877 | .maxlen = sizeof(int), |
| 878 | .mode = 0644, |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 879 | .proc_handler = proc_dointvec_minmax_sysadmin, |
Dan Rosenberg | eaf06b2 | 2010-11-11 14:05:18 -0800 | [diff] [blame] | 880 | .extra1 = &zero, |
| 881 | .extra2 = &one, |
| 882 | }, |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 883 | { |
| 884 | .procname = "kptr_restrict", |
| 885 | .data = &kptr_restrict, |
| 886 | .maxlen = sizeof(int), |
| 887 | .mode = 0644, |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 888 | .proc_handler = proc_dointvec_minmax_sysadmin, |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 889 | .extra1 = &zero, |
| 890 | .extra2 = &two, |
| 891 | }, |
Joe Perches | df6e61d | 2010-11-15 21:17:27 -0800 | [diff] [blame] | 892 | #endif |
Dan Rosenberg | eaf06b2 | 2010-11-11 14:05:18 -0800 | [diff] [blame] | 893 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | .procname = "ngroups_max", |
| 895 | .data = &ngroups_max, |
| 896 | .maxlen = sizeof (int), |
| 897 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 898 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | }, |
Dan Ballard | 73efc03 | 2011-10-31 17:11:20 -0700 | [diff] [blame] | 900 | { |
| 901 | .procname = "cap_last_cap", |
| 902 | .data = (void *)&cap_last_cap, |
| 903 | .maxlen = sizeof(int), |
| 904 | .mode = 0444, |
| 905 | .proc_handler = proc_dointvec, |
| 906 | }, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 907 | #if defined(CONFIG_LOCKUP_DETECTOR) |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 908 | { |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 909 | .procname = "watchdog", |
Thomas Gleixner | 7feeb9c | 2017-09-12 21:37:15 +0200 | [diff] [blame] | 910 | .data = &watchdog_user_enabled, |
| 911 | .maxlen = sizeof(int), |
| 912 | .mode = 0644, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 913 | .proc_handler = proc_watchdog, |
Mandeep Singh Baines | 586692a | 2011-05-22 22:10:22 -0700 | [diff] [blame] | 914 | .extra1 = &zero, |
| 915 | .extra2 = &one, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 916 | }, |
| 917 | { |
| 918 | .procname = "watchdog_thresh", |
Mandeep Singh Baines | 586692a | 2011-05-22 22:10:22 -0700 | [diff] [blame] | 919 | .data = &watchdog_thresh, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 920 | .maxlen = sizeof(int), |
| 921 | .mode = 0644, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 922 | .proc_handler = proc_watchdog_thresh, |
Li Zefan | a6572f8 | 2013-05-17 10:31:04 +0800 | [diff] [blame] | 923 | .extra1 = &zero, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 924 | .extra2 = &sixty, |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 925 | }, |
Don Zickus | 2508ce1 | 2010-05-07 17:11:46 -0400 | [diff] [blame] | 926 | { |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 927 | .procname = "nmi_watchdog", |
Thomas Gleixner | 7feeb9c | 2017-09-12 21:37:15 +0200 | [diff] [blame] | 928 | .data = &nmi_watchdog_user_enabled, |
| 929 | .maxlen = sizeof(int), |
Thomas Gleixner | 51d4052 | 2017-09-12 21:37:14 +0200 | [diff] [blame] | 930 | .mode = NMI_WATCHDOG_SYSCTL_PERM, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 931 | .proc_handler = proc_nmi_watchdog, |
| 932 | .extra1 = &zero, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 933 | .extra2 = &one, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 934 | }, |
| 935 | { |
Nicholas Piggin | 05a4a95 | 2017-07-12 14:35:46 -0700 | [diff] [blame] | 936 | .procname = "watchdog_cpumask", |
| 937 | .data = &watchdog_cpumask_bits, |
| 938 | .maxlen = NR_CPUS, |
| 939 | .mode = 0644, |
| 940 | .proc_handler = proc_watchdog_cpumask, |
| 941 | }, |
| 942 | #ifdef CONFIG_SOFTLOCKUP_DETECTOR |
| 943 | { |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 944 | .procname = "soft_watchdog", |
Thomas Gleixner | 7feeb9c | 2017-09-12 21:37:15 +0200 | [diff] [blame] | 945 | .data = &soft_watchdog_user_enabled, |
| 946 | .maxlen = sizeof(int), |
| 947 | .mode = 0644, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 948 | .proc_handler = proc_soft_watchdog, |
| 949 | .extra1 = &zero, |
| 950 | .extra2 = &one, |
| 951 | }, |
| 952 | { |
Don Zickus | 2508ce1 | 2010-05-07 17:11:46 -0400 | [diff] [blame] | 953 | .procname = "softlockup_panic", |
| 954 | .data = &softlockup_panic, |
| 955 | .maxlen = sizeof(int), |
| 956 | .mode = 0644, |
| 957 | .proc_handler = proc_dointvec_minmax, |
| 958 | .extra1 = &zero, |
| 959 | .extra2 = &one, |
| 960 | }, |
Aaron Tomlin | ed23587 | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 961 | #ifdef CONFIG_SMP |
| 962 | { |
| 963 | .procname = "softlockup_all_cpu_backtrace", |
| 964 | .data = &sysctl_softlockup_all_cpu_backtrace, |
| 965 | .maxlen = sizeof(int), |
| 966 | .mode = 0644, |
| 967 | .proc_handler = proc_dointvec_minmax, |
| 968 | .extra1 = &zero, |
| 969 | .extra2 = &one, |
| 970 | }, |
Nicholas Piggin | 05a4a95 | 2017-07-12 14:35:46 -0700 | [diff] [blame] | 971 | #endif /* CONFIG_SMP */ |
| 972 | #endif |
| 973 | #ifdef CONFIG_HARDLOCKUP_DETECTOR |
| 974 | { |
| 975 | .procname = "hardlockup_panic", |
| 976 | .data = &hardlockup_panic, |
| 977 | .maxlen = sizeof(int), |
| 978 | .mode = 0644, |
| 979 | .proc_handler = proc_dointvec_minmax, |
| 980 | .extra1 = &zero, |
| 981 | .extra2 = &one, |
| 982 | }, |
| 983 | #ifdef CONFIG_SMP |
Jiri Kosina | 5553787 | 2015-11-05 18:44:41 -0800 | [diff] [blame] | 984 | { |
| 985 | .procname = "hardlockup_all_cpu_backtrace", |
| 986 | .data = &sysctl_hardlockup_all_cpu_backtrace, |
| 987 | .maxlen = sizeof(int), |
| 988 | .mode = 0644, |
| 989 | .proc_handler = proc_dointvec_minmax, |
| 990 | .extra1 = &zero, |
| 991 | .extra2 = &one, |
| 992 | }, |
Aaron Tomlin | ed23587 | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 993 | #endif /* CONFIG_SMP */ |
Don Zickus | 5dc3055 | 2010-11-29 17:07:17 -0500 | [diff] [blame] | 994 | #endif |
Nicholas Piggin | 05a4a95 | 2017-07-12 14:35:46 -0700 | [diff] [blame] | 995 | #endif |
| 996 | |
Don Zickus | 5dc3055 | 2010-11-29 17:07:17 -0500 | [diff] [blame] | 997 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) |
| 998 | { |
| 999 | .procname = "unknown_nmi_panic", |
| 1000 | .data = &unknown_nmi_panic, |
| 1001 | .maxlen = sizeof (int), |
| 1002 | .mode = 0644, |
| 1003 | .proc_handler = proc_dointvec, |
| 1004 | }, |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 1005 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | #if defined(CONFIG_X86) |
| 1007 | { |
Don Zickus | 8da5add | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 1008 | .procname = "panic_on_unrecovered_nmi", |
| 1009 | .data = &panic_on_unrecovered_nmi, |
| 1010 | .maxlen = sizeof(int), |
| 1011 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1012 | .proc_handler = proc_dointvec, |
Don Zickus | 8da5add | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 1013 | }, |
| 1014 | { |
Kurt Garloff | 5211a24 | 2009-06-24 14:32:11 -0700 | [diff] [blame] | 1015 | .procname = "panic_on_io_nmi", |
| 1016 | .data = &panic_on_io_nmi, |
| 1017 | .maxlen = sizeof(int), |
| 1018 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1019 | .proc_handler = proc_dointvec, |
Kurt Garloff | 5211a24 | 2009-06-24 14:32:11 -0700 | [diff] [blame] | 1020 | }, |
Mitsuo Hayasaka | 55af779 | 2011-11-29 15:08:36 +0900 | [diff] [blame] | 1021 | #ifdef CONFIG_DEBUG_STACKOVERFLOW |
| 1022 | { |
| 1023 | .procname = "panic_on_stackoverflow", |
| 1024 | .data = &sysctl_panic_on_stackoverflow, |
| 1025 | .maxlen = sizeof(int), |
| 1026 | .mode = 0644, |
| 1027 | .proc_handler = proc_dointvec, |
| 1028 | }, |
| 1029 | #endif |
Kurt Garloff | 5211a24 | 2009-06-24 14:32:11 -0700 | [diff] [blame] | 1030 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | .procname = "bootloader_type", |
| 1032 | .data = &bootloader_type, |
| 1033 | .maxlen = sizeof (int), |
| 1034 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1035 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | }, |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 1037 | { |
H. Peter Anvin | 5031296 | 2009-05-07 16:54:11 -0700 | [diff] [blame] | 1038 | .procname = "bootloader_version", |
| 1039 | .data = &bootloader_version, |
| 1040 | .maxlen = sizeof (int), |
| 1041 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1042 | .proc_handler = proc_dointvec, |
H. Peter Anvin | 5031296 | 2009-05-07 16:54:11 -0700 | [diff] [blame] | 1043 | }, |
| 1044 | { |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 1045 | .procname = "io_delay_type", |
| 1046 | .data = &io_delay_type, |
| 1047 | .maxlen = sizeof(int), |
| 1048 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1049 | .proc_handler = proc_dointvec, |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 1050 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | #endif |
Luke Yang | 7a9166e | 2006-02-20 18:28:07 -0800 | [diff] [blame] | 1052 | #if defined(CONFIG_MMU) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | .procname = "randomize_va_space", |
| 1055 | .data = &randomize_va_space, |
| 1056 | .maxlen = sizeof(int), |
| 1057 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1058 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | }, |
Luke Yang | 7a9166e | 2006-02-20 18:28:07 -0800 | [diff] [blame] | 1060 | #endif |
Martin Schwidefsky | 0152fb3 | 2006-01-14 13:21:00 -0800 | [diff] [blame] | 1061 | #if defined(CONFIG_S390) && defined(CONFIG_SMP) |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 1062 | { |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 1063 | .procname = "spin_retry", |
| 1064 | .data = &spin_retry, |
| 1065 | .maxlen = sizeof (int), |
| 1066 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1067 | .proc_handler = proc_dointvec, |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 1068 | }, |
| 1069 | #endif |
Len Brown | 673d5b4 | 2007-07-28 03:33:16 -0400 | [diff] [blame] | 1070 | #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1071 | { |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1072 | .procname = "acpi_video_flags", |
Pavel Machek | 77afcf7 | 2007-07-19 01:47:41 -0700 | [diff] [blame] | 1073 | .data = &acpi_realmode_flags, |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1074 | .maxlen = sizeof (unsigned long), |
| 1075 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1076 | .proc_handler = proc_doulongvec_minmax, |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1077 | }, |
| 1078 | #endif |
Vineet Gupta | b6fca72 | 2013-01-09 20:06:28 +0530 | [diff] [blame] | 1079 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1080 | { |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1081 | .procname = "ignore-unaligned-usertrap", |
| 1082 | .data = &no_unaligned_warning, |
| 1083 | .maxlen = sizeof (int), |
| 1084 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1085 | .proc_handler = proc_dointvec, |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1086 | }, |
Vineet Gupta | b6fca72 | 2013-01-09 20:06:28 +0530 | [diff] [blame] | 1087 | #endif |
| 1088 | #ifdef CONFIG_IA64 |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 1089 | { |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 1090 | .procname = "unaligned-dump-stack", |
| 1091 | .data = &unaligned_dump_stack, |
| 1092 | .maxlen = sizeof (int), |
| 1093 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1094 | .proc_handler = proc_dointvec, |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 1095 | }, |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1096 | #endif |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 1097 | #ifdef CONFIG_DETECT_HUNG_TASK |
| 1098 | { |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 1099 | .procname = "hung_task_panic", |
| 1100 | .data = &sysctl_hung_task_panic, |
| 1101 | .maxlen = sizeof(int), |
| 1102 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1103 | .proc_handler = proc_dointvec_minmax, |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 1104 | .extra1 = &zero, |
| 1105 | .extra2 = &one, |
| 1106 | }, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1107 | { |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1108 | .procname = "hung_task_check_count", |
| 1109 | .data = &sysctl_hung_task_check_count, |
Li Zefan | cd64647 | 2013-09-23 16:43:58 +0800 | [diff] [blame] | 1110 | .maxlen = sizeof(int), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1111 | .mode = 0644, |
Li Zefan | cd64647 | 2013-09-23 16:43:58 +0800 | [diff] [blame] | 1112 | .proc_handler = proc_dointvec_minmax, |
| 1113 | .extra1 = &zero, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1114 | }, |
| 1115 | { |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1116 | .procname = "hung_task_timeout_secs", |
| 1117 | .data = &sysctl_hung_task_timeout_secs, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 1118 | .maxlen = sizeof(unsigned long), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1119 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1120 | .proc_handler = proc_dohung_task_timeout_secs, |
Liu Hua | 80df284 | 2014-04-07 15:38:57 -0700 | [diff] [blame] | 1121 | .extra2 = &hung_task_timeout_max, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1122 | }, |
| 1123 | { |
Dmitry Vyukov | a2e5144 | 2018-08-21 21:55:52 -0700 | [diff] [blame] | 1124 | .procname = "hung_task_check_interval_secs", |
| 1125 | .data = &sysctl_hung_task_check_interval_secs, |
| 1126 | .maxlen = sizeof(unsigned long), |
| 1127 | .mode = 0644, |
| 1128 | .proc_handler = proc_dohung_task_timeout_secs, |
| 1129 | .extra2 = &hung_task_timeout_max, |
| 1130 | }, |
| 1131 | { |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1132 | .procname = "hung_task_warnings", |
| 1133 | .data = &sysctl_hung_task_warnings, |
Aaron Tomlin | 270750db | 2014-01-20 17:34:13 +0000 | [diff] [blame] | 1134 | .maxlen = sizeof(int), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1135 | .mode = 0644, |
Aaron Tomlin | 270750db | 2014-01-20 17:34:13 +0000 | [diff] [blame] | 1136 | .proc_handler = proc_dointvec_minmax, |
| 1137 | .extra1 = &neg_one, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1138 | }, |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 1139 | #endif |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 1140 | #ifdef CONFIG_RT_MUTEXES |
| 1141 | { |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 1142 | .procname = "max_lock_depth", |
| 1143 | .data = &max_lock_depth, |
| 1144 | .maxlen = sizeof(int), |
| 1145 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1146 | .proc_handler = proc_dointvec, |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 1147 | }, |
| 1148 | #endif |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 1149 | { |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 1150 | .procname = "poweroff_cmd", |
| 1151 | .data = &poweroff_cmd, |
| 1152 | .maxlen = POWEROFF_CMD_PATH_LEN, |
| 1153 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1154 | .proc_handler = proc_dostring, |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 1155 | }, |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 1156 | #ifdef CONFIG_KEYS |
| 1157 | { |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 1158 | .procname = "keys", |
| 1159 | .mode = 0555, |
| 1160 | .child = key_sysctls, |
| 1161 | }, |
| 1162 | #endif |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1163 | #ifdef CONFIG_PERF_EVENTS |
Vince Weaver | aa4a221 | 2011-06-03 17:54:40 -0400 | [diff] [blame] | 1164 | /* |
| 1165 | * User-space scripts rely on the existence of this file |
| 1166 | * as a feature check for perf_events being enabled. |
| 1167 | * |
| 1168 | * So it's an ABI, do not remove! |
| 1169 | */ |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1170 | { |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1171 | .procname = "perf_event_paranoid", |
| 1172 | .data = &sysctl_perf_event_paranoid, |
| 1173 | .maxlen = sizeof(sysctl_perf_event_paranoid), |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1174 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1175 | .proc_handler = proc_dointvec, |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1176 | }, |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 1177 | { |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1178 | .procname = "perf_event_mlock_kb", |
| 1179 | .data = &sysctl_perf_event_mlock, |
| 1180 | .maxlen = sizeof(sysctl_perf_event_mlock), |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 1181 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1182 | .proc_handler = proc_dointvec, |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 1183 | }, |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 1184 | { |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1185 | .procname = "perf_event_max_sample_rate", |
| 1186 | .data = &sysctl_perf_event_sample_rate, |
| 1187 | .maxlen = sizeof(sysctl_perf_event_sample_rate), |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 1188 | .mode = 0644, |
Peter Zijlstra | 163ec43 | 2011-02-16 11:22:34 +0100 | [diff] [blame] | 1189 | .proc_handler = perf_proc_update_handler, |
Knut Petersen | 723478c | 2013-09-25 14:29:37 +0200 | [diff] [blame] | 1190 | .extra1 = &one, |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 1191 | }, |
Dave Hansen | 14c63f1 | 2013-06-21 08:51:36 -0700 | [diff] [blame] | 1192 | { |
| 1193 | .procname = "perf_cpu_time_max_percent", |
| 1194 | .data = &sysctl_perf_cpu_time_max_percent, |
| 1195 | .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), |
| 1196 | .mode = 0644, |
| 1197 | .proc_handler = perf_cpu_time_max_percent_handler, |
| 1198 | .extra1 = &zero, |
| 1199 | .extra2 = &one_hundred, |
| 1200 | }, |
Arnaldo Carvalho de Melo | c5dfd78 | 2016-04-21 12:28:50 -0300 | [diff] [blame] | 1201 | { |
| 1202 | .procname = "perf_event_max_stack", |
Arnaldo Carvalho de Melo | a831100 | 2016-05-10 16:34:53 -0300 | [diff] [blame] | 1203 | .data = &sysctl_perf_event_max_stack, |
Arnaldo Carvalho de Melo | c5dfd78 | 2016-04-21 12:28:50 -0300 | [diff] [blame] | 1204 | .maxlen = sizeof(sysctl_perf_event_max_stack), |
| 1205 | .mode = 0644, |
| 1206 | .proc_handler = perf_event_max_stack_handler, |
| 1207 | .extra1 = &zero, |
| 1208 | .extra2 = &six_hundred_forty_kb, |
| 1209 | }, |
Arnaldo Carvalho de Melo | c85b033 | 2016-05-12 13:06:21 -0300 | [diff] [blame] | 1210 | { |
| 1211 | .procname = "perf_event_max_contexts_per_stack", |
| 1212 | .data = &sysctl_perf_event_max_contexts_per_stack, |
| 1213 | .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), |
| 1214 | .mode = 0644, |
| 1215 | .proc_handler = perf_event_max_stack_handler, |
| 1216 | .extra1 = &zero, |
| 1217 | .extra2 = &one_thousand, |
| 1218 | }, |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1219 | #endif |
Prarit Bhargava | 9e3961a | 2014-12-10 15:45:50 -0800 | [diff] [blame] | 1220 | { |
| 1221 | .procname = "panic_on_warn", |
| 1222 | .data = &panic_on_warn, |
| 1223 | .maxlen = sizeof(int), |
| 1224 | .mode = 0644, |
| 1225 | .proc_handler = proc_dointvec_minmax, |
| 1226 | .extra1 = &zero, |
| 1227 | .extra2 = &one, |
| 1228 | }, |
Thomas Gleixner | bc7a34b | 2015-05-26 22:50:33 +0000 | [diff] [blame] | 1229 | #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) |
| 1230 | { |
| 1231 | .procname = "timer_migration", |
| 1232 | .data = &sysctl_timer_migration, |
| 1233 | .maxlen = sizeof(unsigned int), |
| 1234 | .mode = 0644, |
| 1235 | .proc_handler = timer_migration_handler, |
Myungho Jung | b94bf59 | 2017-04-19 15:24:50 -0700 | [diff] [blame] | 1236 | .extra1 = &zero, |
| 1237 | .extra2 = &one, |
Thomas Gleixner | bc7a34b | 2015-05-26 22:50:33 +0000 | [diff] [blame] | 1238 | }, |
| 1239 | #endif |
Alexei Starovoitov | 1be7f75 | 2015-10-07 22:23:21 -0700 | [diff] [blame] | 1240 | #ifdef CONFIG_BPF_SYSCALL |
| 1241 | { |
| 1242 | .procname = "unprivileged_bpf_disabled", |
| 1243 | .data = &sysctl_unprivileged_bpf_disabled, |
| 1244 | .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), |
| 1245 | .mode = 0644, |
| 1246 | /* only handle a transition from default "0" to "1" */ |
| 1247 | .proc_handler = proc_dointvec_minmax, |
| 1248 | .extra1 = &one, |
| 1249 | .extra2 = &one, |
| 1250 | }, |
Alexei Starovoitov | 492ecee | 2019-02-25 14:28:39 -0800 | [diff] [blame] | 1251 | { |
| 1252 | .procname = "bpf_stats_enabled", |
| 1253 | .data = &sysctl_bpf_stats_enabled, |
| 1254 | .maxlen = sizeof(sysctl_bpf_stats_enabled), |
| 1255 | .mode = 0644, |
| 1256 | .proc_handler = proc_dointvec_minmax_bpf_stats, |
| 1257 | .extra1 = &zero, |
| 1258 | .extra2 = &one, |
| 1259 | }, |
Alexei Starovoitov | 3fcc553 | 2019-02-27 18:30:44 -0800 | [diff] [blame] | 1260 | #endif |
Daniel Bristot de Oliveira | 088e9d2 | 2016-06-02 13:51:41 -0300 | [diff] [blame] | 1261 | #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU) |
| 1262 | { |
| 1263 | .procname = "panic_on_rcu_stall", |
| 1264 | .data = &sysctl_panic_on_rcu_stall, |
| 1265 | .maxlen = sizeof(sysctl_panic_on_rcu_stall), |
| 1266 | .mode = 0644, |
| 1267 | .proc_handler = proc_dointvec_minmax, |
| 1268 | .extra1 = &zero, |
| 1269 | .extra2 = &one, |
| 1270 | }, |
| 1271 | #endif |
Alexander Popov | 964c9df | 2018-08-17 01:17:03 +0300 | [diff] [blame] | 1272 | #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE |
| 1273 | { |
| 1274 | .procname = "stack_erasing", |
| 1275 | .data = NULL, |
| 1276 | .maxlen = sizeof(int), |
| 1277 | .mode = 0600, |
| 1278 | .proc_handler = stack_erasing_sysctl, |
| 1279 | .extra1 = &zero, |
| 1280 | .extra2 = &one, |
| 1281 | }, |
| 1282 | #endif |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1283 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | }; |
| 1285 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1286 | static struct ctl_table vm_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | .procname = "overcommit_memory", |
| 1289 | .data = &sysctl_overcommit_memory, |
| 1290 | .maxlen = sizeof(sysctl_overcommit_memory), |
| 1291 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1292 | .proc_handler = proc_dointvec_minmax, |
| 1293 | .extra1 = &zero, |
| 1294 | .extra2 = &two, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | }, |
| 1296 | { |
KAMEZAWA Hiroyuki | fadd8fb | 2006-06-23 02:03:13 -0700 | [diff] [blame] | 1297 | .procname = "panic_on_oom", |
| 1298 | .data = &sysctl_panic_on_oom, |
| 1299 | .maxlen = sizeof(sysctl_panic_on_oom), |
| 1300 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1301 | .proc_handler = proc_dointvec_minmax, |
| 1302 | .extra1 = &zero, |
| 1303 | .extra2 = &two, |
KAMEZAWA Hiroyuki | fadd8fb | 2006-06-23 02:03:13 -0700 | [diff] [blame] | 1304 | }, |
| 1305 | { |
David Rientjes | fe071d7 | 2007-10-16 23:25:56 -0700 | [diff] [blame] | 1306 | .procname = "oom_kill_allocating_task", |
| 1307 | .data = &sysctl_oom_kill_allocating_task, |
| 1308 | .maxlen = sizeof(sysctl_oom_kill_allocating_task), |
| 1309 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1310 | .proc_handler = proc_dointvec, |
David Rientjes | fe071d7 | 2007-10-16 23:25:56 -0700 | [diff] [blame] | 1311 | }, |
| 1312 | { |
David Rientjes | fef1bdd | 2008-02-07 00:14:07 -0800 | [diff] [blame] | 1313 | .procname = "oom_dump_tasks", |
| 1314 | .data = &sysctl_oom_dump_tasks, |
| 1315 | .maxlen = sizeof(sysctl_oom_dump_tasks), |
| 1316 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1317 | .proc_handler = proc_dointvec, |
David Rientjes | fef1bdd | 2008-02-07 00:14:07 -0800 | [diff] [blame] | 1318 | }, |
| 1319 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | .procname = "overcommit_ratio", |
| 1321 | .data = &sysctl_overcommit_ratio, |
| 1322 | .maxlen = sizeof(sysctl_overcommit_ratio), |
| 1323 | .mode = 0644, |
Jerome Marchand | 49f0ce5 | 2014-01-21 15:49:14 -0800 | [diff] [blame] | 1324 | .proc_handler = overcommit_ratio_handler, |
| 1325 | }, |
| 1326 | { |
| 1327 | .procname = "overcommit_kbytes", |
| 1328 | .data = &sysctl_overcommit_kbytes, |
| 1329 | .maxlen = sizeof(sysctl_overcommit_kbytes), |
| 1330 | .mode = 0644, |
| 1331 | .proc_handler = overcommit_kbytes_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | }, |
| 1333 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | .procname = "page-cluster", |
| 1335 | .data = &page_cluster, |
| 1336 | .maxlen = sizeof(int), |
| 1337 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1338 | .proc_handler = proc_dointvec_minmax, |
| 1339 | .extra1 = &zero, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | }, |
| 1341 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | .procname = "dirty_background_ratio", |
| 1343 | .data = &dirty_background_ratio, |
| 1344 | .maxlen = sizeof(dirty_background_ratio), |
| 1345 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1346 | .proc_handler = dirty_background_ratio_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | .extra1 = &zero, |
| 1348 | .extra2 = &one_hundred, |
| 1349 | }, |
| 1350 | { |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1351 | .procname = "dirty_background_bytes", |
| 1352 | .data = &dirty_background_bytes, |
| 1353 | .maxlen = sizeof(dirty_background_bytes), |
| 1354 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1355 | .proc_handler = dirty_background_bytes_handler, |
Sven Wegener | fc3501d | 2009-02-11 13:04:23 -0800 | [diff] [blame] | 1356 | .extra1 = &one_ul, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1357 | }, |
| 1358 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | .procname = "dirty_ratio", |
| 1360 | .data = &vm_dirty_ratio, |
| 1361 | .maxlen = sizeof(vm_dirty_ratio), |
| 1362 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1363 | .proc_handler = dirty_ratio_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | .extra1 = &zero, |
| 1365 | .extra2 = &one_hundred, |
| 1366 | }, |
| 1367 | { |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1368 | .procname = "dirty_bytes", |
| 1369 | .data = &vm_dirty_bytes, |
| 1370 | .maxlen = sizeof(vm_dirty_bytes), |
| 1371 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1372 | .proc_handler = dirty_bytes_handler, |
Andrea Righi | 9e4a5bd | 2009-04-30 15:08:57 -0700 | [diff] [blame] | 1373 | .extra1 = &dirty_bytes_min, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1374 | }, |
| 1375 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | .procname = "dirty_writeback_centisecs", |
Bart Samwel | f6ef943 | 2006-03-24 03:15:48 -0800 | [diff] [blame] | 1377 | .data = &dirty_writeback_interval, |
| 1378 | .maxlen = sizeof(dirty_writeback_interval), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1380 | .proc_handler = dirty_writeback_centisecs_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | }, |
| 1382 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | .procname = "dirty_expire_centisecs", |
Bart Samwel | f6ef943 | 2006-03-24 03:15:48 -0800 | [diff] [blame] | 1384 | .data = &dirty_expire_interval, |
| 1385 | .maxlen = sizeof(dirty_expire_interval), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1387 | .proc_handler = proc_dointvec_minmax, |
| 1388 | .extra1 = &zero, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | }, |
| 1390 | { |
Theodore Ts'o | 1efff91 | 2015-03-17 12:23:32 -0400 | [diff] [blame] | 1391 | .procname = "dirtytime_expire_seconds", |
| 1392 | .data = &dirtytime_expire_interval, |
Randy Dunlap | 2d87b30 | 2018-04-10 16:35:14 -0700 | [diff] [blame] | 1393 | .maxlen = sizeof(dirtytime_expire_interval), |
Theodore Ts'o | 1efff91 | 2015-03-17 12:23:32 -0400 | [diff] [blame] | 1394 | .mode = 0644, |
| 1395 | .proc_handler = dirtytime_interval_handler, |
| 1396 | .extra1 = &zero, |
| 1397 | }, |
| 1398 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | .procname = "swappiness", |
| 1400 | .data = &vm_swappiness, |
| 1401 | .maxlen = sizeof(vm_swappiness), |
| 1402 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1403 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | .extra1 = &zero, |
| 1405 | .extra2 = &one_hundred, |
| 1406 | }, |
| 1407 | #ifdef CONFIG_HUGETLB_PAGE |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1408 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | .procname = "nr_hugepages", |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1410 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | .maxlen = sizeof(unsigned long), |
| 1412 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1413 | .proc_handler = hugetlb_sysctl_handler, |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1414 | }, |
| 1415 | #ifdef CONFIG_NUMA |
| 1416 | { |
| 1417 | .procname = "nr_hugepages_mempolicy", |
| 1418 | .data = NULL, |
| 1419 | .maxlen = sizeof(unsigned long), |
| 1420 | .mode = 0644, |
| 1421 | .proc_handler = &hugetlb_mempolicy_sysctl_handler, |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1422 | }, |
Kemi Wang | 4518085 | 2017-11-15 17:38:22 -0800 | [diff] [blame] | 1423 | { |
| 1424 | .procname = "numa_stat", |
| 1425 | .data = &sysctl_vm_numa_stat, |
| 1426 | .maxlen = sizeof(int), |
| 1427 | .mode = 0644, |
| 1428 | .proc_handler = sysctl_vm_numa_stat_handler, |
| 1429 | .extra1 = &zero, |
| 1430 | .extra2 = &one, |
| 1431 | }, |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1432 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | .procname = "hugetlb_shm_group", |
| 1435 | .data = &sysctl_hugetlb_shm_group, |
| 1436 | .maxlen = sizeof(gid_t), |
| 1437 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1438 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | }, |
Adam Litke | 54f9f80 | 2007-10-16 01:26:20 -0700 | [diff] [blame] | 1440 | { |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1441 | .procname = "nr_overcommit_hugepages", |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1442 | .data = NULL, |
| 1443 | .maxlen = sizeof(unsigned long), |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1444 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1445 | .proc_handler = hugetlb_overcommit_handler, |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1446 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | #endif |
| 1448 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1449 | .procname = "lowmem_reserve_ratio", |
| 1450 | .data = &sysctl_lowmem_reserve_ratio, |
| 1451 | .maxlen = sizeof(sysctl_lowmem_reserve_ratio), |
| 1452 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1453 | .proc_handler = lowmem_reserve_ratio_sysctl_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | }, |
| 1455 | { |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1456 | .procname = "drop_caches", |
| 1457 | .data = &sysctl_drop_caches, |
| 1458 | .maxlen = sizeof(int), |
| 1459 | .mode = 0644, |
| 1460 | .proc_handler = drop_caches_sysctl_handler, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1461 | .extra1 = &one, |
Dave Hansen | 5509a5d | 2014-04-03 14:48:19 -0700 | [diff] [blame] | 1462 | .extra2 = &four, |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1463 | }, |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 1464 | #ifdef CONFIG_COMPACTION |
| 1465 | { |
| 1466 | .procname = "compact_memory", |
| 1467 | .data = &sysctl_compact_memory, |
| 1468 | .maxlen = sizeof(int), |
| 1469 | .mode = 0200, |
| 1470 | .proc_handler = sysctl_compaction_handler, |
| 1471 | }, |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 1472 | { |
| 1473 | .procname = "extfrag_threshold", |
| 1474 | .data = &sysctl_extfrag_threshold, |
| 1475 | .maxlen = sizeof(int), |
| 1476 | .mode = 0644, |
Matthew Wilcox | 6b7e5ca | 2019-03-05 15:43:41 -0800 | [diff] [blame] | 1477 | .proc_handler = proc_dointvec_minmax, |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 1478 | .extra1 = &min_extfrag_threshold, |
| 1479 | .extra2 = &max_extfrag_threshold, |
| 1480 | }, |
Eric B Munson | 5bbe354 | 2015-04-15 16:13:20 -0700 | [diff] [blame] | 1481 | { |
| 1482 | .procname = "compact_unevictable_allowed", |
| 1483 | .data = &sysctl_compact_unevictable_allowed, |
| 1484 | .maxlen = sizeof(int), |
| 1485 | .mode = 0644, |
| 1486 | .proc_handler = proc_dointvec, |
| 1487 | .extra1 = &zero, |
| 1488 | .extra2 = &one, |
| 1489 | }, |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 1490 | |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 1491 | #endif /* CONFIG_COMPACTION */ |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1492 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1493 | .procname = "min_free_kbytes", |
| 1494 | .data = &min_free_kbytes, |
| 1495 | .maxlen = sizeof(min_free_kbytes), |
| 1496 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1497 | .proc_handler = min_free_kbytes_sysctl_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | .extra1 = &zero, |
| 1499 | }, |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1500 | { |
Mel Gorman | 1c30844 | 2018-12-28 00:35:52 -0800 | [diff] [blame] | 1501 | .procname = "watermark_boost_factor", |
| 1502 | .data = &watermark_boost_factor, |
| 1503 | .maxlen = sizeof(watermark_boost_factor), |
| 1504 | .mode = 0644, |
| 1505 | .proc_handler = watermark_boost_factor_sysctl_handler, |
| 1506 | .extra1 = &zero, |
| 1507 | }, |
| 1508 | { |
Johannes Weiner | 795ae7a | 2016-03-17 14:19:14 -0700 | [diff] [blame] | 1509 | .procname = "watermark_scale_factor", |
| 1510 | .data = &watermark_scale_factor, |
| 1511 | .maxlen = sizeof(watermark_scale_factor), |
| 1512 | .mode = 0644, |
| 1513 | .proc_handler = watermark_scale_factor_sysctl_handler, |
| 1514 | .extra1 = &one, |
| 1515 | .extra2 = &one_thousand, |
| 1516 | }, |
| 1517 | { |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1518 | .procname = "percpu_pagelist_fraction", |
| 1519 | .data = &percpu_pagelist_fraction, |
| 1520 | .maxlen = sizeof(percpu_pagelist_fraction), |
| 1521 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1522 | .proc_handler = percpu_pagelist_fraction_sysctl_handler, |
David Rientjes | 7cd2b0a | 2014-06-23 13:22:04 -0700 | [diff] [blame] | 1523 | .extra1 = &zero, |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1524 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | #ifdef CONFIG_MMU |
| 1526 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | .procname = "max_map_count", |
| 1528 | .data = &sysctl_max_map_count, |
| 1529 | .maxlen = sizeof(sysctl_max_map_count), |
| 1530 | .mode = 0644, |
WANG Cong | 3e26120 | 2009-12-17 15:27:05 -0800 | [diff] [blame] | 1531 | .proc_handler = proc_dointvec_minmax, |
Amerigo Wang | 70da234 | 2009-12-14 17:59:52 -0800 | [diff] [blame] | 1532 | .extra1 = &zero, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | }, |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1534 | #else |
| 1535 | { |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1536 | .procname = "nr_trim_pages", |
| 1537 | .data = &sysctl_nr_trim_pages, |
| 1538 | .maxlen = sizeof(sysctl_nr_trim_pages), |
| 1539 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1540 | .proc_handler = proc_dointvec_minmax, |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1541 | .extra1 = &zero, |
| 1542 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | #endif |
| 1544 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | .procname = "laptop_mode", |
| 1546 | .data = &laptop_mode, |
| 1547 | .maxlen = sizeof(laptop_mode), |
| 1548 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1549 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | }, |
| 1551 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | .procname = "block_dump", |
| 1553 | .data = &block_dump, |
| 1554 | .maxlen = sizeof(block_dump), |
| 1555 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1556 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | .extra1 = &zero, |
| 1558 | }, |
| 1559 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1560 | .procname = "vfs_cache_pressure", |
| 1561 | .data = &sysctl_vfs_cache_pressure, |
| 1562 | .maxlen = sizeof(sysctl_vfs_cache_pressure), |
| 1563 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1564 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | .extra1 = &zero, |
| 1566 | }, |
| 1567 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
| 1568 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | .procname = "legacy_va_layout", |
| 1570 | .data = &sysctl_legacy_va_layout, |
| 1571 | .maxlen = sizeof(sysctl_legacy_va_layout), |
| 1572 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1573 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1574 | .extra1 = &zero, |
| 1575 | }, |
| 1576 | #endif |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1577 | #ifdef CONFIG_NUMA |
| 1578 | { |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1579 | .procname = "zone_reclaim_mode", |
Mel Gorman | a5f5f91 | 2016-07-28 15:46:32 -0700 | [diff] [blame] | 1580 | .data = &node_reclaim_mode, |
| 1581 | .maxlen = sizeof(node_reclaim_mode), |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1582 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1583 | .proc_handler = proc_dointvec, |
Christoph Lameter | c84db23 | 2006-02-01 03:05:29 -0800 | [diff] [blame] | 1584 | .extra1 = &zero, |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1585 | }, |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1586 | { |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1587 | .procname = "min_unmapped_ratio", |
| 1588 | .data = &sysctl_min_unmapped_ratio, |
| 1589 | .maxlen = sizeof(sysctl_min_unmapped_ratio), |
| 1590 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1591 | .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1592 | .extra1 = &zero, |
| 1593 | .extra2 = &one_hundred, |
| 1594 | }, |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1595 | { |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1596 | .procname = "min_slab_ratio", |
| 1597 | .data = &sysctl_min_slab_ratio, |
| 1598 | .maxlen = sizeof(sysctl_min_slab_ratio), |
| 1599 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1600 | .proc_handler = sysctl_min_slab_ratio_sysctl_handler, |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1601 | .extra1 = &zero, |
| 1602 | .extra2 = &one_hundred, |
| 1603 | }, |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1604 | #endif |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1605 | #ifdef CONFIG_SMP |
| 1606 | { |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1607 | .procname = "stat_interval", |
| 1608 | .data = &sysctl_stat_interval, |
| 1609 | .maxlen = sizeof(sysctl_stat_interval), |
| 1610 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1611 | .proc_handler = proc_dointvec_jiffies, |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1612 | }, |
Hugh Dickins | 52b6f46 | 2016-05-19 17:12:50 -0700 | [diff] [blame] | 1613 | { |
| 1614 | .procname = "stat_refresh", |
| 1615 | .data = NULL, |
| 1616 | .maxlen = 0, |
| 1617 | .mode = 0600, |
| 1618 | .proc_handler = vmstat_refresh, |
| 1619 | }, |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1620 | #endif |
David Howells | 6e14154 | 2009-12-15 19:27:45 +0000 | [diff] [blame] | 1621 | #ifdef CONFIG_MMU |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1622 | { |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1623 | .procname = "mmap_min_addr", |
Eric Paris | 788084a | 2009-07-31 12:54:11 -0400 | [diff] [blame] | 1624 | .data = &dac_mmap_min_addr, |
| 1625 | .maxlen = sizeof(unsigned long), |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1626 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1627 | .proc_handler = mmap_min_addr_handler, |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1628 | }, |
David Howells | 6e14154 | 2009-12-15 19:27:45 +0000 | [diff] [blame] | 1629 | #endif |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1630 | #ifdef CONFIG_NUMA |
| 1631 | { |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1632 | .procname = "numa_zonelist_order", |
| 1633 | .data = &numa_zonelist_order, |
| 1634 | .maxlen = NUMA_ZONELIST_ORDER_LEN, |
| 1635 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1636 | .proc_handler = numa_zonelist_order_handler, |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1637 | }, |
| 1638 | #endif |
Al Viro | 2b8232c | 2007-10-13 08:16:04 +0100 | [diff] [blame] | 1639 | #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ |
Paul Mundt | 5c36e65 | 2007-03-01 10:07:42 +0900 | [diff] [blame] | 1640 | (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1641 | { |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1642 | .procname = "vdso_enabled", |
Andy Lutomirski | 3d7ee96 | 2014-05-05 12:19:32 -0700 | [diff] [blame] | 1643 | #ifdef CONFIG_X86_32 |
| 1644 | .data = &vdso32_enabled, |
| 1645 | .maxlen = sizeof(vdso32_enabled), |
| 1646 | #else |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1647 | .data = &vdso_enabled, |
| 1648 | .maxlen = sizeof(vdso_enabled), |
Andy Lutomirski | 3d7ee96 | 2014-05-05 12:19:32 -0700 | [diff] [blame] | 1649 | #endif |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1650 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1651 | .proc_handler = proc_dointvec, |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1652 | .extra1 = &zero, |
| 1653 | }, |
| 1654 | #endif |
Bron Gondwana | 195cf453 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1655 | #ifdef CONFIG_HIGHMEM |
| 1656 | { |
Bron Gondwana | 195cf453 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1657 | .procname = "highmem_is_dirtyable", |
| 1658 | .data = &vm_highmem_is_dirtyable, |
| 1659 | .maxlen = sizeof(vm_highmem_is_dirtyable), |
| 1660 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1661 | .proc_handler = proc_dointvec_minmax, |
Bron Gondwana | 195cf453 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1662 | .extra1 = &zero, |
| 1663 | .extra2 = &one, |
| 1664 | }, |
| 1665 | #endif |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1666 | #ifdef CONFIG_MEMORY_FAILURE |
| 1667 | { |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1668 | .procname = "memory_failure_early_kill", |
| 1669 | .data = &sysctl_memory_failure_early_kill, |
| 1670 | .maxlen = sizeof(sysctl_memory_failure_early_kill), |
| 1671 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1672 | .proc_handler = proc_dointvec_minmax, |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1673 | .extra1 = &zero, |
| 1674 | .extra2 = &one, |
| 1675 | }, |
| 1676 | { |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1677 | .procname = "memory_failure_recovery", |
| 1678 | .data = &sysctl_memory_failure_recovery, |
| 1679 | .maxlen = sizeof(sysctl_memory_failure_recovery), |
| 1680 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1681 | .proc_handler = proc_dointvec_minmax, |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1682 | .extra1 = &zero, |
| 1683 | .extra2 = &one, |
| 1684 | }, |
| 1685 | #endif |
Andrew Shewmaker | c9b1d09 | 2013-04-29 15:08:10 -0700 | [diff] [blame] | 1686 | { |
| 1687 | .procname = "user_reserve_kbytes", |
| 1688 | .data = &sysctl_user_reserve_kbytes, |
| 1689 | .maxlen = sizeof(sysctl_user_reserve_kbytes), |
| 1690 | .mode = 0644, |
| 1691 | .proc_handler = proc_doulongvec_minmax, |
| 1692 | }, |
Andrew Shewmaker | 4eeab4f | 2013-04-29 15:08:11 -0700 | [diff] [blame] | 1693 | { |
| 1694 | .procname = "admin_reserve_kbytes", |
| 1695 | .data = &sysctl_admin_reserve_kbytes, |
| 1696 | .maxlen = sizeof(sysctl_admin_reserve_kbytes), |
| 1697 | .mode = 0644, |
| 1698 | .proc_handler = proc_doulongvec_minmax, |
| 1699 | }, |
Daniel Cashman | d07e225 | 2016-01-14 15:19:53 -0800 | [diff] [blame] | 1700 | #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS |
| 1701 | { |
| 1702 | .procname = "mmap_rnd_bits", |
| 1703 | .data = &mmap_rnd_bits, |
| 1704 | .maxlen = sizeof(mmap_rnd_bits), |
| 1705 | .mode = 0600, |
| 1706 | .proc_handler = proc_dointvec_minmax, |
| 1707 | .extra1 = (void *)&mmap_rnd_bits_min, |
| 1708 | .extra2 = (void *)&mmap_rnd_bits_max, |
| 1709 | }, |
| 1710 | #endif |
| 1711 | #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS |
| 1712 | { |
| 1713 | .procname = "mmap_rnd_compat_bits", |
| 1714 | .data = &mmap_rnd_compat_bits, |
| 1715 | .maxlen = sizeof(mmap_rnd_compat_bits), |
| 1716 | .mode = 0600, |
| 1717 | .proc_handler = proc_dointvec_minmax, |
| 1718 | .extra1 = (void *)&mmap_rnd_compat_bits_min, |
| 1719 | .extra2 = (void *)&mmap_rnd_compat_bits_max, |
| 1720 | }, |
| 1721 | #endif |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1722 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | }; |
| 1724 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1725 | static struct ctl_table fs_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | .procname = "inode-nr", |
| 1728 | .data = &inodes_stat, |
Glauber Costa | 3942c07 | 2013-08-28 10:17:53 +1000 | [diff] [blame] | 1729 | .maxlen = 2*sizeof(long), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1730 | .mode = 0444, |
Dave Chinner | cffbc8a | 2010-10-23 05:03:02 -0400 | [diff] [blame] | 1731 | .proc_handler = proc_nr_inodes, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1732 | }, |
| 1733 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | .procname = "inode-state", |
| 1735 | .data = &inodes_stat, |
Glauber Costa | 3942c07 | 2013-08-28 10:17:53 +1000 | [diff] [blame] | 1736 | .maxlen = 7*sizeof(long), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | .mode = 0444, |
Dave Chinner | cffbc8a | 2010-10-23 05:03:02 -0400 | [diff] [blame] | 1738 | .proc_handler = proc_nr_inodes, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | }, |
| 1740 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1741 | .procname = "file-nr", |
| 1742 | .data = &files_stat, |
Eric Dumazet | 518de9b | 2010-10-26 14:22:44 -0700 | [diff] [blame] | 1743 | .maxlen = sizeof(files_stat), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1745 | .proc_handler = proc_nr_files, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | }, |
| 1747 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | .procname = "file-max", |
| 1749 | .data = &files_stat.max_files, |
Eric Dumazet | 518de9b | 2010-10-26 14:22:44 -0700 | [diff] [blame] | 1750 | .maxlen = sizeof(files_stat.max_files), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | .mode = 0644, |
Eric Dumazet | 518de9b | 2010-10-26 14:22:44 -0700 | [diff] [blame] | 1752 | .proc_handler = proc_doulongvec_minmax, |
Christian Brauner | 32a5ad9 | 2019-03-07 16:29:43 -0800 | [diff] [blame^] | 1753 | .extra1 = &zero, |
| 1754 | .extra2 = &long_max, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | }, |
| 1756 | { |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1757 | .procname = "nr_open", |
| 1758 | .data = &sysctl_nr_open, |
Alexey Dobriyan | 9b80a18 | 2016-09-02 00:38:52 +0300 | [diff] [blame] | 1759 | .maxlen = sizeof(unsigned int), |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1760 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1761 | .proc_handler = proc_dointvec_minmax, |
Al Viro | eceea0b | 2008-05-10 10:08:32 -0400 | [diff] [blame] | 1762 | .extra1 = &sysctl_nr_open_min, |
| 1763 | .extra2 = &sysctl_nr_open_max, |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1764 | }, |
| 1765 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | .procname = "dentry-state", |
| 1767 | .data = &dentry_stat, |
Glauber Costa | 3942c07 | 2013-08-28 10:17:53 +1000 | [diff] [blame] | 1768 | .maxlen = 6*sizeof(long), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | .mode = 0444, |
Christoph Hellwig | 312d3ca | 2010-10-10 05:36:23 -0400 | [diff] [blame] | 1770 | .proc_handler = proc_nr_dentry, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | }, |
| 1772 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | .procname = "overflowuid", |
| 1774 | .data = &fs_overflowuid, |
| 1775 | .maxlen = sizeof(int), |
| 1776 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1777 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | .extra1 = &minolduid, |
| 1779 | .extra2 = &maxolduid, |
| 1780 | }, |
| 1781 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | .procname = "overflowgid", |
| 1783 | .data = &fs_overflowgid, |
| 1784 | .maxlen = sizeof(int), |
| 1785 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1786 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | .extra1 = &minolduid, |
| 1788 | .extra2 = &maxolduid, |
| 1789 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1790 | #ifdef CONFIG_FILE_LOCKING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | .procname = "leases-enable", |
| 1793 | .data = &leases_enable, |
| 1794 | .maxlen = sizeof(int), |
| 1795 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1796 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1797 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1798 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | #ifdef CONFIG_DNOTIFY |
| 1800 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1801 | .procname = "dir-notify-enable", |
| 1802 | .data = &dir_notify_enable, |
| 1803 | .maxlen = sizeof(int), |
| 1804 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1805 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1806 | }, |
| 1807 | #endif |
| 1808 | #ifdef CONFIG_MMU |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1809 | #ifdef CONFIG_FILE_LOCKING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1810 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1811 | .procname = "lease-break-time", |
| 1812 | .data = &lease_break_time, |
| 1813 | .maxlen = sizeof(int), |
| 1814 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1815 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1817 | #endif |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 1818 | #ifdef CONFIG_AIO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | .procname = "aio-nr", |
| 1821 | .data = &aio_nr, |
| 1822 | .maxlen = sizeof(aio_nr), |
| 1823 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1824 | .proc_handler = proc_doulongvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | }, |
| 1826 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1827 | .procname = "aio-max-nr", |
| 1828 | .data = &aio_max_nr, |
| 1829 | .maxlen = sizeof(aio_max_nr), |
| 1830 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1831 | .proc_handler = proc_doulongvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1832 | }, |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 1833 | #endif /* CONFIG_AIO */ |
Amy Griffis | 2d9048e | 2006-06-01 13:10:59 -0700 | [diff] [blame] | 1834 | #ifdef CONFIG_INOTIFY_USER |
Robert Love | 0399cb0 | 2005-07-13 12:38:18 -0400 | [diff] [blame] | 1835 | { |
Robert Love | 0399cb0 | 2005-07-13 12:38:18 -0400 | [diff] [blame] | 1836 | .procname = "inotify", |
| 1837 | .mode = 0555, |
| 1838 | .child = inotify_table, |
| 1839 | }, |
| 1840 | #endif |
Davide Libenzi | 7ef9964 | 2008-12-01 13:13:55 -0800 | [diff] [blame] | 1841 | #ifdef CONFIG_EPOLL |
| 1842 | { |
| 1843 | .procname = "epoll", |
| 1844 | .mode = 0555, |
| 1845 | .child = epoll_table, |
| 1846 | }, |
| 1847 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1848 | #endif |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 1849 | { |
Kees Cook | 800179c | 2012-07-25 17:29:07 -0700 | [diff] [blame] | 1850 | .procname = "protected_symlinks", |
| 1851 | .data = &sysctl_protected_symlinks, |
| 1852 | .maxlen = sizeof(int), |
| 1853 | .mode = 0600, |
| 1854 | .proc_handler = proc_dointvec_minmax, |
| 1855 | .extra1 = &zero, |
| 1856 | .extra2 = &one, |
| 1857 | }, |
| 1858 | { |
| 1859 | .procname = "protected_hardlinks", |
| 1860 | .data = &sysctl_protected_hardlinks, |
| 1861 | .maxlen = sizeof(int), |
| 1862 | .mode = 0600, |
| 1863 | .proc_handler = proc_dointvec_minmax, |
| 1864 | .extra1 = &zero, |
| 1865 | .extra2 = &one, |
| 1866 | }, |
| 1867 | { |
Salvatore Mesoraca | 30aba66 | 2018-08-23 17:00:35 -0700 | [diff] [blame] | 1868 | .procname = "protected_fifos", |
| 1869 | .data = &sysctl_protected_fifos, |
| 1870 | .maxlen = sizeof(int), |
| 1871 | .mode = 0600, |
| 1872 | .proc_handler = proc_dointvec_minmax, |
| 1873 | .extra1 = &zero, |
| 1874 | .extra2 = &two, |
| 1875 | }, |
| 1876 | { |
| 1877 | .procname = "protected_regular", |
| 1878 | .data = &sysctl_protected_regular, |
| 1879 | .maxlen = sizeof(int), |
| 1880 | .mode = 0600, |
| 1881 | .proc_handler = proc_dointvec_minmax, |
| 1882 | .extra1 = &zero, |
| 1883 | .extra2 = &two, |
| 1884 | }, |
| 1885 | { |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 1886 | .procname = "suid_dumpable", |
| 1887 | .data = &suid_dumpable, |
| 1888 | .maxlen = sizeof(int), |
| 1889 | .mode = 0644, |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 1890 | .proc_handler = proc_dointvec_minmax_coredump, |
Matthew Wilcox | 8e654fb | 2009-04-02 16:58:33 -0700 | [diff] [blame] | 1891 | .extra1 = &zero, |
| 1892 | .extra2 = &two, |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 1893 | }, |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 1894 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
| 1895 | { |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 1896 | .procname = "binfmt_misc", |
| 1897 | .mode = 0555, |
Eric W. Biederman | f9bd673 | 2015-05-09 22:09:14 -0500 | [diff] [blame] | 1898 | .child = sysctl_mount_point, |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 1899 | }, |
| 1900 | #endif |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 1901 | { |
Jens Axboe | ff9da69 | 2010-06-03 14:54:39 +0200 | [diff] [blame] | 1902 | .procname = "pipe-max-size", |
| 1903 | .data = &pipe_max_size, |
Joe Lawrence | 98159d9 | 2017-11-17 15:29:17 -0800 | [diff] [blame] | 1904 | .maxlen = sizeof(pipe_max_size), |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 1905 | .mode = 0644, |
Eric Biggers | 319e0a2 | 2018-02-06 15:41:49 -0800 | [diff] [blame] | 1906 | .proc_handler = proc_dopipe_max_size, |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 1907 | }, |
Willy Tarreau | 759c011 | 2016-01-18 16:36:09 +0100 | [diff] [blame] | 1908 | { |
| 1909 | .procname = "pipe-user-pages-hard", |
| 1910 | .data = &pipe_user_pages_hard, |
| 1911 | .maxlen = sizeof(pipe_user_pages_hard), |
| 1912 | .mode = 0644, |
| 1913 | .proc_handler = proc_doulongvec_minmax, |
| 1914 | }, |
| 1915 | { |
| 1916 | .procname = "pipe-user-pages-soft", |
| 1917 | .data = &pipe_user_pages_soft, |
| 1918 | .maxlen = sizeof(pipe_user_pages_soft), |
| 1919 | .mode = 0644, |
| 1920 | .proc_handler = proc_doulongvec_minmax, |
| 1921 | }, |
Eric W. Biederman | d292168 | 2016-09-28 00:27:17 -0500 | [diff] [blame] | 1922 | { |
| 1923 | .procname = "mount-max", |
| 1924 | .data = &sysctl_mount_max, |
| 1925 | .maxlen = sizeof(unsigned int), |
| 1926 | .mode = 0644, |
| 1927 | .proc_handler = proc_dointvec_minmax, |
| 1928 | .extra1 = &one, |
| 1929 | }, |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1930 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1931 | }; |
| 1932 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1933 | static struct ctl_table debug_table[] = { |
Catalin Marinas | 7ac57a8 | 2012-10-08 16:28:16 -0700 | [diff] [blame] | 1934 | #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 1935 | { |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 1936 | .procname = "exception-trace", |
| 1937 | .data = &show_unhandled_signals, |
| 1938 | .maxlen = sizeof(int), |
| 1939 | .mode = 0644, |
| 1940 | .proc_handler = proc_dointvec |
| 1941 | }, |
| 1942 | #endif |
Masami Hiramatsu | b2be84d | 2010-02-25 08:34:15 -0500 | [diff] [blame] | 1943 | #if defined(CONFIG_OPTPROBES) |
| 1944 | { |
| 1945 | .procname = "kprobes-optimization", |
| 1946 | .data = &sysctl_kprobes_optimization, |
| 1947 | .maxlen = sizeof(int), |
| 1948 | .mode = 0644, |
| 1949 | .proc_handler = proc_kprobes_optimization_handler, |
| 1950 | .extra1 = &zero, |
| 1951 | .extra2 = &one, |
| 1952 | }, |
| 1953 | #endif |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1954 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1955 | }; |
| 1956 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1957 | static struct ctl_table dev_table[] = { |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1958 | { } |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 1959 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1960 | |
Eric W. Biederman | de4e83bd | 2012-01-06 03:34:20 -0800 | [diff] [blame] | 1961 | int __init sysctl_init(void) |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 1962 | { |
Steven Rostedt | fd4b616 | 2012-07-30 14:42:48 -0700 | [diff] [blame] | 1963 | struct ctl_table_header *hdr; |
| 1964 | |
| 1965 | hdr = register_sysctl_table(sysctl_base_table); |
| 1966 | kmemleak_not_leak(hdr); |
Eric W. Biederman | d912b0c | 2007-02-14 00:34:13 -0800 | [diff] [blame] | 1967 | return 0; |
| 1968 | } |
| 1969 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 1970 | #endif /* CONFIG_SYSCTL */ |
| 1971 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | /* |
| 1973 | * /proc/sys support |
| 1974 | */ |
| 1975 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 1976 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1977 | |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 1978 | static int _proc_do_string(char *data, int maxlen, int write, |
| 1979 | char __user *buffer, |
Adrian Bunk | b1ba4dd | 2006-10-02 02:18:05 -0700 | [diff] [blame] | 1980 | size_t *lenp, loff_t *ppos) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 1981 | { |
| 1982 | size_t len; |
| 1983 | char __user *p; |
| 1984 | char c; |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 1985 | |
| 1986 | if (!data || !maxlen || !*lenp) { |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 1987 | *lenp = 0; |
| 1988 | return 0; |
| 1989 | } |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 1990 | |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 1991 | if (write) { |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 1992 | if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { |
| 1993 | /* Only continue writes not past the end of buffer. */ |
| 1994 | len = strlen(data); |
| 1995 | if (len > maxlen - 1) |
| 1996 | len = maxlen - 1; |
| 1997 | |
| 1998 | if (*ppos > len) |
| 1999 | return 0; |
| 2000 | len = *ppos; |
| 2001 | } else { |
| 2002 | /* Start writing from beginning of buffer. */ |
| 2003 | len = 0; |
| 2004 | } |
| 2005 | |
Kees Cook | 2ca9bb4 | 2014-06-06 14:37:18 -0700 | [diff] [blame] | 2006 | *ppos += *lenp; |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2007 | p = buffer; |
Kees Cook | 2ca9bb4 | 2014-06-06 14:37:18 -0700 | [diff] [blame] | 2008 | while ((p - buffer) < *lenp && len < maxlen - 1) { |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2009 | if (get_user(c, p++)) |
| 2010 | return -EFAULT; |
| 2011 | if (c == 0 || c == '\n') |
| 2012 | break; |
Kees Cook | 2ca9bb4 | 2014-06-06 14:37:18 -0700 | [diff] [blame] | 2013 | data[len++] = c; |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2014 | } |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2015 | data[len] = 0; |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2016 | } else { |
| 2017 | len = strlen(data); |
| 2018 | if (len > maxlen) |
| 2019 | len = maxlen; |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2020 | |
| 2021 | if (*ppos > len) { |
| 2022 | *lenp = 0; |
| 2023 | return 0; |
| 2024 | } |
| 2025 | |
| 2026 | data += *ppos; |
| 2027 | len -= *ppos; |
| 2028 | |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2029 | if (len > *lenp) |
| 2030 | len = *lenp; |
| 2031 | if (len) |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2032 | if (copy_to_user(buffer, data, len)) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2033 | return -EFAULT; |
| 2034 | if (len < *lenp) { |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2035 | if (put_user('\n', buffer + len)) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2036 | return -EFAULT; |
| 2037 | len++; |
| 2038 | } |
| 2039 | *lenp = len; |
| 2040 | *ppos += len; |
| 2041 | } |
| 2042 | return 0; |
| 2043 | } |
| 2044 | |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2045 | static void warn_sysctl_write(struct ctl_table *table) |
| 2046 | { |
| 2047 | pr_warn_once("%s wrote to %s when file position was not 0!\n" |
| 2048 | "This will not be supported in the future. To silence this\n" |
| 2049 | "warning, set kernel.sysctl_writes_strict = -1\n", |
| 2050 | current->comm, table->procname); |
| 2051 | } |
| 2052 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | /** |
Randy Dunlap | 5f733e8 | 2018-08-21 22:01:06 -0700 | [diff] [blame] | 2054 | * proc_first_pos_non_zero_ignore - check if first position is allowed |
Luis R. Rodriguez | d383d48 | 2017-07-12 14:33:33 -0700 | [diff] [blame] | 2055 | * @ppos: file position |
| 2056 | * @table: the sysctl table |
| 2057 | * |
| 2058 | * Returns true if the first position is non-zero and the sysctl_writes_strict |
| 2059 | * mode indicates this is not allowed for numeric input types. String proc |
Randy Dunlap | 5f733e8 | 2018-08-21 22:01:06 -0700 | [diff] [blame] | 2060 | * handlers can ignore the return value. |
Luis R. Rodriguez | d383d48 | 2017-07-12 14:33:33 -0700 | [diff] [blame] | 2061 | */ |
| 2062 | static bool proc_first_pos_non_zero_ignore(loff_t *ppos, |
| 2063 | struct ctl_table *table) |
| 2064 | { |
| 2065 | if (!*ppos) |
| 2066 | return false; |
| 2067 | |
| 2068 | switch (sysctl_writes_strict) { |
| 2069 | case SYSCTL_WRITES_STRICT: |
| 2070 | return true; |
| 2071 | case SYSCTL_WRITES_WARN: |
| 2072 | warn_sysctl_write(table); |
| 2073 | return false; |
| 2074 | default: |
| 2075 | return false; |
| 2076 | } |
| 2077 | } |
| 2078 | |
| 2079 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2080 | * proc_dostring - read a string sysctl |
| 2081 | * @table: the sysctl table |
| 2082 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | * @buffer: the user buffer |
| 2084 | * @lenp: the size of the user buffer |
| 2085 | * @ppos: file position |
| 2086 | * |
| 2087 | * Reads/writes a string from/to the user buffer. If the kernel |
| 2088 | * buffer provided is not large enough to hold the string, the |
| 2089 | * string is truncated. The copied string is %NULL-terminated. |
| 2090 | * If the string is being read by the user process, it is copied |
| 2091 | * and a newline '\n' is added. It is truncated if the buffer is |
| 2092 | * not large enough. |
| 2093 | * |
| 2094 | * Returns 0 on success. |
| 2095 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2096 | int proc_dostring(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2098 | { |
Luis R. Rodriguez | d383d48 | 2017-07-12 14:33:33 -0700 | [diff] [blame] | 2099 | if (write) |
| 2100 | proc_first_pos_non_zero_ignore(ppos, table); |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2101 | |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2102 | return _proc_do_string((char *)(table->data), table->maxlen, write, |
| 2103 | (char __user *)buffer, lenp, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2104 | } |
| 2105 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2106 | static size_t proc_skip_spaces(char **buf) |
| 2107 | { |
| 2108 | size_t ret; |
| 2109 | char *tmp = skip_spaces(*buf); |
| 2110 | ret = tmp - *buf; |
| 2111 | *buf = tmp; |
| 2112 | return ret; |
| 2113 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 2115 | static void proc_skip_char(char **buf, size_t *size, const char v) |
| 2116 | { |
| 2117 | while (*size) { |
| 2118 | if (**buf != v) |
| 2119 | break; |
| 2120 | (*size)--; |
| 2121 | (*buf)++; |
| 2122 | } |
| 2123 | } |
| 2124 | |
Christian Brauner | 7f2923c | 2019-03-07 16:29:40 -0800 | [diff] [blame] | 2125 | /** |
| 2126 | * strtoul_lenient - parse an ASCII formatted integer from a buffer and only |
| 2127 | * fail on overflow |
| 2128 | * |
| 2129 | * @cp: kernel buffer containing the string to parse |
| 2130 | * @endp: pointer to store the trailing characters |
| 2131 | * @base: the base to use |
| 2132 | * @res: where the parsed integer will be stored |
| 2133 | * |
| 2134 | * In case of success 0 is returned and @res will contain the parsed integer, |
| 2135 | * @endp will hold any trailing characters. |
| 2136 | * This function will fail the parse on overflow. If there wasn't an overflow |
| 2137 | * the function will defer the decision what characters count as invalid to the |
| 2138 | * caller. |
| 2139 | */ |
| 2140 | static int strtoul_lenient(const char *cp, char **endp, unsigned int base, |
| 2141 | unsigned long *res) |
| 2142 | { |
| 2143 | unsigned long long result; |
| 2144 | unsigned int rv; |
| 2145 | |
| 2146 | cp = _parse_integer_fixup_radix(cp, &base); |
| 2147 | rv = _parse_integer(cp, base, &result); |
| 2148 | if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) |
| 2149 | return -ERANGE; |
| 2150 | |
| 2151 | cp += rv; |
| 2152 | |
| 2153 | if (endp) |
| 2154 | *endp = (char *)cp; |
| 2155 | |
| 2156 | *res = (unsigned long)result; |
| 2157 | return 0; |
| 2158 | } |
| 2159 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2160 | #define TMPBUFLEN 22 |
| 2161 | /** |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2162 | * proc_get_long - reads an ASCII formatted integer from a user buffer |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2163 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2164 | * @buf: a kernel buffer |
| 2165 | * @size: size of the kernel buffer |
| 2166 | * @val: this is where the number will be stored |
| 2167 | * @neg: set to %TRUE if number is negative |
| 2168 | * @perm_tr: a vector which contains the allowed trailers |
| 2169 | * @perm_tr_len: size of the perm_tr vector |
| 2170 | * @tr: pointer to store the trailer character |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2171 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2172 | * In case of success %0 is returned and @buf and @size are updated with |
| 2173 | * the amount of bytes read. If @tr is non-NULL and a trailing |
| 2174 | * character exists (size is non-zero after returning from this |
| 2175 | * function), @tr is updated with the trailing character. |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2176 | */ |
| 2177 | static int proc_get_long(char **buf, size_t *size, |
| 2178 | unsigned long *val, bool *neg, |
| 2179 | const char *perm_tr, unsigned perm_tr_len, char *tr) |
| 2180 | { |
| 2181 | int len; |
| 2182 | char *p, tmp[TMPBUFLEN]; |
| 2183 | |
| 2184 | if (!*size) |
| 2185 | return -EINVAL; |
| 2186 | |
| 2187 | len = *size; |
| 2188 | if (len > TMPBUFLEN - 1) |
| 2189 | len = TMPBUFLEN - 1; |
| 2190 | |
| 2191 | memcpy(tmp, *buf, len); |
| 2192 | |
| 2193 | tmp[len] = 0; |
| 2194 | p = tmp; |
| 2195 | if (*p == '-' && *size > 1) { |
| 2196 | *neg = true; |
| 2197 | p++; |
| 2198 | } else |
| 2199 | *neg = false; |
| 2200 | if (!isdigit(*p)) |
| 2201 | return -EINVAL; |
| 2202 | |
Christian Brauner | 7f2923c | 2019-03-07 16:29:40 -0800 | [diff] [blame] | 2203 | if (strtoul_lenient(p, &p, 0, val)) |
| 2204 | return -EINVAL; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2205 | |
| 2206 | len = p - tmp; |
| 2207 | |
| 2208 | /* We don't know if the next char is whitespace thus we may accept |
| 2209 | * invalid integers (e.g. 1234...a) or two integers instead of one |
| 2210 | * (e.g. 123...1). So lets not allow such large numbers. */ |
| 2211 | if (len == TMPBUFLEN - 1) |
| 2212 | return -EINVAL; |
| 2213 | |
| 2214 | if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) |
| 2215 | return -EINVAL; |
| 2216 | |
| 2217 | if (tr && (len < *size)) |
| 2218 | *tr = *p; |
| 2219 | |
| 2220 | *buf += len; |
| 2221 | *size -= len; |
| 2222 | |
| 2223 | return 0; |
| 2224 | } |
| 2225 | |
| 2226 | /** |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2227 | * proc_put_long - converts an integer to a decimal ASCII formatted string |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2228 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2229 | * @buf: the user buffer |
| 2230 | * @size: the size of the user buffer |
| 2231 | * @val: the integer to be converted |
| 2232 | * @neg: sign of the number, %TRUE for negative |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2233 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2234 | * In case of success %0 is returned and @buf and @size are updated with |
| 2235 | * the amount of bytes written. |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2236 | */ |
| 2237 | static int proc_put_long(void __user **buf, size_t *size, unsigned long val, |
| 2238 | bool neg) |
| 2239 | { |
| 2240 | int len; |
| 2241 | char tmp[TMPBUFLEN], *p = tmp; |
| 2242 | |
| 2243 | sprintf(p, "%s%lu", neg ? "-" : "", val); |
| 2244 | len = strlen(tmp); |
| 2245 | if (len > *size) |
| 2246 | len = *size; |
| 2247 | if (copy_to_user(*buf, tmp, len)) |
| 2248 | return -EFAULT; |
| 2249 | *size -= len; |
| 2250 | *buf += len; |
| 2251 | return 0; |
| 2252 | } |
| 2253 | #undef TMPBUFLEN |
| 2254 | |
| 2255 | static int proc_put_char(void __user **buf, size_t *size, char c) |
| 2256 | { |
| 2257 | if (*size) { |
| 2258 | char __user **buffer = (char __user **)buf; |
| 2259 | if (put_user(c, *buffer)) |
| 2260 | return -EFAULT; |
| 2261 | (*size)--, (*buffer)++; |
| 2262 | *buf = *buffer; |
| 2263 | } |
| 2264 | return 0; |
| 2265 | } |
| 2266 | |
| 2267 | static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | int *valp, |
| 2269 | int write, void *data) |
| 2270 | { |
| 2271 | if (write) { |
Heinrich Schuchardt | 230633d | 2015-04-16 12:48:07 -0700 | [diff] [blame] | 2272 | if (*negp) { |
| 2273 | if (*lvalp > (unsigned long) INT_MAX + 1) |
| 2274 | return -EINVAL; |
| 2275 | *valp = -*lvalp; |
| 2276 | } else { |
| 2277 | if (*lvalp > (unsigned long) INT_MAX) |
| 2278 | return -EINVAL; |
| 2279 | *valp = *lvalp; |
| 2280 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | } else { |
| 2282 | int val = *valp; |
| 2283 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2284 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2285 | *lvalp = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2287 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | *lvalp = (unsigned long)val; |
| 2289 | } |
| 2290 | } |
| 2291 | return 0; |
| 2292 | } |
| 2293 | |
Luis R. Rodriguez | 4f2fec0 | 2017-07-12 14:33:36 -0700 | [diff] [blame] | 2294 | static int do_proc_douintvec_conv(unsigned long *lvalp, |
| 2295 | unsigned int *valp, |
| 2296 | int write, void *data) |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2297 | { |
| 2298 | if (write) { |
Luis R. Rodriguez | 4f2fec0 | 2017-07-12 14:33:36 -0700 | [diff] [blame] | 2299 | if (*lvalp > UINT_MAX) |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2300 | return -EINVAL; |
| 2301 | *valp = *lvalp; |
| 2302 | } else { |
| 2303 | unsigned int val = *valp; |
| 2304 | *lvalp = (unsigned long)val; |
| 2305 | } |
| 2306 | return 0; |
| 2307 | } |
| 2308 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2309 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; |
| 2310 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2311 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2312 | int write, void __user *buffer, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2313 | size_t *lenp, loff_t *ppos, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2314 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2315 | int write, void *data), |
| 2316 | void *data) |
| 2317 | { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2318 | int *i, vleft, first = 1, err = 0; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2319 | size_t left; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2320 | char *kbuf = NULL, *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2322 | if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | *lenp = 0; |
| 2324 | return 0; |
| 2325 | } |
| 2326 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2327 | i = (int *) tbl_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | vleft = table->maxlen / sizeof(*i); |
| 2329 | left = *lenp; |
| 2330 | |
| 2331 | if (!conv) |
| 2332 | conv = do_proc_dointvec_conv; |
| 2333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | if (write) { |
Luis R. Rodriguez | d383d48 | 2017-07-12 14:33:33 -0700 | [diff] [blame] | 2335 | if (proc_first_pos_non_zero_ignore(ppos, table)) |
| 2336 | goto out; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2337 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2338 | if (left > PAGE_SIZE - 1) |
| 2339 | left = PAGE_SIZE - 1; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2340 | p = kbuf = memdup_user_nul(buffer, left); |
| 2341 | if (IS_ERR(kbuf)) |
| 2342 | return PTR_ERR(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2343 | } |
| 2344 | |
| 2345 | for (; left && vleft--; i++, first=0) { |
| 2346 | unsigned long lval; |
| 2347 | bool neg; |
| 2348 | |
| 2349 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2350 | left -= proc_skip_spaces(&p); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2351 | |
J. R. Okajima | 563b046 | 2010-05-25 16:10:14 -0700 | [diff] [blame] | 2352 | if (!left) |
| 2353 | break; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2354 | err = proc_get_long(&p, &left, &lval, &neg, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2355 | proc_wspace_sep, |
| 2356 | sizeof(proc_wspace_sep), NULL); |
| 2357 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2358 | break; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2359 | if (conv(&neg, &lval, i, 1, data)) { |
| 2360 | err = -EINVAL; |
| 2361 | break; |
| 2362 | } |
| 2363 | } else { |
| 2364 | if (conv(&neg, &lval, i, 0, data)) { |
| 2365 | err = -EINVAL; |
| 2366 | break; |
| 2367 | } |
| 2368 | if (!first) |
| 2369 | err = proc_put_char(&buffer, &left, '\t'); |
| 2370 | if (err) |
| 2371 | break; |
| 2372 | err = proc_put_long(&buffer, &left, lval, neg); |
| 2373 | if (err) |
| 2374 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2375 | } |
| 2376 | } |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2377 | |
| 2378 | if (!write && !first && left && !err) |
| 2379 | err = proc_put_char(&buffer, &left, '\n'); |
J. R. Okajima | 563b046 | 2010-05-25 16:10:14 -0700 | [diff] [blame] | 2380 | if (write && !err && left) |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2381 | left -= proc_skip_spaces(&p); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2382 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2383 | kfree(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2384 | if (first) |
| 2385 | return err ? : -EINVAL; |
| 2386 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2387 | *lenp -= left; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2388 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2389 | *ppos += *lenp; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2390 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2391 | } |
| 2392 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2393 | static int do_proc_dointvec(struct ctl_table *table, int write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2394 | void __user *buffer, size_t *lenp, loff_t *ppos, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2395 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2396 | int write, void *data), |
| 2397 | void *data) |
| 2398 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2399 | return __do_proc_dointvec(table->data, table, write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2400 | buffer, lenp, ppos, conv, data); |
| 2401 | } |
| 2402 | |
Luis R. Rodriguez | 4f2fec0 | 2017-07-12 14:33:36 -0700 | [diff] [blame] | 2403 | static int do_proc_douintvec_w(unsigned int *tbl_data, |
| 2404 | struct ctl_table *table, |
| 2405 | void __user *buffer, |
| 2406 | size_t *lenp, loff_t *ppos, |
| 2407 | int (*conv)(unsigned long *lvalp, |
| 2408 | unsigned int *valp, |
| 2409 | int write, void *data), |
| 2410 | void *data) |
| 2411 | { |
| 2412 | unsigned long lval; |
| 2413 | int err = 0; |
| 2414 | size_t left; |
| 2415 | bool neg; |
| 2416 | char *kbuf = NULL, *p; |
| 2417 | |
| 2418 | left = *lenp; |
| 2419 | |
| 2420 | if (proc_first_pos_non_zero_ignore(ppos, table)) |
| 2421 | goto bail_early; |
| 2422 | |
| 2423 | if (left > PAGE_SIZE - 1) |
| 2424 | left = PAGE_SIZE - 1; |
| 2425 | |
| 2426 | p = kbuf = memdup_user_nul(buffer, left); |
| 2427 | if (IS_ERR(kbuf)) |
| 2428 | return -EINVAL; |
| 2429 | |
| 2430 | left -= proc_skip_spaces(&p); |
| 2431 | if (!left) { |
| 2432 | err = -EINVAL; |
| 2433 | goto out_free; |
| 2434 | } |
| 2435 | |
| 2436 | err = proc_get_long(&p, &left, &lval, &neg, |
| 2437 | proc_wspace_sep, |
| 2438 | sizeof(proc_wspace_sep), NULL); |
| 2439 | if (err || neg) { |
| 2440 | err = -EINVAL; |
| 2441 | goto out_free; |
| 2442 | } |
| 2443 | |
| 2444 | if (conv(&lval, tbl_data, 1, data)) { |
| 2445 | err = -EINVAL; |
| 2446 | goto out_free; |
| 2447 | } |
| 2448 | |
| 2449 | if (!err && left) |
| 2450 | left -= proc_skip_spaces(&p); |
| 2451 | |
| 2452 | out_free: |
| 2453 | kfree(kbuf); |
| 2454 | if (err) |
| 2455 | return -EINVAL; |
| 2456 | |
| 2457 | return 0; |
| 2458 | |
| 2459 | /* This is in keeping with old __do_proc_dointvec() */ |
| 2460 | bail_early: |
| 2461 | *ppos += *lenp; |
| 2462 | return err; |
| 2463 | } |
| 2464 | |
| 2465 | static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer, |
| 2466 | size_t *lenp, loff_t *ppos, |
| 2467 | int (*conv)(unsigned long *lvalp, |
| 2468 | unsigned int *valp, |
| 2469 | int write, void *data), |
| 2470 | void *data) |
| 2471 | { |
| 2472 | unsigned long lval; |
| 2473 | int err = 0; |
| 2474 | size_t left; |
| 2475 | |
| 2476 | left = *lenp; |
| 2477 | |
| 2478 | if (conv(&lval, tbl_data, 0, data)) { |
| 2479 | err = -EINVAL; |
| 2480 | goto out; |
| 2481 | } |
| 2482 | |
| 2483 | err = proc_put_long(&buffer, &left, lval, false); |
| 2484 | if (err || !left) |
| 2485 | goto out; |
| 2486 | |
| 2487 | err = proc_put_char(&buffer, &left, '\n'); |
| 2488 | |
| 2489 | out: |
| 2490 | *lenp -= left; |
| 2491 | *ppos += *lenp; |
| 2492 | |
| 2493 | return err; |
| 2494 | } |
| 2495 | |
| 2496 | static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, |
| 2497 | int write, void __user *buffer, |
| 2498 | size_t *lenp, loff_t *ppos, |
| 2499 | int (*conv)(unsigned long *lvalp, |
| 2500 | unsigned int *valp, |
| 2501 | int write, void *data), |
| 2502 | void *data) |
| 2503 | { |
| 2504 | unsigned int *i, vleft; |
| 2505 | |
| 2506 | if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { |
| 2507 | *lenp = 0; |
| 2508 | return 0; |
| 2509 | } |
| 2510 | |
| 2511 | i = (unsigned int *) tbl_data; |
| 2512 | vleft = table->maxlen / sizeof(*i); |
| 2513 | |
| 2514 | /* |
| 2515 | * Arrays are not supported, keep this simple. *Do not* add |
| 2516 | * support for them. |
| 2517 | */ |
| 2518 | if (vleft != 1) { |
| 2519 | *lenp = 0; |
| 2520 | return -EINVAL; |
| 2521 | } |
| 2522 | |
| 2523 | if (!conv) |
| 2524 | conv = do_proc_douintvec_conv; |
| 2525 | |
| 2526 | if (write) |
| 2527 | return do_proc_douintvec_w(i, table, buffer, lenp, ppos, |
| 2528 | conv, data); |
| 2529 | return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); |
| 2530 | } |
| 2531 | |
| 2532 | static int do_proc_douintvec(struct ctl_table *table, int write, |
| 2533 | void __user *buffer, size_t *lenp, loff_t *ppos, |
| 2534 | int (*conv)(unsigned long *lvalp, |
| 2535 | unsigned int *valp, |
| 2536 | int write, void *data), |
| 2537 | void *data) |
| 2538 | { |
| 2539 | return __do_proc_douintvec(table->data, table, write, |
| 2540 | buffer, lenp, ppos, conv, data); |
| 2541 | } |
| 2542 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2543 | /** |
| 2544 | * proc_dointvec - read a vector of integers |
| 2545 | * @table: the sysctl table |
| 2546 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | * @buffer: the user buffer |
| 2548 | * @lenp: the size of the user buffer |
| 2549 | * @ppos: file position |
| 2550 | * |
| 2551 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2552 | * values from/to the user buffer, treated as an ASCII string. |
| 2553 | * |
| 2554 | * Returns 0 on success. |
| 2555 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2556 | int proc_dointvec(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2558 | { |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2559 | return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); |
| 2560 | } |
| 2561 | |
| 2562 | /** |
| 2563 | * proc_douintvec - read a vector of unsigned integers |
| 2564 | * @table: the sysctl table |
| 2565 | * @write: %TRUE if this is a write to the sysctl file |
| 2566 | * @buffer: the user buffer |
| 2567 | * @lenp: the size of the user buffer |
| 2568 | * @ppos: file position |
| 2569 | * |
| 2570 | * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer |
| 2571 | * values from/to the user buffer, treated as an ASCII string. |
| 2572 | * |
| 2573 | * Returns 0 on success. |
| 2574 | */ |
| 2575 | int proc_douintvec(struct ctl_table *table, int write, |
| 2576 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2577 | { |
Luis R. Rodriguez | 4f2fec0 | 2017-07-12 14:33:36 -0700 | [diff] [blame] | 2578 | return do_proc_douintvec(table, write, buffer, lenp, ppos, |
| 2579 | do_proc_douintvec_conv, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2580 | } |
| 2581 | |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2582 | /* |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2583 | * Taint values can only be increased |
| 2584 | * This means we can safely use a temporary. |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2585 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2586 | static int proc_taint(struct ctl_table *table, int write, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2587 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2588 | { |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2589 | struct ctl_table t; |
| 2590 | unsigned long tmptaint = get_taint(); |
| 2591 | int err; |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2592 | |
Bastian Blank | 91fcd41 | 2007-04-23 14:41:14 -0700 | [diff] [blame] | 2593 | if (write && !capable(CAP_SYS_ADMIN)) |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2594 | return -EPERM; |
| 2595 | |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2596 | t = *table; |
| 2597 | t.data = &tmptaint; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2598 | err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2599 | if (err < 0) |
| 2600 | return err; |
| 2601 | |
| 2602 | if (write) { |
| 2603 | /* |
| 2604 | * Poor man's atomic or. Not worth adding a primitive |
| 2605 | * to everyone's atomic.h for this |
| 2606 | */ |
| 2607 | int i; |
| 2608 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { |
| 2609 | if ((tmptaint >> i) & 1) |
Rusty Russell | 373d4d0 | 2013-01-21 17:17:39 +1030 | [diff] [blame] | 2610 | add_taint(i, LOCKDEP_STILL_OK); |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2611 | } |
| 2612 | } |
| 2613 | |
| 2614 | return err; |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2615 | } |
| 2616 | |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 2617 | #ifdef CONFIG_PRINTK |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 2618 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 2619 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2620 | { |
| 2621 | if (write && !capable(CAP_SYS_ADMIN)) |
| 2622 | return -EPERM; |
| 2623 | |
| 2624 | return proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
| 2625 | } |
| 2626 | #endif |
| 2627 | |
Waiman Long | 24704f3 | 2018-04-10 16:35:38 -0700 | [diff] [blame] | 2628 | /** |
| 2629 | * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure |
| 2630 | * @min: pointer to minimum allowable value |
| 2631 | * @max: pointer to maximum allowable value |
| 2632 | * |
| 2633 | * The do_proc_dointvec_minmax_conv_param structure provides the |
| 2634 | * minimum and maximum values for doing range checking for those sysctl |
| 2635 | * parameters that use the proc_dointvec_minmax() handler. |
| 2636 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2637 | struct do_proc_dointvec_minmax_conv_param { |
| 2638 | int *min; |
| 2639 | int *max; |
| 2640 | }; |
| 2641 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2642 | static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, |
| 2643 | int *valp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2644 | int write, void *data) |
| 2645 | { |
| 2646 | struct do_proc_dointvec_minmax_conv_param *param = data; |
| 2647 | if (write) { |
| 2648 | int val = *negp ? -*lvalp : *lvalp; |
| 2649 | if ((param->min && *param->min > val) || |
| 2650 | (param->max && *param->max < val)) |
| 2651 | return -EINVAL; |
| 2652 | *valp = val; |
| 2653 | } else { |
| 2654 | int val = *valp; |
| 2655 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2656 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2657 | *lvalp = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2659 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2660 | *lvalp = (unsigned long)val; |
| 2661 | } |
| 2662 | } |
| 2663 | return 0; |
| 2664 | } |
| 2665 | |
| 2666 | /** |
| 2667 | * proc_dointvec_minmax - read a vector of integers with min/max values |
| 2668 | * @table: the sysctl table |
| 2669 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | * @buffer: the user buffer |
| 2671 | * @lenp: the size of the user buffer |
| 2672 | * @ppos: file position |
| 2673 | * |
| 2674 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2675 | * values from/to the user buffer, treated as an ASCII string. |
| 2676 | * |
| 2677 | * This routine will ensure the values are within the range specified by |
| 2678 | * table->extra1 (min) and table->extra2 (max). |
| 2679 | * |
Waiman Long | 24704f3 | 2018-04-10 16:35:38 -0700 | [diff] [blame] | 2680 | * Returns 0 on success or -EINVAL on write when the range check fails. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2681 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2682 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2684 | { |
| 2685 | struct do_proc_dointvec_minmax_conv_param param = { |
| 2686 | .min = (int *) table->extra1, |
| 2687 | .max = (int *) table->extra2, |
| 2688 | }; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2689 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2690 | do_proc_dointvec_minmax_conv, ¶m); |
| 2691 | } |
| 2692 | |
Waiman Long | 24704f3 | 2018-04-10 16:35:38 -0700 | [diff] [blame] | 2693 | /** |
| 2694 | * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure |
| 2695 | * @min: pointer to minimum allowable value |
| 2696 | * @max: pointer to maximum allowable value |
| 2697 | * |
| 2698 | * The do_proc_douintvec_minmax_conv_param structure provides the |
| 2699 | * minimum and maximum values for doing range checking for those sysctl |
| 2700 | * parameters that use the proc_douintvec_minmax() handler. |
| 2701 | */ |
Luis R. Rodriguez | 61d9b56 | 2017-07-12 14:33:40 -0700 | [diff] [blame] | 2702 | struct do_proc_douintvec_minmax_conv_param { |
| 2703 | unsigned int *min; |
| 2704 | unsigned int *max; |
| 2705 | }; |
| 2706 | |
| 2707 | static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, |
| 2708 | unsigned int *valp, |
| 2709 | int write, void *data) |
| 2710 | { |
| 2711 | struct do_proc_douintvec_minmax_conv_param *param = data; |
| 2712 | |
| 2713 | if (write) { |
| 2714 | unsigned int val = *lvalp; |
| 2715 | |
Joe Lawrence | fb910c4 | 2017-11-17 15:29:28 -0800 | [diff] [blame] | 2716 | if (*lvalp > UINT_MAX) |
| 2717 | return -EINVAL; |
| 2718 | |
Luis R. Rodriguez | 61d9b56 | 2017-07-12 14:33:40 -0700 | [diff] [blame] | 2719 | if ((param->min && *param->min > val) || |
| 2720 | (param->max && *param->max < val)) |
| 2721 | return -ERANGE; |
| 2722 | |
Luis R. Rodriguez | 61d9b56 | 2017-07-12 14:33:40 -0700 | [diff] [blame] | 2723 | *valp = val; |
| 2724 | } else { |
| 2725 | unsigned int val = *valp; |
| 2726 | *lvalp = (unsigned long) val; |
| 2727 | } |
| 2728 | |
| 2729 | return 0; |
| 2730 | } |
| 2731 | |
| 2732 | /** |
| 2733 | * proc_douintvec_minmax - read a vector of unsigned ints with min/max values |
| 2734 | * @table: the sysctl table |
| 2735 | * @write: %TRUE if this is a write to the sysctl file |
| 2736 | * @buffer: the user buffer |
| 2737 | * @lenp: the size of the user buffer |
| 2738 | * @ppos: file position |
| 2739 | * |
| 2740 | * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer |
| 2741 | * values from/to the user buffer, treated as an ASCII string. Negative |
| 2742 | * strings are not allowed. |
| 2743 | * |
| 2744 | * This routine will ensure the values are within the range specified by |
| 2745 | * table->extra1 (min) and table->extra2 (max). There is a final sanity |
| 2746 | * check for UINT_MAX to avoid having to support wrap around uses from |
| 2747 | * userspace. |
| 2748 | * |
Waiman Long | 24704f3 | 2018-04-10 16:35:38 -0700 | [diff] [blame] | 2749 | * Returns 0 on success or -ERANGE on write when the range check fails. |
Luis R. Rodriguez | 61d9b56 | 2017-07-12 14:33:40 -0700 | [diff] [blame] | 2750 | */ |
| 2751 | int proc_douintvec_minmax(struct ctl_table *table, int write, |
| 2752 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2753 | { |
| 2754 | struct do_proc_douintvec_minmax_conv_param param = { |
| 2755 | .min = (unsigned int *) table->extra1, |
| 2756 | .max = (unsigned int *) table->extra2, |
| 2757 | }; |
| 2758 | return do_proc_douintvec(table, write, buffer, lenp, ppos, |
| 2759 | do_proc_douintvec_minmax_conv, ¶m); |
| 2760 | } |
| 2761 | |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2762 | static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, |
| 2763 | unsigned int *valp, |
| 2764 | int write, void *data) |
| 2765 | { |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2766 | if (write) { |
Joe Lawrence | fb910c4 | 2017-11-17 15:29:28 -0800 | [diff] [blame] | 2767 | unsigned int val; |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2768 | |
Joe Lawrence | fb910c4 | 2017-11-17 15:29:28 -0800 | [diff] [blame] | 2769 | val = round_pipe_size(*lvalp); |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2770 | if (val == 0) |
| 2771 | return -EINVAL; |
| 2772 | |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2773 | *valp = val; |
| 2774 | } else { |
| 2775 | unsigned int val = *valp; |
| 2776 | *lvalp = (unsigned long) val; |
| 2777 | } |
| 2778 | |
| 2779 | return 0; |
| 2780 | } |
| 2781 | |
Eric Biggers | 319e0a2 | 2018-02-06 15:41:49 -0800 | [diff] [blame] | 2782 | static int proc_dopipe_max_size(struct ctl_table *table, int write, |
| 2783 | void __user *buffer, size_t *lenp, loff_t *ppos) |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2784 | { |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2785 | return do_proc_douintvec(table, write, buffer, lenp, ppos, |
Eric Biggers | 4c2e4be | 2018-02-06 15:41:45 -0800 | [diff] [blame] | 2786 | do_proc_dopipe_max_size_conv, NULL); |
Joe Lawrence | 7a8d181 | 2017-11-17 15:29:24 -0800 | [diff] [blame] | 2787 | } |
| 2788 | |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2789 | static void validate_coredump_safety(void) |
| 2790 | { |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2791 | #ifdef CONFIG_COREDUMP |
Kees Cook | e579d2c | 2013-02-27 17:03:15 -0800 | [diff] [blame] | 2792 | if (suid_dumpable == SUID_DUMP_ROOT && |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2793 | core_pattern[0] != '/' && core_pattern[0] != '|') { |
Alexey Dobriyan | 760c6a9 | 2016-12-14 15:04:14 -0800 | [diff] [blame] | 2794 | printk(KERN_WARNING |
| 2795 | "Unsafe core_pattern used with fs.suid_dumpable=2.\n" |
| 2796 | "Pipe handler or fully qualified core dump path required.\n" |
| 2797 | "Set kernel.core_pattern before fs.suid_dumpable.\n" |
| 2798 | ); |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2799 | } |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2800 | #endif |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2801 | } |
| 2802 | |
| 2803 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, |
| 2804 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2805 | { |
| 2806 | int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
| 2807 | if (!error) |
| 2808 | validate_coredump_safety(); |
| 2809 | return error; |
| 2810 | } |
| 2811 | |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2812 | #ifdef CONFIG_COREDUMP |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2813 | static int proc_dostring_coredump(struct ctl_table *table, int write, |
| 2814 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2815 | { |
| 2816 | int error = proc_dostring(table, write, buffer, lenp, ppos); |
| 2817 | if (!error) |
| 2818 | validate_coredump_safety(); |
| 2819 | return error; |
| 2820 | } |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2821 | #endif |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2822 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2823 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2824 | void __user *buffer, |
| 2825 | size_t *lenp, loff_t *ppos, |
| 2826 | unsigned long convmul, |
| 2827 | unsigned long convdiv) |
| 2828 | { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2829 | unsigned long *i, *min, *max; |
| 2830 | int vleft, first = 1, err = 0; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2831 | size_t left; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2832 | char *kbuf = NULL, *p; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2833 | |
| 2834 | if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2835 | *lenp = 0; |
| 2836 | return 0; |
| 2837 | } |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2838 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2839 | i = (unsigned long *) data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | min = (unsigned long *) table->extra1; |
| 2841 | max = (unsigned long *) table->extra2; |
| 2842 | vleft = table->maxlen / sizeof(unsigned long); |
| 2843 | left = *lenp; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2844 | |
| 2845 | if (write) { |
Luis R. Rodriguez | d383d48 | 2017-07-12 14:33:33 -0700 | [diff] [blame] | 2846 | if (proc_first_pos_non_zero_ignore(ppos, table)) |
| 2847 | goto out; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2848 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2849 | if (left > PAGE_SIZE - 1) |
| 2850 | left = PAGE_SIZE - 1; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2851 | p = kbuf = memdup_user_nul(buffer, left); |
| 2852 | if (IS_ERR(kbuf)) |
| 2853 | return PTR_ERR(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2854 | } |
| 2855 | |
Eric Dumazet | 27b3d80 | 2010-10-07 12:59:29 -0700 | [diff] [blame] | 2856 | for (; left && vleft--; i++, first = 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2857 | unsigned long val; |
| 2858 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2859 | if (write) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2860 | bool neg; |
| 2861 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2862 | left -= proc_skip_spaces(&p); |
Cheng Lin | 09be178 | 2019-01-03 15:26:13 -0800 | [diff] [blame] | 2863 | if (!left) |
| 2864 | break; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2865 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2866 | err = proc_get_long(&p, &left, &val, &neg, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2867 | proc_wspace_sep, |
| 2868 | sizeof(proc_wspace_sep), NULL); |
| 2869 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2870 | break; |
| 2871 | if (neg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2872 | continue; |
Eric Dumazet | ff9f8a7 | 2017-01-25 18:20:55 -0800 | [diff] [blame] | 2873 | val = convmul * val / convdiv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2874 | if ((min && val < *min) || (max && val > *max)) |
| 2875 | continue; |
| 2876 | *i = val; |
| 2877 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2878 | val = convdiv * (*i) / convmul; |
Chen Gang | 7833819 | 2013-11-12 15:11:21 -0800 | [diff] [blame] | 2879 | if (!first) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2880 | err = proc_put_char(&buffer, &left, '\t'); |
Chen Gang | 7833819 | 2013-11-12 15:11:21 -0800 | [diff] [blame] | 2881 | if (err) |
| 2882 | break; |
| 2883 | } |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2884 | err = proc_put_long(&buffer, &left, val, false); |
| 2885 | if (err) |
| 2886 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | } |
| 2888 | } |
| 2889 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2890 | if (!write && !first && left && !err) |
| 2891 | err = proc_put_char(&buffer, &left, '\n'); |
| 2892 | if (write && !err) |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2893 | left -= proc_skip_spaces(&p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2894 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2895 | kfree(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2896 | if (first) |
| 2897 | return err ? : -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2898 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2899 | *lenp -= left; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2900 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | *ppos += *lenp; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2902 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2903 | } |
| 2904 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2905 | static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2906 | void __user *buffer, |
| 2907 | size_t *lenp, loff_t *ppos, |
| 2908 | unsigned long convmul, |
| 2909 | unsigned long convdiv) |
| 2910 | { |
| 2911 | return __do_proc_doulongvec_minmax(table->data, table, write, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2912 | buffer, lenp, ppos, convmul, convdiv); |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2913 | } |
| 2914 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2915 | /** |
| 2916 | * proc_doulongvec_minmax - read a vector of long integers with min/max values |
| 2917 | * @table: the sysctl table |
| 2918 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2919 | * @buffer: the user buffer |
| 2920 | * @lenp: the size of the user buffer |
| 2921 | * @ppos: file position |
| 2922 | * |
| 2923 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
| 2924 | * values from/to the user buffer, treated as an ASCII string. |
| 2925 | * |
| 2926 | * This routine will ensure the values are within the range specified by |
| 2927 | * table->extra1 (min) and table->extra2 (max). |
| 2928 | * |
| 2929 | * Returns 0 on success. |
| 2930 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2931 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2932 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2933 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2934 | return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | } |
| 2936 | |
| 2937 | /** |
| 2938 | * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values |
| 2939 | * @table: the sysctl table |
| 2940 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | * @buffer: the user buffer |
| 2942 | * @lenp: the size of the user buffer |
| 2943 | * @ppos: file position |
| 2944 | * |
| 2945 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
| 2946 | * values from/to the user buffer, treated as an ASCII string. The values |
| 2947 | * are treated as milliseconds, and converted to jiffies when they are stored. |
| 2948 | * |
| 2949 | * This routine will ensure the values are within the range specified by |
| 2950 | * table->extra1 (min) and table->extra2 (max). |
| 2951 | * |
| 2952 | * Returns 0 on success. |
| 2953 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2954 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2955 | void __user *buffer, |
| 2956 | size_t *lenp, loff_t *ppos) |
| 2957 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2958 | return do_proc_doulongvec_minmax(table, write, buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2959 | lenp, ppos, HZ, 1000l); |
| 2960 | } |
| 2961 | |
| 2962 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2963 | static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2964 | int *valp, |
| 2965 | int write, void *data) |
| 2966 | { |
| 2967 | if (write) { |
Gao Feng | 6325945 | 2017-05-08 15:54:58 -0700 | [diff] [blame] | 2968 | if (*lvalp > INT_MAX / HZ) |
Bart Samwel | cba9f33 | 2006-03-24 03:15:50 -0800 | [diff] [blame] | 2969 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2970 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); |
| 2971 | } else { |
| 2972 | int val = *valp; |
| 2973 | unsigned long lval; |
| 2974 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2975 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2976 | lval = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2978 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2979 | lval = (unsigned long)val; |
| 2980 | } |
| 2981 | *lvalp = lval / HZ; |
| 2982 | } |
| 2983 | return 0; |
| 2984 | } |
| 2985 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2986 | static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2987 | int *valp, |
| 2988 | int write, void *data) |
| 2989 | { |
| 2990 | if (write) { |
Bart Samwel | cba9f33 | 2006-03-24 03:15:50 -0800 | [diff] [blame] | 2991 | if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) |
| 2992 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2993 | *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); |
| 2994 | } else { |
| 2995 | int val = *valp; |
| 2996 | unsigned long lval; |
| 2997 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2998 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2999 | lval = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3000 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 3001 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | lval = (unsigned long)val; |
| 3003 | } |
| 3004 | *lvalp = jiffies_to_clock_t(lval); |
| 3005 | } |
| 3006 | return 0; |
| 3007 | } |
| 3008 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 3009 | static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3010 | int *valp, |
| 3011 | int write, void *data) |
| 3012 | { |
| 3013 | if (write) { |
Francesco Fusco | d738ce8 | 2013-07-24 10:39:07 +0200 | [diff] [blame] | 3014 | unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); |
| 3015 | |
| 3016 | if (jif > INT_MAX) |
| 3017 | return 1; |
| 3018 | *valp = (int)jif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3019 | } else { |
| 3020 | int val = *valp; |
| 3021 | unsigned long lval; |
| 3022 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 3023 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 3024 | lval = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3025 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 3026 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3027 | lval = (unsigned long)val; |
| 3028 | } |
| 3029 | *lvalp = jiffies_to_msecs(lval); |
| 3030 | } |
| 3031 | return 0; |
| 3032 | } |
| 3033 | |
| 3034 | /** |
| 3035 | * proc_dointvec_jiffies - read a vector of integers as seconds |
| 3036 | * @table: the sysctl table |
| 3037 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3038 | * @buffer: the user buffer |
| 3039 | * @lenp: the size of the user buffer |
| 3040 | * @ppos: file position |
| 3041 | * |
| 3042 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 3043 | * values from/to the user buffer, treated as an ASCII string. |
| 3044 | * The values read are assumed to be in seconds, and are converted into |
| 3045 | * jiffies. |
| 3046 | * |
| 3047 | * Returns 0 on success. |
| 3048 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3049 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3050 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3051 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3052 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3053 | do_proc_dointvec_jiffies_conv,NULL); |
| 3054 | } |
| 3055 | |
| 3056 | /** |
| 3057 | * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds |
| 3058 | * @table: the sysctl table |
| 3059 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3060 | * @buffer: the user buffer |
| 3061 | * @lenp: the size of the user buffer |
Randy Dunlap | 1e5d533 | 2005-11-07 01:01:06 -0800 | [diff] [blame] | 3062 | * @ppos: pointer to the file position |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3063 | * |
| 3064 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 3065 | * values from/to the user buffer, treated as an ASCII string. |
| 3066 | * The values read are assumed to be in 1/USER_HZ seconds, and |
| 3067 | * are converted into jiffies. |
| 3068 | * |
| 3069 | * Returns 0 on success. |
| 3070 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3071 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3072 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3073 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3074 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3075 | do_proc_dointvec_userhz_jiffies_conv,NULL); |
| 3076 | } |
| 3077 | |
| 3078 | /** |
| 3079 | * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds |
| 3080 | * @table: the sysctl table |
| 3081 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3082 | * @buffer: the user buffer |
| 3083 | * @lenp: the size of the user buffer |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 3084 | * @ppos: file position |
| 3085 | * @ppos: the current position in the file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3086 | * |
| 3087 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 3088 | * values from/to the user buffer, treated as an ASCII string. |
| 3089 | * The values read are assumed to be in 1/1000 seconds, and |
| 3090 | * are converted into jiffies. |
| 3091 | * |
| 3092 | * Returns 0 on success. |
| 3093 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3094 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3095 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3096 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3097 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | do_proc_dointvec_ms_jiffies_conv, NULL); |
| 3099 | } |
| 3100 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3101 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 3102 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3103 | { |
| 3104 | struct pid *new_pid; |
| 3105 | pid_t tmp; |
| 3106 | int r; |
| 3107 | |
Pavel Emelyanov | 6c5f3e7 | 2008-02-08 04:19:20 -0800 | [diff] [blame] | 3108 | tmp = pid_vnr(cad_pid); |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 3109 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3110 | r = __do_proc_dointvec(&tmp, table, write, buffer, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 3111 | lenp, ppos, NULL, NULL); |
| 3112 | if (r || !write) |
| 3113 | return r; |
| 3114 | |
| 3115 | new_pid = find_get_pid(tmp); |
| 3116 | if (!new_pid) |
| 3117 | return -ESRCH; |
| 3118 | |
| 3119 | put_pid(xchg(&cad_pid, new_pid)); |
| 3120 | return 0; |
| 3121 | } |
| 3122 | |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3123 | /** |
| 3124 | * proc_do_large_bitmap - read/write from/to a large bitmap |
| 3125 | * @table: the sysctl table |
| 3126 | * @write: %TRUE if this is a write to the sysctl file |
| 3127 | * @buffer: the user buffer |
| 3128 | * @lenp: the size of the user buffer |
| 3129 | * @ppos: file position |
| 3130 | * |
| 3131 | * The bitmap is stored at table->data and the bitmap length (in bits) |
| 3132 | * in table->maxlen. |
| 3133 | * |
| 3134 | * We use a range comma separated format (e.g. 1,3-4,10-10) so that |
| 3135 | * large bitmaps may be represented in a compact manner. Writing into |
| 3136 | * the file will clear the bitmap then update it with the given input. |
| 3137 | * |
| 3138 | * Returns 0 on success. |
| 3139 | */ |
| 3140 | int proc_do_large_bitmap(struct ctl_table *table, int write, |
| 3141 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3142 | { |
| 3143 | int err = 0; |
| 3144 | bool first = 1; |
| 3145 | size_t left = *lenp; |
| 3146 | unsigned long bitmap_len = table->maxlen; |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 3147 | unsigned long *bitmap = *(unsigned long **) table->data; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3148 | unsigned long *tmp_bitmap = NULL; |
| 3149 | char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; |
| 3150 | |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 3151 | if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3152 | *lenp = 0; |
| 3153 | return 0; |
| 3154 | } |
| 3155 | |
| 3156 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3157 | char *kbuf, *p; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3158 | |
| 3159 | if (left > PAGE_SIZE - 1) |
| 3160 | left = PAGE_SIZE - 1; |
| 3161 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3162 | p = kbuf = memdup_user_nul(buffer, left); |
| 3163 | if (IS_ERR(kbuf)) |
| 3164 | return PTR_ERR(kbuf); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3165 | |
Kees Cook | 6396bb2 | 2018-06-12 14:03:40 -0700 | [diff] [blame] | 3166 | tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len), |
| 3167 | sizeof(unsigned long), |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3168 | GFP_KERNEL); |
| 3169 | if (!tmp_bitmap) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3170 | kfree(kbuf); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3171 | return -ENOMEM; |
| 3172 | } |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3173 | proc_skip_char(&p, &left, '\n'); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3174 | while (!err && left) { |
| 3175 | unsigned long val_a, val_b; |
| 3176 | bool neg; |
| 3177 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3178 | err = proc_get_long(&p, &left, &val_a, &neg, tr_a, |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3179 | sizeof(tr_a), &c); |
| 3180 | if (err) |
| 3181 | break; |
| 3182 | if (val_a >= bitmap_len || neg) { |
| 3183 | err = -EINVAL; |
| 3184 | break; |
| 3185 | } |
| 3186 | |
| 3187 | val_b = val_a; |
| 3188 | if (left) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3189 | p++; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3190 | left--; |
| 3191 | } |
| 3192 | |
| 3193 | if (c == '-') { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3194 | err = proc_get_long(&p, &left, &val_b, |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3195 | &neg, tr_b, sizeof(tr_b), |
| 3196 | &c); |
| 3197 | if (err) |
| 3198 | break; |
| 3199 | if (val_b >= bitmap_len || neg || |
| 3200 | val_a > val_b) { |
| 3201 | err = -EINVAL; |
| 3202 | break; |
| 3203 | } |
| 3204 | if (left) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3205 | p++; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3206 | left--; |
| 3207 | } |
| 3208 | } |
| 3209 | |
Akinobu Mita | 5a04cca | 2012-03-28 14:42:50 -0700 | [diff] [blame] | 3210 | bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3211 | first = 0; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3212 | proc_skip_char(&p, &left, '\n'); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3213 | } |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3214 | kfree(kbuf); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3215 | } else { |
| 3216 | unsigned long bit_a, bit_b = 0; |
| 3217 | |
| 3218 | while (left) { |
| 3219 | bit_a = find_next_bit(bitmap, bitmap_len, bit_b); |
| 3220 | if (bit_a >= bitmap_len) |
| 3221 | break; |
| 3222 | bit_b = find_next_zero_bit(bitmap, bitmap_len, |
| 3223 | bit_a + 1) - 1; |
| 3224 | |
| 3225 | if (!first) { |
| 3226 | err = proc_put_char(&buffer, &left, ','); |
| 3227 | if (err) |
| 3228 | break; |
| 3229 | } |
| 3230 | err = proc_put_long(&buffer, &left, bit_a, false); |
| 3231 | if (err) |
| 3232 | break; |
| 3233 | if (bit_a != bit_b) { |
| 3234 | err = proc_put_char(&buffer, &left, '-'); |
| 3235 | if (err) |
| 3236 | break; |
| 3237 | err = proc_put_long(&buffer, &left, bit_b, false); |
| 3238 | if (err) |
| 3239 | break; |
| 3240 | } |
| 3241 | |
| 3242 | first = 0; bit_b++; |
| 3243 | } |
| 3244 | if (!err) |
| 3245 | err = proc_put_char(&buffer, &left, '\n'); |
| 3246 | } |
| 3247 | |
| 3248 | if (!err) { |
| 3249 | if (write) { |
| 3250 | if (*ppos) |
| 3251 | bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); |
| 3252 | else |
Akinobu Mita | 5a04cca | 2012-03-28 14:42:50 -0700 | [diff] [blame] | 3253 | bitmap_copy(bitmap, tmp_bitmap, bitmap_len); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3254 | } |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3255 | *lenp -= left; |
| 3256 | *ppos += *lenp; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3257 | } |
Ola N. Kaldestad | f9eb2fd | 2017-11-17 15:30:26 -0800 | [diff] [blame] | 3258 | |
| 3259 | kfree(tmp_bitmap); |
| 3260 | return err; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3261 | } |
| 3262 | |
Jovi Zhang | 5561050 | 2011-01-12 17:00:45 -0800 | [diff] [blame] | 3263 | #else /* CONFIG_PROC_SYSCTL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3264 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3265 | int proc_dostring(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3266 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3267 | { |
| 3268 | return -ENOSYS; |
| 3269 | } |
| 3270 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3271 | int proc_dointvec(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3273 | { |
| 3274 | return -ENOSYS; |
| 3275 | } |
| 3276 | |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 3277 | int proc_douintvec(struct ctl_table *table, int write, |
| 3278 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3279 | { |
| 3280 | return -ENOSYS; |
| 3281 | } |
| 3282 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3283 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3284 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3285 | { |
| 3286 | return -ENOSYS; |
| 3287 | } |
| 3288 | |
Luis R. Rodriguez | 61d9b56 | 2017-07-12 14:33:40 -0700 | [diff] [blame] | 3289 | int proc_douintvec_minmax(struct ctl_table *table, int write, |
| 3290 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3291 | { |
| 3292 | return -ENOSYS; |
| 3293 | } |
| 3294 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3295 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3297 | { |
| 3298 | return -ENOSYS; |
| 3299 | } |
| 3300 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3301 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3302 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3303 | { |
| 3304 | return -ENOSYS; |
| 3305 | } |
| 3306 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3307 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3308 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3309 | { |
| 3310 | return -ENOSYS; |
| 3311 | } |
| 3312 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3313 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3315 | { |
| 3316 | return -ENOSYS; |
| 3317 | } |
| 3318 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 3319 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3320 | void __user *buffer, |
| 3321 | size_t *lenp, loff_t *ppos) |
| 3322 | { |
| 3323 | return -ENOSYS; |
| 3324 | } |
| 3325 | |
| 3326 | |
Jovi Zhang | 5561050 | 2011-01-12 17:00:45 -0800 | [diff] [blame] | 3327 | #endif /* CONFIG_PROC_SYSCTL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3328 | |
Alexei Starovoitov | 3fcc553 | 2019-02-27 18:30:44 -0800 | [diff] [blame] | 3329 | #ifdef CONFIG_BPF_SYSCALL |
Alexei Starovoitov | 492ecee | 2019-02-25 14:28:39 -0800 | [diff] [blame] | 3330 | static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write, |
| 3331 | void __user *buffer, size_t *lenp, |
| 3332 | loff_t *ppos) |
| 3333 | { |
| 3334 | int ret, bpf_stats = *(int *)table->data; |
| 3335 | struct ctl_table tmp = *table; |
| 3336 | |
| 3337 | if (write && !capable(CAP_SYS_ADMIN)) |
| 3338 | return -EPERM; |
| 3339 | |
| 3340 | tmp.data = &bpf_stats; |
| 3341 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
| 3342 | if (write && !ret) { |
| 3343 | *(int *)table->data = bpf_stats; |
| 3344 | if (bpf_stats) |
| 3345 | static_branch_enable(&bpf_stats_enabled_key); |
| 3346 | else |
| 3347 | static_branch_disable(&bpf_stats_enabled_key); |
| 3348 | } |
| 3349 | return ret; |
| 3350 | } |
Alexei Starovoitov | 3fcc553 | 2019-02-27 18:30:44 -0800 | [diff] [blame] | 3351 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | /* |
| 3353 | * No sense putting this after each symbol definition, twice, |
| 3354 | * exception granted :-) |
| 3355 | */ |
| 3356 | EXPORT_SYMBOL(proc_dointvec); |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 3357 | EXPORT_SYMBOL(proc_douintvec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3358 | EXPORT_SYMBOL(proc_dointvec_jiffies); |
| 3359 | EXPORT_SYMBOL(proc_dointvec_minmax); |
Luis R. Rodriguez | 61d9b56 | 2017-07-12 14:33:40 -0700 | [diff] [blame] | 3360 | EXPORT_SYMBOL_GPL(proc_douintvec_minmax); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3361 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); |
| 3362 | EXPORT_SYMBOL(proc_dointvec_ms_jiffies); |
| 3363 | EXPORT_SYMBOL(proc_dostring); |
| 3364 | EXPORT_SYMBOL(proc_doulongvec_minmax); |
| 3365 | EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); |