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