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