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