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