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