blob: d48ff4fd44c328eb3458390b79facac08734b7b9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Dave Youngd33ed522010-03-10 15:23:59 -080026#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080027#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070029#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020031#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070032#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/init.h>
34#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010035#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030036#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/sysrq.h>
38#include <linux/highuid.h>
39#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020040#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070041#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070044#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/times.h>
46#include <linux/limits.h>
47#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020048#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070050#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080051#include <linux/nfs_fs.h>
52#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070053#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020054#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020055#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050056#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020057#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070058#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040059#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070060#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000061#include <linux/binfmts.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63#include <asm/uaccess.h>
64#include <asm/processor.h>
65
Andi Kleen29cbc782006-09-30 01:47:55 +020066#ifdef CONFIG_X86
67#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010068#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010069#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020070#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080071#ifdef CONFIG_BSD_PROCESS_ACCT
72#include <linux/acct.h>
73#endif
Dave Young4f0e0562010-03-10 15:24:09 -080074#ifdef CONFIG_RT_MUTEXES
75#include <linux/rtmutex.h>
76#endif
Dave Young2edf5e42010-03-10 15:24:10 -080077#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
78#include <linux/lockdep.h>
79#endif
Dave Young15485a42010-03-10 15:24:07 -080080#ifdef CONFIG_CHR_DEV_SG
81#include <scsi/sg.h>
82#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020083
Don Zickus58687ac2010-05-07 17:11:44 -040084#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050085#include <linux/nmi.h>
86#endif
87
Eric W. Biederman7058cb02007-10-18 03:05:58 -070088
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#if defined(CONFIG_SYSCTL)
90
91/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092extern int sysctl_overcommit_memory;
93extern int sysctl_overcommit_ratio;
94extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070096extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070098extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern int pid_max;
100extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800102extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800103extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200104extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100105extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400106extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000107#ifndef CONFIG_MMU
108extern int sysctl_nr_trim_pages;
109#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200110#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200111extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700114/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400115#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200117static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118#endif
119
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700121static int __maybe_unused one = 1;
122static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700123static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800124static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700126#ifdef CONFIG_PRINTK
127static int ten_thousand = 10000;
128#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700130/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
131static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
134static int maxolduid = 65535;
135static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800136static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700139static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Dave Youngd14f1722010-02-25 20:28:57 -0500141#ifdef CONFIG_INOTIFY_USER
142#include <linux/inotify.h>
143#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700144#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700145#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif
147
David S. Miller08714202008-11-16 23:49:24 -0800148#ifdef CONFIG_SPARC64
149extern int sysctl_tsb_ratio;
150#endif
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#ifdef __hppa__
153extern int pwrsw_enabled;
154extern int unaligned_enabled;
155#endif
156
Jes Sorensend2b176e2006-02-28 09:42:23 -0800157#ifdef CONFIG_IA64
158extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800159extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800160#endif
161
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700162#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700163static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700164 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700165static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800166 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700167#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700168
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700169#ifdef CONFIG_PRINTK
170static int proc_dmesg_restrict(struct ctl_table *table, int write,
171 void __user *buffer, size_t *lenp, loff_t *ppos);
172#endif
173
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700174#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800175/* Note: sysrq code uses it's own private copy */
176static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700177
178static int sysrq_sysctl_handler(ctl_table *table, int write,
179 void __user *buffer, size_t *lenp,
180 loff_t *ppos)
181{
182 int error;
183
184 error = proc_dointvec(table, write, buffer, lenp, ppos);
185 if (error)
186 return error;
187
188 if (write)
189 sysrq_toggle_support(__sysrq_enabled);
190
191 return 0;
192}
193
194#endif
195
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700196static struct ctl_table kern_table[];
197static struct ctl_table vm_table[];
198static struct ctl_table fs_table[];
199static struct ctl_table debug_table[];
200static struct ctl_table dev_table[];
201extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800202#ifdef CONFIG_EPOLL
203extern struct ctl_table epoll_table[];
204#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
207int sysctl_legacy_va_layout;
208#endif
209
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210/* The default sysctl tables: */
211
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800212static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 .procname = "kernel",
215 .mode = 0555,
216 .child = kern_table,
217 },
218 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 .procname = "vm",
220 .mode = 0555,
221 .child = vm_table,
222 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 .procname = "fs",
225 .mode = 0555,
226 .child = fs_table,
227 },
228 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 .procname = "debug",
230 .mode = 0555,
231 .child = debug_table,
232 },
233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "dev",
235 .mode = 0555,
236 .child = dev_table,
237 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700238 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239};
240
Ingo Molnar77e54a12007-07-09 18:52:00 +0200241#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100242static int min_sched_granularity_ns = 100000; /* 100 usecs */
243static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
244static int min_wakeup_granularity_ns; /* 0 usecs */
245static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100246static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
247static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200248#endif
249
Mel Gorman5e771902010-05-24 14:32:31 -0700250#ifdef CONFIG_COMPACTION
251static int min_extfrag_threshold;
252static int max_extfrag_threshold = 1000;
253#endif
254
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700255static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200256 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200257 .procname = "sched_child_runs_first",
258 .data = &sysctl_sched_child_runs_first,
259 .maxlen = sizeof(unsigned int),
260 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800261 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200262 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200263#ifdef CONFIG_SCHED_DEBUG
264 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100265 .procname = "sched_min_granularity_ns",
266 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267 .maxlen = sizeof(unsigned int),
268 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800269 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100270 .extra1 = &min_sched_granularity_ns,
271 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200272 },
273 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200274 .procname = "sched_latency_ns",
275 .data = &sysctl_sched_latency,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800278 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200279 .extra1 = &min_sched_granularity_ns,
280 .extra2 = &max_sched_granularity_ns,
281 },
282 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283 .procname = "sched_wakeup_granularity_ns",
284 .data = &sysctl_sched_wakeup_granularity,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800287 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200288 .extra1 = &min_wakeup_granularity_ns,
289 .extra2 = &max_wakeup_granularity_ns,
290 },
291 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100292 .procname = "sched_tunable_scaling",
293 .data = &sysctl_sched_tunable_scaling,
294 .maxlen = sizeof(enum sched_tunable_scaling),
295 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800296 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100297 .extra1 = &min_sched_tunable_scaling,
298 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200299 },
300 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200301 .procname = "sched_migration_cost",
302 .data = &sysctl_sched_migration_cost,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800305 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200306 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100307 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100308 .procname = "sched_nr_migrate",
309 .data = &sysctl_sched_nr_migrate,
310 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100311 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800312 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100313 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530314 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200315 .procname = "sched_time_avg",
316 .data = &sysctl_sched_time_avg,
317 .maxlen = sizeof(unsigned int),
318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800319 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200320 },
321 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800322 .procname = "sched_shares_window",
323 .data = &sysctl_sched_shares_window,
324 .maxlen = sizeof(unsigned int),
325 .mode = 0644,
326 .proc_handler = proc_dointvec,
327 },
328 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530329 .procname = "timer_migration",
330 .data = &sysctl_timer_migration,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800333 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530334 .extra1 = &zero,
335 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530336 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200337#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200338 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100339 .procname = "sched_rt_period_us",
340 .data = &sysctl_sched_rt_period,
341 .maxlen = sizeof(unsigned int),
342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800343 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100344 },
345 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100346 .procname = "sched_rt_runtime_us",
347 .data = &sysctl_sched_rt_runtime,
348 .maxlen = sizeof(int),
349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800350 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100351 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100352#ifdef CONFIG_SCHED_AUTOGROUP
353 {
354 .procname = "sched_autogroup_enabled",
355 .data = &sysctl_sched_autogroup_enabled,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800358 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100359 .extra1 = &zero,
360 .extra2 = &one,
361 },
362#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700363#ifdef CONFIG_CFS_BANDWIDTH
364 {
365 .procname = "sched_cfs_bandwidth_slice_us",
366 .data = &sysctl_sched_cfs_bandwidth_slice,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec_minmax,
370 .extra1 = &one,
371 },
372#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700373#ifdef CONFIG_PROVE_LOCKING
374 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700375 .procname = "prove_locking",
376 .data = &prove_locking,
377 .maxlen = sizeof(int),
378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800379 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700380 },
381#endif
382#ifdef CONFIG_LOCK_STAT
383 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700384 .procname = "lock_stat",
385 .data = &lock_stat,
386 .maxlen = sizeof(int),
387 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800388 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700389 },
390#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200391 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 .procname = "panic",
393 .data = &panic_timeout,
394 .maxlen = sizeof(int),
395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800396 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 },
398 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 .procname = "core_uses_pid",
400 .data = &core_uses_pid,
401 .maxlen = sizeof(int),
402 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800403 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 },
405 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 .procname = "core_pattern",
407 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700408 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800410 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 },
Neil Hormana2939802009-09-23 15:56:56 -0700412 {
Neil Hormana2939802009-09-23 15:56:56 -0700413 .procname = "core_pipe_limit",
414 .data = &core_pipe_limit,
415 .maxlen = sizeof(unsigned int),
416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800417 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700418 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800419#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700422 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800424 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800426#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100427#ifdef CONFIG_LATENCYTOP
428 {
429 .procname = "latencytop",
430 .data = &latencytop_enabled,
431 .maxlen = sizeof(int),
432 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800433 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100434 },
435#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436#ifdef CONFIG_BLK_DEV_INITRD
437 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 .procname = "real-root-dev",
439 .data = &real_root_dev,
440 .maxlen = sizeof(int),
441 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800442 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 },
444#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700445 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700446 .procname = "print-fatal-signals",
447 .data = &print_fatal_signals,
448 .maxlen = sizeof(int),
449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800450 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700451 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700452#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 .procname = "reboot-cmd",
455 .data = reboot_command,
456 .maxlen = 256,
457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800458 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 },
460 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 .procname = "stop-a",
462 .data = &stop_a_enabled,
463 .maxlen = sizeof (int),
464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800465 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 },
467 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 .procname = "scons-poweroff",
469 .data = &scons_pwroff,
470 .maxlen = sizeof (int),
471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800472 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 },
474#endif
David S. Miller08714202008-11-16 23:49:24 -0800475#ifdef CONFIG_SPARC64
476 {
David S. Miller08714202008-11-16 23:49:24 -0800477 .procname = "tsb-ratio",
478 .data = &sysctl_tsb_ratio,
479 .maxlen = sizeof (int),
480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800481 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800482 },
483#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484#ifdef __hppa__
485 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 .procname = "soft-power",
487 .data = &pwrsw_enabled,
488 .maxlen = sizeof (int),
489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800490 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 },
492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 .procname = "unaligned-trap",
494 .data = &unaligned_enabled,
495 .maxlen = sizeof (int),
496 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800497 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 },
499#endif
500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 .procname = "ctrl-alt-del",
502 .data = &C_A_D,
503 .maxlen = sizeof(int),
504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400507#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200508 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200509 .procname = "ftrace_enabled",
510 .data = &ftrace_enabled,
511 .maxlen = sizeof(int),
512 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800513 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200514 },
515#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500516#ifdef CONFIG_STACK_TRACER
517 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500518 .procname = "stack_tracer_enabled",
519 .data = &stack_tracer_enabled,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500523 },
524#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400525#ifdef CONFIG_TRACING
526 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100527 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400528 .data = &ftrace_dump_on_oops,
529 .maxlen = sizeof(int),
530 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800531 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400532 },
533#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200534#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 .procname = "modprobe",
537 .data = &modprobe_path,
538 .maxlen = KMOD_PATH_LEN,
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 },
Kees Cook3d433212009-04-02 15:49:29 -0700542 {
Kees Cook3d433212009-04-02 15:49:29 -0700543 .procname = "modules_disabled",
544 .data = &modules_disabled,
545 .maxlen = sizeof(int),
546 .mode = 0644,
547 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700549 .extra1 = &one,
550 .extra2 = &one,
551 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100553#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100556 .data = &uevent_helper,
557 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800559 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 },
561#endif
562#ifdef CONFIG_CHR_DEV_SG
563 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 .procname = "sg-big-buff",
565 .data = &sg_big_buff,
566 .maxlen = sizeof (int),
567 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800568 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 },
570#endif
571#ifdef CONFIG_BSD_PROCESS_ACCT
572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 .procname = "acct",
574 .data = &acct_parm,
575 .maxlen = 3*sizeof(int),
576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800577 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 },
579#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580#ifdef CONFIG_MAGIC_SYSRQ
581 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800583 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 .maxlen = sizeof (int),
585 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700586 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 },
588#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700589#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700592 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .maxlen = sizeof (int),
594 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800595 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700597#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .procname = "threads-max",
600 .data = &max_threads,
601 .maxlen = sizeof(int),
602 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800603 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 },
605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "random",
607 .mode = 0555,
608 .child = random_table,
609 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 {
Eric Paris17f60a72011-04-01 17:07:50 -0400611 .procname = "usermodehelper",
612 .mode = 0555,
613 .child = usermodehelper_table,
614 },
615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "overflowuid",
617 .data = &overflowuid,
618 .maxlen = sizeof(int),
619 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800620 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .extra1 = &minolduid,
622 .extra2 = &maxolduid,
623 },
624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "overflowgid",
626 .data = &overflowgid,
627 .maxlen = sizeof(int),
628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .extra1 = &minolduid,
631 .extra2 = &maxolduid,
632 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800633#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634#ifdef CONFIG_MATHEMU
635 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 .procname = "ieee_emulation_warnings",
637 .data = &sysctl_ieee_emulation_warnings,
638 .maxlen = sizeof(int),
639 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800640 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 },
642#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200645 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 .maxlen = sizeof(int),
647 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800648 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 },
650#endif
651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 .procname = "pid_max",
653 .data = &pid_max,
654 .maxlen = sizeof (int),
655 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800656 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .extra1 = &pid_max_min,
658 .extra2 = &pid_max_max,
659 },
660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "panic_on_oops",
662 .data = &panic_on_oops,
663 .maxlen = sizeof(int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800667#if defined CONFIG_PRINTK
668 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800669 .procname = "printk",
670 .data = &console_loglevel,
671 .maxlen = 4*sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800674 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700677 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .maxlen = sizeof(int),
679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700684 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .maxlen = sizeof(int),
686 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 },
Dave Youngaf913222009-09-22 16:43:33 -0700689 {
Dave Youngaf913222009-09-22 16:43:33 -0700690 .procname = "printk_delay",
691 .data = &printk_delay_msec,
692 .maxlen = sizeof(int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700695 .extra1 = &zero,
696 .extra2 = &ten_thousand,
697 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800699 .procname = "dmesg_restrict",
700 .data = &dmesg_restrict,
701 .maxlen = sizeof(int),
702 .mode = 0644,
703 .proc_handler = proc_dointvec_minmax,
704 .extra1 = &zero,
705 .extra2 = &one,
706 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800707 {
708 .procname = "kptr_restrict",
709 .data = &kptr_restrict,
710 .maxlen = sizeof(int),
711 .mode = 0644,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700712 .proc_handler = proc_dmesg_restrict,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800713 .extra1 = &zero,
714 .extra2 = &two,
715 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800716#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "ngroups_max",
719 .data = &ngroups_max,
720 .maxlen = sizeof (int),
721 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
Dan Ballard73efc032011-10-31 17:11:20 -0700724 {
725 .procname = "cap_last_cap",
726 .data = (void *)&cap_last_cap,
727 .maxlen = sizeof(int),
728 .mode = 0444,
729 .proc_handler = proc_dointvec,
730 },
Don Zickus58687ac2010-05-07 17:11:44 -0400731#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500732 {
Don Zickus58687ac2010-05-07 17:11:44 -0400733 .procname = "watchdog",
734 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500735 .maxlen = sizeof (int),
736 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700737 .proc_handler = proc_dowatchdog,
738 .extra1 = &zero,
739 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400740 },
741 {
742 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700743 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400744 .maxlen = sizeof(int),
745 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700746 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400747 .extra1 = &neg_one,
748 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500749 },
Don Zickus2508ce12010-05-07 17:11:46 -0400750 {
751 .procname = "softlockup_panic",
752 .data = &softlockup_panic,
753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = proc_dointvec_minmax,
756 .extra1 = &zero,
757 .extra2 = &one,
758 },
Don Zickus5dc30552010-11-29 17:07:17 -0500759 {
760 .procname = "nmi_watchdog",
761 .data = &watchdog_enabled,
762 .maxlen = sizeof (int),
763 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700764 .proc_handler = proc_dowatchdog,
765 .extra1 = &zero,
766 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500767 },
768#endif
769#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
770 {
771 .procname = "unknown_nmi_panic",
772 .data = &unknown_nmi_panic,
773 .maxlen = sizeof (int),
774 .mode = 0644,
775 .proc_handler = proc_dointvec,
776 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500777#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778#if defined(CONFIG_X86)
779 {
Don Zickus8da5add2006-09-26 10:52:27 +0200780 .procname = "panic_on_unrecovered_nmi",
781 .data = &panic_on_unrecovered_nmi,
782 .maxlen = sizeof(int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200785 },
786 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700787 .procname = "panic_on_io_nmi",
788 .data = &panic_on_io_nmi,
789 .maxlen = sizeof(int),
790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700792 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900793#ifdef CONFIG_DEBUG_STACKOVERFLOW
794 {
795 .procname = "panic_on_stackoverflow",
796 .data = &sysctl_panic_on_stackoverflow,
797 .maxlen = sizeof(int),
798 .mode = 0644,
799 .proc_handler = proc_dointvec,
800 },
801#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700802 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 .procname = "bootloader_type",
804 .data = &bootloader_type,
805 .maxlen = sizeof (int),
806 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100809 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700810 .procname = "bootloader_version",
811 .data = &bootloader_version,
812 .maxlen = sizeof (int),
813 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800814 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700815 },
816 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100817 .procname = "kstack_depth_to_print",
818 .data = &kstack_depth_to_print,
819 .maxlen = sizeof(int),
820 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800821 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100822 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100823 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100824 .procname = "io_delay_type",
825 .data = &io_delay_type,
826 .maxlen = sizeof(int),
827 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800828 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100829 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800831#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 .procname = "randomize_va_space",
834 .data = &randomize_va_space,
835 .maxlen = sizeof(int),
836 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800837 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800839#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800840#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700841 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700842 .procname = "spin_retry",
843 .data = &spin_retry,
844 .maxlen = sizeof (int),
845 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800846 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700847 },
848#endif
Len Brown673d5b42007-07-28 03:33:16 -0400849#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800850 {
Pavel Machekc255d842006-02-20 18:27:58 -0800851 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700852 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800853 .maxlen = sizeof (unsigned long),
854 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800855 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800856 },
857#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800858#ifdef CONFIG_IA64
859 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800860 .procname = "ignore-unaligned-usertrap",
861 .data = &no_unaligned_warning,
862 .maxlen = sizeof (int),
863 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800864 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800865 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800866 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800867 .procname = "unaligned-dump-stack",
868 .data = &unaligned_dump_stack,
869 .maxlen = sizeof (int),
870 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800871 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800872 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800873#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800874#ifdef CONFIG_DETECT_HUNG_TASK
875 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800876 .procname = "hung_task_panic",
877 .data = &sysctl_hung_task_panic,
878 .maxlen = sizeof(int),
879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800880 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800881 .extra1 = &zero,
882 .extra2 = &one,
883 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100884 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100885 .procname = "hung_task_check_count",
886 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100887 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100888 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800889 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100890 },
891 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100892 .procname = "hung_task_timeout_secs",
893 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100894 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100895 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800896 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100897 },
898 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100899 .procname = "hung_task_warnings",
900 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100901 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100902 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800903 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100904 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700905#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200906#ifdef CONFIG_COMPAT
907 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200908 .procname = "compat-log",
909 .data = &compat_log,
910 .maxlen = sizeof (int),
911 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200913 },
914#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700915#ifdef CONFIG_RT_MUTEXES
916 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700917 .procname = "max_lock_depth",
918 .data = &max_lock_depth,
919 .maxlen = sizeof(int),
920 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800921 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700922 },
923#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700924 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700925 .procname = "poweroff_cmd",
926 .data = &poweroff_cmd,
927 .maxlen = POWEROFF_CMD_PATH_LEN,
928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700930 },
David Howells0b77f5b2008-04-29 01:01:32 -0700931#ifdef CONFIG_KEYS
932 {
David Howells0b77f5b2008-04-29 01:01:32 -0700933 .procname = "keys",
934 .mode = 0555,
935 .child = key_sysctls,
936 },
937#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700938#ifdef CONFIG_RCU_TORTURE_TEST
939 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700940 .procname = "rcutorture_runnable",
941 .data = &rcutorture_runnable,
942 .maxlen = sizeof(int),
943 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800944 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700945 },
946#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200947#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400948 /*
949 * User-space scripts rely on the existence of this file
950 * as a feature check for perf_events being enabled.
951 *
952 * So it's an ABI, do not remove!
953 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200954 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200955 .procname = "perf_event_paranoid",
956 .data = &sysctl_perf_event_paranoid,
957 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200960 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200961 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200962 .procname = "perf_event_mlock_kb",
963 .data = &sysctl_perf_event_mlock,
964 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200965 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800966 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200967 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200968 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200969 .procname = "perf_event_max_sample_rate",
970 .data = &sysctl_perf_event_sample_rate,
971 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200972 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100973 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200974 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200975#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200976#ifdef CONFIG_KMEMCHECK
977 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200978 .procname = "kmemcheck",
979 .data = &kmemcheck_enabled,
980 .maxlen = sizeof(int),
981 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800982 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200983 },
984#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200985#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200986 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200987 .procname = "blk_iopoll",
988 .data = &blk_iopoll_enabled,
989 .maxlen = sizeof(int),
990 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200992 },
Jens Axboecb684b52009-09-15 21:53:11 +0200993#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700994 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995};
996
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700997static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 .procname = "overcommit_memory",
1000 .data = &sysctl_overcommit_memory,
1001 .maxlen = sizeof(sysctl_overcommit_memory),
1002 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001003 .proc_handler = proc_dointvec_minmax,
1004 .extra1 = &zero,
1005 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 },
1007 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001008 .procname = "panic_on_oom",
1009 .data = &sysctl_panic_on_oom,
1010 .maxlen = sizeof(sysctl_panic_on_oom),
1011 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001012 .proc_handler = proc_dointvec_minmax,
1013 .extra1 = &zero,
1014 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001015 },
1016 {
David Rientjesfe071d72007-10-16 23:25:56 -07001017 .procname = "oom_kill_allocating_task",
1018 .data = &sysctl_oom_kill_allocating_task,
1019 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1020 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001021 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001022 },
1023 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001024 .procname = "oom_dump_tasks",
1025 .data = &sysctl_oom_dump_tasks,
1026 .maxlen = sizeof(sysctl_oom_dump_tasks),
1027 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001028 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001029 },
1030 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 .procname = "overcommit_ratio",
1032 .data = &sysctl_overcommit_ratio,
1033 .maxlen = sizeof(sysctl_overcommit_ratio),
1034 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001035 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 },
1037 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 .procname = "page-cluster",
1039 .data = &page_cluster,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001042 .proc_handler = proc_dointvec_minmax,
1043 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 },
1045 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 .procname = "dirty_background_ratio",
1047 .data = &dirty_background_ratio,
1048 .maxlen = sizeof(dirty_background_ratio),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 .extra1 = &zero,
1052 .extra2 = &one_hundred,
1053 },
1054 {
David Rientjes2da02992009-01-06 14:39:31 -08001055 .procname = "dirty_background_bytes",
1056 .data = &dirty_background_bytes,
1057 .maxlen = sizeof(dirty_background_bytes),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001060 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001061 },
1062 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 .procname = "dirty_ratio",
1064 .data = &vm_dirty_ratio,
1065 .maxlen = sizeof(vm_dirty_ratio),
1066 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001067 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 .extra1 = &zero,
1069 .extra2 = &one_hundred,
1070 },
1071 {
David Rientjes2da02992009-01-06 14:39:31 -08001072 .procname = "dirty_bytes",
1073 .data = &vm_dirty_bytes,
1074 .maxlen = sizeof(vm_dirty_bytes),
1075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001077 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001078 },
1079 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001081 .data = &dirty_writeback_interval,
1082 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001084 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 },
1086 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001088 .data = &dirty_expire_interval,
1089 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001091 .proc_handler = proc_dointvec_minmax,
1092 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 },
1094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "nr_pdflush_threads",
1096 .data = &nr_pdflush_threads,
1097 .maxlen = sizeof nr_pdflush_threads,
1098 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 },
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .procname = "swappiness",
1103 .data = &vm_swappiness,
1104 .maxlen = sizeof(vm_swappiness),
1105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 .extra1 = &zero,
1108 .extra2 = &one_hundred,
1109 },
1110#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001113 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 .maxlen = sizeof(unsigned long),
1115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 .extra1 = (void *)&hugetlb_zero,
1118 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001119 },
1120#ifdef CONFIG_NUMA
1121 {
1122 .procname = "nr_hugepages_mempolicy",
1123 .data = NULL,
1124 .maxlen = sizeof(unsigned long),
1125 .mode = 0644,
1126 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1127 .extra1 = (void *)&hugetlb_zero,
1128 .extra2 = (void *)&hugetlb_infinity,
1129 },
1130#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 .procname = "hugetlb_shm_group",
1133 .data = &sysctl_hugetlb_shm_group,
1134 .maxlen = sizeof(gid_t),
1135 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001136 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 },
Mel Gorman396faf02007-07-17 04:03:13 -07001138 {
Mel Gorman396faf02007-07-17 04:03:13 -07001139 .procname = "hugepages_treat_as_movable",
1140 .data = &hugepages_treat_as_movable,
1141 .maxlen = sizeof(int),
1142 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001143 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001144 },
Adam Litke54f9f802007-10-16 01:26:20 -07001145 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001146 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001147 .data = NULL,
1148 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001149 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001150 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001151 .extra1 = (void *)&hugetlb_zero,
1152 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001153 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154#endif
1155 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 .procname = "lowmem_reserve_ratio",
1157 .data = &sysctl_lowmem_reserve_ratio,
1158 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1159 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001160 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 },
1162 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001163 .procname = "drop_caches",
1164 .data = &sysctl_drop_caches,
1165 .maxlen = sizeof(int),
1166 .mode = 0644,
1167 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001168 .extra1 = &one,
1169 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001170 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001171#ifdef CONFIG_COMPACTION
1172 {
1173 .procname = "compact_memory",
1174 .data = &sysctl_compact_memory,
1175 .maxlen = sizeof(int),
1176 .mode = 0200,
1177 .proc_handler = sysctl_compaction_handler,
1178 },
Mel Gorman5e771902010-05-24 14:32:31 -07001179 {
1180 .procname = "extfrag_threshold",
1181 .data = &sysctl_extfrag_threshold,
1182 .maxlen = sizeof(int),
1183 .mode = 0644,
1184 .proc_handler = sysctl_extfrag_handler,
1185 .extra1 = &min_extfrag_threshold,
1186 .extra2 = &max_extfrag_threshold,
1187 },
1188
Mel Gorman76ab0f52010-05-24 14:32:28 -07001189#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001190 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 .procname = "min_free_kbytes",
1192 .data = &min_free_kbytes,
1193 .maxlen = sizeof(min_free_kbytes),
1194 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001195 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 .extra1 = &zero,
1197 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001198 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001199 .procname = "percpu_pagelist_fraction",
1200 .data = &percpu_pagelist_fraction,
1201 .maxlen = sizeof(percpu_pagelist_fraction),
1202 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001203 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001204 .extra1 = &min_percpu_pagelist_fract,
1205 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206#ifdef CONFIG_MMU
1207 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 .procname = "max_map_count",
1209 .data = &sysctl_max_map_count,
1210 .maxlen = sizeof(sysctl_max_map_count),
1211 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001212 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001213 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001215#else
1216 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001217 .procname = "nr_trim_pages",
1218 .data = &sysctl_nr_trim_pages,
1219 .maxlen = sizeof(sysctl_nr_trim_pages),
1220 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001221 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001222 .extra1 = &zero,
1223 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224#endif
1225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 .procname = "laptop_mode",
1227 .data = &laptop_mode,
1228 .maxlen = sizeof(laptop_mode),
1229 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001230 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 },
1232 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 .procname = "block_dump",
1234 .data = &block_dump,
1235 .maxlen = sizeof(block_dump),
1236 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001237 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 .extra1 = &zero,
1239 },
1240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 .procname = "vfs_cache_pressure",
1242 .data = &sysctl_vfs_cache_pressure,
1243 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1244 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001245 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 .extra1 = &zero,
1247 },
1248#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 .procname = "legacy_va_layout",
1251 .data = &sysctl_legacy_va_layout,
1252 .maxlen = sizeof(sysctl_legacy_va_layout),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .extra1 = &zero,
1256 },
1257#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001258#ifdef CONFIG_NUMA
1259 {
Christoph Lameter17436602006-01-18 17:42:32 -08001260 .procname = "zone_reclaim_mode",
1261 .data = &zone_reclaim_mode,
1262 .maxlen = sizeof(zone_reclaim_mode),
1263 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001264 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001265 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001266 },
Christoph Lameter96146342006-07-03 00:24:13 -07001267 {
Christoph Lameter96146342006-07-03 00:24:13 -07001268 .procname = "min_unmapped_ratio",
1269 .data = &sysctl_min_unmapped_ratio,
1270 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1271 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001272 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001273 .extra1 = &zero,
1274 .extra2 = &one_hundred,
1275 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001276 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001277 .procname = "min_slab_ratio",
1278 .data = &sysctl_min_slab_ratio,
1279 .maxlen = sizeof(sysctl_min_slab_ratio),
1280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001282 .extra1 = &zero,
1283 .extra2 = &one_hundred,
1284 },
Christoph Lameter17436602006-01-18 17:42:32 -08001285#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001286#ifdef CONFIG_SMP
1287 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001288 .procname = "stat_interval",
1289 .data = &sysctl_stat_interval,
1290 .maxlen = sizeof(sysctl_stat_interval),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001293 },
1294#endif
David Howells6e141542009-12-15 19:27:45 +00001295#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001296 {
Eric Parised032182007-06-28 15:55:21 -04001297 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001298 .data = &dac_mmap_min_addr,
1299 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001300 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001302 },
David Howells6e141542009-12-15 19:27:45 +00001303#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001304#ifdef CONFIG_NUMA
1305 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001306 .procname = "numa_zonelist_order",
1307 .data = &numa_zonelist_order,
1308 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1309 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001310 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001311 },
1312#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001313#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001314 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001315 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001316 .procname = "vdso_enabled",
1317 .data = &vdso_enabled,
1318 .maxlen = sizeof(vdso_enabled),
1319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001320 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001321 .extra1 = &zero,
1322 },
1323#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001324#ifdef CONFIG_HIGHMEM
1325 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001326 .procname = "highmem_is_dirtyable",
1327 .data = &vm_highmem_is_dirtyable,
1328 .maxlen = sizeof(vm_highmem_is_dirtyable),
1329 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001330 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001331 .extra1 = &zero,
1332 .extra2 = &one,
1333 },
1334#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001335 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001336 .procname = "scan_unevictable_pages",
1337 .data = &scan_unevictable_pages,
1338 .maxlen = sizeof(scan_unevictable_pages),
1339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001340 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001341 },
Andi Kleen6a460792009-09-16 11:50:15 +02001342#ifdef CONFIG_MEMORY_FAILURE
1343 {
Andi Kleen6a460792009-09-16 11:50:15 +02001344 .procname = "memory_failure_early_kill",
1345 .data = &sysctl_memory_failure_early_kill,
1346 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1347 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001348 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001349 .extra1 = &zero,
1350 .extra2 = &one,
1351 },
1352 {
Andi Kleen6a460792009-09-16 11:50:15 +02001353 .procname = "memory_failure_recovery",
1354 .data = &sysctl_memory_failure_recovery,
1355 .maxlen = sizeof(sysctl_memory_failure_recovery),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001358 .extra1 = &zero,
1359 .extra2 = &one,
1360 },
1361#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001362 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363};
1364
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001365#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001366static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001367 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001368};
1369#endif
1370
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001371static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 .procname = "inode-nr",
1374 .data = &inodes_stat,
1375 .maxlen = 2*sizeof(int),
1376 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001377 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 },
1379 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 .procname = "inode-state",
1381 .data = &inodes_stat,
1382 .maxlen = 7*sizeof(int),
1383 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001384 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 },
1386 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 .procname = "file-nr",
1388 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001389 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001391 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 },
1393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 .procname = "file-max",
1395 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001396 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001398 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 },
1400 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001401 .procname = "nr_open",
1402 .data = &sysctl_nr_open,
1403 .maxlen = sizeof(int),
1404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001406 .extra1 = &sysctl_nr_open_min,
1407 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001408 },
1409 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410 .procname = "dentry-state",
1411 .data = &dentry_stat,
1412 .maxlen = 6*sizeof(int),
1413 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001414 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001415 },
1416 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001417 .procname = "overflowuid",
1418 .data = &fs_overflowuid,
1419 .maxlen = sizeof(int),
1420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001421 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 .extra1 = &minolduid,
1423 .extra2 = &maxolduid,
1424 },
1425 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001426 .procname = "overflowgid",
1427 .data = &fs_overflowgid,
1428 .maxlen = sizeof(int),
1429 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001430 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 .extra1 = &minolduid,
1432 .extra2 = &maxolduid,
1433 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001434#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 .procname = "leases-enable",
1437 .data = &leases_enable,
1438 .maxlen = sizeof(int),
1439 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001440 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001442#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443#ifdef CONFIG_DNOTIFY
1444 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 .procname = "dir-notify-enable",
1446 .data = &dir_notify_enable,
1447 .maxlen = sizeof(int),
1448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001449 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 },
1451#endif
1452#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001453#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 .procname = "lease-break-time",
1456 .data = &lease_break_time,
1457 .maxlen = sizeof(int),
1458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001461#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001462#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "aio-nr",
1465 .data = &aio_nr,
1466 .maxlen = sizeof(aio_nr),
1467 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001468 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 },
1470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 .procname = "aio-max-nr",
1472 .data = &aio_max_nr,
1473 .maxlen = sizeof(aio_max_nr),
1474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001475 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001477#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001478#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001479 {
Robert Love0399cb02005-07-13 12:38:18 -04001480 .procname = "inotify",
1481 .mode = 0555,
1482 .child = inotify_table,
1483 },
1484#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001485#ifdef CONFIG_EPOLL
1486 {
1487 .procname = "epoll",
1488 .mode = 0555,
1489 .child = epoll_table,
1490 },
1491#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001493 {
Alan Coxd6e71142005-06-23 00:09:43 -07001494 .procname = "suid_dumpable",
1495 .data = &suid_dumpable,
1496 .maxlen = sizeof(int),
1497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001498 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001499 .extra1 = &zero,
1500 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001501 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001502#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1503 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001504 .procname = "binfmt_misc",
1505 .mode = 0555,
1506 .child = binfmt_misc_table,
1507 },
1508#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001509 {
Jens Axboeff9da692010-06-03 14:54:39 +02001510 .procname = "pipe-max-size",
1511 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001512 .maxlen = sizeof(int),
1513 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001514 .proc_handler = &pipe_proc_fn,
1515 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001516 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001517 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518};
1519
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001520static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001521#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001522 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001523 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001524 .procname = "exception-trace",
1525 .data = &show_unhandled_signals,
1526 .maxlen = sizeof(int),
1527 .mode = 0644,
1528 .proc_handler = proc_dointvec
1529 },
1530#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001531#if defined(CONFIG_OPTPROBES)
1532 {
1533 .procname = "kprobes-optimization",
1534 .data = &sysctl_kprobes_optimization,
1535 .maxlen = sizeof(int),
1536 .mode = 0644,
1537 .proc_handler = proc_kprobes_optimization_handler,
1538 .extra1 = &zero,
1539 .extra2 = &one,
1540 },
1541#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001542 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543};
1544
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001545static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001546 { }
Robert Love0eeca282005-07-12 17:06:03 -04001547};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001549int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001550{
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001551 register_sysctl_table(sysctl_base_table);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001552 return 0;
1553}
1554
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001555#endif /* CONFIG_SYSCTL */
1556
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557/*
1558 * /proc/sys support
1559 */
1560
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001561#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001563static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001564 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001565 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001566{
1567 size_t len;
1568 char __user *p;
1569 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001570
1571 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001572 *lenp = 0;
1573 return 0;
1574 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001575
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001576 if (write) {
1577 len = 0;
1578 p = buffer;
1579 while (len < *lenp) {
1580 if (get_user(c, p++))
1581 return -EFAULT;
1582 if (c == 0 || c == '\n')
1583 break;
1584 len++;
1585 }
1586 if (len >= maxlen)
1587 len = maxlen-1;
1588 if(copy_from_user(data, buffer, len))
1589 return -EFAULT;
1590 ((char *) data)[len] = 0;
1591 *ppos += *lenp;
1592 } else {
1593 len = strlen(data);
1594 if (len > maxlen)
1595 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001596
1597 if (*ppos > len) {
1598 *lenp = 0;
1599 return 0;
1600 }
1601
1602 data += *ppos;
1603 len -= *ppos;
1604
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001605 if (len > *lenp)
1606 len = *lenp;
1607 if (len)
1608 if(copy_to_user(buffer, data, len))
1609 return -EFAULT;
1610 if (len < *lenp) {
1611 if(put_user('\n', ((char __user *) buffer) + len))
1612 return -EFAULT;
1613 len++;
1614 }
1615 *lenp = len;
1616 *ppos += len;
1617 }
1618 return 0;
1619}
1620
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621/**
1622 * proc_dostring - read a string sysctl
1623 * @table: the sysctl table
1624 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625 * @buffer: the user buffer
1626 * @lenp: the size of the user buffer
1627 * @ppos: file position
1628 *
1629 * Reads/writes a string from/to the user buffer. If the kernel
1630 * buffer provided is not large enough to hold the string, the
1631 * string is truncated. The copied string is %NULL-terminated.
1632 * If the string is being read by the user process, it is copied
1633 * and a newline '\n' is added. It is truncated if the buffer is
1634 * not large enough.
1635 *
1636 * Returns 0 on success.
1637 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001638int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639 void __user *buffer, size_t *lenp, loff_t *ppos)
1640{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001641 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001642 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001643}
1644
Amerigo Wang00b7c332010-05-05 00:26:45 +00001645static size_t proc_skip_spaces(char **buf)
1646{
1647 size_t ret;
1648 char *tmp = skip_spaces(*buf);
1649 ret = tmp - *buf;
1650 *buf = tmp;
1651 return ret;
1652}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001654static void proc_skip_char(char **buf, size_t *size, const char v)
1655{
1656 while (*size) {
1657 if (**buf != v)
1658 break;
1659 (*size)--;
1660 (*buf)++;
1661 }
1662}
1663
Amerigo Wang00b7c332010-05-05 00:26:45 +00001664#define TMPBUFLEN 22
1665/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001666 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001667 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001668 * @buf: a kernel buffer
1669 * @size: size of the kernel buffer
1670 * @val: this is where the number will be stored
1671 * @neg: set to %TRUE if number is negative
1672 * @perm_tr: a vector which contains the allowed trailers
1673 * @perm_tr_len: size of the perm_tr vector
1674 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001675 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001676 * In case of success %0 is returned and @buf and @size are updated with
1677 * the amount of bytes read. If @tr is non-NULL and a trailing
1678 * character exists (size is non-zero after returning from this
1679 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001680 */
1681static int proc_get_long(char **buf, size_t *size,
1682 unsigned long *val, bool *neg,
1683 const char *perm_tr, unsigned perm_tr_len, char *tr)
1684{
1685 int len;
1686 char *p, tmp[TMPBUFLEN];
1687
1688 if (!*size)
1689 return -EINVAL;
1690
1691 len = *size;
1692 if (len > TMPBUFLEN - 1)
1693 len = TMPBUFLEN - 1;
1694
1695 memcpy(tmp, *buf, len);
1696
1697 tmp[len] = 0;
1698 p = tmp;
1699 if (*p == '-' && *size > 1) {
1700 *neg = true;
1701 p++;
1702 } else
1703 *neg = false;
1704 if (!isdigit(*p))
1705 return -EINVAL;
1706
1707 *val = simple_strtoul(p, &p, 0);
1708
1709 len = p - tmp;
1710
1711 /* We don't know if the next char is whitespace thus we may accept
1712 * invalid integers (e.g. 1234...a) or two integers instead of one
1713 * (e.g. 123...1). So lets not allow such large numbers. */
1714 if (len == TMPBUFLEN - 1)
1715 return -EINVAL;
1716
1717 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1718 return -EINVAL;
1719
1720 if (tr && (len < *size))
1721 *tr = *p;
1722
1723 *buf += len;
1724 *size -= len;
1725
1726 return 0;
1727}
1728
1729/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001730 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001731 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001732 * @buf: the user buffer
1733 * @size: the size of the user buffer
1734 * @val: the integer to be converted
1735 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001736 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001737 * In case of success %0 is returned and @buf and @size are updated with
1738 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001739 */
1740static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1741 bool neg)
1742{
1743 int len;
1744 char tmp[TMPBUFLEN], *p = tmp;
1745
1746 sprintf(p, "%s%lu", neg ? "-" : "", val);
1747 len = strlen(tmp);
1748 if (len > *size)
1749 len = *size;
1750 if (copy_to_user(*buf, tmp, len))
1751 return -EFAULT;
1752 *size -= len;
1753 *buf += len;
1754 return 0;
1755}
1756#undef TMPBUFLEN
1757
1758static int proc_put_char(void __user **buf, size_t *size, char c)
1759{
1760 if (*size) {
1761 char __user **buffer = (char __user **)buf;
1762 if (put_user(c, *buffer))
1763 return -EFAULT;
1764 (*size)--, (*buffer)++;
1765 *buf = *buffer;
1766 }
1767 return 0;
1768}
1769
1770static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771 int *valp,
1772 int write, void *data)
1773{
1774 if (write) {
1775 *valp = *negp ? -*lvalp : *lvalp;
1776 } else {
1777 int val = *valp;
1778 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001779 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780 *lvalp = (unsigned long)-val;
1781 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001782 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 *lvalp = (unsigned long)val;
1784 }
1785 }
1786 return 0;
1787}
1788
Amerigo Wang00b7c332010-05-05 00:26:45 +00001789static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1790
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001791static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001792 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001793 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001794 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795 int write, void *data),
1796 void *data)
1797{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001798 int *i, vleft, first = 1, err = 0;
1799 unsigned long page = 0;
1800 size_t left;
1801 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001802
Amerigo Wang00b7c332010-05-05 00:26:45 +00001803 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804 *lenp = 0;
1805 return 0;
1806 }
1807
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001808 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809 vleft = table->maxlen / sizeof(*i);
1810 left = *lenp;
1811
1812 if (!conv)
1813 conv = do_proc_dointvec_conv;
1814
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001816 if (left > PAGE_SIZE - 1)
1817 left = PAGE_SIZE - 1;
1818 page = __get_free_page(GFP_TEMPORARY);
1819 kbuf = (char *) page;
1820 if (!kbuf)
1821 return -ENOMEM;
1822 if (copy_from_user(kbuf, buffer, left)) {
1823 err = -EFAULT;
1824 goto free;
1825 }
1826 kbuf[left] = 0;
1827 }
1828
1829 for (; left && vleft--; i++, first=0) {
1830 unsigned long lval;
1831 bool neg;
1832
1833 if (write) {
1834 left -= proc_skip_spaces(&kbuf);
1835
J. R. Okajima563b0462010-05-25 16:10:14 -07001836 if (!left)
1837 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001838 err = proc_get_long(&kbuf, &left, &lval, &neg,
1839 proc_wspace_sep,
1840 sizeof(proc_wspace_sep), NULL);
1841 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001843 if (conv(&neg, &lval, i, 1, data)) {
1844 err = -EINVAL;
1845 break;
1846 }
1847 } else {
1848 if (conv(&neg, &lval, i, 0, data)) {
1849 err = -EINVAL;
1850 break;
1851 }
1852 if (!first)
1853 err = proc_put_char(&buffer, &left, '\t');
1854 if (err)
1855 break;
1856 err = proc_put_long(&buffer, &left, lval, neg);
1857 if (err)
1858 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859 }
1860 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861
1862 if (!write && !first && left && !err)
1863 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001864 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001865 left -= proc_skip_spaces(&kbuf);
1866free:
1867 if (write) {
1868 free_page(page);
1869 if (first)
1870 return err ? : -EINVAL;
1871 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 *lenp -= left;
1873 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001874 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875}
1876
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001877static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001878 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001879 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001880 int write, void *data),
1881 void *data)
1882{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001883 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001884 buffer, lenp, ppos, conv, data);
1885}
1886
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887/**
1888 * proc_dointvec - read a vector of integers
1889 * @table: the sysctl table
1890 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891 * @buffer: the user buffer
1892 * @lenp: the size of the user buffer
1893 * @ppos: file position
1894 *
1895 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1896 * values from/to the user buffer, treated as an ASCII string.
1897 *
1898 * Returns 0 on success.
1899 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001900int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901 void __user *buffer, size_t *lenp, loff_t *ppos)
1902{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001903 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 NULL,NULL);
1905}
1906
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001907/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001908 * Taint values can only be increased
1909 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001910 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001911static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001912 void __user *buffer, size_t *lenp, loff_t *ppos)
1913{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001914 struct ctl_table t;
1915 unsigned long tmptaint = get_taint();
1916 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001917
Bastian Blank91fcd412007-04-23 14:41:14 -07001918 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001919 return -EPERM;
1920
Andi Kleen25ddbb12008-10-15 22:01:41 -07001921 t = *table;
1922 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001923 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001924 if (err < 0)
1925 return err;
1926
1927 if (write) {
1928 /*
1929 * Poor man's atomic or. Not worth adding a primitive
1930 * to everyone's atomic.h for this
1931 */
1932 int i;
1933 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
1934 if ((tmptaint >> i) & 1)
1935 add_taint(i);
1936 }
1937 }
1938
1939 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001940}
1941
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07001942#ifdef CONFIG_PRINTK
1943static int proc_dmesg_restrict(struct ctl_table *table, int write,
1944 void __user *buffer, size_t *lenp, loff_t *ppos)
1945{
1946 if (write && !capable(CAP_SYS_ADMIN))
1947 return -EPERM;
1948
1949 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1950}
1951#endif
1952
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953struct do_proc_dointvec_minmax_conv_param {
1954 int *min;
1955 int *max;
1956};
1957
Amerigo Wang00b7c332010-05-05 00:26:45 +00001958static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
1959 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960 int write, void *data)
1961{
1962 struct do_proc_dointvec_minmax_conv_param *param = data;
1963 if (write) {
1964 int val = *negp ? -*lvalp : *lvalp;
1965 if ((param->min && *param->min > val) ||
1966 (param->max && *param->max < val))
1967 return -EINVAL;
1968 *valp = val;
1969 } else {
1970 int val = *valp;
1971 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001972 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973 *lvalp = (unsigned long)-val;
1974 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001975 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 *lvalp = (unsigned long)val;
1977 }
1978 }
1979 return 0;
1980}
1981
1982/**
1983 * proc_dointvec_minmax - read a vector of integers with min/max values
1984 * @table: the sysctl table
1985 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 * @buffer: the user buffer
1987 * @lenp: the size of the user buffer
1988 * @ppos: file position
1989 *
1990 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1991 * values from/to the user buffer, treated as an ASCII string.
1992 *
1993 * This routine will ensure the values are within the range specified by
1994 * table->extra1 (min) and table->extra2 (max).
1995 *
1996 * Returns 0 on success.
1997 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001998int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 void __user *buffer, size_t *lenp, loff_t *ppos)
2000{
2001 struct do_proc_dointvec_minmax_conv_param param = {
2002 .min = (int *) table->extra1,
2003 .max = (int *) table->extra2,
2004 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002005 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006 do_proc_dointvec_minmax_conv, &param);
2007}
2008
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002009static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010 void __user *buffer,
2011 size_t *lenp, loff_t *ppos,
2012 unsigned long convmul,
2013 unsigned long convdiv)
2014{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002015 unsigned long *i, *min, *max;
2016 int vleft, first = 1, err = 0;
2017 unsigned long page = 0;
2018 size_t left;
2019 char *kbuf;
2020
2021 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022 *lenp = 0;
2023 return 0;
2024 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002025
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002026 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 min = (unsigned long *) table->extra1;
2028 max = (unsigned long *) table->extra2;
2029 vleft = table->maxlen / sizeof(unsigned long);
2030 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002031
2032 if (write) {
2033 if (left > PAGE_SIZE - 1)
2034 left = PAGE_SIZE - 1;
2035 page = __get_free_page(GFP_TEMPORARY);
2036 kbuf = (char *) page;
2037 if (!kbuf)
2038 return -ENOMEM;
2039 if (copy_from_user(kbuf, buffer, left)) {
2040 err = -EFAULT;
2041 goto free;
2042 }
2043 kbuf[left] = 0;
2044 }
2045
Eric Dumazet27b3d802010-10-07 12:59:29 -07002046 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002047 unsigned long val;
2048
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002050 bool neg;
2051
2052 left -= proc_skip_spaces(&kbuf);
2053
2054 err = proc_get_long(&kbuf, &left, &val, &neg,
2055 proc_wspace_sep,
2056 sizeof(proc_wspace_sep), NULL);
2057 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058 break;
2059 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060 continue;
2061 if ((min && val < *min) || (max && val > *max))
2062 continue;
2063 *i = val;
2064 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002065 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002067 err = proc_put_char(&buffer, &left, '\t');
2068 err = proc_put_long(&buffer, &left, val, false);
2069 if (err)
2070 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071 }
2072 }
2073
Amerigo Wang00b7c332010-05-05 00:26:45 +00002074 if (!write && !first && left && !err)
2075 err = proc_put_char(&buffer, &left, '\n');
2076 if (write && !err)
2077 left -= proc_skip_spaces(&kbuf);
2078free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002080 free_page(page);
2081 if (first)
2082 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 *lenp -= left;
2085 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002086 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087}
2088
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002089static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002090 void __user *buffer,
2091 size_t *lenp, loff_t *ppos,
2092 unsigned long convmul,
2093 unsigned long convdiv)
2094{
2095 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002096 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002097}
2098
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099/**
2100 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2101 * @table: the sysctl table
2102 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 * @buffer: the user buffer
2104 * @lenp: the size of the user buffer
2105 * @ppos: file position
2106 *
2107 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2108 * values from/to the user buffer, treated as an ASCII string.
2109 *
2110 * This routine will ensure the values are within the range specified by
2111 * table->extra1 (min) and table->extra2 (max).
2112 *
2113 * Returns 0 on success.
2114 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002115int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 void __user *buffer, size_t *lenp, loff_t *ppos)
2117{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002118 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119}
2120
2121/**
2122 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2123 * @table: the sysctl table
2124 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 * @buffer: the user buffer
2126 * @lenp: the size of the user buffer
2127 * @ppos: file position
2128 *
2129 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2130 * values from/to the user buffer, treated as an ASCII string. The values
2131 * are treated as milliseconds, and converted to jiffies when they are stored.
2132 *
2133 * This routine will ensure the values are within the range specified by
2134 * table->extra1 (min) and table->extra2 (max).
2135 *
2136 * Returns 0 on success.
2137 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002138int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139 void __user *buffer,
2140 size_t *lenp, loff_t *ppos)
2141{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002142 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002143 lenp, ppos, HZ, 1000l);
2144}
2145
2146
Amerigo Wang00b7c332010-05-05 00:26:45 +00002147static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148 int *valp,
2149 int write, void *data)
2150{
2151 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002152 if (*lvalp > LONG_MAX / HZ)
2153 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2155 } else {
2156 int val = *valp;
2157 unsigned long lval;
2158 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160 lval = (unsigned long)-val;
2161 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002162 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163 lval = (unsigned long)val;
2164 }
2165 *lvalp = lval / HZ;
2166 }
2167 return 0;
2168}
2169
Amerigo Wang00b7c332010-05-05 00:26:45 +00002170static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 int *valp,
2172 int write, void *data)
2173{
2174 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002175 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2176 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2178 } else {
2179 int val = *valp;
2180 unsigned long lval;
2181 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002182 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183 lval = (unsigned long)-val;
2184 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 lval = (unsigned long)val;
2187 }
2188 *lvalp = jiffies_to_clock_t(lval);
2189 }
2190 return 0;
2191}
2192
Amerigo Wang00b7c332010-05-05 00:26:45 +00002193static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 int *valp,
2195 int write, void *data)
2196{
2197 if (write) {
2198 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2199 } else {
2200 int val = *valp;
2201 unsigned long lval;
2202 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 lval = (unsigned long)-val;
2205 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002206 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 lval = (unsigned long)val;
2208 }
2209 *lvalp = jiffies_to_msecs(lval);
2210 }
2211 return 0;
2212}
2213
2214/**
2215 * proc_dointvec_jiffies - read a vector of integers as seconds
2216 * @table: the sysctl table
2217 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218 * @buffer: the user buffer
2219 * @lenp: the size of the user buffer
2220 * @ppos: file position
2221 *
2222 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2223 * values from/to the user buffer, treated as an ASCII string.
2224 * The values read are assumed to be in seconds, and are converted into
2225 * jiffies.
2226 *
2227 * Returns 0 on success.
2228 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002229int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 void __user *buffer, size_t *lenp, loff_t *ppos)
2231{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002232 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 do_proc_dointvec_jiffies_conv,NULL);
2234}
2235
2236/**
2237 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2238 * @table: the sysctl table
2239 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 * @buffer: the user buffer
2241 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002242 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 *
2244 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2245 * values from/to the user buffer, treated as an ASCII string.
2246 * The values read are assumed to be in 1/USER_HZ seconds, and
2247 * are converted into jiffies.
2248 *
2249 * Returns 0 on success.
2250 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002251int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 void __user *buffer, size_t *lenp, loff_t *ppos)
2253{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002254 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 do_proc_dointvec_userhz_jiffies_conv,NULL);
2256}
2257
2258/**
2259 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2260 * @table: the sysctl table
2261 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 * @buffer: the user buffer
2263 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002264 * @ppos: file position
2265 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266 *
2267 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2268 * values from/to the user buffer, treated as an ASCII string.
2269 * The values read are assumed to be in 1/1000 seconds, and
2270 * are converted into jiffies.
2271 *
2272 * Returns 0 on success.
2273 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002274int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 void __user *buffer, size_t *lenp, loff_t *ppos)
2276{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002277 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 do_proc_dointvec_ms_jiffies_conv, NULL);
2279}
2280
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002281static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002282 void __user *buffer, size_t *lenp, loff_t *ppos)
2283{
2284 struct pid *new_pid;
2285 pid_t tmp;
2286 int r;
2287
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002288 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002289
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002290 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002291 lenp, ppos, NULL, NULL);
2292 if (r || !write)
2293 return r;
2294
2295 new_pid = find_get_pid(tmp);
2296 if (!new_pid)
2297 return -ESRCH;
2298
2299 put_pid(xchg(&cad_pid, new_pid));
2300 return 0;
2301}
2302
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002303/**
2304 * proc_do_large_bitmap - read/write from/to a large bitmap
2305 * @table: the sysctl table
2306 * @write: %TRUE if this is a write to the sysctl file
2307 * @buffer: the user buffer
2308 * @lenp: the size of the user buffer
2309 * @ppos: file position
2310 *
2311 * The bitmap is stored at table->data and the bitmap length (in bits)
2312 * in table->maxlen.
2313 *
2314 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2315 * large bitmaps may be represented in a compact manner. Writing into
2316 * the file will clear the bitmap then update it with the given input.
2317 *
2318 * Returns 0 on success.
2319 */
2320int proc_do_large_bitmap(struct ctl_table *table, int write,
2321 void __user *buffer, size_t *lenp, loff_t *ppos)
2322{
2323 int err = 0;
2324 bool first = 1;
2325 size_t left = *lenp;
2326 unsigned long bitmap_len = table->maxlen;
2327 unsigned long *bitmap = (unsigned long *) table->data;
2328 unsigned long *tmp_bitmap = NULL;
2329 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2330
2331 if (!bitmap_len || !left || (*ppos && !write)) {
2332 *lenp = 0;
2333 return 0;
2334 }
2335
2336 if (write) {
2337 unsigned long page = 0;
2338 char *kbuf;
2339
2340 if (left > PAGE_SIZE - 1)
2341 left = PAGE_SIZE - 1;
2342
2343 page = __get_free_page(GFP_TEMPORARY);
2344 kbuf = (char *) page;
2345 if (!kbuf)
2346 return -ENOMEM;
2347 if (copy_from_user(kbuf, buffer, left)) {
2348 free_page(page);
2349 return -EFAULT;
2350 }
2351 kbuf[left] = 0;
2352
2353 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2354 GFP_KERNEL);
2355 if (!tmp_bitmap) {
2356 free_page(page);
2357 return -ENOMEM;
2358 }
2359 proc_skip_char(&kbuf, &left, '\n');
2360 while (!err && left) {
2361 unsigned long val_a, val_b;
2362 bool neg;
2363
2364 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2365 sizeof(tr_a), &c);
2366 if (err)
2367 break;
2368 if (val_a >= bitmap_len || neg) {
2369 err = -EINVAL;
2370 break;
2371 }
2372
2373 val_b = val_a;
2374 if (left) {
2375 kbuf++;
2376 left--;
2377 }
2378
2379 if (c == '-') {
2380 err = proc_get_long(&kbuf, &left, &val_b,
2381 &neg, tr_b, sizeof(tr_b),
2382 &c);
2383 if (err)
2384 break;
2385 if (val_b >= bitmap_len || neg ||
2386 val_a > val_b) {
2387 err = -EINVAL;
2388 break;
2389 }
2390 if (left) {
2391 kbuf++;
2392 left--;
2393 }
2394 }
2395
2396 while (val_a <= val_b)
2397 set_bit(val_a++, tmp_bitmap);
2398
2399 first = 0;
2400 proc_skip_char(&kbuf, &left, '\n');
2401 }
2402 free_page(page);
2403 } else {
2404 unsigned long bit_a, bit_b = 0;
2405
2406 while (left) {
2407 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2408 if (bit_a >= bitmap_len)
2409 break;
2410 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2411 bit_a + 1) - 1;
2412
2413 if (!first) {
2414 err = proc_put_char(&buffer, &left, ',');
2415 if (err)
2416 break;
2417 }
2418 err = proc_put_long(&buffer, &left, bit_a, false);
2419 if (err)
2420 break;
2421 if (bit_a != bit_b) {
2422 err = proc_put_char(&buffer, &left, '-');
2423 if (err)
2424 break;
2425 err = proc_put_long(&buffer, &left, bit_b, false);
2426 if (err)
2427 break;
2428 }
2429
2430 first = 0; bit_b++;
2431 }
2432 if (!err)
2433 err = proc_put_char(&buffer, &left, '\n');
2434 }
2435
2436 if (!err) {
2437 if (write) {
2438 if (*ppos)
2439 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2440 else
2441 memcpy(bitmap, tmp_bitmap,
2442 BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
2443 }
2444 kfree(tmp_bitmap);
2445 *lenp -= left;
2446 *ppos += *lenp;
2447 return 0;
2448 } else {
2449 kfree(tmp_bitmap);
2450 return err;
2451 }
2452}
2453
Jovi Zhang55610502011-01-12 17:00:45 -08002454#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002456int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 void __user *buffer, size_t *lenp, loff_t *ppos)
2458{
2459 return -ENOSYS;
2460}
2461
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002462int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463 void __user *buffer, size_t *lenp, loff_t *ppos)
2464{
2465 return -ENOSYS;
2466}
2467
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002468int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469 void __user *buffer, size_t *lenp, loff_t *ppos)
2470{
2471 return -ENOSYS;
2472}
2473
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002474int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 void __user *buffer, size_t *lenp, loff_t *ppos)
2476{
2477 return -ENOSYS;
2478}
2479
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002480int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 void __user *buffer, size_t *lenp, loff_t *ppos)
2482{
2483 return -ENOSYS;
2484}
2485
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002486int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 void __user *buffer, size_t *lenp, loff_t *ppos)
2488{
2489 return -ENOSYS;
2490}
2491
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002492int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 void __user *buffer, size_t *lenp, loff_t *ppos)
2494{
2495 return -ENOSYS;
2496}
2497
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002498int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 void __user *buffer,
2500 size_t *lenp, loff_t *ppos)
2501{
2502 return -ENOSYS;
2503}
2504
2505
Jovi Zhang55610502011-01-12 17:00:45 -08002506#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508/*
2509 * No sense putting this after each symbol definition, twice,
2510 * exception granted :-)
2511 */
2512EXPORT_SYMBOL(proc_dointvec);
2513EXPORT_SYMBOL(proc_dointvec_jiffies);
2514EXPORT_SYMBOL(proc_dointvec_minmax);
2515EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2516EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2517EXPORT_SYMBOL(proc_dostring);
2518EXPORT_SYMBOL(proc_doulongvec_minmax);
2519EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);