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