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