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