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