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