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