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