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