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