blob: dbd70bdc1765349db4e3e8163abaaec341b8e12c [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>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070026#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080027#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080028#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070030#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020032#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070033#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/init.h>
35#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010036#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030037#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <linux/sysrq.h>
39#include <linux/highuid.h>
40#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020041#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070042#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070045#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/times.h>
47#include <linux/limits.h>
48#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020049#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070051#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080052#include <linux/nfs_fs.h>
53#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070054#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020055#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020056#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050057#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020058#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070059#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040060#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070061#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000062#include <linux/binfmts.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64#include <asm/uaccess.h>
65#include <asm/processor.h>
66
Andi Kleen29cbc782006-09-30 01:47:55 +020067#ifdef CONFIG_X86
68#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010069#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010070#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020071#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080072#ifdef CONFIG_BSD_PROCESS_ACCT
73#include <linux/acct.h>
74#endif
Dave Young4f0e0562010-03-10 15:24:09 -080075#ifdef CONFIG_RT_MUTEXES
76#include <linux/rtmutex.h>
77#endif
Dave Young2edf5e42010-03-10 15:24:10 -080078#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
79#include <linux/lockdep.h>
80#endif
Dave Young15485a42010-03-10 15:24:07 -080081#ifdef CONFIG_CHR_DEV_SG
82#include <scsi/sg.h>
83#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020084
Don Zickus58687ac2010-05-07 17:11:44 -040085#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050086#include <linux/nmi.h>
87#endif
88
Eric W. Biederman7058cb02007-10-18 03:05:58 -070089
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#if defined(CONFIG_SYSCTL)
91
92/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern int sysctl_overcommit_memory;
94extern int sysctl_overcommit_ratio;
95extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070097extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070099extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100extern int pid_max;
101extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800103extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800104extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200105extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100106extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400107extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000108#ifndef CONFIG_MMU
109extern int sysctl_nr_trim_pages;
110#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200111#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200112extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200113#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700115/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400116#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200118static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119#endif
120
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700122static int __maybe_unused one = 1;
123static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700124static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800125static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700127#ifdef CONFIG_PRINTK
128static int ten_thousand = 10000;
129#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700130
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700131/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
132static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
135static int maxolduid = 65535;
136static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800137static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700140static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
Dave Youngd14f1722010-02-25 20:28:57 -0500142#ifdef CONFIG_INOTIFY_USER
143#include <linux/inotify.h>
144#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700145#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700146#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147#endif
148
David S. Miller08714202008-11-16 23:49:24 -0800149#ifdef CONFIG_SPARC64
150extern int sysctl_tsb_ratio;
151#endif
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153#ifdef __hppa__
154extern int pwrsw_enabled;
155extern int unaligned_enabled;
156#endif
157
Jes Sorensend2b176e2006-02-28 09:42:23 -0800158#ifdef CONFIG_IA64
159extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800160extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800161#endif
162
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700163#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700164static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700166static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800167 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700168#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700169
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700170#ifdef CONFIG_PRINTK
171static int proc_dmesg_restrict(struct ctl_table *table, int write,
172 void __user *buffer, size_t *lenp, loff_t *ppos);
173#endif
174
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700175#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800176/* Note: sysrq code uses it's own private copy */
177static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700178
179static int sysrq_sysctl_handler(ctl_table *table, int write,
180 void __user *buffer, size_t *lenp,
181 loff_t *ppos)
182{
183 int error;
184
185 error = proc_dointvec(table, write, buffer, lenp, ppos);
186 if (error)
187 return error;
188
189 if (write)
190 sysrq_toggle_support(__sysrq_enabled);
191
192 return 0;
193}
194
195#endif
196
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700197static struct ctl_table kern_table[];
198static struct ctl_table vm_table[];
199static struct ctl_table fs_table[];
200static struct ctl_table debug_table[];
201static struct ctl_table dev_table[];
202extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800203#ifdef CONFIG_EPOLL
204extern struct ctl_table epoll_table[];
205#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
208int sysctl_legacy_va_layout;
209#endif
210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211/* The default sysctl tables: */
212
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800213static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 .procname = "kernel",
216 .mode = 0555,
217 .child = kern_table,
218 },
219 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 .procname = "vm",
221 .mode = 0555,
222 .child = vm_table,
223 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 .procname = "fs",
226 .mode = 0555,
227 .child = fs_table,
228 },
229 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 .procname = "debug",
231 .mode = 0555,
232 .child = debug_table,
233 },
234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .procname = "dev",
236 .mode = 0555,
237 .child = dev_table,
238 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700239 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240};
241
Ingo Molnar77e54a12007-07-09 18:52:00 +0200242#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100243static int min_sched_granularity_ns = 100000; /* 100 usecs */
244static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
245static int min_wakeup_granularity_ns; /* 0 usecs */
246static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100247static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
248static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200249#endif
250
Mel Gorman5e771902010-05-24 14:32:31 -0700251#ifdef CONFIG_COMPACTION
252static int min_extfrag_threshold;
253static int max_extfrag_threshold = 1000;
254#endif
255
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700256static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200257 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200258 .procname = "sched_child_runs_first",
259 .data = &sysctl_sched_child_runs_first,
260 .maxlen = sizeof(unsigned int),
261 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800262 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200263 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200264#ifdef CONFIG_SCHED_DEBUG
265 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100266 .procname = "sched_min_granularity_ns",
267 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200268 .maxlen = sizeof(unsigned int),
269 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800270 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100271 .extra1 = &min_sched_granularity_ns,
272 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200273 },
274 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200275 .procname = "sched_latency_ns",
276 .data = &sysctl_sched_latency,
277 .maxlen = sizeof(unsigned int),
278 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800279 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200280 .extra1 = &min_sched_granularity_ns,
281 .extra2 = &max_sched_granularity_ns,
282 },
283 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200284 .procname = "sched_wakeup_granularity_ns",
285 .data = &sysctl_sched_wakeup_granularity,
286 .maxlen = sizeof(unsigned int),
287 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800288 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289 .extra1 = &min_wakeup_granularity_ns,
290 .extra2 = &max_wakeup_granularity_ns,
291 },
292 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100293 .procname = "sched_tunable_scaling",
294 .data = &sysctl_sched_tunable_scaling,
295 .maxlen = sizeof(enum sched_tunable_scaling),
296 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800297 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100298 .extra1 = &min_sched_tunable_scaling,
299 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200300 },
301 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200302 .procname = "sched_migration_cost",
303 .data = &sysctl_sched_migration_cost,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800306 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200307 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100308 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100309 .procname = "sched_nr_migrate",
310 .data = &sysctl_sched_nr_migrate,
311 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100312 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800313 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100314 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530315 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200316 .procname = "sched_time_avg",
317 .data = &sysctl_sched_time_avg,
318 .maxlen = sizeof(unsigned int),
319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800320 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200321 },
322 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800323 .procname = "sched_shares_window",
324 .data = &sysctl_sched_shares_window,
325 .maxlen = sizeof(unsigned int),
326 .mode = 0644,
327 .proc_handler = proc_dointvec,
328 },
329 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530330 .procname = "timer_migration",
331 .data = &sysctl_timer_migration,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530335 .extra1 = &zero,
336 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530337 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200338#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200339 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100340 .procname = "sched_rt_period_us",
341 .data = &sysctl_sched_rt_period,
342 .maxlen = sizeof(unsigned int),
343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800344 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100345 },
346 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100347 .procname = "sched_rt_runtime_us",
348 .data = &sysctl_sched_rt_runtime,
349 .maxlen = sizeof(int),
350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800351 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100352 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100353#ifdef CONFIG_SCHED_AUTOGROUP
354 {
355 .procname = "sched_autogroup_enabled",
356 .data = &sysctl_sched_autogroup_enabled,
357 .maxlen = sizeof(unsigned int),
358 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800359 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100360 .extra1 = &zero,
361 .extra2 = &one,
362 },
363#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700364#ifdef CONFIG_CFS_BANDWIDTH
365 {
366 .procname = "sched_cfs_bandwidth_slice_us",
367 .data = &sysctl_sched_cfs_bandwidth_slice,
368 .maxlen = sizeof(unsigned int),
369 .mode = 0644,
370 .proc_handler = proc_dointvec_minmax,
371 .extra1 = &one,
372 },
373#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700374#ifdef CONFIG_PROVE_LOCKING
375 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700376 .procname = "prove_locking",
377 .data = &prove_locking,
378 .maxlen = sizeof(int),
379 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800380 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700381 },
382#endif
383#ifdef CONFIG_LOCK_STAT
384 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700385 .procname = "lock_stat",
386 .data = &lock_stat,
387 .maxlen = sizeof(int),
388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800389 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700390 },
391#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200392 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 .procname = "panic",
394 .data = &panic_timeout,
395 .maxlen = sizeof(int),
396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800397 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 },
399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .procname = "core_uses_pid",
401 .data = &core_uses_pid,
402 .maxlen = sizeof(int),
403 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800404 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 },
406 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 .procname = "core_pattern",
408 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700409 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800411 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 },
Neil Hormana2939802009-09-23 15:56:56 -0700413 {
Neil Hormana2939802009-09-23 15:56:56 -0700414 .procname = "core_pipe_limit",
415 .data = &core_pipe_limit,
416 .maxlen = sizeof(unsigned int),
417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800418 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700419 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800420#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700423 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800425 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800427#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100428#ifdef CONFIG_LATENCYTOP
429 {
430 .procname = "latencytop",
431 .data = &latencytop_enabled,
432 .maxlen = sizeof(int),
433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800434 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100435 },
436#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437#ifdef CONFIG_BLK_DEV_INITRD
438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 .procname = "real-root-dev",
440 .data = &real_root_dev,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 },
445#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700446 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700447 .procname = "print-fatal-signals",
448 .data = &print_fatal_signals,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700452 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700453#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "reboot-cmd",
456 .data = reboot_command,
457 .maxlen = 256,
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "stop-a",
463 .data = &stop_a_enabled,
464 .maxlen = sizeof (int),
465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 .procname = "scons-poweroff",
470 .data = &scons_pwroff,
471 .maxlen = sizeof (int),
472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800473 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 },
475#endif
David S. Miller08714202008-11-16 23:49:24 -0800476#ifdef CONFIG_SPARC64
477 {
David S. Miller08714202008-11-16 23:49:24 -0800478 .procname = "tsb-ratio",
479 .data = &sysctl_tsb_ratio,
480 .maxlen = sizeof (int),
481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800482 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800483 },
484#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485#ifdef __hppa__
486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "soft-power",
488 .data = &pwrsw_enabled,
489 .maxlen = sizeof (int),
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 .procname = "unaligned-trap",
495 .data = &unaligned_enabled,
496 .maxlen = sizeof (int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 },
500#endif
501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 .procname = "ctrl-alt-del",
503 .data = &C_A_D,
504 .maxlen = sizeof(int),
505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400508#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200509 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200510 .procname = "ftrace_enabled",
511 .data = &ftrace_enabled,
512 .maxlen = sizeof(int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200515 },
516#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500517#ifdef CONFIG_STACK_TRACER
518 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500519 .procname = "stack_tracer_enabled",
520 .data = &stack_tracer_enabled,
521 .maxlen = sizeof(int),
522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800523 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500524 },
525#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400526#ifdef CONFIG_TRACING
527 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100528 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400529 .data = &ftrace_dump_on_oops,
530 .maxlen = sizeof(int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400533 },
534#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200535#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 .procname = "modprobe",
538 .data = &modprobe_path,
539 .maxlen = KMOD_PATH_LEN,
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 },
Kees Cook3d433212009-04-02 15:49:29 -0700543 {
Kees Cook3d433212009-04-02 15:49:29 -0700544 .procname = "modules_disabled",
545 .data = &modules_disabled,
546 .maxlen = sizeof(int),
547 .mode = 0644,
548 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700550 .extra1 = &one,
551 .extra2 = &one,
552 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100554#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100557 .data = &uevent_helper,
558 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800560 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 },
562#endif
563#ifdef CONFIG_CHR_DEV_SG
564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 .procname = "sg-big-buff",
566 .data = &sg_big_buff,
567 .maxlen = sizeof (int),
568 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800569 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 },
571#endif
572#ifdef CONFIG_BSD_PROCESS_ACCT
573 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .procname = "acct",
575 .data = &acct_parm,
576 .maxlen = 3*sizeof(int),
577 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800578 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 },
580#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581#ifdef CONFIG_MAGIC_SYSRQ
582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800584 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .maxlen = sizeof (int),
586 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700587 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 },
589#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700590#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700593 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .maxlen = sizeof (int),
595 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800596 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700598#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .procname = "threads-max",
601 .data = &max_threads,
602 .maxlen = sizeof(int),
603 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800604 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
606 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .procname = "random",
608 .mode = 0555,
609 .child = random_table,
610 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 {
Eric Paris17f60a72011-04-01 17:07:50 -0400612 .procname = "usermodehelper",
613 .mode = 0555,
614 .child = usermodehelper_table,
615 },
616 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 .procname = "overflowuid",
618 .data = &overflowuid,
619 .maxlen = sizeof(int),
620 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800621 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 .extra1 = &minolduid,
623 .extra2 = &maxolduid,
624 },
625 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 .procname = "overflowgid",
627 .data = &overflowgid,
628 .maxlen = sizeof(int),
629 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800630 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .extra1 = &minolduid,
632 .extra2 = &maxolduid,
633 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800634#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635#ifdef CONFIG_MATHEMU
636 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 .procname = "ieee_emulation_warnings",
638 .data = &sysctl_ieee_emulation_warnings,
639 .maxlen = sizeof(int),
640 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 },
643#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200646 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .maxlen = sizeof(int),
648 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800649 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 },
651#endif
652 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 .procname = "pid_max",
654 .data = &pid_max,
655 .maxlen = sizeof (int),
656 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800657 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .extra1 = &pid_max_min,
659 .extra2 = &pid_max_max,
660 },
661 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .procname = "panic_on_oops",
663 .data = &panic_on_oops,
664 .maxlen = sizeof(int),
665 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800668#if defined CONFIG_PRINTK
669 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800670 .procname = "printk",
671 .data = &console_loglevel,
672 .maxlen = 4*sizeof(int),
673 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800674 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800675 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700678 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .maxlen = sizeof(int),
680 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800681 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 },
683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700685 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .maxlen = sizeof(int),
687 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800688 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 },
Dave Youngaf913222009-09-22 16:43:33 -0700690 {
Dave Youngaf913222009-09-22 16:43:33 -0700691 .procname = "printk_delay",
692 .data = &printk_delay_msec,
693 .maxlen = sizeof(int),
694 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800695 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700696 .extra1 = &zero,
697 .extra2 = &ten_thousand,
698 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800700 .procname = "dmesg_restrict",
701 .data = &dmesg_restrict,
702 .maxlen = sizeof(int),
703 .mode = 0644,
704 .proc_handler = proc_dointvec_minmax,
705 .extra1 = &zero,
706 .extra2 = &one,
707 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800708 {
709 .procname = "kptr_restrict",
710 .data = &kptr_restrict,
711 .maxlen = sizeof(int),
712 .mode = 0644,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700713 .proc_handler = proc_dmesg_restrict,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800714 .extra1 = &zero,
715 .extra2 = &two,
716 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800717#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .procname = "ngroups_max",
720 .data = &ngroups_max,
721 .maxlen = sizeof (int),
722 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800723 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 },
Dan Ballard73efc032011-10-31 17:11:20 -0700725 {
726 .procname = "cap_last_cap",
727 .data = (void *)&cap_last_cap,
728 .maxlen = sizeof(int),
729 .mode = 0444,
730 .proc_handler = proc_dointvec,
731 },
Don Zickus58687ac2010-05-07 17:11:44 -0400732#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500733 {
Don Zickus58687ac2010-05-07 17:11:44 -0400734 .procname = "watchdog",
735 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500736 .maxlen = sizeof (int),
737 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700738 .proc_handler = proc_dowatchdog,
739 .extra1 = &zero,
740 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400741 },
742 {
743 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700744 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400745 .maxlen = sizeof(int),
746 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700747 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400748 .extra1 = &neg_one,
749 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500750 },
Don Zickus2508ce12010-05-07 17:11:46 -0400751 {
752 .procname = "softlockup_panic",
753 .data = &softlockup_panic,
754 .maxlen = sizeof(int),
755 .mode = 0644,
756 .proc_handler = proc_dointvec_minmax,
757 .extra1 = &zero,
758 .extra2 = &one,
759 },
Don Zickus5dc30552010-11-29 17:07:17 -0500760 {
761 .procname = "nmi_watchdog",
762 .data = &watchdog_enabled,
763 .maxlen = sizeof (int),
764 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700765 .proc_handler = proc_dowatchdog,
766 .extra1 = &zero,
767 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500768 },
769#endif
770#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
771 {
772 .procname = "unknown_nmi_panic",
773 .data = &unknown_nmi_panic,
774 .maxlen = sizeof (int),
775 .mode = 0644,
776 .proc_handler = proc_dointvec,
777 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500778#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779#if defined(CONFIG_X86)
780 {
Don Zickus8da5add2006-09-26 10:52:27 +0200781 .procname = "panic_on_unrecovered_nmi",
782 .data = &panic_on_unrecovered_nmi,
783 .maxlen = sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200786 },
787 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700788 .procname = "panic_on_io_nmi",
789 .data = &panic_on_io_nmi,
790 .maxlen = sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700793 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900794#ifdef CONFIG_DEBUG_STACKOVERFLOW
795 {
796 .procname = "panic_on_stackoverflow",
797 .data = &sysctl_panic_on_stackoverflow,
798 .maxlen = sizeof(int),
799 .mode = 0644,
800 .proc_handler = proc_dointvec,
801 },
802#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700803 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 .procname = "bootloader_type",
805 .data = &bootloader_type,
806 .maxlen = sizeof (int),
807 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800808 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100810 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700811 .procname = "bootloader_version",
812 .data = &bootloader_version,
813 .maxlen = sizeof (int),
814 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800815 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700816 },
817 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100818 .procname = "kstack_depth_to_print",
819 .data = &kstack_depth_to_print,
820 .maxlen = sizeof(int),
821 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800822 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100823 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100824 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100825 .procname = "io_delay_type",
826 .data = &io_delay_type,
827 .maxlen = sizeof(int),
828 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800829 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100830 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800832#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 .procname = "randomize_va_space",
835 .data = &randomize_va_space,
836 .maxlen = sizeof(int),
837 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800838 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800840#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800841#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700842 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700843 .procname = "spin_retry",
844 .data = &spin_retry,
845 .maxlen = sizeof (int),
846 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800847 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700848 },
849#endif
Len Brown673d5b42007-07-28 03:33:16 -0400850#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800851 {
Pavel Machekc255d842006-02-20 18:27:58 -0800852 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700853 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800854 .maxlen = sizeof (unsigned long),
855 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800856 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800857 },
858#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800859#ifdef CONFIG_IA64
860 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800861 .procname = "ignore-unaligned-usertrap",
862 .data = &no_unaligned_warning,
863 .maxlen = sizeof (int),
864 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800865 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800866 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800867 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800868 .procname = "unaligned-dump-stack",
869 .data = &unaligned_dump_stack,
870 .maxlen = sizeof (int),
871 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800872 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800873 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800874#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800875#ifdef CONFIG_DETECT_HUNG_TASK
876 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800877 .procname = "hung_task_panic",
878 .data = &sysctl_hung_task_panic,
879 .maxlen = sizeof(int),
880 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800881 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800882 .extra1 = &zero,
883 .extra2 = &one,
884 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100885 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100886 .procname = "hung_task_check_count",
887 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100888 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100891 },
892 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100893 .procname = "hung_task_timeout_secs",
894 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100895 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100898 },
899 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100900 .procname = "hung_task_warnings",
901 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100902 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100905 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700906#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200907#ifdef CONFIG_COMPAT
908 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200909 .procname = "compat-log",
910 .data = &compat_log,
911 .maxlen = sizeof (int),
912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200914 },
915#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700916#ifdef CONFIG_RT_MUTEXES
917 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700918 .procname = "max_lock_depth",
919 .data = &max_lock_depth,
920 .maxlen = sizeof(int),
921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800922 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700923 },
924#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700925 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700926 .procname = "poweroff_cmd",
927 .data = &poweroff_cmd,
928 .maxlen = POWEROFF_CMD_PATH_LEN,
929 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800930 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700931 },
David Howells0b77f5b2008-04-29 01:01:32 -0700932#ifdef CONFIG_KEYS
933 {
David Howells0b77f5b2008-04-29 01:01:32 -0700934 .procname = "keys",
935 .mode = 0555,
936 .child = key_sysctls,
937 },
938#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700939#ifdef CONFIG_RCU_TORTURE_TEST
940 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700941 .procname = "rcutorture_runnable",
942 .data = &rcutorture_runnable,
943 .maxlen = sizeof(int),
944 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800945 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700946 },
947#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200948#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400949 /*
950 * User-space scripts rely on the existence of this file
951 * as a feature check for perf_events being enabled.
952 *
953 * So it's an ABI, do not remove!
954 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200955 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200956 .procname = "perf_event_paranoid",
957 .data = &sysctl_perf_event_paranoid,
958 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200961 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200962 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200963 .procname = "perf_event_mlock_kb",
964 .data = &sysctl_perf_event_mlock,
965 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200966 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800967 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200968 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200969 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200970 .procname = "perf_event_max_sample_rate",
971 .data = &sysctl_perf_event_sample_rate,
972 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200973 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100974 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200975 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200976#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200977#ifdef CONFIG_KMEMCHECK
978 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200979 .procname = "kmemcheck",
980 .data = &kmemcheck_enabled,
981 .maxlen = sizeof(int),
982 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200984 },
985#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200986#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200987 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200988 .procname = "blk_iopoll",
989 .data = &blk_iopoll_enabled,
990 .maxlen = sizeof(int),
991 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800992 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200993 },
Jens Axboecb684b52009-09-15 21:53:11 +0200994#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700995 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996};
997
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700998static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 .procname = "overcommit_memory",
1001 .data = &sysctl_overcommit_memory,
1002 .maxlen = sizeof(sysctl_overcommit_memory),
1003 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001004 .proc_handler = proc_dointvec_minmax,
1005 .extra1 = &zero,
1006 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 },
1008 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001009 .procname = "panic_on_oom",
1010 .data = &sysctl_panic_on_oom,
1011 .maxlen = sizeof(sysctl_panic_on_oom),
1012 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001013 .proc_handler = proc_dointvec_minmax,
1014 .extra1 = &zero,
1015 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001016 },
1017 {
David Rientjesfe071d72007-10-16 23:25:56 -07001018 .procname = "oom_kill_allocating_task",
1019 .data = &sysctl_oom_kill_allocating_task,
1020 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1021 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001022 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001023 },
1024 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001025 .procname = "oom_dump_tasks",
1026 .data = &sysctl_oom_dump_tasks,
1027 .maxlen = sizeof(sysctl_oom_dump_tasks),
1028 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001029 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001030 },
1031 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 .procname = "overcommit_ratio",
1033 .data = &sysctl_overcommit_ratio,
1034 .maxlen = sizeof(sysctl_overcommit_ratio),
1035 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001036 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 },
1038 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 .procname = "page-cluster",
1040 .data = &page_cluster,
1041 .maxlen = sizeof(int),
1042 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001043 .proc_handler = proc_dointvec_minmax,
1044 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 },
1046 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 .procname = "dirty_background_ratio",
1048 .data = &dirty_background_ratio,
1049 .maxlen = sizeof(dirty_background_ratio),
1050 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001051 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052 .extra1 = &zero,
1053 .extra2 = &one_hundred,
1054 },
1055 {
David Rientjes2da02992009-01-06 14:39:31 -08001056 .procname = "dirty_background_bytes",
1057 .data = &dirty_background_bytes,
1058 .maxlen = sizeof(dirty_background_bytes),
1059 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001060 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001061 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001062 },
1063 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 .procname = "dirty_ratio",
1065 .data = &vm_dirty_ratio,
1066 .maxlen = sizeof(vm_dirty_ratio),
1067 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001068 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 .extra1 = &zero,
1070 .extra2 = &one_hundred,
1071 },
1072 {
David Rientjes2da02992009-01-06 14:39:31 -08001073 .procname = "dirty_bytes",
1074 .data = &vm_dirty_bytes,
1075 .maxlen = sizeof(vm_dirty_bytes),
1076 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001077 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001078 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001079 },
1080 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001082 .data = &dirty_writeback_interval,
1083 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001085 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 },
1087 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001089 .data = &dirty_expire_interval,
1090 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001092 .proc_handler = proc_dointvec_minmax,
1093 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 },
1095 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 .procname = "nr_pdflush_threads",
1097 .data = &nr_pdflush_threads,
1098 .maxlen = sizeof nr_pdflush_threads,
1099 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001100 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 },
1102 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 .procname = "swappiness",
1104 .data = &vm_swappiness,
1105 .maxlen = sizeof(vm_swappiness),
1106 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001107 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 .extra1 = &zero,
1109 .extra2 = &one_hundred,
1110 },
1111#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001112 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001114 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .maxlen = sizeof(unsigned long),
1116 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001117 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 .extra1 = (void *)&hugetlb_zero,
1119 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001120 },
1121#ifdef CONFIG_NUMA
1122 {
1123 .procname = "nr_hugepages_mempolicy",
1124 .data = NULL,
1125 .maxlen = sizeof(unsigned long),
1126 .mode = 0644,
1127 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1128 .extra1 = (void *)&hugetlb_zero,
1129 .extra2 = (void *)&hugetlb_infinity,
1130 },
1131#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 .procname = "hugetlb_shm_group",
1134 .data = &sysctl_hugetlb_shm_group,
1135 .maxlen = sizeof(gid_t),
1136 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001137 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 },
Mel Gorman396faf02007-07-17 04:03:13 -07001139 {
Mel Gorman396faf02007-07-17 04:03:13 -07001140 .procname = "hugepages_treat_as_movable",
1141 .data = &hugepages_treat_as_movable,
1142 .maxlen = sizeof(int),
1143 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001144 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001145 },
Adam Litke54f9f802007-10-16 01:26:20 -07001146 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001147 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001148 .data = NULL,
1149 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001150 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001151 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001152 .extra1 = (void *)&hugetlb_zero,
1153 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001154 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155#endif
1156 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .procname = "lowmem_reserve_ratio",
1158 .data = &sysctl_lowmem_reserve_ratio,
1159 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1160 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001161 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 },
1163 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001164 .procname = "drop_caches",
1165 .data = &sysctl_drop_caches,
1166 .maxlen = sizeof(int),
1167 .mode = 0644,
1168 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001169 .extra1 = &one,
1170 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001171 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001172#ifdef CONFIG_COMPACTION
1173 {
1174 .procname = "compact_memory",
1175 .data = &sysctl_compact_memory,
1176 .maxlen = sizeof(int),
1177 .mode = 0200,
1178 .proc_handler = sysctl_compaction_handler,
1179 },
Mel Gorman5e771902010-05-24 14:32:31 -07001180 {
1181 .procname = "extfrag_threshold",
1182 .data = &sysctl_extfrag_threshold,
1183 .maxlen = sizeof(int),
1184 .mode = 0644,
1185 .proc_handler = sysctl_extfrag_handler,
1186 .extra1 = &min_extfrag_threshold,
1187 .extra2 = &max_extfrag_threshold,
1188 },
1189
Mel Gorman76ab0f52010-05-24 14:32:28 -07001190#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001191 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 .procname = "min_free_kbytes",
1193 .data = &min_free_kbytes,
1194 .maxlen = sizeof(min_free_kbytes),
1195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 .extra1 = &zero,
1198 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001199 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001200 .procname = "percpu_pagelist_fraction",
1201 .data = &percpu_pagelist_fraction,
1202 .maxlen = sizeof(percpu_pagelist_fraction),
1203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001204 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001205 .extra1 = &min_percpu_pagelist_fract,
1206 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207#ifdef CONFIG_MMU
1208 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 .procname = "max_map_count",
1210 .data = &sysctl_max_map_count,
1211 .maxlen = sizeof(sysctl_max_map_count),
1212 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001213 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001214 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001216#else
1217 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001218 .procname = "nr_trim_pages",
1219 .data = &sysctl_nr_trim_pages,
1220 .maxlen = sizeof(sysctl_nr_trim_pages),
1221 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001222 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001223 .extra1 = &zero,
1224 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225#endif
1226 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 .procname = "laptop_mode",
1228 .data = &laptop_mode,
1229 .maxlen = sizeof(laptop_mode),
1230 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001231 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 },
1233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 .procname = "block_dump",
1235 .data = &block_dump,
1236 .maxlen = sizeof(block_dump),
1237 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001238 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 .extra1 = &zero,
1240 },
1241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 .procname = "vfs_cache_pressure",
1243 .data = &sysctl_vfs_cache_pressure,
1244 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1245 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001246 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 .extra1 = &zero,
1248 },
1249#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 .procname = "legacy_va_layout",
1252 .data = &sysctl_legacy_va_layout,
1253 .maxlen = sizeof(sysctl_legacy_va_layout),
1254 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001255 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256 .extra1 = &zero,
1257 },
1258#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001259#ifdef CONFIG_NUMA
1260 {
Christoph Lameter17436602006-01-18 17:42:32 -08001261 .procname = "zone_reclaim_mode",
1262 .data = &zone_reclaim_mode,
1263 .maxlen = sizeof(zone_reclaim_mode),
1264 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001265 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001266 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001267 },
Christoph Lameter96146342006-07-03 00:24:13 -07001268 {
Christoph Lameter96146342006-07-03 00:24:13 -07001269 .procname = "min_unmapped_ratio",
1270 .data = &sysctl_min_unmapped_ratio,
1271 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1272 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001273 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001274 .extra1 = &zero,
1275 .extra2 = &one_hundred,
1276 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001277 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001278 .procname = "min_slab_ratio",
1279 .data = &sysctl_min_slab_ratio,
1280 .maxlen = sizeof(sysctl_min_slab_ratio),
1281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001282 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001283 .extra1 = &zero,
1284 .extra2 = &one_hundred,
1285 },
Christoph Lameter17436602006-01-18 17:42:32 -08001286#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001287#ifdef CONFIG_SMP
1288 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001289 .procname = "stat_interval",
1290 .data = &sysctl_stat_interval,
1291 .maxlen = sizeof(sysctl_stat_interval),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001294 },
1295#endif
David Howells6e141542009-12-15 19:27:45 +00001296#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001297 {
Eric Parised032182007-06-28 15:55:21 -04001298 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001299 .data = &dac_mmap_min_addr,
1300 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001301 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001302 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001303 },
David Howells6e141542009-12-15 19:27:45 +00001304#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001305#ifdef CONFIG_NUMA
1306 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001307 .procname = "numa_zonelist_order",
1308 .data = &numa_zonelist_order,
1309 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1310 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001312 },
1313#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001314#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001315 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001316 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001317 .procname = "vdso_enabled",
1318 .data = &vdso_enabled,
1319 .maxlen = sizeof(vdso_enabled),
1320 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001321 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001322 .extra1 = &zero,
1323 },
1324#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001325#ifdef CONFIG_HIGHMEM
1326 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001327 .procname = "highmem_is_dirtyable",
1328 .data = &vm_highmem_is_dirtyable,
1329 .maxlen = sizeof(vm_highmem_is_dirtyable),
1330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001331 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001332 .extra1 = &zero,
1333 .extra2 = &one,
1334 },
1335#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001336 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001337 .procname = "scan_unevictable_pages",
1338 .data = &scan_unevictable_pages,
1339 .maxlen = sizeof(scan_unevictable_pages),
1340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001342 },
Andi Kleen6a460792009-09-16 11:50:15 +02001343#ifdef CONFIG_MEMORY_FAILURE
1344 {
Andi Kleen6a460792009-09-16 11:50:15 +02001345 .procname = "memory_failure_early_kill",
1346 .data = &sysctl_memory_failure_early_kill,
1347 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1348 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001349 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001350 .extra1 = &zero,
1351 .extra2 = &one,
1352 },
1353 {
Andi Kleen6a460792009-09-16 11:50:15 +02001354 .procname = "memory_failure_recovery",
1355 .data = &sysctl_memory_failure_recovery,
1356 .maxlen = sizeof(sysctl_memory_failure_recovery),
1357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001358 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001359 .extra1 = &zero,
1360 .extra2 = &one,
1361 },
1362#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001363 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364};
1365
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001366#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001367static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001368 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001369};
1370#endif
1371
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001372static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 .procname = "inode-nr",
1375 .data = &inodes_stat,
1376 .maxlen = 2*sizeof(int),
1377 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001378 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 },
1380 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 .procname = "inode-state",
1382 .data = &inodes_stat,
1383 .maxlen = 7*sizeof(int),
1384 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001385 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 },
1387 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 .procname = "file-nr",
1389 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001390 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001392 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 },
1394 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 .procname = "file-max",
1396 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001397 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001399 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 },
1401 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001402 .procname = "nr_open",
1403 .data = &sysctl_nr_open,
1404 .maxlen = sizeof(int),
1405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001406 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001407 .extra1 = &sysctl_nr_open_min,
1408 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001409 },
1410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "dentry-state",
1412 .data = &dentry_stat,
1413 .maxlen = 6*sizeof(int),
1414 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001415 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416 },
1417 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418 .procname = "overflowuid",
1419 .data = &fs_overflowuid,
1420 .maxlen = sizeof(int),
1421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001422 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 .extra1 = &minolduid,
1424 .extra2 = &maxolduid,
1425 },
1426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 .procname = "overflowgid",
1428 .data = &fs_overflowgid,
1429 .maxlen = sizeof(int),
1430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001431 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 .extra1 = &minolduid,
1433 .extra2 = &maxolduid,
1434 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001435#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 .procname = "leases-enable",
1438 .data = &leases_enable,
1439 .maxlen = sizeof(int),
1440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001441 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001443#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444#ifdef CONFIG_DNOTIFY
1445 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 .procname = "dir-notify-enable",
1447 .data = &dir_notify_enable,
1448 .maxlen = sizeof(int),
1449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001450 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 },
1452#endif
1453#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001454#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .procname = "lease-break-time",
1457 .data = &lease_break_time,
1458 .maxlen = sizeof(int),
1459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001460 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001462#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001463#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 .procname = "aio-nr",
1466 .data = &aio_nr,
1467 .maxlen = sizeof(aio_nr),
1468 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001469 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 },
1471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 .procname = "aio-max-nr",
1473 .data = &aio_max_nr,
1474 .maxlen = sizeof(aio_max_nr),
1475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001476 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001478#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001479#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001480 {
Robert Love0399cb02005-07-13 12:38:18 -04001481 .procname = "inotify",
1482 .mode = 0555,
1483 .child = inotify_table,
1484 },
1485#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001486#ifdef CONFIG_EPOLL
1487 {
1488 .procname = "epoll",
1489 .mode = 0555,
1490 .child = epoll_table,
1491 },
1492#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001494 {
Alan Coxd6e71142005-06-23 00:09:43 -07001495 .procname = "suid_dumpable",
1496 .data = &suid_dumpable,
1497 .maxlen = sizeof(int),
1498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001500 .extra1 = &zero,
1501 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001502 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001503#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1504 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001505 .procname = "binfmt_misc",
1506 .mode = 0555,
1507 .child = binfmt_misc_table,
1508 },
1509#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001510 {
Jens Axboeff9da692010-06-03 14:54:39 +02001511 .procname = "pipe-max-size",
1512 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001513 .maxlen = sizeof(int),
1514 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001515 .proc_handler = &pipe_proc_fn,
1516 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001517 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001518 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519};
1520
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001521static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001522#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001523 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001524 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001525 .procname = "exception-trace",
1526 .data = &show_unhandled_signals,
1527 .maxlen = sizeof(int),
1528 .mode = 0644,
1529 .proc_handler = proc_dointvec
1530 },
1531#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001532#if defined(CONFIG_OPTPROBES)
1533 {
1534 .procname = "kprobes-optimization",
1535 .data = &sysctl_kprobes_optimization,
1536 .maxlen = sizeof(int),
1537 .mode = 0644,
1538 .proc_handler = proc_kprobes_optimization_handler,
1539 .extra1 = &zero,
1540 .extra2 = &one,
1541 },
1542#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001543 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544};
1545
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001546static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001547 { }
Robert Love0eeca282005-07-12 17:06:03 -04001548};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001550int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001551{
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001552 register_sysctl_table(sysctl_base_table);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001553 return 0;
1554}
1555
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001556#endif /* CONFIG_SYSCTL */
1557
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558/*
1559 * /proc/sys support
1560 */
1561
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001562#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001564static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001565 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001566 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001567{
1568 size_t len;
1569 char __user *p;
1570 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001571
1572 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001573 *lenp = 0;
1574 return 0;
1575 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001576
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001577 if (write) {
1578 len = 0;
1579 p = buffer;
1580 while (len < *lenp) {
1581 if (get_user(c, p++))
1582 return -EFAULT;
1583 if (c == 0 || c == '\n')
1584 break;
1585 len++;
1586 }
1587 if (len >= maxlen)
1588 len = maxlen-1;
1589 if(copy_from_user(data, buffer, len))
1590 return -EFAULT;
1591 ((char *) data)[len] = 0;
1592 *ppos += *lenp;
1593 } else {
1594 len = strlen(data);
1595 if (len > maxlen)
1596 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001597
1598 if (*ppos > len) {
1599 *lenp = 0;
1600 return 0;
1601 }
1602
1603 data += *ppos;
1604 len -= *ppos;
1605
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001606 if (len > *lenp)
1607 len = *lenp;
1608 if (len)
1609 if(copy_to_user(buffer, data, len))
1610 return -EFAULT;
1611 if (len < *lenp) {
1612 if(put_user('\n', ((char __user *) buffer) + len))
1613 return -EFAULT;
1614 len++;
1615 }
1616 *lenp = len;
1617 *ppos += len;
1618 }
1619 return 0;
1620}
1621
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622/**
1623 * proc_dostring - read a string sysctl
1624 * @table: the sysctl table
1625 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626 * @buffer: the user buffer
1627 * @lenp: the size of the user buffer
1628 * @ppos: file position
1629 *
1630 * Reads/writes a string from/to the user buffer. If the kernel
1631 * buffer provided is not large enough to hold the string, the
1632 * string is truncated. The copied string is %NULL-terminated.
1633 * If the string is being read by the user process, it is copied
1634 * and a newline '\n' is added. It is truncated if the buffer is
1635 * not large enough.
1636 *
1637 * Returns 0 on success.
1638 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001639int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640 void __user *buffer, size_t *lenp, loff_t *ppos)
1641{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001642 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001643 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644}
1645
Amerigo Wang00b7c332010-05-05 00:26:45 +00001646static size_t proc_skip_spaces(char **buf)
1647{
1648 size_t ret;
1649 char *tmp = skip_spaces(*buf);
1650 ret = tmp - *buf;
1651 *buf = tmp;
1652 return ret;
1653}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001655static void proc_skip_char(char **buf, size_t *size, const char v)
1656{
1657 while (*size) {
1658 if (**buf != v)
1659 break;
1660 (*size)--;
1661 (*buf)++;
1662 }
1663}
1664
Amerigo Wang00b7c332010-05-05 00:26:45 +00001665#define TMPBUFLEN 22
1666/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001667 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001668 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001669 * @buf: a kernel buffer
1670 * @size: size of the kernel buffer
1671 * @val: this is where the number will be stored
1672 * @neg: set to %TRUE if number is negative
1673 * @perm_tr: a vector which contains the allowed trailers
1674 * @perm_tr_len: size of the perm_tr vector
1675 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001676 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001677 * In case of success %0 is returned and @buf and @size are updated with
1678 * the amount of bytes read. If @tr is non-NULL and a trailing
1679 * character exists (size is non-zero after returning from this
1680 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001681 */
1682static int proc_get_long(char **buf, size_t *size,
1683 unsigned long *val, bool *neg,
1684 const char *perm_tr, unsigned perm_tr_len, char *tr)
1685{
1686 int len;
1687 char *p, tmp[TMPBUFLEN];
1688
1689 if (!*size)
1690 return -EINVAL;
1691
1692 len = *size;
1693 if (len > TMPBUFLEN - 1)
1694 len = TMPBUFLEN - 1;
1695
1696 memcpy(tmp, *buf, len);
1697
1698 tmp[len] = 0;
1699 p = tmp;
1700 if (*p == '-' && *size > 1) {
1701 *neg = true;
1702 p++;
1703 } else
1704 *neg = false;
1705 if (!isdigit(*p))
1706 return -EINVAL;
1707
1708 *val = simple_strtoul(p, &p, 0);
1709
1710 len = p - tmp;
1711
1712 /* We don't know if the next char is whitespace thus we may accept
1713 * invalid integers (e.g. 1234...a) or two integers instead of one
1714 * (e.g. 123...1). So lets not allow such large numbers. */
1715 if (len == TMPBUFLEN - 1)
1716 return -EINVAL;
1717
1718 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1719 return -EINVAL;
1720
1721 if (tr && (len < *size))
1722 *tr = *p;
1723
1724 *buf += len;
1725 *size -= len;
1726
1727 return 0;
1728}
1729
1730/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001731 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001732 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001733 * @buf: the user buffer
1734 * @size: the size of the user buffer
1735 * @val: the integer to be converted
1736 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001737 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001738 * In case of success %0 is returned and @buf and @size are updated with
1739 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001740 */
1741static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1742 bool neg)
1743{
1744 int len;
1745 char tmp[TMPBUFLEN], *p = tmp;
1746
1747 sprintf(p, "%s%lu", neg ? "-" : "", val);
1748 len = strlen(tmp);
1749 if (len > *size)
1750 len = *size;
1751 if (copy_to_user(*buf, tmp, len))
1752 return -EFAULT;
1753 *size -= len;
1754 *buf += len;
1755 return 0;
1756}
1757#undef TMPBUFLEN
1758
1759static int proc_put_char(void __user **buf, size_t *size, char c)
1760{
1761 if (*size) {
1762 char __user **buffer = (char __user **)buf;
1763 if (put_user(c, *buffer))
1764 return -EFAULT;
1765 (*size)--, (*buffer)++;
1766 *buf = *buffer;
1767 }
1768 return 0;
1769}
1770
1771static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001772 int *valp,
1773 int write, void *data)
1774{
1775 if (write) {
1776 *valp = *negp ? -*lvalp : *lvalp;
1777 } else {
1778 int val = *valp;
1779 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001780 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781 *lvalp = (unsigned long)-val;
1782 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001783 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 *lvalp = (unsigned long)val;
1785 }
1786 }
1787 return 0;
1788}
1789
Amerigo Wang00b7c332010-05-05 00:26:45 +00001790static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1791
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001792static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001793 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001794 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001795 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796 int write, void *data),
1797 void *data)
1798{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001799 int *i, vleft, first = 1, err = 0;
1800 unsigned long page = 0;
1801 size_t left;
1802 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803
Amerigo Wang00b7c332010-05-05 00:26:45 +00001804 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 *lenp = 0;
1806 return 0;
1807 }
1808
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001809 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001810 vleft = table->maxlen / sizeof(*i);
1811 left = *lenp;
1812
1813 if (!conv)
1814 conv = do_proc_dointvec_conv;
1815
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001817 if (left > PAGE_SIZE - 1)
1818 left = PAGE_SIZE - 1;
1819 page = __get_free_page(GFP_TEMPORARY);
1820 kbuf = (char *) page;
1821 if (!kbuf)
1822 return -ENOMEM;
1823 if (copy_from_user(kbuf, buffer, left)) {
1824 err = -EFAULT;
1825 goto free;
1826 }
1827 kbuf[left] = 0;
1828 }
1829
1830 for (; left && vleft--; i++, first=0) {
1831 unsigned long lval;
1832 bool neg;
1833
1834 if (write) {
1835 left -= proc_skip_spaces(&kbuf);
1836
J. R. Okajima563b0462010-05-25 16:10:14 -07001837 if (!left)
1838 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001839 err = proc_get_long(&kbuf, &left, &lval, &neg,
1840 proc_wspace_sep,
1841 sizeof(proc_wspace_sep), NULL);
1842 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001844 if (conv(&neg, &lval, i, 1, data)) {
1845 err = -EINVAL;
1846 break;
1847 }
1848 } else {
1849 if (conv(&neg, &lval, i, 0, data)) {
1850 err = -EINVAL;
1851 break;
1852 }
1853 if (!first)
1854 err = proc_put_char(&buffer, &left, '\t');
1855 if (err)
1856 break;
1857 err = proc_put_long(&buffer, &left, lval, neg);
1858 if (err)
1859 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 }
1861 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001862
1863 if (!write && !first && left && !err)
1864 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001865 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001866 left -= proc_skip_spaces(&kbuf);
1867free:
1868 if (write) {
1869 free_page(page);
1870 if (first)
1871 return err ? : -EINVAL;
1872 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873 *lenp -= left;
1874 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001875 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876}
1877
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001878static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001879 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001880 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001881 int write, void *data),
1882 void *data)
1883{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001884 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001885 buffer, lenp, ppos, conv, data);
1886}
1887
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888/**
1889 * proc_dointvec - read a vector of integers
1890 * @table: the sysctl table
1891 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 * @buffer: the user buffer
1893 * @lenp: the size of the user buffer
1894 * @ppos: file position
1895 *
1896 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1897 * values from/to the user buffer, treated as an ASCII string.
1898 *
1899 * Returns 0 on success.
1900 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001901int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 void __user *buffer, size_t *lenp, loff_t *ppos)
1903{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001904 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905 NULL,NULL);
1906}
1907
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001908/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001909 * Taint values can only be increased
1910 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001911 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001912static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001913 void __user *buffer, size_t *lenp, loff_t *ppos)
1914{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001915 struct ctl_table t;
1916 unsigned long tmptaint = get_taint();
1917 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001918
Bastian Blank91fcd412007-04-23 14:41:14 -07001919 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001920 return -EPERM;
1921
Andi Kleen25ddbb12008-10-15 22:01:41 -07001922 t = *table;
1923 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001924 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001925 if (err < 0)
1926 return err;
1927
1928 if (write) {
1929 /*
1930 * Poor man's atomic or. Not worth adding a primitive
1931 * to everyone's atomic.h for this
1932 */
1933 int i;
1934 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
1935 if ((tmptaint >> i) & 1)
1936 add_taint(i);
1937 }
1938 }
1939
1940 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001941}
1942
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07001943#ifdef CONFIG_PRINTK
1944static int proc_dmesg_restrict(struct ctl_table *table, int write,
1945 void __user *buffer, size_t *lenp, loff_t *ppos)
1946{
1947 if (write && !capable(CAP_SYS_ADMIN))
1948 return -EPERM;
1949
1950 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1951}
1952#endif
1953
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954struct do_proc_dointvec_minmax_conv_param {
1955 int *min;
1956 int *max;
1957};
1958
Amerigo Wang00b7c332010-05-05 00:26:45 +00001959static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
1960 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 int write, void *data)
1962{
1963 struct do_proc_dointvec_minmax_conv_param *param = data;
1964 if (write) {
1965 int val = *negp ? -*lvalp : *lvalp;
1966 if ((param->min && *param->min > val) ||
1967 (param->max && *param->max < val))
1968 return -EINVAL;
1969 *valp = val;
1970 } else {
1971 int val = *valp;
1972 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001973 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001974 *lvalp = (unsigned long)-val;
1975 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001976 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 *lvalp = (unsigned long)val;
1978 }
1979 }
1980 return 0;
1981}
1982
1983/**
1984 * proc_dointvec_minmax - read a vector of integers with min/max values
1985 * @table: the sysctl table
1986 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987 * @buffer: the user buffer
1988 * @lenp: the size of the user buffer
1989 * @ppos: file position
1990 *
1991 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1992 * values from/to the user buffer, treated as an ASCII string.
1993 *
1994 * This routine will ensure the values are within the range specified by
1995 * table->extra1 (min) and table->extra2 (max).
1996 *
1997 * Returns 0 on success.
1998 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001999int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 void __user *buffer, size_t *lenp, loff_t *ppos)
2001{
2002 struct do_proc_dointvec_minmax_conv_param param = {
2003 .min = (int *) table->extra1,
2004 .max = (int *) table->extra2,
2005 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002006 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 do_proc_dointvec_minmax_conv, &param);
2008}
2009
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002010static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011 void __user *buffer,
2012 size_t *lenp, loff_t *ppos,
2013 unsigned long convmul,
2014 unsigned long convdiv)
2015{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002016 unsigned long *i, *min, *max;
2017 int vleft, first = 1, err = 0;
2018 unsigned long page = 0;
2019 size_t left;
2020 char *kbuf;
2021
2022 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 *lenp = 0;
2024 return 0;
2025 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002026
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002027 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028 min = (unsigned long *) table->extra1;
2029 max = (unsigned long *) table->extra2;
2030 vleft = table->maxlen / sizeof(unsigned long);
2031 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002032
2033 if (write) {
2034 if (left > PAGE_SIZE - 1)
2035 left = PAGE_SIZE - 1;
2036 page = __get_free_page(GFP_TEMPORARY);
2037 kbuf = (char *) page;
2038 if (!kbuf)
2039 return -ENOMEM;
2040 if (copy_from_user(kbuf, buffer, left)) {
2041 err = -EFAULT;
2042 goto free;
2043 }
2044 kbuf[left] = 0;
2045 }
2046
Eric Dumazet27b3d802010-10-07 12:59:29 -07002047 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002048 unsigned long val;
2049
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002051 bool neg;
2052
2053 left -= proc_skip_spaces(&kbuf);
2054
2055 err = proc_get_long(&kbuf, &left, &val, &neg,
2056 proc_wspace_sep,
2057 sizeof(proc_wspace_sep), NULL);
2058 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 break;
2060 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002061 continue;
2062 if ((min && val < *min) || (max && val > *max))
2063 continue;
2064 *i = val;
2065 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002066 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002068 err = proc_put_char(&buffer, &left, '\t');
2069 err = proc_put_long(&buffer, &left, val, false);
2070 if (err)
2071 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002072 }
2073 }
2074
Amerigo Wang00b7c332010-05-05 00:26:45 +00002075 if (!write && !first && left && !err)
2076 err = proc_put_char(&buffer, &left, '\n');
2077 if (write && !err)
2078 left -= proc_skip_spaces(&kbuf);
2079free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002081 free_page(page);
2082 if (first)
2083 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 *lenp -= left;
2086 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002087 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088}
2089
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002090static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002091 void __user *buffer,
2092 size_t *lenp, loff_t *ppos,
2093 unsigned long convmul,
2094 unsigned long convdiv)
2095{
2096 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002097 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002098}
2099
Linus Torvalds1da177e2005-04-16 15:20:36 -07002100/**
2101 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2102 * @table: the sysctl table
2103 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104 * @buffer: the user buffer
2105 * @lenp: the size of the user buffer
2106 * @ppos: file position
2107 *
2108 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2109 * values from/to the user buffer, treated as an ASCII string.
2110 *
2111 * This routine will ensure the values are within the range specified by
2112 * table->extra1 (min) and table->extra2 (max).
2113 *
2114 * Returns 0 on success.
2115 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002116int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117 void __user *buffer, size_t *lenp, loff_t *ppos)
2118{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002119 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120}
2121
2122/**
2123 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2124 * @table: the sysctl table
2125 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126 * @buffer: the user buffer
2127 * @lenp: the size of the user buffer
2128 * @ppos: file position
2129 *
2130 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2131 * values from/to the user buffer, treated as an ASCII string. The values
2132 * are treated as milliseconds, and converted to jiffies when they are stored.
2133 *
2134 * This routine will ensure the values are within the range specified by
2135 * table->extra1 (min) and table->extra2 (max).
2136 *
2137 * Returns 0 on success.
2138 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002139int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140 void __user *buffer,
2141 size_t *lenp, loff_t *ppos)
2142{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002143 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 lenp, ppos, HZ, 1000l);
2145}
2146
2147
Amerigo Wang00b7c332010-05-05 00:26:45 +00002148static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 int *valp,
2150 int write, void *data)
2151{
2152 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002153 if (*lvalp > LONG_MAX / HZ)
2154 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2156 } else {
2157 int val = *valp;
2158 unsigned long lval;
2159 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002160 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161 lval = (unsigned long)-val;
2162 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002163 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 lval = (unsigned long)val;
2165 }
2166 *lvalp = lval / HZ;
2167 }
2168 return 0;
2169}
2170
Amerigo Wang00b7c332010-05-05 00:26:45 +00002171static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 int *valp,
2173 int write, void *data)
2174{
2175 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002176 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2177 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2179 } else {
2180 int val = *valp;
2181 unsigned long lval;
2182 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002183 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184 lval = (unsigned long)-val;
2185 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002186 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 lval = (unsigned long)val;
2188 }
2189 *lvalp = jiffies_to_clock_t(lval);
2190 }
2191 return 0;
2192}
2193
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 int *valp,
2196 int write, void *data)
2197{
2198 if (write) {
2199 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2200 } else {
2201 int val = *valp;
2202 unsigned long lval;
2203 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002204 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 lval = (unsigned long)-val;
2206 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002207 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 lval = (unsigned long)val;
2209 }
2210 *lvalp = jiffies_to_msecs(lval);
2211 }
2212 return 0;
2213}
2214
2215/**
2216 * proc_dointvec_jiffies - read a vector of integers as seconds
2217 * @table: the sysctl table
2218 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 * @buffer: the user buffer
2220 * @lenp: the size of the user buffer
2221 * @ppos: file position
2222 *
2223 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2224 * values from/to the user buffer, treated as an ASCII string.
2225 * The values read are assumed to be in seconds, and are converted into
2226 * jiffies.
2227 *
2228 * Returns 0 on success.
2229 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002230int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231 void __user *buffer, size_t *lenp, loff_t *ppos)
2232{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002233 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 do_proc_dointvec_jiffies_conv,NULL);
2235}
2236
2237/**
2238 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2239 * @table: the sysctl table
2240 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 * @buffer: the user buffer
2242 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002243 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 *
2245 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2246 * values from/to the user buffer, treated as an ASCII string.
2247 * The values read are assumed to be in 1/USER_HZ seconds, and
2248 * are converted into jiffies.
2249 *
2250 * Returns 0 on success.
2251 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002252int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 void __user *buffer, size_t *lenp, loff_t *ppos)
2254{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002255 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 do_proc_dointvec_userhz_jiffies_conv,NULL);
2257}
2258
2259/**
2260 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2261 * @table: the sysctl table
2262 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 * @buffer: the user buffer
2264 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002265 * @ppos: file position
2266 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 *
2268 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2269 * values from/to the user buffer, treated as an ASCII string.
2270 * The values read are assumed to be in 1/1000 seconds, and
2271 * are converted into jiffies.
2272 *
2273 * Returns 0 on success.
2274 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002275int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276 void __user *buffer, size_t *lenp, loff_t *ppos)
2277{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002278 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 do_proc_dointvec_ms_jiffies_conv, NULL);
2280}
2281
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002282static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002283 void __user *buffer, size_t *lenp, loff_t *ppos)
2284{
2285 struct pid *new_pid;
2286 pid_t tmp;
2287 int r;
2288
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002289 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002290
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002291 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002292 lenp, ppos, NULL, NULL);
2293 if (r || !write)
2294 return r;
2295
2296 new_pid = find_get_pid(tmp);
2297 if (!new_pid)
2298 return -ESRCH;
2299
2300 put_pid(xchg(&cad_pid, new_pid));
2301 return 0;
2302}
2303
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002304/**
2305 * proc_do_large_bitmap - read/write from/to a large bitmap
2306 * @table: the sysctl table
2307 * @write: %TRUE if this is a write to the sysctl file
2308 * @buffer: the user buffer
2309 * @lenp: the size of the user buffer
2310 * @ppos: file position
2311 *
2312 * The bitmap is stored at table->data and the bitmap length (in bits)
2313 * in table->maxlen.
2314 *
2315 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2316 * large bitmaps may be represented in a compact manner. Writing into
2317 * the file will clear the bitmap then update it with the given input.
2318 *
2319 * Returns 0 on success.
2320 */
2321int proc_do_large_bitmap(struct ctl_table *table, int write,
2322 void __user *buffer, size_t *lenp, loff_t *ppos)
2323{
2324 int err = 0;
2325 bool first = 1;
2326 size_t left = *lenp;
2327 unsigned long bitmap_len = table->maxlen;
2328 unsigned long *bitmap = (unsigned long *) table->data;
2329 unsigned long *tmp_bitmap = NULL;
2330 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2331
2332 if (!bitmap_len || !left || (*ppos && !write)) {
2333 *lenp = 0;
2334 return 0;
2335 }
2336
2337 if (write) {
2338 unsigned long page = 0;
2339 char *kbuf;
2340
2341 if (left > PAGE_SIZE - 1)
2342 left = PAGE_SIZE - 1;
2343
2344 page = __get_free_page(GFP_TEMPORARY);
2345 kbuf = (char *) page;
2346 if (!kbuf)
2347 return -ENOMEM;
2348 if (copy_from_user(kbuf, buffer, left)) {
2349 free_page(page);
2350 return -EFAULT;
2351 }
2352 kbuf[left] = 0;
2353
2354 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2355 GFP_KERNEL);
2356 if (!tmp_bitmap) {
2357 free_page(page);
2358 return -ENOMEM;
2359 }
2360 proc_skip_char(&kbuf, &left, '\n');
2361 while (!err && left) {
2362 unsigned long val_a, val_b;
2363 bool neg;
2364
2365 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2366 sizeof(tr_a), &c);
2367 if (err)
2368 break;
2369 if (val_a >= bitmap_len || neg) {
2370 err = -EINVAL;
2371 break;
2372 }
2373
2374 val_b = val_a;
2375 if (left) {
2376 kbuf++;
2377 left--;
2378 }
2379
2380 if (c == '-') {
2381 err = proc_get_long(&kbuf, &left, &val_b,
2382 &neg, tr_b, sizeof(tr_b),
2383 &c);
2384 if (err)
2385 break;
2386 if (val_b >= bitmap_len || neg ||
2387 val_a > val_b) {
2388 err = -EINVAL;
2389 break;
2390 }
2391 if (left) {
2392 kbuf++;
2393 left--;
2394 }
2395 }
2396
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002397 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002398 first = 0;
2399 proc_skip_char(&kbuf, &left, '\n');
2400 }
2401 free_page(page);
2402 } else {
2403 unsigned long bit_a, bit_b = 0;
2404
2405 while (left) {
2406 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2407 if (bit_a >= bitmap_len)
2408 break;
2409 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2410 bit_a + 1) - 1;
2411
2412 if (!first) {
2413 err = proc_put_char(&buffer, &left, ',');
2414 if (err)
2415 break;
2416 }
2417 err = proc_put_long(&buffer, &left, bit_a, false);
2418 if (err)
2419 break;
2420 if (bit_a != bit_b) {
2421 err = proc_put_char(&buffer, &left, '-');
2422 if (err)
2423 break;
2424 err = proc_put_long(&buffer, &left, bit_b, false);
2425 if (err)
2426 break;
2427 }
2428
2429 first = 0; bit_b++;
2430 }
2431 if (!err)
2432 err = proc_put_char(&buffer, &left, '\n');
2433 }
2434
2435 if (!err) {
2436 if (write) {
2437 if (*ppos)
2438 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2439 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002440 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002441 }
2442 kfree(tmp_bitmap);
2443 *lenp -= left;
2444 *ppos += *lenp;
2445 return 0;
2446 } else {
2447 kfree(tmp_bitmap);
2448 return err;
2449 }
2450}
2451
Jovi Zhang55610502011-01-12 17:00:45 -08002452#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002454int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455 void __user *buffer, size_t *lenp, loff_t *ppos)
2456{
2457 return -ENOSYS;
2458}
2459
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002460int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461 void __user *buffer, size_t *lenp, loff_t *ppos)
2462{
2463 return -ENOSYS;
2464}
2465
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002466int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 void __user *buffer, size_t *lenp, loff_t *ppos)
2468{
2469 return -ENOSYS;
2470}
2471
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002472int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 void __user *buffer, size_t *lenp, loff_t *ppos)
2474{
2475 return -ENOSYS;
2476}
2477
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002478int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479 void __user *buffer, size_t *lenp, loff_t *ppos)
2480{
2481 return -ENOSYS;
2482}
2483
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002484int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 void __user *buffer, size_t *lenp, loff_t *ppos)
2486{
2487 return -ENOSYS;
2488}
2489
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002490int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 void __user *buffer, size_t *lenp, loff_t *ppos)
2492{
2493 return -ENOSYS;
2494}
2495
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002496int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 void __user *buffer,
2498 size_t *lenp, loff_t *ppos)
2499{
2500 return -ENOSYS;
2501}
2502
2503
Jovi Zhang55610502011-01-12 17:00:45 -08002504#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506/*
2507 * No sense putting this after each symbol definition, twice,
2508 * exception granted :-)
2509 */
2510EXPORT_SYMBOL(proc_dointvec);
2511EXPORT_SYMBOL(proc_dointvec_jiffies);
2512EXPORT_SYMBOL(proc_dointvec_minmax);
2513EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2514EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2515EXPORT_SYMBOL(proc_dostring);
2516EXPORT_SYMBOL(proc_doulongvec_minmax);
2517EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);