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