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