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