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