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