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