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