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