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