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