blob: 840fd5eb2309344e16248c8449af2b69b7edeb59 [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>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070033#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070034#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/init.h>
36#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010037#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030038#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/sysrq.h>
40#include <linux/highuid.h>
41#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020042#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070043#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070046#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/times.h>
48#include <linux/limits.h>
49#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020050#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070052#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080053#include <linux/nfs_fs.h>
54#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070055#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020056#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020057#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050058#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020059#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070060#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040061#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070062#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000063#include <linux/binfmts.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#include <asm/uaccess.h>
66#include <asm/processor.h>
67
Andi Kleen29cbc782006-09-30 01:47:55 +020068#ifdef CONFIG_X86
69#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010070#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010071#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020072#endif
David Howellsd550bbd2012-03-28 18:30:03 +010073#ifdef CONFIG_SPARC
74#include <asm/setup.h>
75#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080076#ifdef CONFIG_BSD_PROCESS_ACCT
77#include <linux/acct.h>
78#endif
Dave Young4f0e0562010-03-10 15:24:09 -080079#ifdef CONFIG_RT_MUTEXES
80#include <linux/rtmutex.h>
81#endif
Dave Young2edf5e42010-03-10 15:24:10 -080082#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
83#include <linux/lockdep.h>
84#endif
Dave Young15485a42010-03-10 15:24:07 -080085#ifdef CONFIG_CHR_DEV_SG
86#include <scsi/sg.h>
87#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020088
Don Zickus58687ac2010-05-07 17:11:44 -040089#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050090#include <linux/nmi.h>
91#endif
92
Eric W. Biederman7058cb02007-10-18 03:05:58 -070093
Linus Torvalds1da177e2005-04-16 15:20:36 -070094#if defined(CONFIG_SYSCTL)
95
96/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern int sysctl_overcommit_memory;
98extern int sysctl_overcommit_ratio;
99extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700100extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700101#ifdef CONFIG_COREDUMP
102extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700104extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700105#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max;
107extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800109extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200111extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100112extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400113extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000114#ifndef CONFIG_MMU
115extern int sysctl_nr_trim_pages;
116#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200117#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200118extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400122#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200124static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125#endif
126
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700127static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700128static int __maybe_unused one = 1;
129static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700130static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800131static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800143static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Dave Youngd14f1722010-02-25 20:28:57 -0500148#ifdef CONFIG_INOTIFY_USER
149#include <linux/inotify.h>
150#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700151#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif
153
David S. Miller08714202008-11-16 23:49:24 -0800154#ifdef CONFIG_SPARC64
155extern int sysctl_tsb_ratio;
156#endif
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#ifdef __hppa__
159extern int pwrsw_enabled;
160extern int unaligned_enabled;
161#endif
162
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800164extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800165#endif
166
Vineet Guptab6fca722013-01-09 20:06:28 +0530167#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
168extern int no_unaligned_warning;
169#endif
170
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700171#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700172static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700173 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700174static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800175 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700176#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700177
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700178#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700179static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700180 void __user *buffer, size_t *lenp, loff_t *ppos);
181#endif
182
Kees Cook54b50192012-07-30 14:39:18 -0700183static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
184 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700185#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700186static int proc_dostring_coredump(struct ctl_table *table, int write,
187 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700188#endif
Kees Cook54b50192012-07-30 14:39:18 -0700189
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700190#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800191/* Note: sysrq code uses it's own private copy */
192static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700193
194static int sysrq_sysctl_handler(ctl_table *table, int write,
195 void __user *buffer, size_t *lenp,
196 loff_t *ppos)
197{
198 int error;
199
200 error = proc_dointvec(table, write, buffer, lenp, ppos);
201 if (error)
202 return error;
203
204 if (write)
205 sysrq_toggle_support(__sysrq_enabled);
206
207 return 0;
208}
209
210#endif
211
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700212static struct ctl_table kern_table[];
213static struct ctl_table vm_table[];
214static struct ctl_table fs_table[];
215static struct ctl_table debug_table[];
216static struct ctl_table dev_table[];
217extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800218#ifdef CONFIG_EPOLL
219extern struct ctl_table epoll_table[];
220#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
223int sysctl_legacy_va_layout;
224#endif
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226/* The default sysctl tables: */
227
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800228static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 .procname = "kernel",
231 .mode = 0555,
232 .child = kern_table,
233 },
234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .procname = "vm",
236 .mode = 0555,
237 .child = vm_table,
238 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "fs",
241 .mode = 0555,
242 .child = fs_table,
243 },
244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "debug",
246 .mode = 0555,
247 .child = debug_table,
248 },
249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "dev",
251 .mode = 0555,
252 .child = dev_table,
253 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700254 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255};
256
Ingo Molnar77e54a12007-07-09 18:52:00 +0200257#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100258static int min_sched_granularity_ns = 100000; /* 100 usecs */
259static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
260static int min_wakeup_granularity_ns; /* 0 usecs */
261static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200262#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100263static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
264static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200265#endif /* CONFIG_SMP */
266#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267
Mel Gorman5e771902010-05-24 14:32:31 -0700268#ifdef CONFIG_COMPACTION
269static int min_extfrag_threshold;
270static int max_extfrag_threshold = 1000;
271#endif
272
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700273static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200274 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200275 .procname = "sched_child_runs_first",
276 .data = &sysctl_sched_child_runs_first,
277 .maxlen = sizeof(unsigned int),
278 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800279 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200280 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281#ifdef CONFIG_SCHED_DEBUG
282 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100283 .procname = "sched_min_granularity_ns",
284 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800287 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100288 .extra1 = &min_sched_granularity_ns,
289 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200290 },
291 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200292 .procname = "sched_latency_ns",
293 .data = &sysctl_sched_latency,
294 .maxlen = sizeof(unsigned int),
295 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800296 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200297 .extra1 = &min_sched_granularity_ns,
298 .extra2 = &max_sched_granularity_ns,
299 },
300 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200301 .procname = "sched_wakeup_granularity_ns",
302 .data = &sysctl_sched_wakeup_granularity,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800305 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200306 .extra1 = &min_wakeup_granularity_ns,
307 .extra2 = &max_wakeup_granularity_ns,
308 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200309#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200310 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100311 .procname = "sched_tunable_scaling",
312 .data = &sysctl_sched_tunable_scaling,
313 .maxlen = sizeof(enum sched_tunable_scaling),
314 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800315 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100316 .extra1 = &min_sched_tunable_scaling,
317 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200318 },
319 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900320 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200321 .data = &sysctl_sched_migration_cost,
322 .maxlen = sizeof(unsigned int),
323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800324 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200325 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100326 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100327 .procname = "sched_nr_migrate",
328 .data = &sysctl_sched_nr_migrate,
329 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100332 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530333 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900334 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200335 .data = &sysctl_sched_time_avg,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200339 },
340 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900341 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800342 .data = &sysctl_sched_shares_window,
343 .maxlen = sizeof(unsigned int),
344 .mode = 0644,
345 .proc_handler = proc_dointvec,
346 },
347 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530348 .procname = "timer_migration",
349 .data = &sysctl_timer_migration,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800352 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530353 .extra1 = &zero,
354 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530355 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200356#endif /* CONFIG_SMP */
357#ifdef CONFIG_NUMA_BALANCING
358 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200359 .procname = "numa_balancing_scan_delay_ms",
360 .data = &sysctl_numa_balancing_scan_delay,
361 .maxlen = sizeof(unsigned int),
362 .mode = 0644,
363 .proc_handler = proc_dointvec,
364 },
365 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200366 .procname = "numa_balancing_scan_period_min_ms",
367 .data = &sysctl_numa_balancing_scan_period_min,
368 .maxlen = sizeof(unsigned int),
369 .mode = 0644,
370 .proc_handler = proc_dointvec,
371 },
372 {
Mel Gormanb8593bf2012-11-21 01:18:23 +0000373 .procname = "numa_balancing_scan_period_reset",
374 .data = &sysctl_numa_balancing_scan_period_reset,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = proc_dointvec,
378 },
379 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200380 .procname = "numa_balancing_scan_period_max_ms",
381 .data = &sysctl_numa_balancing_scan_period_max,
382 .maxlen = sizeof(unsigned int),
383 .mode = 0644,
384 .proc_handler = proc_dointvec,
385 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200386 {
387 .procname = "numa_balancing_scan_size_mb",
388 .data = &sysctl_numa_balancing_scan_size,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = proc_dointvec,
392 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200393#endif /* CONFIG_NUMA_BALANCING */
394#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200395 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100396 .procname = "sched_rt_period_us",
397 .data = &sysctl_sched_rt_period,
398 .maxlen = sizeof(unsigned int),
399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800400 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100401 },
402 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100403 .procname = "sched_rt_runtime_us",
404 .data = &sysctl_sched_rt_runtime,
405 .maxlen = sizeof(int),
406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800407 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100408 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100409#ifdef CONFIG_SCHED_AUTOGROUP
410 {
411 .procname = "sched_autogroup_enabled",
412 .data = &sysctl_sched_autogroup_enabled,
413 .maxlen = sizeof(unsigned int),
414 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800415 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100416 .extra1 = &zero,
417 .extra2 = &one,
418 },
419#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700420#ifdef CONFIG_CFS_BANDWIDTH
421 {
422 .procname = "sched_cfs_bandwidth_slice_us",
423 .data = &sysctl_sched_cfs_bandwidth_slice,
424 .maxlen = sizeof(unsigned int),
425 .mode = 0644,
426 .proc_handler = proc_dointvec_minmax,
427 .extra1 = &one,
428 },
429#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700430#ifdef CONFIG_PROVE_LOCKING
431 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700432 .procname = "prove_locking",
433 .data = &prove_locking,
434 .maxlen = sizeof(int),
435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800436 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700437 },
438#endif
439#ifdef CONFIG_LOCK_STAT
440 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700441 .procname = "lock_stat",
442 .data = &lock_stat,
443 .maxlen = sizeof(int),
444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800445 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446 },
447#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200448 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 .procname = "panic",
450 .data = &panic_timeout,
451 .maxlen = sizeof(int),
452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800453 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 },
Alex Kelly046d6622012-10-04 17:15:23 -0700455#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .procname = "core_uses_pid",
458 .data = &core_uses_pid,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 },
463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "core_pattern",
465 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700466 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700468 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
Neil Hormana2939802009-09-23 15:56:56 -0700470 {
Neil Hormana2939802009-09-23 15:56:56 -0700471 .procname = "core_pipe_limit",
472 .data = &core_pipe_limit,
473 .maxlen = sizeof(unsigned int),
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700476 },
Alex Kelly046d6622012-10-04 17:15:23 -0700477#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800478#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700481 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800483 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800485#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100486#ifdef CONFIG_LATENCYTOP
487 {
488 .procname = "latencytop",
489 .data = &latencytop_enabled,
490 .maxlen = sizeof(int),
491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100493 },
494#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495#ifdef CONFIG_BLK_DEV_INITRD
496 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 .procname = "real-root-dev",
498 .data = &real_root_dev,
499 .maxlen = sizeof(int),
500 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800501 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 },
503#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700504 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700505 .procname = "print-fatal-signals",
506 .data = &print_fatal_signals,
507 .maxlen = sizeof(int),
508 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800509 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700510 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700511#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 .procname = "reboot-cmd",
514 .data = reboot_command,
515 .maxlen = 256,
516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800517 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 },
519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 .procname = "stop-a",
521 .data = &stop_a_enabled,
522 .maxlen = sizeof (int),
523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800524 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 },
526 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 .procname = "scons-poweroff",
528 .data = &scons_pwroff,
529 .maxlen = sizeof (int),
530 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800531 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 },
533#endif
David S. Miller08714202008-11-16 23:49:24 -0800534#ifdef CONFIG_SPARC64
535 {
David S. Miller08714202008-11-16 23:49:24 -0800536 .procname = "tsb-ratio",
537 .data = &sysctl_tsb_ratio,
538 .maxlen = sizeof (int),
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800541 },
542#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543#ifdef __hppa__
544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "soft-power",
546 .data = &pwrsw_enabled,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "unaligned-trap",
553 .data = &unaligned_enabled,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558#endif
559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "ctrl-alt-del",
561 .data = &C_A_D,
562 .maxlen = sizeof(int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400566#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200567 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200568 .procname = "ftrace_enabled",
569 .data = &ftrace_enabled,
570 .maxlen = sizeof(int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200573 },
574#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500575#ifdef CONFIG_STACK_TRACER
576 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500577 .procname = "stack_tracer_enabled",
578 .data = &stack_tracer_enabled,
579 .maxlen = sizeof(int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500582 },
583#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400584#ifdef CONFIG_TRACING
585 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100586 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400587 .data = &ftrace_dump_on_oops,
588 .maxlen = sizeof(int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400591 },
592#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200593#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 .procname = "modprobe",
596 .data = &modprobe_path,
597 .maxlen = KMOD_PATH_LEN,
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 },
Kees Cook3d433212009-04-02 15:49:29 -0700601 {
Kees Cook3d433212009-04-02 15:49:29 -0700602 .procname = "modules_disabled",
603 .data = &modules_disabled,
604 .maxlen = sizeof(int),
605 .mode = 0644,
606 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700608 .extra1 = &one,
609 .extra2 = &one,
610 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500612
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100615 .data = &uevent_helper,
616 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500620
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621#ifdef CONFIG_CHR_DEV_SG
622 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .procname = "sg-big-buff",
624 .data = &sg_big_buff,
625 .maxlen = sizeof (int),
626 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800627 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 },
629#endif
630#ifdef CONFIG_BSD_PROCESS_ACCT
631 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 .procname = "acct",
633 .data = &acct_parm,
634 .maxlen = 3*sizeof(int),
635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800636 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 },
638#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639#ifdef CONFIG_MAGIC_SYSRQ
640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800642 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 .maxlen = sizeof (int),
644 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700645 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 },
647#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700648#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700651 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 .maxlen = sizeof (int),
653 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700656#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "threads-max",
659 .data = &max_threads,
660 .maxlen = sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 },
664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "random",
666 .mode = 0555,
667 .child = random_table,
668 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 {
Eric Paris17f60a72011-04-01 17:07:50 -0400670 .procname = "usermodehelper",
671 .mode = 0555,
672 .child = usermodehelper_table,
673 },
674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "overflowuid",
676 .data = &overflowuid,
677 .maxlen = sizeof(int),
678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800679 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 .extra1 = &minolduid,
681 .extra2 = &maxolduid,
682 },
683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "overflowgid",
685 .data = &overflowgid,
686 .maxlen = sizeof(int),
687 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800688 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .extra1 = &minolduid,
690 .extra2 = &maxolduid,
691 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800692#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693#ifdef CONFIG_MATHEMU
694 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .procname = "ieee_emulation_warnings",
696 .data = &sysctl_ieee_emulation_warnings,
697 .maxlen = sizeof(int),
698 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800699 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 },
701#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200704 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 .maxlen = sizeof(int),
706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800707 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 },
709#endif
710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "pid_max",
712 .data = &pid_max,
713 .maxlen = sizeof (int),
714 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800715 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .extra1 = &pid_max_min,
717 .extra2 = &pid_max_max,
718 },
719 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .procname = "panic_on_oops",
721 .data = &panic_on_oops,
722 .maxlen = sizeof(int),
723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800724 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800726#if defined CONFIG_PRINTK
727 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800728 .procname = "printk",
729 .data = &console_loglevel,
730 .maxlen = 4*sizeof(int),
731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800732 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800733 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700736 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 .maxlen = sizeof(int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 },
741 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700743 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .maxlen = sizeof(int),
745 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800746 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 },
Dave Youngaf913222009-09-22 16:43:33 -0700748 {
Dave Youngaf913222009-09-22 16:43:33 -0700749 .procname = "printk_delay",
750 .data = &printk_delay_msec,
751 .maxlen = sizeof(int),
752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700754 .extra1 = &zero,
755 .extra2 = &ten_thousand,
756 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800758 .procname = "dmesg_restrict",
759 .data = &dmesg_restrict,
760 .maxlen = sizeof(int),
761 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700762 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800763 .extra1 = &zero,
764 .extra2 = &one,
765 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800766 {
767 .procname = "kptr_restrict",
768 .data = &kptr_restrict,
769 .maxlen = sizeof(int),
770 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700771 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800772 .extra1 = &zero,
773 .extra2 = &two,
774 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800775#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800776 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 .procname = "ngroups_max",
778 .data = &ngroups_max,
779 .maxlen = sizeof (int),
780 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800781 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 },
Dan Ballard73efc032011-10-31 17:11:20 -0700783 {
784 .procname = "cap_last_cap",
785 .data = (void *)&cap_last_cap,
786 .maxlen = sizeof(int),
787 .mode = 0444,
788 .proc_handler = proc_dointvec,
789 },
Don Zickus58687ac2010-05-07 17:11:44 -0400790#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500791 {
Don Zickus58687ac2010-05-07 17:11:44 -0400792 .procname = "watchdog",
793 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500794 .maxlen = sizeof (int),
795 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700796 .proc_handler = proc_dowatchdog,
797 .extra1 = &zero,
798 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400799 },
800 {
801 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700802 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400803 .maxlen = sizeof(int),
804 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700805 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400806 .extra1 = &neg_one,
807 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500808 },
Don Zickus2508ce12010-05-07 17:11:46 -0400809 {
810 .procname = "softlockup_panic",
811 .data = &softlockup_panic,
812 .maxlen = sizeof(int),
813 .mode = 0644,
814 .proc_handler = proc_dointvec_minmax,
815 .extra1 = &zero,
816 .extra2 = &one,
817 },
Don Zickus5dc30552010-11-29 17:07:17 -0500818 {
819 .procname = "nmi_watchdog",
820 .data = &watchdog_enabled,
821 .maxlen = sizeof (int),
822 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700823 .proc_handler = proc_dowatchdog,
824 .extra1 = &zero,
825 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500826 },
827#endif
828#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
829 {
830 .procname = "unknown_nmi_panic",
831 .data = &unknown_nmi_panic,
832 .maxlen = sizeof (int),
833 .mode = 0644,
834 .proc_handler = proc_dointvec,
835 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500836#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837#if defined(CONFIG_X86)
838 {
Don Zickus8da5add2006-09-26 10:52:27 +0200839 .procname = "panic_on_unrecovered_nmi",
840 .data = &panic_on_unrecovered_nmi,
841 .maxlen = sizeof(int),
842 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800843 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200844 },
845 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700846 .procname = "panic_on_io_nmi",
847 .data = &panic_on_io_nmi,
848 .maxlen = sizeof(int),
849 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800850 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700851 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900852#ifdef CONFIG_DEBUG_STACKOVERFLOW
853 {
854 .procname = "panic_on_stackoverflow",
855 .data = &sysctl_panic_on_stackoverflow,
856 .maxlen = sizeof(int),
857 .mode = 0644,
858 .proc_handler = proc_dointvec,
859 },
860#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700861 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 .procname = "bootloader_type",
863 .data = &bootloader_type,
864 .maxlen = sizeof (int),
865 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800866 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100868 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700869 .procname = "bootloader_version",
870 .data = &bootloader_version,
871 .maxlen = sizeof (int),
872 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800873 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700874 },
875 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100876 .procname = "kstack_depth_to_print",
877 .data = &kstack_depth_to_print,
878 .maxlen = sizeof(int),
879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800880 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100881 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100882 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100883 .procname = "io_delay_type",
884 .data = &io_delay_type,
885 .maxlen = sizeof(int),
886 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800887 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100888 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800890#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 .procname = "randomize_va_space",
893 .data = &randomize_va_space,
894 .maxlen = sizeof(int),
895 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800896 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800898#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800899#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700900 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700901 .procname = "spin_retry",
902 .data = &spin_retry,
903 .maxlen = sizeof (int),
904 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800905 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700906 },
907#endif
Len Brown673d5b42007-07-28 03:33:16 -0400908#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800909 {
Pavel Machekc255d842006-02-20 18:27:58 -0800910 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700911 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800912 .maxlen = sizeof (unsigned long),
913 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800914 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800915 },
916#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530917#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800918 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800919 .procname = "ignore-unaligned-usertrap",
920 .data = &no_unaligned_warning,
921 .maxlen = sizeof (int),
922 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800923 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800924 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530925#endif
926#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800927 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800928 .procname = "unaligned-dump-stack",
929 .data = &unaligned_dump_stack,
930 .maxlen = sizeof (int),
931 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800932 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800933 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800934#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800935#ifdef CONFIG_DETECT_HUNG_TASK
936 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800937 .procname = "hung_task_panic",
938 .data = &sysctl_hung_task_panic,
939 .maxlen = sizeof(int),
940 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800941 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800942 .extra1 = &zero,
943 .extra2 = &one,
944 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100945 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100946 .procname = "hung_task_check_count",
947 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100948 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100949 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800950 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100951 },
952 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100953 .procname = "hung_task_timeout_secs",
954 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100955 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100956 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800957 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100958 },
959 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100960 .procname = "hung_task_warnings",
961 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100962 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100963 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800964 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100965 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700966#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200967#ifdef CONFIG_COMPAT
968 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200969 .procname = "compat-log",
970 .data = &compat_log,
971 .maxlen = sizeof (int),
972 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800973 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200974 },
975#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700976#ifdef CONFIG_RT_MUTEXES
977 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700978 .procname = "max_lock_depth",
979 .data = &max_lock_depth,
980 .maxlen = sizeof(int),
981 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800982 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700983 },
984#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700985 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700986 .procname = "poweroff_cmd",
987 .data = &poweroff_cmd,
988 .maxlen = POWEROFF_CMD_PATH_LEN,
989 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800990 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700991 },
David Howells0b77f5b2008-04-29 01:01:32 -0700992#ifdef CONFIG_KEYS
993 {
David Howells0b77f5b2008-04-29 01:01:32 -0700994 .procname = "keys",
995 .mode = 0555,
996 .child = key_sysctls,
997 },
998#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700999#ifdef CONFIG_RCU_TORTURE_TEST
1000 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001001 .procname = "rcutorture_runnable",
1002 .data = &rcutorture_runnable,
1003 .maxlen = sizeof(int),
1004 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001005 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001006 },
1007#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001008#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001009 /*
1010 * User-space scripts rely on the existence of this file
1011 * as a feature check for perf_events being enabled.
1012 *
1013 * So it's an ABI, do not remove!
1014 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001015 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001016 .procname = "perf_event_paranoid",
1017 .data = &sysctl_perf_event_paranoid,
1018 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001019 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001020 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001021 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001022 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001023 .procname = "perf_event_mlock_kb",
1024 .data = &sysctl_perf_event_mlock,
1025 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001026 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001027 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001028 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001029 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001030 .procname = "perf_event_max_sample_rate",
1031 .data = &sysctl_perf_event_sample_rate,
1032 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001033 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001034 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001035 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001036#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001037#ifdef CONFIG_KMEMCHECK
1038 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001039 .procname = "kmemcheck",
1040 .data = &kmemcheck_enabled,
1041 .maxlen = sizeof(int),
1042 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001043 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001044 },
1045#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001046#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001047 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001048 .procname = "blk_iopoll",
1049 .data = &blk_iopoll_enabled,
1050 .maxlen = sizeof(int),
1051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001053 },
Jens Axboecb684b52009-09-15 21:53:11 +02001054#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001055 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056};
1057
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001058static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 .procname = "overcommit_memory",
1061 .data = &sysctl_overcommit_memory,
1062 .maxlen = sizeof(sysctl_overcommit_memory),
1063 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001064 .proc_handler = proc_dointvec_minmax,
1065 .extra1 = &zero,
1066 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 },
1068 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001069 .procname = "panic_on_oom",
1070 .data = &sysctl_panic_on_oom,
1071 .maxlen = sizeof(sysctl_panic_on_oom),
1072 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001073 .proc_handler = proc_dointvec_minmax,
1074 .extra1 = &zero,
1075 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001076 },
1077 {
David Rientjesfe071d72007-10-16 23:25:56 -07001078 .procname = "oom_kill_allocating_task",
1079 .data = &sysctl_oom_kill_allocating_task,
1080 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1081 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001082 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001083 },
1084 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001085 .procname = "oom_dump_tasks",
1086 .data = &sysctl_oom_dump_tasks,
1087 .maxlen = sizeof(sysctl_oom_dump_tasks),
1088 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001089 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001090 },
1091 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 .procname = "overcommit_ratio",
1093 .data = &sysctl_overcommit_ratio,
1094 .maxlen = sizeof(sysctl_overcommit_ratio),
1095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 },
1098 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 .procname = "page-cluster",
1100 .data = &page_cluster,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001103 .proc_handler = proc_dointvec_minmax,
1104 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 },
1106 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 .procname = "dirty_background_ratio",
1108 .data = &dirty_background_ratio,
1109 .maxlen = sizeof(dirty_background_ratio),
1110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .extra1 = &zero,
1113 .extra2 = &one_hundred,
1114 },
1115 {
David Rientjes2da02992009-01-06 14:39:31 -08001116 .procname = "dirty_background_bytes",
1117 .data = &dirty_background_bytes,
1118 .maxlen = sizeof(dirty_background_bytes),
1119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001120 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001121 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001122 },
1123 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 .procname = "dirty_ratio",
1125 .data = &vm_dirty_ratio,
1126 .maxlen = sizeof(vm_dirty_ratio),
1127 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001128 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .extra1 = &zero,
1130 .extra2 = &one_hundred,
1131 },
1132 {
David Rientjes2da02992009-01-06 14:39:31 -08001133 .procname = "dirty_bytes",
1134 .data = &vm_dirty_bytes,
1135 .maxlen = sizeof(vm_dirty_bytes),
1136 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001137 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001138 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001139 },
1140 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001142 .data = &dirty_writeback_interval,
1143 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001145 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 },
1147 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001149 .data = &dirty_expire_interval,
1150 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001152 .proc_handler = proc_dointvec_minmax,
1153 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 },
1155 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001156 .procname = "nr_pdflush_threads",
1157 .mode = 0444 /* read-only */,
1158 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 },
1160 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .procname = "swappiness",
1162 .data = &vm_swappiness,
1163 .maxlen = sizeof(vm_swappiness),
1164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001165 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 .extra1 = &zero,
1167 .extra2 = &one_hundred,
1168 },
1169#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001170 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001172 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 .maxlen = sizeof(unsigned long),
1174 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001175 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 .extra1 = (void *)&hugetlb_zero,
1177 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001178 },
1179#ifdef CONFIG_NUMA
1180 {
1181 .procname = "nr_hugepages_mempolicy",
1182 .data = NULL,
1183 .maxlen = sizeof(unsigned long),
1184 .mode = 0644,
1185 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1186 .extra1 = (void *)&hugetlb_zero,
1187 .extra2 = (void *)&hugetlb_infinity,
1188 },
1189#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 .procname = "hugetlb_shm_group",
1192 .data = &sysctl_hugetlb_shm_group,
1193 .maxlen = sizeof(gid_t),
1194 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001195 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 },
Mel Gorman396faf02007-07-17 04:03:13 -07001197 {
Mel Gorman396faf02007-07-17 04:03:13 -07001198 .procname = "hugepages_treat_as_movable",
1199 .data = &hugepages_treat_as_movable,
1200 .maxlen = sizeof(int),
1201 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001202 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001203 },
Adam Litke54f9f802007-10-16 01:26:20 -07001204 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001205 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001206 .data = NULL,
1207 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001208 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001209 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001210 .extra1 = (void *)&hugetlb_zero,
1211 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001212 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213#endif
1214 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 .procname = "lowmem_reserve_ratio",
1216 .data = &sysctl_lowmem_reserve_ratio,
1217 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1218 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001219 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 },
1221 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001222 .procname = "drop_caches",
1223 .data = &sysctl_drop_caches,
1224 .maxlen = sizeof(int),
1225 .mode = 0644,
1226 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001227 .extra1 = &one,
1228 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001229 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001230#ifdef CONFIG_COMPACTION
1231 {
1232 .procname = "compact_memory",
1233 .data = &sysctl_compact_memory,
1234 .maxlen = sizeof(int),
1235 .mode = 0200,
1236 .proc_handler = sysctl_compaction_handler,
1237 },
Mel Gorman5e771902010-05-24 14:32:31 -07001238 {
1239 .procname = "extfrag_threshold",
1240 .data = &sysctl_extfrag_threshold,
1241 .maxlen = sizeof(int),
1242 .mode = 0644,
1243 .proc_handler = sysctl_extfrag_handler,
1244 .extra1 = &min_extfrag_threshold,
1245 .extra2 = &max_extfrag_threshold,
1246 },
1247
Mel Gorman76ab0f52010-05-24 14:32:28 -07001248#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 .procname = "min_free_kbytes",
1251 .data = &min_free_kbytes,
1252 .maxlen = sizeof(min_free_kbytes),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .extra1 = &zero,
1256 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001257 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001258 .procname = "percpu_pagelist_fraction",
1259 .data = &percpu_pagelist_fraction,
1260 .maxlen = sizeof(percpu_pagelist_fraction),
1261 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001262 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001263 .extra1 = &min_percpu_pagelist_fract,
1264 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265#ifdef CONFIG_MMU
1266 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 .procname = "max_map_count",
1268 .data = &sysctl_max_map_count,
1269 .maxlen = sizeof(sysctl_max_map_count),
1270 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001271 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001272 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001274#else
1275 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001276 .procname = "nr_trim_pages",
1277 .data = &sysctl_nr_trim_pages,
1278 .maxlen = sizeof(sysctl_nr_trim_pages),
1279 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001280 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001281 .extra1 = &zero,
1282 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283#endif
1284 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285 .procname = "laptop_mode",
1286 .data = &laptop_mode,
1287 .maxlen = sizeof(laptop_mode),
1288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001289 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 },
1291 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001292 .procname = "block_dump",
1293 .data = &block_dump,
1294 .maxlen = sizeof(block_dump),
1295 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001296 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .extra1 = &zero,
1298 },
1299 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .procname = "vfs_cache_pressure",
1301 .data = &sysctl_vfs_cache_pressure,
1302 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1303 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001304 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 .extra1 = &zero,
1306 },
1307#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1308 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 .procname = "legacy_va_layout",
1310 .data = &sysctl_legacy_va_layout,
1311 .maxlen = sizeof(sysctl_legacy_va_layout),
1312 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001313 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 .extra1 = &zero,
1315 },
1316#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001317#ifdef CONFIG_NUMA
1318 {
Christoph Lameter17436602006-01-18 17:42:32 -08001319 .procname = "zone_reclaim_mode",
1320 .data = &zone_reclaim_mode,
1321 .maxlen = sizeof(zone_reclaim_mode),
1322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001323 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001324 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001325 },
Christoph Lameter96146342006-07-03 00:24:13 -07001326 {
Christoph Lameter96146342006-07-03 00:24:13 -07001327 .procname = "min_unmapped_ratio",
1328 .data = &sysctl_min_unmapped_ratio,
1329 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001331 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001332 .extra1 = &zero,
1333 .extra2 = &one_hundred,
1334 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001335 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001336 .procname = "min_slab_ratio",
1337 .data = &sysctl_min_slab_ratio,
1338 .maxlen = sizeof(sysctl_min_slab_ratio),
1339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001340 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001341 .extra1 = &zero,
1342 .extra2 = &one_hundred,
1343 },
Christoph Lameter17436602006-01-18 17:42:32 -08001344#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001345#ifdef CONFIG_SMP
1346 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001347 .procname = "stat_interval",
1348 .data = &sysctl_stat_interval,
1349 .maxlen = sizeof(sysctl_stat_interval),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001352 },
1353#endif
David Howells6e141542009-12-15 19:27:45 +00001354#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001355 {
Eric Parised032182007-06-28 15:55:21 -04001356 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001357 .data = &dac_mmap_min_addr,
1358 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001361 },
David Howells6e141542009-12-15 19:27:45 +00001362#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001363#ifdef CONFIG_NUMA
1364 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001365 .procname = "numa_zonelist_order",
1366 .data = &numa_zonelist_order,
1367 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001369 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001370 },
1371#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001372#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001373 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001374 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001375 .procname = "vdso_enabled",
1376 .data = &vdso_enabled,
1377 .maxlen = sizeof(vdso_enabled),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001380 .extra1 = &zero,
1381 },
1382#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001383#ifdef CONFIG_HIGHMEM
1384 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001385 .procname = "highmem_is_dirtyable",
1386 .data = &vm_highmem_is_dirtyable,
1387 .maxlen = sizeof(vm_highmem_is_dirtyable),
1388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001389 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001390 .extra1 = &zero,
1391 .extra2 = &one,
1392 },
1393#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001394 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001395 .procname = "scan_unevictable_pages",
1396 .data = &scan_unevictable_pages,
1397 .maxlen = sizeof(scan_unevictable_pages),
1398 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001399 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001400 },
Andi Kleen6a460792009-09-16 11:50:15 +02001401#ifdef CONFIG_MEMORY_FAILURE
1402 {
Andi Kleen6a460792009-09-16 11:50:15 +02001403 .procname = "memory_failure_early_kill",
1404 .data = &sysctl_memory_failure_early_kill,
1405 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001407 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001408 .extra1 = &zero,
1409 .extra2 = &one,
1410 },
1411 {
Andi Kleen6a460792009-09-16 11:50:15 +02001412 .procname = "memory_failure_recovery",
1413 .data = &sysctl_memory_failure_recovery,
1414 .maxlen = sizeof(sysctl_memory_failure_recovery),
1415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001416 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001417 .extra1 = &zero,
1418 .extra2 = &one,
1419 },
1420#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001421 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422};
1423
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001424#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001425static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001426 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001427};
1428#endif
1429
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001430static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 .procname = "inode-nr",
1433 .data = &inodes_stat,
1434 .maxlen = 2*sizeof(int),
1435 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001436 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 },
1438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .procname = "inode-state",
1440 .data = &inodes_stat,
1441 .maxlen = 7*sizeof(int),
1442 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001443 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 },
1445 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 .procname = "file-nr",
1447 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001448 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001450 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 },
1452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 .procname = "file-max",
1454 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001455 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001457 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 },
1459 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001460 .procname = "nr_open",
1461 .data = &sysctl_nr_open,
1462 .maxlen = sizeof(int),
1463 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001464 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001465 .extra1 = &sysctl_nr_open_min,
1466 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001467 },
1468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .procname = "dentry-state",
1470 .data = &dentry_stat,
1471 .maxlen = 6*sizeof(int),
1472 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001473 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 },
1475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 .procname = "overflowuid",
1477 .data = &fs_overflowuid,
1478 .maxlen = sizeof(int),
1479 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001480 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .extra1 = &minolduid,
1482 .extra2 = &maxolduid,
1483 },
1484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "overflowgid",
1486 .data = &fs_overflowgid,
1487 .maxlen = sizeof(int),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 .extra1 = &minolduid,
1491 .extra2 = &maxolduid,
1492 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001493#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "leases-enable",
1496 .data = &leases_enable,
1497 .maxlen = sizeof(int),
1498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001501#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502#ifdef CONFIG_DNOTIFY
1503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 .procname = "dir-notify-enable",
1505 .data = &dir_notify_enable,
1506 .maxlen = sizeof(int),
1507 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001508 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 },
1510#endif
1511#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001512#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .procname = "lease-break-time",
1515 .data = &lease_break_time,
1516 .maxlen = sizeof(int),
1517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001518 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001520#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001521#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 .procname = "aio-nr",
1524 .data = &aio_nr,
1525 .maxlen = sizeof(aio_nr),
1526 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001527 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 },
1529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .procname = "aio-max-nr",
1531 .data = &aio_max_nr,
1532 .maxlen = sizeof(aio_max_nr),
1533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001534 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001536#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001537#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001538 {
Robert Love0399cb02005-07-13 12:38:18 -04001539 .procname = "inotify",
1540 .mode = 0555,
1541 .child = inotify_table,
1542 },
1543#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001544#ifdef CONFIG_EPOLL
1545 {
1546 .procname = "epoll",
1547 .mode = 0555,
1548 .child = epoll_table,
1549 },
1550#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001552 {
Kees Cook800179c2012-07-25 17:29:07 -07001553 .procname = "protected_symlinks",
1554 .data = &sysctl_protected_symlinks,
1555 .maxlen = sizeof(int),
1556 .mode = 0600,
1557 .proc_handler = proc_dointvec_minmax,
1558 .extra1 = &zero,
1559 .extra2 = &one,
1560 },
1561 {
1562 .procname = "protected_hardlinks",
1563 .data = &sysctl_protected_hardlinks,
1564 .maxlen = sizeof(int),
1565 .mode = 0600,
1566 .proc_handler = proc_dointvec_minmax,
1567 .extra1 = &zero,
1568 .extra2 = &one,
1569 },
1570 {
Alan Coxd6e71142005-06-23 00:09:43 -07001571 .procname = "suid_dumpable",
1572 .data = &suid_dumpable,
1573 .maxlen = sizeof(int),
1574 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001575 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001576 .extra1 = &zero,
1577 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001578 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001579#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1580 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001581 .procname = "binfmt_misc",
1582 .mode = 0555,
1583 .child = binfmt_misc_table,
1584 },
1585#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001586 {
Jens Axboeff9da692010-06-03 14:54:39 +02001587 .procname = "pipe-max-size",
1588 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001589 .maxlen = sizeof(int),
1590 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001591 .proc_handler = &pipe_proc_fn,
1592 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001593 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001594 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595};
1596
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001597static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001598#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001599 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001600 .procname = "exception-trace",
1601 .data = &show_unhandled_signals,
1602 .maxlen = sizeof(int),
1603 .mode = 0644,
1604 .proc_handler = proc_dointvec
1605 },
1606#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001607#if defined(CONFIG_OPTPROBES)
1608 {
1609 .procname = "kprobes-optimization",
1610 .data = &sysctl_kprobes_optimization,
1611 .maxlen = sizeof(int),
1612 .mode = 0644,
1613 .proc_handler = proc_kprobes_optimization_handler,
1614 .extra1 = &zero,
1615 .extra2 = &one,
1616 },
1617#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001618 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619};
1620
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001621static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001622 { }
Robert Love0eeca282005-07-12 17:06:03 -04001623};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001625int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001626{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001627 struct ctl_table_header *hdr;
1628
1629 hdr = register_sysctl_table(sysctl_base_table);
1630 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001631 return 0;
1632}
1633
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001634#endif /* CONFIG_SYSCTL */
1635
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636/*
1637 * /proc/sys support
1638 */
1639
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001640#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001642static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001643 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001644 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001645{
1646 size_t len;
1647 char __user *p;
1648 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001649
1650 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001651 *lenp = 0;
1652 return 0;
1653 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001654
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001655 if (write) {
1656 len = 0;
1657 p = buffer;
1658 while (len < *lenp) {
1659 if (get_user(c, p++))
1660 return -EFAULT;
1661 if (c == 0 || c == '\n')
1662 break;
1663 len++;
1664 }
1665 if (len >= maxlen)
1666 len = maxlen-1;
1667 if(copy_from_user(data, buffer, len))
1668 return -EFAULT;
1669 ((char *) data)[len] = 0;
1670 *ppos += *lenp;
1671 } else {
1672 len = strlen(data);
1673 if (len > maxlen)
1674 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001675
1676 if (*ppos > len) {
1677 *lenp = 0;
1678 return 0;
1679 }
1680
1681 data += *ppos;
1682 len -= *ppos;
1683
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001684 if (len > *lenp)
1685 len = *lenp;
1686 if (len)
1687 if(copy_to_user(buffer, data, len))
1688 return -EFAULT;
1689 if (len < *lenp) {
1690 if(put_user('\n', ((char __user *) buffer) + len))
1691 return -EFAULT;
1692 len++;
1693 }
1694 *lenp = len;
1695 *ppos += len;
1696 }
1697 return 0;
1698}
1699
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700/**
1701 * proc_dostring - read a string sysctl
1702 * @table: the sysctl table
1703 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704 * @buffer: the user buffer
1705 * @lenp: the size of the user buffer
1706 * @ppos: file position
1707 *
1708 * Reads/writes a string from/to the user buffer. If the kernel
1709 * buffer provided is not large enough to hold the string, the
1710 * string is truncated. The copied string is %NULL-terminated.
1711 * If the string is being read by the user process, it is copied
1712 * and a newline '\n' is added. It is truncated if the buffer is
1713 * not large enough.
1714 *
1715 * Returns 0 on success.
1716 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001717int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718 void __user *buffer, size_t *lenp, loff_t *ppos)
1719{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001720 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001721 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722}
1723
Amerigo Wang00b7c332010-05-05 00:26:45 +00001724static size_t proc_skip_spaces(char **buf)
1725{
1726 size_t ret;
1727 char *tmp = skip_spaces(*buf);
1728 ret = tmp - *buf;
1729 *buf = tmp;
1730 return ret;
1731}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001733static void proc_skip_char(char **buf, size_t *size, const char v)
1734{
1735 while (*size) {
1736 if (**buf != v)
1737 break;
1738 (*size)--;
1739 (*buf)++;
1740 }
1741}
1742
Amerigo Wang00b7c332010-05-05 00:26:45 +00001743#define TMPBUFLEN 22
1744/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001745 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001746 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001747 * @buf: a kernel buffer
1748 * @size: size of the kernel buffer
1749 * @val: this is where the number will be stored
1750 * @neg: set to %TRUE if number is negative
1751 * @perm_tr: a vector which contains the allowed trailers
1752 * @perm_tr_len: size of the perm_tr vector
1753 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001754 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001755 * In case of success %0 is returned and @buf and @size are updated with
1756 * the amount of bytes read. If @tr is non-NULL and a trailing
1757 * character exists (size is non-zero after returning from this
1758 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001759 */
1760static int proc_get_long(char **buf, size_t *size,
1761 unsigned long *val, bool *neg,
1762 const char *perm_tr, unsigned perm_tr_len, char *tr)
1763{
1764 int len;
1765 char *p, tmp[TMPBUFLEN];
1766
1767 if (!*size)
1768 return -EINVAL;
1769
1770 len = *size;
1771 if (len > TMPBUFLEN - 1)
1772 len = TMPBUFLEN - 1;
1773
1774 memcpy(tmp, *buf, len);
1775
1776 tmp[len] = 0;
1777 p = tmp;
1778 if (*p == '-' && *size > 1) {
1779 *neg = true;
1780 p++;
1781 } else
1782 *neg = false;
1783 if (!isdigit(*p))
1784 return -EINVAL;
1785
1786 *val = simple_strtoul(p, &p, 0);
1787
1788 len = p - tmp;
1789
1790 /* We don't know if the next char is whitespace thus we may accept
1791 * invalid integers (e.g. 1234...a) or two integers instead of one
1792 * (e.g. 123...1). So lets not allow such large numbers. */
1793 if (len == TMPBUFLEN - 1)
1794 return -EINVAL;
1795
1796 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1797 return -EINVAL;
1798
1799 if (tr && (len < *size))
1800 *tr = *p;
1801
1802 *buf += len;
1803 *size -= len;
1804
1805 return 0;
1806}
1807
1808/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001809 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001810 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001811 * @buf: the user buffer
1812 * @size: the size of the user buffer
1813 * @val: the integer to be converted
1814 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001815 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001816 * In case of success %0 is returned and @buf and @size are updated with
1817 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001818 */
1819static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1820 bool neg)
1821{
1822 int len;
1823 char tmp[TMPBUFLEN], *p = tmp;
1824
1825 sprintf(p, "%s%lu", neg ? "-" : "", val);
1826 len = strlen(tmp);
1827 if (len > *size)
1828 len = *size;
1829 if (copy_to_user(*buf, tmp, len))
1830 return -EFAULT;
1831 *size -= len;
1832 *buf += len;
1833 return 0;
1834}
1835#undef TMPBUFLEN
1836
1837static int proc_put_char(void __user **buf, size_t *size, char c)
1838{
1839 if (*size) {
1840 char __user **buffer = (char __user **)buf;
1841 if (put_user(c, *buffer))
1842 return -EFAULT;
1843 (*size)--, (*buffer)++;
1844 *buf = *buffer;
1845 }
1846 return 0;
1847}
1848
1849static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 int *valp,
1851 int write, void *data)
1852{
1853 if (write) {
1854 *valp = *negp ? -*lvalp : *lvalp;
1855 } else {
1856 int val = *valp;
1857 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001858 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859 *lvalp = (unsigned long)-val;
1860 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 *lvalp = (unsigned long)val;
1863 }
1864 }
1865 return 0;
1866}
1867
Amerigo Wang00b7c332010-05-05 00:26:45 +00001868static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1869
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001870static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001871 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001872 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001873 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 int write, void *data),
1875 void *data)
1876{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001877 int *i, vleft, first = 1, err = 0;
1878 unsigned long page = 0;
1879 size_t left;
1880 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881
Amerigo Wang00b7c332010-05-05 00:26:45 +00001882 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883 *lenp = 0;
1884 return 0;
1885 }
1886
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001887 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 vleft = table->maxlen / sizeof(*i);
1889 left = *lenp;
1890
1891 if (!conv)
1892 conv = do_proc_dointvec_conv;
1893
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001895 if (left > PAGE_SIZE - 1)
1896 left = PAGE_SIZE - 1;
1897 page = __get_free_page(GFP_TEMPORARY);
1898 kbuf = (char *) page;
1899 if (!kbuf)
1900 return -ENOMEM;
1901 if (copy_from_user(kbuf, buffer, left)) {
1902 err = -EFAULT;
1903 goto free;
1904 }
1905 kbuf[left] = 0;
1906 }
1907
1908 for (; left && vleft--; i++, first=0) {
1909 unsigned long lval;
1910 bool neg;
1911
1912 if (write) {
1913 left -= proc_skip_spaces(&kbuf);
1914
J. R. Okajima563b0462010-05-25 16:10:14 -07001915 if (!left)
1916 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001917 err = proc_get_long(&kbuf, &left, &lval, &neg,
1918 proc_wspace_sep,
1919 sizeof(proc_wspace_sep), NULL);
1920 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001922 if (conv(&neg, &lval, i, 1, data)) {
1923 err = -EINVAL;
1924 break;
1925 }
1926 } else {
1927 if (conv(&neg, &lval, i, 0, data)) {
1928 err = -EINVAL;
1929 break;
1930 }
1931 if (!first)
1932 err = proc_put_char(&buffer, &left, '\t');
1933 if (err)
1934 break;
1935 err = proc_put_long(&buffer, &left, lval, neg);
1936 if (err)
1937 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 }
1939 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001940
1941 if (!write && !first && left && !err)
1942 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001943 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001944 left -= proc_skip_spaces(&kbuf);
1945free:
1946 if (write) {
1947 free_page(page);
1948 if (first)
1949 return err ? : -EINVAL;
1950 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001951 *lenp -= left;
1952 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001953 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954}
1955
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001956static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001957 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001958 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001959 int write, void *data),
1960 void *data)
1961{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001962 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001963 buffer, lenp, ppos, conv, data);
1964}
1965
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966/**
1967 * proc_dointvec - read a vector of integers
1968 * @table: the sysctl table
1969 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970 * @buffer: the user buffer
1971 * @lenp: the size of the user buffer
1972 * @ppos: file position
1973 *
1974 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1975 * values from/to the user buffer, treated as an ASCII string.
1976 *
1977 * Returns 0 on success.
1978 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001979int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001980 void __user *buffer, size_t *lenp, loff_t *ppos)
1981{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001982 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001983 NULL,NULL);
1984}
1985
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001986/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001987 * Taint values can only be increased
1988 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001989 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001990static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001991 void __user *buffer, size_t *lenp, loff_t *ppos)
1992{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001993 struct ctl_table t;
1994 unsigned long tmptaint = get_taint();
1995 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001996
Bastian Blank91fcd412007-04-23 14:41:14 -07001997 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001998 return -EPERM;
1999
Andi Kleen25ddbb12008-10-15 22:01:41 -07002000 t = *table;
2001 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002002 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002003 if (err < 0)
2004 return err;
2005
2006 if (write) {
2007 /*
2008 * Poor man's atomic or. Not worth adding a primitive
2009 * to everyone's atomic.h for this
2010 */
2011 int i;
2012 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2013 if ((tmptaint >> i) & 1)
2014 add_taint(i);
2015 }
2016 }
2017
2018 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002019}
2020
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002021#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002022static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002023 void __user *buffer, size_t *lenp, loff_t *ppos)
2024{
2025 if (write && !capable(CAP_SYS_ADMIN))
2026 return -EPERM;
2027
2028 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2029}
2030#endif
2031
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032struct do_proc_dointvec_minmax_conv_param {
2033 int *min;
2034 int *max;
2035};
2036
Amerigo Wang00b7c332010-05-05 00:26:45 +00002037static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2038 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 int write, void *data)
2040{
2041 struct do_proc_dointvec_minmax_conv_param *param = data;
2042 if (write) {
2043 int val = *negp ? -*lvalp : *lvalp;
2044 if ((param->min && *param->min > val) ||
2045 (param->max && *param->max < val))
2046 return -EINVAL;
2047 *valp = val;
2048 } else {
2049 int val = *valp;
2050 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002051 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 *lvalp = (unsigned long)-val;
2053 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002054 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055 *lvalp = (unsigned long)val;
2056 }
2057 }
2058 return 0;
2059}
2060
2061/**
2062 * proc_dointvec_minmax - read a vector of integers with min/max values
2063 * @table: the sysctl table
2064 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065 * @buffer: the user buffer
2066 * @lenp: the size of the user buffer
2067 * @ppos: file position
2068 *
2069 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2070 * values from/to the user buffer, treated as an ASCII string.
2071 *
2072 * This routine will ensure the values are within the range specified by
2073 * table->extra1 (min) and table->extra2 (max).
2074 *
2075 * Returns 0 on success.
2076 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002077int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002078 void __user *buffer, size_t *lenp, loff_t *ppos)
2079{
2080 struct do_proc_dointvec_minmax_conv_param param = {
2081 .min = (int *) table->extra1,
2082 .max = (int *) table->extra2,
2083 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002084 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 do_proc_dointvec_minmax_conv, &param);
2086}
2087
Kees Cook54b50192012-07-30 14:39:18 -07002088static void validate_coredump_safety(void)
2089{
Alex Kelly046d6622012-10-04 17:15:23 -07002090#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002091 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2092 core_pattern[0] != '/' && core_pattern[0] != '|') {
2093 printk(KERN_WARNING "Unsafe core_pattern used with "\
2094 "suid_dumpable=2. Pipe handler or fully qualified "\
2095 "core dump path required.\n");
2096 }
Alex Kelly046d6622012-10-04 17:15:23 -07002097#endif
Kees Cook54b50192012-07-30 14:39:18 -07002098}
2099
2100static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2101 void __user *buffer, size_t *lenp, loff_t *ppos)
2102{
2103 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2104 if (!error)
2105 validate_coredump_safety();
2106 return error;
2107}
2108
Alex Kelly046d6622012-10-04 17:15:23 -07002109#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002110static int proc_dostring_coredump(struct ctl_table *table, int write,
2111 void __user *buffer, size_t *lenp, loff_t *ppos)
2112{
2113 int error = proc_dostring(table, write, buffer, lenp, ppos);
2114 if (!error)
2115 validate_coredump_safety();
2116 return error;
2117}
Alex Kelly046d6622012-10-04 17:15:23 -07002118#endif
Kees Cook54b50192012-07-30 14:39:18 -07002119
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002120static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 void __user *buffer,
2122 size_t *lenp, loff_t *ppos,
2123 unsigned long convmul,
2124 unsigned long convdiv)
2125{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002126 unsigned long *i, *min, *max;
2127 int vleft, first = 1, err = 0;
2128 unsigned long page = 0;
2129 size_t left;
2130 char *kbuf;
2131
2132 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133 *lenp = 0;
2134 return 0;
2135 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002136
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002137 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002138 min = (unsigned long *) table->extra1;
2139 max = (unsigned long *) table->extra2;
2140 vleft = table->maxlen / sizeof(unsigned long);
2141 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002142
2143 if (write) {
2144 if (left > PAGE_SIZE - 1)
2145 left = PAGE_SIZE - 1;
2146 page = __get_free_page(GFP_TEMPORARY);
2147 kbuf = (char *) page;
2148 if (!kbuf)
2149 return -ENOMEM;
2150 if (copy_from_user(kbuf, buffer, left)) {
2151 err = -EFAULT;
2152 goto free;
2153 }
2154 kbuf[left] = 0;
2155 }
2156
Eric Dumazet27b3d802010-10-07 12:59:29 -07002157 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002158 unsigned long val;
2159
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002161 bool neg;
2162
2163 left -= proc_skip_spaces(&kbuf);
2164
2165 err = proc_get_long(&kbuf, &left, &val, &neg,
2166 proc_wspace_sep,
2167 sizeof(proc_wspace_sep), NULL);
2168 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169 break;
2170 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 continue;
2172 if ((min && val < *min) || (max && val > *max))
2173 continue;
2174 *i = val;
2175 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002176 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002178 err = proc_put_char(&buffer, &left, '\t');
2179 err = proc_put_long(&buffer, &left, val, false);
2180 if (err)
2181 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 }
2183 }
2184
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 if (!write && !first && left && !err)
2186 err = proc_put_char(&buffer, &left, '\n');
2187 if (write && !err)
2188 left -= proc_skip_spaces(&kbuf);
2189free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002191 free_page(page);
2192 if (first)
2193 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 *lenp -= left;
2196 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002197 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198}
2199
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002200static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002201 void __user *buffer,
2202 size_t *lenp, loff_t *ppos,
2203 unsigned long convmul,
2204 unsigned long convdiv)
2205{
2206 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002207 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002208}
2209
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210/**
2211 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2212 * @table: the sysctl table
2213 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214 * @buffer: the user buffer
2215 * @lenp: the size of the user buffer
2216 * @ppos: file position
2217 *
2218 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2219 * values from/to the user buffer, treated as an ASCII string.
2220 *
2221 * This routine will ensure the values are within the range specified by
2222 * table->extra1 (min) and table->extra2 (max).
2223 *
2224 * Returns 0 on success.
2225 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002226int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 void __user *buffer, size_t *lenp, loff_t *ppos)
2228{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002229 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230}
2231
2232/**
2233 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2234 * @table: the sysctl table
2235 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 * @buffer: the user buffer
2237 * @lenp: the size of the user buffer
2238 * @ppos: file position
2239 *
2240 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2241 * values from/to the user buffer, treated as an ASCII string. The values
2242 * are treated as milliseconds, and converted to jiffies when they are stored.
2243 *
2244 * This routine will ensure the values are within the range specified by
2245 * table->extra1 (min) and table->extra2 (max).
2246 *
2247 * Returns 0 on success.
2248 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002249int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 void __user *buffer,
2251 size_t *lenp, loff_t *ppos)
2252{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002253 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254 lenp, ppos, HZ, 1000l);
2255}
2256
2257
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 int *valp,
2260 int write, void *data)
2261{
2262 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002263 if (*lvalp > LONG_MAX / HZ)
2264 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2266 } else {
2267 int val = *valp;
2268 unsigned long lval;
2269 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002270 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271 lval = (unsigned long)-val;
2272 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002273 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 lval = (unsigned long)val;
2275 }
2276 *lvalp = lval / HZ;
2277 }
2278 return 0;
2279}
2280
Amerigo Wang00b7c332010-05-05 00:26:45 +00002281static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 int *valp,
2283 int write, void *data)
2284{
2285 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002286 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2287 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2289 } else {
2290 int val = *valp;
2291 unsigned long lval;
2292 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002293 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 lval = (unsigned long)-val;
2295 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002296 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297 lval = (unsigned long)val;
2298 }
2299 *lvalp = jiffies_to_clock_t(lval);
2300 }
2301 return 0;
2302}
2303
Amerigo Wang00b7c332010-05-05 00:26:45 +00002304static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 int *valp,
2306 int write, void *data)
2307{
2308 if (write) {
2309 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2310 } else {
2311 int val = *valp;
2312 unsigned long lval;
2313 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002314 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 lval = (unsigned long)-val;
2316 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002317 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 lval = (unsigned long)val;
2319 }
2320 *lvalp = jiffies_to_msecs(lval);
2321 }
2322 return 0;
2323}
2324
2325/**
2326 * proc_dointvec_jiffies - read a vector of integers as seconds
2327 * @table: the sysctl table
2328 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 * @buffer: the user buffer
2330 * @lenp: the size of the user buffer
2331 * @ppos: file position
2332 *
2333 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2334 * values from/to the user buffer, treated as an ASCII string.
2335 * The values read are assumed to be in seconds, and are converted into
2336 * jiffies.
2337 *
2338 * Returns 0 on success.
2339 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002340int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 void __user *buffer, size_t *lenp, loff_t *ppos)
2342{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002343 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 do_proc_dointvec_jiffies_conv,NULL);
2345}
2346
2347/**
2348 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2349 * @table: the sysctl table
2350 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 * @buffer: the user buffer
2352 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002353 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 *
2355 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2356 * values from/to the user buffer, treated as an ASCII string.
2357 * The values read are assumed to be in 1/USER_HZ seconds, and
2358 * are converted into jiffies.
2359 *
2360 * Returns 0 on success.
2361 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002362int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002363 void __user *buffer, size_t *lenp, loff_t *ppos)
2364{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002365 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 do_proc_dointvec_userhz_jiffies_conv,NULL);
2367}
2368
2369/**
2370 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2371 * @table: the sysctl table
2372 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373 * @buffer: the user buffer
2374 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002375 * @ppos: file position
2376 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 *
2378 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2379 * values from/to the user buffer, treated as an ASCII string.
2380 * The values read are assumed to be in 1/1000 seconds, and
2381 * are converted into jiffies.
2382 *
2383 * Returns 0 on success.
2384 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002385int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 void __user *buffer, size_t *lenp, loff_t *ppos)
2387{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002388 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 do_proc_dointvec_ms_jiffies_conv, NULL);
2390}
2391
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002392static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002393 void __user *buffer, size_t *lenp, loff_t *ppos)
2394{
2395 struct pid *new_pid;
2396 pid_t tmp;
2397 int r;
2398
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002399 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002400
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002401 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002402 lenp, ppos, NULL, NULL);
2403 if (r || !write)
2404 return r;
2405
2406 new_pid = find_get_pid(tmp);
2407 if (!new_pid)
2408 return -ESRCH;
2409
2410 put_pid(xchg(&cad_pid, new_pid));
2411 return 0;
2412}
2413
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002414/**
2415 * proc_do_large_bitmap - read/write from/to a large bitmap
2416 * @table: the sysctl table
2417 * @write: %TRUE if this is a write to the sysctl file
2418 * @buffer: the user buffer
2419 * @lenp: the size of the user buffer
2420 * @ppos: file position
2421 *
2422 * The bitmap is stored at table->data and the bitmap length (in bits)
2423 * in table->maxlen.
2424 *
2425 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2426 * large bitmaps may be represented in a compact manner. Writing into
2427 * the file will clear the bitmap then update it with the given input.
2428 *
2429 * Returns 0 on success.
2430 */
2431int proc_do_large_bitmap(struct ctl_table *table, int write,
2432 void __user *buffer, size_t *lenp, loff_t *ppos)
2433{
2434 int err = 0;
2435 bool first = 1;
2436 size_t left = *lenp;
2437 unsigned long bitmap_len = table->maxlen;
2438 unsigned long *bitmap = (unsigned long *) table->data;
2439 unsigned long *tmp_bitmap = NULL;
2440 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2441
2442 if (!bitmap_len || !left || (*ppos && !write)) {
2443 *lenp = 0;
2444 return 0;
2445 }
2446
2447 if (write) {
2448 unsigned long page = 0;
2449 char *kbuf;
2450
2451 if (left > PAGE_SIZE - 1)
2452 left = PAGE_SIZE - 1;
2453
2454 page = __get_free_page(GFP_TEMPORARY);
2455 kbuf = (char *) page;
2456 if (!kbuf)
2457 return -ENOMEM;
2458 if (copy_from_user(kbuf, buffer, left)) {
2459 free_page(page);
2460 return -EFAULT;
2461 }
2462 kbuf[left] = 0;
2463
2464 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2465 GFP_KERNEL);
2466 if (!tmp_bitmap) {
2467 free_page(page);
2468 return -ENOMEM;
2469 }
2470 proc_skip_char(&kbuf, &left, '\n');
2471 while (!err && left) {
2472 unsigned long val_a, val_b;
2473 bool neg;
2474
2475 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2476 sizeof(tr_a), &c);
2477 if (err)
2478 break;
2479 if (val_a >= bitmap_len || neg) {
2480 err = -EINVAL;
2481 break;
2482 }
2483
2484 val_b = val_a;
2485 if (left) {
2486 kbuf++;
2487 left--;
2488 }
2489
2490 if (c == '-') {
2491 err = proc_get_long(&kbuf, &left, &val_b,
2492 &neg, tr_b, sizeof(tr_b),
2493 &c);
2494 if (err)
2495 break;
2496 if (val_b >= bitmap_len || neg ||
2497 val_a > val_b) {
2498 err = -EINVAL;
2499 break;
2500 }
2501 if (left) {
2502 kbuf++;
2503 left--;
2504 }
2505 }
2506
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002507 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002508 first = 0;
2509 proc_skip_char(&kbuf, &left, '\n');
2510 }
2511 free_page(page);
2512 } else {
2513 unsigned long bit_a, bit_b = 0;
2514
2515 while (left) {
2516 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2517 if (bit_a >= bitmap_len)
2518 break;
2519 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2520 bit_a + 1) - 1;
2521
2522 if (!first) {
2523 err = proc_put_char(&buffer, &left, ',');
2524 if (err)
2525 break;
2526 }
2527 err = proc_put_long(&buffer, &left, bit_a, false);
2528 if (err)
2529 break;
2530 if (bit_a != bit_b) {
2531 err = proc_put_char(&buffer, &left, '-');
2532 if (err)
2533 break;
2534 err = proc_put_long(&buffer, &left, bit_b, false);
2535 if (err)
2536 break;
2537 }
2538
2539 first = 0; bit_b++;
2540 }
2541 if (!err)
2542 err = proc_put_char(&buffer, &left, '\n');
2543 }
2544
2545 if (!err) {
2546 if (write) {
2547 if (*ppos)
2548 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2549 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002550 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002551 }
2552 kfree(tmp_bitmap);
2553 *lenp -= left;
2554 *ppos += *lenp;
2555 return 0;
2556 } else {
2557 kfree(tmp_bitmap);
2558 return err;
2559 }
2560}
2561
Jovi Zhang55610502011-01-12 17:00:45 -08002562#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002564int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 void __user *buffer, size_t *lenp, loff_t *ppos)
2566{
2567 return -ENOSYS;
2568}
2569
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 void __user *buffer, size_t *lenp, loff_t *ppos)
2572{
2573 return -ENOSYS;
2574}
2575
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002576int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577 void __user *buffer, size_t *lenp, loff_t *ppos)
2578{
2579 return -ENOSYS;
2580}
2581
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002582int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 void __user *buffer, size_t *lenp, loff_t *ppos)
2584{
2585 return -ENOSYS;
2586}
2587
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002588int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589 void __user *buffer, size_t *lenp, loff_t *ppos)
2590{
2591 return -ENOSYS;
2592}
2593
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002594int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 void __user *buffer, size_t *lenp, loff_t *ppos)
2596{
2597 return -ENOSYS;
2598}
2599
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002600int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 void __user *buffer, size_t *lenp, loff_t *ppos)
2602{
2603 return -ENOSYS;
2604}
2605
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002606int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 void __user *buffer,
2608 size_t *lenp, loff_t *ppos)
2609{
2610 return -ENOSYS;
2611}
2612
2613
Jovi Zhang55610502011-01-12 17:00:45 -08002614#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616/*
2617 * No sense putting this after each symbol definition, twice,
2618 * exception granted :-)
2619 */
2620EXPORT_SYMBOL(proc_dointvec);
2621EXPORT_SYMBOL(proc_dointvec_jiffies);
2622EXPORT_SYMBOL(proc_dointvec_minmax);
2623EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2624EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2625EXPORT_SYMBOL(proc_dostring);
2626EXPORT_SYMBOL(proc_doulongvec_minmax);
2627EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);