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