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