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