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