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