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