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