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