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