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