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