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