blob: 7357e23aaf68e6ec0980d03155989842abaa507c [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>
Clark Williamscf4aebc22013-02-07 09:46:59 -060064#include <linux/sched/sysctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#include <asm/uaccess.h>
67#include <asm/processor.h>
68
Andi Kleen29cbc782006-09-30 01:47:55 +020069#ifdef CONFIG_X86
70#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010071#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010072#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020073#endif
David Howellsd550bbd2012-03-28 18:30:03 +010074#ifdef CONFIG_SPARC
75#include <asm/setup.h>
76#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080077#ifdef CONFIG_BSD_PROCESS_ACCT
78#include <linux/acct.h>
79#endif
Dave Young4f0e0562010-03-10 15:24:09 -080080#ifdef CONFIG_RT_MUTEXES
81#include <linux/rtmutex.h>
82#endif
Dave Young2edf5e42010-03-10 15:24:10 -080083#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
84#include <linux/lockdep.h>
85#endif
Dave Young15485a42010-03-10 15:24:07 -080086#ifdef CONFIG_CHR_DEV_SG
87#include <scsi/sg.h>
88#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020089
Don Zickus58687ac2010-05-07 17:11:44 -040090#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050091#include <linux/nmi.h>
92#endif
93
Eric W. Biederman7058cb02007-10-18 03:05:58 -070094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#if defined(CONFIG_SYSCTL)
96
97/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern int sysctl_overcommit_memory;
99extern int sysctl_overcommit_ratio;
100extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
108extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800110extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800111extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200112extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100113extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400114extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000115#ifndef CONFIG_MMU
116extern int sysctl_nr_trim_pages;
117#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200118#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200119extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200120#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700122/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400123#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200125static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126#endif
127
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700129static int __maybe_unused one = 1;
130static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700131static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800132static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700133static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700134#ifdef CONFIG_PRINTK
135static int ten_thousand = 10000;
136#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700137
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700138/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142static int maxolduid = 65535;
143static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800144static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700147static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Dave Youngd14f1722010-02-25 20:28:57 -0500149#ifdef CONFIG_INOTIFY_USER
150#include <linux/inotify.h>
151#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700152#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153#endif
154
David S. Miller08714202008-11-16 23:49:24 -0800155#ifdef CONFIG_SPARC64
156extern int sysctl_tsb_ratio;
157#endif
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#ifdef __hppa__
160extern int pwrsw_enabled;
161extern int unaligned_enabled;
162#endif
163
Jes Sorensend2b176e2006-02-28 09:42:23 -0800164#ifdef CONFIG_IA64
165extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800166extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#endif
168
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700169#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700170static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700171 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700172static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800173 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700175
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700176#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700177static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700178 void __user *buffer, size_t *lenp, loff_t *ppos);
179#endif
180
Kees Cook54b50192012-07-30 14:39:18 -0700181static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
182 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700183#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700184static int proc_dostring_coredump(struct ctl_table *table, int write,
185 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700186#endif
Kees Cook54b50192012-07-30 14:39:18 -0700187
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700188#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800189/* Note: sysrq code uses it's own private copy */
190static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700191
192static int sysrq_sysctl_handler(ctl_table *table, int write,
193 void __user *buffer, size_t *lenp,
194 loff_t *ppos)
195{
196 int error;
197
198 error = proc_dointvec(table, write, buffer, lenp, ppos);
199 if (error)
200 return error;
201
202 if (write)
203 sysrq_toggle_support(__sysrq_enabled);
204
205 return 0;
206}
207
208#endif
209
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700210static struct ctl_table kern_table[];
211static struct ctl_table vm_table[];
212static struct ctl_table fs_table[];
213static struct ctl_table debug_table[];
214static struct ctl_table dev_table[];
215extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800216#ifdef CONFIG_EPOLL
217extern struct ctl_table epoll_table[];
218#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
221int sysctl_legacy_va_layout;
222#endif
223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224/* The default sysctl tables: */
225
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800226static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 .procname = "kernel",
229 .mode = 0555,
230 .child = kern_table,
231 },
232 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 .procname = "vm",
234 .mode = 0555,
235 .child = vm_table,
236 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 .procname = "fs",
239 .mode = 0555,
240 .child = fs_table,
241 },
242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "debug",
244 .mode = 0555,
245 .child = debug_table,
246 },
247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "dev",
249 .mode = 0555,
250 .child = dev_table,
251 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700252 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253};
254
Ingo Molnar77e54a12007-07-09 18:52:00 +0200255#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100256static int min_sched_granularity_ns = 100000; /* 100 usecs */
257static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
258static int min_wakeup_granularity_ns; /* 0 usecs */
259static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200260#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100261static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
262static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200263#endif /* CONFIG_SMP */
264#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200265
Mel Gorman5e771902010-05-24 14:32:31 -0700266#ifdef CONFIG_COMPACTION
267static int min_extfrag_threshold;
268static int max_extfrag_threshold = 1000;
269#endif
270
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700271static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200272 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200273 .procname = "sched_child_runs_first",
274 .data = &sysctl_sched_child_runs_first,
275 .maxlen = sizeof(unsigned int),
276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800277 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200278 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200279#ifdef CONFIG_SCHED_DEBUG
280 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100281 .procname = "sched_min_granularity_ns",
282 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283 .maxlen = sizeof(unsigned int),
284 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800285 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100286 .extra1 = &min_sched_granularity_ns,
287 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200288 },
289 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200290 .procname = "sched_latency_ns",
291 .data = &sysctl_sched_latency,
292 .maxlen = sizeof(unsigned int),
293 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800294 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200295 .extra1 = &min_sched_granularity_ns,
296 .extra2 = &max_sched_granularity_ns,
297 },
298 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200299 .procname = "sched_wakeup_granularity_ns",
300 .data = &sysctl_sched_wakeup_granularity,
301 .maxlen = sizeof(unsigned int),
302 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800303 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200304 .extra1 = &min_wakeup_granularity_ns,
305 .extra2 = &max_wakeup_granularity_ns,
306 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200307#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200308 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100309 .procname = "sched_tunable_scaling",
310 .data = &sysctl_sched_tunable_scaling,
311 .maxlen = sizeof(enum sched_tunable_scaling),
312 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800313 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100314 .extra1 = &min_sched_tunable_scaling,
315 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200316 },
317 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900318 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200319 .data = &sysctl_sched_migration_cost,
320 .maxlen = sizeof(unsigned int),
321 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800322 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200323 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100324 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100325 .procname = "sched_nr_migrate",
326 .data = &sysctl_sched_nr_migrate,
327 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100328 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800329 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100330 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530331 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900332 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200333 .data = &sysctl_sched_time_avg,
334 .maxlen = sizeof(unsigned int),
335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800336 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200337 },
338 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900339 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800340 .data = &sysctl_sched_shares_window,
341 .maxlen = sizeof(unsigned int),
342 .mode = 0644,
343 .proc_handler = proc_dointvec,
344 },
345 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530346 .procname = "timer_migration",
347 .data = &sysctl_timer_migration,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800350 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530351 .extra1 = &zero,
352 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530353 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200354#endif /* CONFIG_SMP */
355#ifdef CONFIG_NUMA_BALANCING
356 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200357 .procname = "numa_balancing_scan_delay_ms",
358 .data = &sysctl_numa_balancing_scan_delay,
359 .maxlen = sizeof(unsigned int),
360 .mode = 0644,
361 .proc_handler = proc_dointvec,
362 },
363 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200364 .procname = "numa_balancing_scan_period_min_ms",
365 .data = &sysctl_numa_balancing_scan_period_min,
366 .maxlen = sizeof(unsigned int),
367 .mode = 0644,
368 .proc_handler = proc_dointvec,
369 },
370 {
Mel Gormanb8593bf2012-11-21 01:18:23 +0000371 .procname = "numa_balancing_scan_period_reset",
372 .data = &sysctl_numa_balancing_scan_period_reset,
373 .maxlen = sizeof(unsigned int),
374 .mode = 0644,
375 .proc_handler = proc_dointvec,
376 },
377 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200378 .procname = "numa_balancing_scan_period_max_ms",
379 .data = &sysctl_numa_balancing_scan_period_max,
380 .maxlen = sizeof(unsigned int),
381 .mode = 0644,
382 .proc_handler = proc_dointvec,
383 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200384 {
385 .procname = "numa_balancing_scan_size_mb",
386 .data = &sysctl_numa_balancing_scan_size,
387 .maxlen = sizeof(unsigned int),
388 .mode = 0644,
389 .proc_handler = proc_dointvec,
390 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200391#endif /* CONFIG_NUMA_BALANCING */
392#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200393 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100394 .procname = "sched_rt_period_us",
395 .data = &sysctl_sched_rt_period,
396 .maxlen = sizeof(unsigned int),
397 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800398 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100399 },
400 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100401 .procname = "sched_rt_runtime_us",
402 .data = &sysctl_sched_rt_runtime,
403 .maxlen = sizeof(int),
404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800405 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100406 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100407#ifdef CONFIG_SCHED_AUTOGROUP
408 {
409 .procname = "sched_autogroup_enabled",
410 .data = &sysctl_sched_autogroup_enabled,
411 .maxlen = sizeof(unsigned int),
412 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800413 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100414 .extra1 = &zero,
415 .extra2 = &one,
416 },
417#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700418#ifdef CONFIG_CFS_BANDWIDTH
419 {
420 .procname = "sched_cfs_bandwidth_slice_us",
421 .data = &sysctl_sched_cfs_bandwidth_slice,
422 .maxlen = sizeof(unsigned int),
423 .mode = 0644,
424 .proc_handler = proc_dointvec_minmax,
425 .extra1 = &one,
426 },
427#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700428#ifdef CONFIG_PROVE_LOCKING
429 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700430 .procname = "prove_locking",
431 .data = &prove_locking,
432 .maxlen = sizeof(int),
433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800434 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700435 },
436#endif
437#ifdef CONFIG_LOCK_STAT
438 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700439 .procname = "lock_stat",
440 .data = &lock_stat,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700444 },
445#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 .procname = "panic",
448 .data = &panic_timeout,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 },
Alex Kelly046d6622012-10-04 17:15:23 -0700453#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "core_uses_pid",
456 .data = &core_uses_pid,
457 .maxlen = sizeof(int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "core_pattern",
463 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700464 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700466 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
Neil Hormana2939802009-09-23 15:56:56 -0700468 {
Neil Hormana2939802009-09-23 15:56:56 -0700469 .procname = "core_pipe_limit",
470 .data = &core_pipe_limit,
471 .maxlen = sizeof(unsigned int),
472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800473 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700474 },
Alex Kelly046d6622012-10-04 17:15:23 -0700475#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800476#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700479 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800481 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800483#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100484#ifdef CONFIG_LATENCYTOP
485 {
486 .procname = "latencytop",
487 .data = &latencytop_enabled,
488 .maxlen = sizeof(int),
489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800490 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100491 },
492#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493#ifdef CONFIG_BLK_DEV_INITRD
494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 .procname = "real-root-dev",
496 .data = &real_root_dev,
497 .maxlen = sizeof(int),
498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 },
501#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700502 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700503 .procname = "print-fatal-signals",
504 .data = &print_fatal_signals,
505 .maxlen = sizeof(int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700508 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700509#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 .procname = "reboot-cmd",
512 .data = reboot_command,
513 .maxlen = 256,
514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800515 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 },
517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .procname = "stop-a",
519 .data = &stop_a_enabled,
520 .maxlen = sizeof (int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 },
524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 .procname = "scons-poweroff",
526 .data = &scons_pwroff,
527 .maxlen = sizeof (int),
528 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800529 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 },
531#endif
David S. Miller08714202008-11-16 23:49:24 -0800532#ifdef CONFIG_SPARC64
533 {
David S. Miller08714202008-11-16 23:49:24 -0800534 .procname = "tsb-ratio",
535 .data = &sysctl_tsb_ratio,
536 .maxlen = sizeof (int),
537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800538 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800539 },
540#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541#ifdef __hppa__
542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .procname = "soft-power",
544 .data = &pwrsw_enabled,
545 .maxlen = sizeof (int),
546 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800547 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 },
549 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 .procname = "unaligned-trap",
551 .data = &unaligned_enabled,
552 .maxlen = sizeof (int),
553 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800554 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 },
556#endif
557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .procname = "ctrl-alt-del",
559 .data = &C_A_D,
560 .maxlen = sizeof(int),
561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400564#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200565 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200566 .procname = "ftrace_enabled",
567 .data = &ftrace_enabled,
568 .maxlen = sizeof(int),
569 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800570 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200571 },
572#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500573#ifdef CONFIG_STACK_TRACER
574 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500575 .procname = "stack_tracer_enabled",
576 .data = &stack_tracer_enabled,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500580 },
581#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400582#ifdef CONFIG_TRACING
583 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100584 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400585 .data = &ftrace_dump_on_oops,
586 .maxlen = sizeof(int),
587 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800588 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400589 },
590#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200591#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .procname = "modprobe",
594 .data = &modprobe_path,
595 .maxlen = KMOD_PATH_LEN,
596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 },
Kees Cook3d433212009-04-02 15:49:29 -0700599 {
Kees Cook3d433212009-04-02 15:49:29 -0700600 .procname = "modules_disabled",
601 .data = &modules_disabled,
602 .maxlen = sizeof(int),
603 .mode = 0644,
604 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800605 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700606 .extra1 = &one,
607 .extra2 = &one,
608 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500610
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100613 .data = &uevent_helper,
614 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500618
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619#ifdef CONFIG_CHR_DEV_SG
620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .procname = "sg-big-buff",
622 .data = &sg_big_buff,
623 .maxlen = sizeof (int),
624 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800625 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 },
627#endif
628#ifdef CONFIG_BSD_PROCESS_ACCT
629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .procname = "acct",
631 .data = &acct_parm,
632 .maxlen = 3*sizeof(int),
633 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800634 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 },
636#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637#ifdef CONFIG_MAGIC_SYSRQ
638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800640 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .maxlen = sizeof (int),
642 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700643 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 },
645#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700646#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700649 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .maxlen = sizeof (int),
651 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800652 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700654#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .procname = "threads-max",
657 .data = &max_threads,
658 .maxlen = sizeof(int),
659 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800660 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 },
662 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .procname = "random",
664 .mode = 0555,
665 .child = random_table,
666 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 {
Eric Paris17f60a72011-04-01 17:07:50 -0400668 .procname = "usermodehelper",
669 .mode = 0555,
670 .child = usermodehelper_table,
671 },
672 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 .procname = "overflowuid",
674 .data = &overflowuid,
675 .maxlen = sizeof(int),
676 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800677 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .extra1 = &minolduid,
679 .extra2 = &maxolduid,
680 },
681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "overflowgid",
683 .data = &overflowgid,
684 .maxlen = sizeof(int),
685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .extra1 = &minolduid,
688 .extra2 = &maxolduid,
689 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800690#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691#ifdef CONFIG_MATHEMU
692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "ieee_emulation_warnings",
694 .data = &sysctl_ieee_emulation_warnings,
695 .maxlen = sizeof(int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200702 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .maxlen = sizeof(int),
704 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800705 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707#endif
708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "pid_max",
710 .data = &pid_max,
711 .maxlen = sizeof (int),
712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .extra1 = &pid_max_min,
715 .extra2 = &pid_max_max,
716 },
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "panic_on_oops",
719 .data = &panic_on_oops,
720 .maxlen = sizeof(int),
721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800724#if defined CONFIG_PRINTK
725 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800726 .procname = "printk",
727 .data = &console_loglevel,
728 .maxlen = 4*sizeof(int),
729 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800730 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800731 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700734 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .maxlen = sizeof(int),
736 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800737 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 },
739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700741 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .maxlen = sizeof(int),
743 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800744 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 },
Dave Youngaf913222009-09-22 16:43:33 -0700746 {
Dave Youngaf913222009-09-22 16:43:33 -0700747 .procname = "printk_delay",
748 .data = &printk_delay_msec,
749 .maxlen = sizeof(int),
750 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800751 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700752 .extra1 = &zero,
753 .extra2 = &ten_thousand,
754 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800756 .procname = "dmesg_restrict",
757 .data = &dmesg_restrict,
758 .maxlen = sizeof(int),
759 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700760 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800761 .extra1 = &zero,
762 .extra2 = &one,
763 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800764 {
765 .procname = "kptr_restrict",
766 .data = &kptr_restrict,
767 .maxlen = sizeof(int),
768 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700769 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800770 .extra1 = &zero,
771 .extra2 = &two,
772 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800773#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800774 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 .procname = "ngroups_max",
776 .data = &ngroups_max,
777 .maxlen = sizeof (int),
778 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800779 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 },
Dan Ballard73efc032011-10-31 17:11:20 -0700781 {
782 .procname = "cap_last_cap",
783 .data = (void *)&cap_last_cap,
784 .maxlen = sizeof(int),
785 .mode = 0444,
786 .proc_handler = proc_dointvec,
787 },
Don Zickus58687ac2010-05-07 17:11:44 -0400788#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500789 {
Don Zickus58687ac2010-05-07 17:11:44 -0400790 .procname = "watchdog",
791 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500792 .maxlen = sizeof (int),
793 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700794 .proc_handler = proc_dowatchdog,
795 .extra1 = &zero,
796 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400797 },
798 {
799 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700800 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400801 .maxlen = sizeof(int),
802 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700803 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400804 .extra1 = &neg_one,
805 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500806 },
Don Zickus2508ce12010-05-07 17:11:46 -0400807 {
808 .procname = "softlockup_panic",
809 .data = &softlockup_panic,
810 .maxlen = sizeof(int),
811 .mode = 0644,
812 .proc_handler = proc_dointvec_minmax,
813 .extra1 = &zero,
814 .extra2 = &one,
815 },
Don Zickus5dc30552010-11-29 17:07:17 -0500816 {
817 .procname = "nmi_watchdog",
818 .data = &watchdog_enabled,
819 .maxlen = sizeof (int),
820 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700821 .proc_handler = proc_dowatchdog,
822 .extra1 = &zero,
823 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500824 },
825#endif
826#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
827 {
828 .procname = "unknown_nmi_panic",
829 .data = &unknown_nmi_panic,
830 .maxlen = sizeof (int),
831 .mode = 0644,
832 .proc_handler = proc_dointvec,
833 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500834#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835#if defined(CONFIG_X86)
836 {
Don Zickus8da5add2006-09-26 10:52:27 +0200837 .procname = "panic_on_unrecovered_nmi",
838 .data = &panic_on_unrecovered_nmi,
839 .maxlen = sizeof(int),
840 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800841 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200842 },
843 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700844 .procname = "panic_on_io_nmi",
845 .data = &panic_on_io_nmi,
846 .maxlen = sizeof(int),
847 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700849 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900850#ifdef CONFIG_DEBUG_STACKOVERFLOW
851 {
852 .procname = "panic_on_stackoverflow",
853 .data = &sysctl_panic_on_stackoverflow,
854 .maxlen = sizeof(int),
855 .mode = 0644,
856 .proc_handler = proc_dointvec,
857 },
858#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700859 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 .procname = "bootloader_type",
861 .data = &bootloader_type,
862 .maxlen = sizeof (int),
863 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800864 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100866 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700867 .procname = "bootloader_version",
868 .data = &bootloader_version,
869 .maxlen = sizeof (int),
870 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800871 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700872 },
873 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100874 .procname = "kstack_depth_to_print",
875 .data = &kstack_depth_to_print,
876 .maxlen = sizeof(int),
877 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800878 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100879 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100880 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100881 .procname = "io_delay_type",
882 .data = &io_delay_type,
883 .maxlen = sizeof(int),
884 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800885 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100886 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800888#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 .procname = "randomize_va_space",
891 .data = &randomize_va_space,
892 .maxlen = sizeof(int),
893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800894 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800896#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800897#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700898 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700899 .procname = "spin_retry",
900 .data = &spin_retry,
901 .maxlen = sizeof (int),
902 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800903 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700904 },
905#endif
Len Brown673d5b42007-07-28 03:33:16 -0400906#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800907 {
Pavel Machekc255d842006-02-20 18:27:58 -0800908 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700909 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800910 .maxlen = sizeof (unsigned long),
911 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800913 },
914#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800915#ifdef CONFIG_IA64
916 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800917 .procname = "ignore-unaligned-usertrap",
918 .data = &no_unaligned_warning,
919 .maxlen = sizeof (int),
920 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800921 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800922 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800923 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800924 .procname = "unaligned-dump-stack",
925 .data = &unaligned_dump_stack,
926 .maxlen = sizeof (int),
927 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800928 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800929 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800930#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800931#ifdef CONFIG_DETECT_HUNG_TASK
932 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800933 .procname = "hung_task_panic",
934 .data = &sysctl_hung_task_panic,
935 .maxlen = sizeof(int),
936 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800937 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800938 .extra1 = &zero,
939 .extra2 = &one,
940 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100941 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100942 .procname = "hung_task_check_count",
943 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100944 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100945 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800946 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100947 },
948 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100949 .procname = "hung_task_timeout_secs",
950 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100951 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100952 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800953 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100954 },
955 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100956 .procname = "hung_task_warnings",
957 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100958 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100961 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700962#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200963#ifdef CONFIG_COMPAT
964 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200965 .procname = "compat-log",
966 .data = &compat_log,
967 .maxlen = sizeof (int),
968 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800969 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200970 },
971#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700972#ifdef CONFIG_RT_MUTEXES
973 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700974 .procname = "max_lock_depth",
975 .data = &max_lock_depth,
976 .maxlen = sizeof(int),
977 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800978 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700979 },
980#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700981 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700982 .procname = "poweroff_cmd",
983 .data = &poweroff_cmd,
984 .maxlen = POWEROFF_CMD_PATH_LEN,
985 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800986 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700987 },
David Howells0b77f5b2008-04-29 01:01:32 -0700988#ifdef CONFIG_KEYS
989 {
David Howells0b77f5b2008-04-29 01:01:32 -0700990 .procname = "keys",
991 .mode = 0555,
992 .child = key_sysctls,
993 },
994#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700995#ifdef CONFIG_RCU_TORTURE_TEST
996 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700997 .procname = "rcutorture_runnable",
998 .data = &rcutorture_runnable,
999 .maxlen = sizeof(int),
1000 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001001 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001002 },
1003#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001004#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001005 /*
1006 * User-space scripts rely on the existence of this file
1007 * as a feature check for perf_events being enabled.
1008 *
1009 * So it's an ABI, do not remove!
1010 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001011 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001012 .procname = "perf_event_paranoid",
1013 .data = &sysctl_perf_event_paranoid,
1014 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001015 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001016 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001017 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001018 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001019 .procname = "perf_event_mlock_kb",
1020 .data = &sysctl_perf_event_mlock,
1021 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001024 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001025 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001026 .procname = "perf_event_max_sample_rate",
1027 .data = &sysctl_perf_event_sample_rate,
1028 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001029 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001030 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001031 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001032#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001033#ifdef CONFIG_KMEMCHECK
1034 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001035 .procname = "kmemcheck",
1036 .data = &kmemcheck_enabled,
1037 .maxlen = sizeof(int),
1038 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001039 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001040 },
1041#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001042#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001043 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001044 .procname = "blk_iopoll",
1045 .data = &blk_iopoll_enabled,
1046 .maxlen = sizeof(int),
1047 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001048 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001049 },
Jens Axboecb684b52009-09-15 21:53:11 +02001050#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001051 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052};
1053
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001054static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 .procname = "overcommit_memory",
1057 .data = &sysctl_overcommit_memory,
1058 .maxlen = sizeof(sysctl_overcommit_memory),
1059 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001060 .proc_handler = proc_dointvec_minmax,
1061 .extra1 = &zero,
1062 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 },
1064 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001065 .procname = "panic_on_oom",
1066 .data = &sysctl_panic_on_oom,
1067 .maxlen = sizeof(sysctl_panic_on_oom),
1068 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001069 .proc_handler = proc_dointvec_minmax,
1070 .extra1 = &zero,
1071 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001072 },
1073 {
David Rientjesfe071d72007-10-16 23:25:56 -07001074 .procname = "oom_kill_allocating_task",
1075 .data = &sysctl_oom_kill_allocating_task,
1076 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1077 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001078 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001079 },
1080 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001081 .procname = "oom_dump_tasks",
1082 .data = &sysctl_oom_dump_tasks,
1083 .maxlen = sizeof(sysctl_oom_dump_tasks),
1084 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001085 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001086 },
1087 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 .procname = "overcommit_ratio",
1089 .data = &sysctl_overcommit_ratio,
1090 .maxlen = sizeof(sysctl_overcommit_ratio),
1091 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001092 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 },
1094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "page-cluster",
1096 .data = &page_cluster,
1097 .maxlen = sizeof(int),
1098 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001099 .proc_handler = proc_dointvec_minmax,
1100 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 },
1102 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 .procname = "dirty_background_ratio",
1104 .data = &dirty_background_ratio,
1105 .maxlen = sizeof(dirty_background_ratio),
1106 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001107 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 .extra1 = &zero,
1109 .extra2 = &one_hundred,
1110 },
1111 {
David Rientjes2da02992009-01-06 14:39:31 -08001112 .procname = "dirty_background_bytes",
1113 .data = &dirty_background_bytes,
1114 .maxlen = sizeof(dirty_background_bytes),
1115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001117 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001118 },
1119 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 .procname = "dirty_ratio",
1121 .data = &vm_dirty_ratio,
1122 .maxlen = sizeof(vm_dirty_ratio),
1123 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001124 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 .extra1 = &zero,
1126 .extra2 = &one_hundred,
1127 },
1128 {
David Rientjes2da02992009-01-06 14:39:31 -08001129 .procname = "dirty_bytes",
1130 .data = &vm_dirty_bytes,
1131 .maxlen = sizeof(vm_dirty_bytes),
1132 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001133 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001134 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001135 },
1136 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001138 .data = &dirty_writeback_interval,
1139 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001141 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 },
1143 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001145 .data = &dirty_expire_interval,
1146 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001148 .proc_handler = proc_dointvec_minmax,
1149 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 },
1151 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001152 .procname = "nr_pdflush_threads",
1153 .mode = 0444 /* read-only */,
1154 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 },
1156 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .procname = "swappiness",
1158 .data = &vm_swappiness,
1159 .maxlen = sizeof(vm_swappiness),
1160 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001161 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 .extra1 = &zero,
1163 .extra2 = &one_hundred,
1164 },
1165#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001166 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001168 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .maxlen = sizeof(unsigned long),
1170 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001171 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .extra1 = (void *)&hugetlb_zero,
1173 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001174 },
1175#ifdef CONFIG_NUMA
1176 {
1177 .procname = "nr_hugepages_mempolicy",
1178 .data = NULL,
1179 .maxlen = sizeof(unsigned long),
1180 .mode = 0644,
1181 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1182 .extra1 = (void *)&hugetlb_zero,
1183 .extra2 = (void *)&hugetlb_infinity,
1184 },
1185#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 .procname = "hugetlb_shm_group",
1188 .data = &sysctl_hugetlb_shm_group,
1189 .maxlen = sizeof(gid_t),
1190 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001191 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 },
Mel Gorman396faf02007-07-17 04:03:13 -07001193 {
Mel Gorman396faf02007-07-17 04:03:13 -07001194 .procname = "hugepages_treat_as_movable",
1195 .data = &hugepages_treat_as_movable,
1196 .maxlen = sizeof(int),
1197 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001198 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001199 },
Adam Litke54f9f802007-10-16 01:26:20 -07001200 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001201 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001202 .data = NULL,
1203 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001204 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001205 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001206 .extra1 = (void *)&hugetlb_zero,
1207 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001208 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209#endif
1210 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 .procname = "lowmem_reserve_ratio",
1212 .data = &sysctl_lowmem_reserve_ratio,
1213 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1214 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001215 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 },
1217 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001218 .procname = "drop_caches",
1219 .data = &sysctl_drop_caches,
1220 .maxlen = sizeof(int),
1221 .mode = 0644,
1222 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001223 .extra1 = &one,
1224 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001225 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001226#ifdef CONFIG_COMPACTION
1227 {
1228 .procname = "compact_memory",
1229 .data = &sysctl_compact_memory,
1230 .maxlen = sizeof(int),
1231 .mode = 0200,
1232 .proc_handler = sysctl_compaction_handler,
1233 },
Mel Gorman5e771902010-05-24 14:32:31 -07001234 {
1235 .procname = "extfrag_threshold",
1236 .data = &sysctl_extfrag_threshold,
1237 .maxlen = sizeof(int),
1238 .mode = 0644,
1239 .proc_handler = sysctl_extfrag_handler,
1240 .extra1 = &min_extfrag_threshold,
1241 .extra2 = &max_extfrag_threshold,
1242 },
1243
Mel Gorman76ab0f52010-05-24 14:32:28 -07001244#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 .procname = "min_free_kbytes",
1247 .data = &min_free_kbytes,
1248 .maxlen = sizeof(min_free_kbytes),
1249 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001250 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 .extra1 = &zero,
1252 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001253 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001254 .procname = "percpu_pagelist_fraction",
1255 .data = &percpu_pagelist_fraction,
1256 .maxlen = sizeof(percpu_pagelist_fraction),
1257 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001258 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001259 .extra1 = &min_percpu_pagelist_fract,
1260 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261#ifdef CONFIG_MMU
1262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 .procname = "max_map_count",
1264 .data = &sysctl_max_map_count,
1265 .maxlen = sizeof(sysctl_max_map_count),
1266 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001267 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001268 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001270#else
1271 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001272 .procname = "nr_trim_pages",
1273 .data = &sysctl_nr_trim_pages,
1274 .maxlen = sizeof(sysctl_nr_trim_pages),
1275 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001276 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001277 .extra1 = &zero,
1278 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279#endif
1280 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 .procname = "laptop_mode",
1282 .data = &laptop_mode,
1283 .maxlen = sizeof(laptop_mode),
1284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001285 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 },
1287 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288 .procname = "block_dump",
1289 .data = &block_dump,
1290 .maxlen = sizeof(block_dump),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 .extra1 = &zero,
1294 },
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "vfs_cache_pressure",
1297 .data = &sysctl_vfs_cache_pressure,
1298 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1299 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001300 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 .extra1 = &zero,
1302 },
1303#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1304 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 .procname = "legacy_va_layout",
1306 .data = &sysctl_legacy_va_layout,
1307 .maxlen = sizeof(sysctl_legacy_va_layout),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 .extra1 = &zero,
1311 },
1312#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001313#ifdef CONFIG_NUMA
1314 {
Christoph Lameter17436602006-01-18 17:42:32 -08001315 .procname = "zone_reclaim_mode",
1316 .data = &zone_reclaim_mode,
1317 .maxlen = sizeof(zone_reclaim_mode),
1318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001320 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001321 },
Christoph Lameter96146342006-07-03 00:24:13 -07001322 {
Christoph Lameter96146342006-07-03 00:24:13 -07001323 .procname = "min_unmapped_ratio",
1324 .data = &sysctl_min_unmapped_ratio,
1325 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001327 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001328 .extra1 = &zero,
1329 .extra2 = &one_hundred,
1330 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001331 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001332 .procname = "min_slab_ratio",
1333 .data = &sysctl_min_slab_ratio,
1334 .maxlen = sizeof(sysctl_min_slab_ratio),
1335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001336 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001337 .extra1 = &zero,
1338 .extra2 = &one_hundred,
1339 },
Christoph Lameter17436602006-01-18 17:42:32 -08001340#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001341#ifdef CONFIG_SMP
1342 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001343 .procname = "stat_interval",
1344 .data = &sysctl_stat_interval,
1345 .maxlen = sizeof(sysctl_stat_interval),
1346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001347 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001348 },
1349#endif
David Howells6e141542009-12-15 19:27:45 +00001350#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001351 {
Eric Parised032182007-06-28 15:55:21 -04001352 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001353 .data = &dac_mmap_min_addr,
1354 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001355 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001356 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001357 },
David Howells6e141542009-12-15 19:27:45 +00001358#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001359#ifdef CONFIG_NUMA
1360 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001361 .procname = "numa_zonelist_order",
1362 .data = &numa_zonelist_order,
1363 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1364 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001365 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001366 },
1367#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001368#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001369 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001370 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001371 .procname = "vdso_enabled",
1372 .data = &vdso_enabled,
1373 .maxlen = sizeof(vdso_enabled),
1374 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001375 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001376 .extra1 = &zero,
1377 },
1378#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001379#ifdef CONFIG_HIGHMEM
1380 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001381 .procname = "highmem_is_dirtyable",
1382 .data = &vm_highmem_is_dirtyable,
1383 .maxlen = sizeof(vm_highmem_is_dirtyable),
1384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001386 .extra1 = &zero,
1387 .extra2 = &one,
1388 },
1389#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001390 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001391 .procname = "scan_unevictable_pages",
1392 .data = &scan_unevictable_pages,
1393 .maxlen = sizeof(scan_unevictable_pages),
1394 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001395 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001396 },
Andi Kleen6a460792009-09-16 11:50:15 +02001397#ifdef CONFIG_MEMORY_FAILURE
1398 {
Andi Kleen6a460792009-09-16 11:50:15 +02001399 .procname = "memory_failure_early_kill",
1400 .data = &sysctl_memory_failure_early_kill,
1401 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1402 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001403 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001404 .extra1 = &zero,
1405 .extra2 = &one,
1406 },
1407 {
Andi Kleen6a460792009-09-16 11:50:15 +02001408 .procname = "memory_failure_recovery",
1409 .data = &sysctl_memory_failure_recovery,
1410 .maxlen = sizeof(sysctl_memory_failure_recovery),
1411 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001412 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001413 .extra1 = &zero,
1414 .extra2 = &one,
1415 },
1416#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001417 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418};
1419
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001420#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001421static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001422 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001423};
1424#endif
1425
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001426static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 .procname = "inode-nr",
1429 .data = &inodes_stat,
1430 .maxlen = 2*sizeof(int),
1431 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001432 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 },
1434 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 .procname = "inode-state",
1436 .data = &inodes_stat,
1437 .maxlen = 7*sizeof(int),
1438 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001439 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 },
1441 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 .procname = "file-nr",
1443 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001444 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001446 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 },
1448 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 .procname = "file-max",
1450 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001451 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001453 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 },
1455 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001456 .procname = "nr_open",
1457 .data = &sysctl_nr_open,
1458 .maxlen = sizeof(int),
1459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001460 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001461 .extra1 = &sysctl_nr_open_min,
1462 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001463 },
1464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 .procname = "dentry-state",
1466 .data = &dentry_stat,
1467 .maxlen = 6*sizeof(int),
1468 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001469 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 },
1471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 .procname = "overflowuid",
1473 .data = &fs_overflowuid,
1474 .maxlen = sizeof(int),
1475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001476 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .extra1 = &minolduid,
1478 .extra2 = &maxolduid,
1479 },
1480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .procname = "overflowgid",
1482 .data = &fs_overflowgid,
1483 .maxlen = sizeof(int),
1484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001485 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 .extra1 = &minolduid,
1487 .extra2 = &maxolduid,
1488 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001489#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .procname = "leases-enable",
1492 .data = &leases_enable,
1493 .maxlen = sizeof(int),
1494 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001495 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001497#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498#ifdef CONFIG_DNOTIFY
1499 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 .procname = "dir-notify-enable",
1501 .data = &dir_notify_enable,
1502 .maxlen = sizeof(int),
1503 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001504 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 },
1506#endif
1507#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001508#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 .procname = "lease-break-time",
1511 .data = &lease_break_time,
1512 .maxlen = sizeof(int),
1513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001514 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001516#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001517#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 .procname = "aio-nr",
1520 .data = &aio_nr,
1521 .maxlen = sizeof(aio_nr),
1522 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 },
1525 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 .procname = "aio-max-nr",
1527 .data = &aio_max_nr,
1528 .maxlen = sizeof(aio_max_nr),
1529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001530 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001532#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001533#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001534 {
Robert Love0399cb02005-07-13 12:38:18 -04001535 .procname = "inotify",
1536 .mode = 0555,
1537 .child = inotify_table,
1538 },
1539#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001540#ifdef CONFIG_EPOLL
1541 {
1542 .procname = "epoll",
1543 .mode = 0555,
1544 .child = epoll_table,
1545 },
1546#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001548 {
Kees Cook800179c2012-07-25 17:29:07 -07001549 .procname = "protected_symlinks",
1550 .data = &sysctl_protected_symlinks,
1551 .maxlen = sizeof(int),
1552 .mode = 0600,
1553 .proc_handler = proc_dointvec_minmax,
1554 .extra1 = &zero,
1555 .extra2 = &one,
1556 },
1557 {
1558 .procname = "protected_hardlinks",
1559 .data = &sysctl_protected_hardlinks,
1560 .maxlen = sizeof(int),
1561 .mode = 0600,
1562 .proc_handler = proc_dointvec_minmax,
1563 .extra1 = &zero,
1564 .extra2 = &one,
1565 },
1566 {
Alan Coxd6e71142005-06-23 00:09:43 -07001567 .procname = "suid_dumpable",
1568 .data = &suid_dumpable,
1569 .maxlen = sizeof(int),
1570 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001571 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001572 .extra1 = &zero,
1573 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001574 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001575#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1576 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001577 .procname = "binfmt_misc",
1578 .mode = 0555,
1579 .child = binfmt_misc_table,
1580 },
1581#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001582 {
Jens Axboeff9da692010-06-03 14:54:39 +02001583 .procname = "pipe-max-size",
1584 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001585 .maxlen = sizeof(int),
1586 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001587 .proc_handler = &pipe_proc_fn,
1588 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001589 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001590 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591};
1592
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001593static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001594#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001595 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001596 .procname = "exception-trace",
1597 .data = &show_unhandled_signals,
1598 .maxlen = sizeof(int),
1599 .mode = 0644,
1600 .proc_handler = proc_dointvec
1601 },
1602#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001603#if defined(CONFIG_OPTPROBES)
1604 {
1605 .procname = "kprobes-optimization",
1606 .data = &sysctl_kprobes_optimization,
1607 .maxlen = sizeof(int),
1608 .mode = 0644,
1609 .proc_handler = proc_kprobes_optimization_handler,
1610 .extra1 = &zero,
1611 .extra2 = &one,
1612 },
1613#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001614 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615};
1616
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001617static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001618 { }
Robert Love0eeca282005-07-12 17:06:03 -04001619};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001621int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001622{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001623 struct ctl_table_header *hdr;
1624
1625 hdr = register_sysctl_table(sysctl_base_table);
1626 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001627 return 0;
1628}
1629
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001630#endif /* CONFIG_SYSCTL */
1631
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632/*
1633 * /proc/sys support
1634 */
1635
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001636#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001638static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001639 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001640 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001641{
1642 size_t len;
1643 char __user *p;
1644 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001645
1646 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001647 *lenp = 0;
1648 return 0;
1649 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001650
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001651 if (write) {
1652 len = 0;
1653 p = buffer;
1654 while (len < *lenp) {
1655 if (get_user(c, p++))
1656 return -EFAULT;
1657 if (c == 0 || c == '\n')
1658 break;
1659 len++;
1660 }
1661 if (len >= maxlen)
1662 len = maxlen-1;
1663 if(copy_from_user(data, buffer, len))
1664 return -EFAULT;
1665 ((char *) data)[len] = 0;
1666 *ppos += *lenp;
1667 } else {
1668 len = strlen(data);
1669 if (len > maxlen)
1670 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001671
1672 if (*ppos > len) {
1673 *lenp = 0;
1674 return 0;
1675 }
1676
1677 data += *ppos;
1678 len -= *ppos;
1679
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001680 if (len > *lenp)
1681 len = *lenp;
1682 if (len)
1683 if(copy_to_user(buffer, data, len))
1684 return -EFAULT;
1685 if (len < *lenp) {
1686 if(put_user('\n', ((char __user *) buffer) + len))
1687 return -EFAULT;
1688 len++;
1689 }
1690 *lenp = len;
1691 *ppos += len;
1692 }
1693 return 0;
1694}
1695
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696/**
1697 * proc_dostring - read a string sysctl
1698 * @table: the sysctl table
1699 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 * @buffer: the user buffer
1701 * @lenp: the size of the user buffer
1702 * @ppos: file position
1703 *
1704 * Reads/writes a string from/to the user buffer. If the kernel
1705 * buffer provided is not large enough to hold the string, the
1706 * string is truncated. The copied string is %NULL-terminated.
1707 * If the string is being read by the user process, it is copied
1708 * and a newline '\n' is added. It is truncated if the buffer is
1709 * not large enough.
1710 *
1711 * Returns 0 on success.
1712 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001713int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714 void __user *buffer, size_t *lenp, loff_t *ppos)
1715{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001716 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001717 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718}
1719
Amerigo Wang00b7c332010-05-05 00:26:45 +00001720static size_t proc_skip_spaces(char **buf)
1721{
1722 size_t ret;
1723 char *tmp = skip_spaces(*buf);
1724 ret = tmp - *buf;
1725 *buf = tmp;
1726 return ret;
1727}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001729static void proc_skip_char(char **buf, size_t *size, const char v)
1730{
1731 while (*size) {
1732 if (**buf != v)
1733 break;
1734 (*size)--;
1735 (*buf)++;
1736 }
1737}
1738
Amerigo Wang00b7c332010-05-05 00:26:45 +00001739#define TMPBUFLEN 22
1740/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001741 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001742 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001743 * @buf: a kernel buffer
1744 * @size: size of the kernel buffer
1745 * @val: this is where the number will be stored
1746 * @neg: set to %TRUE if number is negative
1747 * @perm_tr: a vector which contains the allowed trailers
1748 * @perm_tr_len: size of the perm_tr vector
1749 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001750 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001751 * In case of success %0 is returned and @buf and @size are updated with
1752 * the amount of bytes read. If @tr is non-NULL and a trailing
1753 * character exists (size is non-zero after returning from this
1754 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001755 */
1756static int proc_get_long(char **buf, size_t *size,
1757 unsigned long *val, bool *neg,
1758 const char *perm_tr, unsigned perm_tr_len, char *tr)
1759{
1760 int len;
1761 char *p, tmp[TMPBUFLEN];
1762
1763 if (!*size)
1764 return -EINVAL;
1765
1766 len = *size;
1767 if (len > TMPBUFLEN - 1)
1768 len = TMPBUFLEN - 1;
1769
1770 memcpy(tmp, *buf, len);
1771
1772 tmp[len] = 0;
1773 p = tmp;
1774 if (*p == '-' && *size > 1) {
1775 *neg = true;
1776 p++;
1777 } else
1778 *neg = false;
1779 if (!isdigit(*p))
1780 return -EINVAL;
1781
1782 *val = simple_strtoul(p, &p, 0);
1783
1784 len = p - tmp;
1785
1786 /* We don't know if the next char is whitespace thus we may accept
1787 * invalid integers (e.g. 1234...a) or two integers instead of one
1788 * (e.g. 123...1). So lets not allow such large numbers. */
1789 if (len == TMPBUFLEN - 1)
1790 return -EINVAL;
1791
1792 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1793 return -EINVAL;
1794
1795 if (tr && (len < *size))
1796 *tr = *p;
1797
1798 *buf += len;
1799 *size -= len;
1800
1801 return 0;
1802}
1803
1804/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001805 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001806 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001807 * @buf: the user buffer
1808 * @size: the size of the user buffer
1809 * @val: the integer to be converted
1810 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001811 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001812 * In case of success %0 is returned and @buf and @size are updated with
1813 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001814 */
1815static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1816 bool neg)
1817{
1818 int len;
1819 char tmp[TMPBUFLEN], *p = tmp;
1820
1821 sprintf(p, "%s%lu", neg ? "-" : "", val);
1822 len = strlen(tmp);
1823 if (len > *size)
1824 len = *size;
1825 if (copy_to_user(*buf, tmp, len))
1826 return -EFAULT;
1827 *size -= len;
1828 *buf += len;
1829 return 0;
1830}
1831#undef TMPBUFLEN
1832
1833static int proc_put_char(void __user **buf, size_t *size, char c)
1834{
1835 if (*size) {
1836 char __user **buffer = (char __user **)buf;
1837 if (put_user(c, *buffer))
1838 return -EFAULT;
1839 (*size)--, (*buffer)++;
1840 *buf = *buffer;
1841 }
1842 return 0;
1843}
1844
1845static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 int *valp,
1847 int write, void *data)
1848{
1849 if (write) {
1850 *valp = *negp ? -*lvalp : *lvalp;
1851 } else {
1852 int val = *valp;
1853 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001854 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001855 *lvalp = (unsigned long)-val;
1856 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001857 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001858 *lvalp = (unsigned long)val;
1859 }
1860 }
1861 return 0;
1862}
1863
Amerigo Wang00b7c332010-05-05 00:26:45 +00001864static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1865
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001866static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001867 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001868 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001869 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870 int write, void *data),
1871 void *data)
1872{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001873 int *i, vleft, first = 1, err = 0;
1874 unsigned long page = 0;
1875 size_t left;
1876 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877
Amerigo Wang00b7c332010-05-05 00:26:45 +00001878 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879 *lenp = 0;
1880 return 0;
1881 }
1882
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001883 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884 vleft = table->maxlen / sizeof(*i);
1885 left = *lenp;
1886
1887 if (!conv)
1888 conv = do_proc_dointvec_conv;
1889
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001891 if (left > PAGE_SIZE - 1)
1892 left = PAGE_SIZE - 1;
1893 page = __get_free_page(GFP_TEMPORARY);
1894 kbuf = (char *) page;
1895 if (!kbuf)
1896 return -ENOMEM;
1897 if (copy_from_user(kbuf, buffer, left)) {
1898 err = -EFAULT;
1899 goto free;
1900 }
1901 kbuf[left] = 0;
1902 }
1903
1904 for (; left && vleft--; i++, first=0) {
1905 unsigned long lval;
1906 bool neg;
1907
1908 if (write) {
1909 left -= proc_skip_spaces(&kbuf);
1910
J. R. Okajima563b0462010-05-25 16:10:14 -07001911 if (!left)
1912 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001913 err = proc_get_long(&kbuf, &left, &lval, &neg,
1914 proc_wspace_sep,
1915 sizeof(proc_wspace_sep), NULL);
1916 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001918 if (conv(&neg, &lval, i, 1, data)) {
1919 err = -EINVAL;
1920 break;
1921 }
1922 } else {
1923 if (conv(&neg, &lval, i, 0, data)) {
1924 err = -EINVAL;
1925 break;
1926 }
1927 if (!first)
1928 err = proc_put_char(&buffer, &left, '\t');
1929 if (err)
1930 break;
1931 err = proc_put_long(&buffer, &left, lval, neg);
1932 if (err)
1933 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934 }
1935 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001936
1937 if (!write && !first && left && !err)
1938 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001939 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001940 left -= proc_skip_spaces(&kbuf);
1941free:
1942 if (write) {
1943 free_page(page);
1944 if (first)
1945 return err ? : -EINVAL;
1946 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 *lenp -= left;
1948 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001949 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950}
1951
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001952static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001953 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001954 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001955 int write, void *data),
1956 void *data)
1957{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001958 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001959 buffer, lenp, ppos, conv, data);
1960}
1961
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962/**
1963 * proc_dointvec - read a vector of integers
1964 * @table: the sysctl table
1965 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 * @buffer: the user buffer
1967 * @lenp: the size of the user buffer
1968 * @ppos: file position
1969 *
1970 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1971 * values from/to the user buffer, treated as an ASCII string.
1972 *
1973 * Returns 0 on success.
1974 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001975int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 void __user *buffer, size_t *lenp, loff_t *ppos)
1977{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001978 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001979 NULL,NULL);
1980}
1981
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001982/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001983 * Taint values can only be increased
1984 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001985 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001986static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001987 void __user *buffer, size_t *lenp, loff_t *ppos)
1988{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001989 struct ctl_table t;
1990 unsigned long tmptaint = get_taint();
1991 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001992
Bastian Blank91fcd412007-04-23 14:41:14 -07001993 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001994 return -EPERM;
1995
Andi Kleen25ddbb12008-10-15 22:01:41 -07001996 t = *table;
1997 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001998 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001999 if (err < 0)
2000 return err;
2001
2002 if (write) {
2003 /*
2004 * Poor man's atomic or. Not worth adding a primitive
2005 * to everyone's atomic.h for this
2006 */
2007 int i;
2008 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2009 if ((tmptaint >> i) & 1)
2010 add_taint(i);
2011 }
2012 }
2013
2014 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002015}
2016
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002017#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002018static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002019 void __user *buffer, size_t *lenp, loff_t *ppos)
2020{
2021 if (write && !capable(CAP_SYS_ADMIN))
2022 return -EPERM;
2023
2024 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2025}
2026#endif
2027
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028struct do_proc_dointvec_minmax_conv_param {
2029 int *min;
2030 int *max;
2031};
2032
Amerigo Wang00b7c332010-05-05 00:26:45 +00002033static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2034 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035 int write, void *data)
2036{
2037 struct do_proc_dointvec_minmax_conv_param *param = data;
2038 if (write) {
2039 int val = *negp ? -*lvalp : *lvalp;
2040 if ((param->min && *param->min > val) ||
2041 (param->max && *param->max < val))
2042 return -EINVAL;
2043 *valp = val;
2044 } else {
2045 int val = *valp;
2046 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002047 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048 *lvalp = (unsigned long)-val;
2049 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002050 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051 *lvalp = (unsigned long)val;
2052 }
2053 }
2054 return 0;
2055}
2056
2057/**
2058 * proc_dointvec_minmax - read a vector of integers with min/max values
2059 * @table: the sysctl table
2060 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002061 * @buffer: the user buffer
2062 * @lenp: the size of the user buffer
2063 * @ppos: file position
2064 *
2065 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2066 * values from/to the user buffer, treated as an ASCII string.
2067 *
2068 * This routine will ensure the values are within the range specified by
2069 * table->extra1 (min) and table->extra2 (max).
2070 *
2071 * Returns 0 on success.
2072 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002073int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 void __user *buffer, size_t *lenp, loff_t *ppos)
2075{
2076 struct do_proc_dointvec_minmax_conv_param param = {
2077 .min = (int *) table->extra1,
2078 .max = (int *) table->extra2,
2079 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002080 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081 do_proc_dointvec_minmax_conv, &param);
2082}
2083
Kees Cook54b50192012-07-30 14:39:18 -07002084static void validate_coredump_safety(void)
2085{
Alex Kelly046d6622012-10-04 17:15:23 -07002086#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002087 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2088 core_pattern[0] != '/' && core_pattern[0] != '|') {
2089 printk(KERN_WARNING "Unsafe core_pattern used with "\
2090 "suid_dumpable=2. Pipe handler or fully qualified "\
2091 "core dump path required.\n");
2092 }
Alex Kelly046d6622012-10-04 17:15:23 -07002093#endif
Kees Cook54b50192012-07-30 14:39:18 -07002094}
2095
2096static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2097 void __user *buffer, size_t *lenp, loff_t *ppos)
2098{
2099 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2100 if (!error)
2101 validate_coredump_safety();
2102 return error;
2103}
2104
Alex Kelly046d6622012-10-04 17:15:23 -07002105#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002106static int proc_dostring_coredump(struct ctl_table *table, int write,
2107 void __user *buffer, size_t *lenp, loff_t *ppos)
2108{
2109 int error = proc_dostring(table, write, buffer, lenp, ppos);
2110 if (!error)
2111 validate_coredump_safety();
2112 return error;
2113}
Alex Kelly046d6622012-10-04 17:15:23 -07002114#endif
Kees Cook54b50192012-07-30 14:39:18 -07002115
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002116static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117 void __user *buffer,
2118 size_t *lenp, loff_t *ppos,
2119 unsigned long convmul,
2120 unsigned long convdiv)
2121{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002122 unsigned long *i, *min, *max;
2123 int vleft, first = 1, err = 0;
2124 unsigned long page = 0;
2125 size_t left;
2126 char *kbuf;
2127
2128 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 *lenp = 0;
2130 return 0;
2131 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002132
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002133 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 min = (unsigned long *) table->extra1;
2135 max = (unsigned long *) table->extra2;
2136 vleft = table->maxlen / sizeof(unsigned long);
2137 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002138
2139 if (write) {
2140 if (left > PAGE_SIZE - 1)
2141 left = PAGE_SIZE - 1;
2142 page = __get_free_page(GFP_TEMPORARY);
2143 kbuf = (char *) page;
2144 if (!kbuf)
2145 return -ENOMEM;
2146 if (copy_from_user(kbuf, buffer, left)) {
2147 err = -EFAULT;
2148 goto free;
2149 }
2150 kbuf[left] = 0;
2151 }
2152
Eric Dumazet27b3d802010-10-07 12:59:29 -07002153 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002154 unsigned long val;
2155
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002157 bool neg;
2158
2159 left -= proc_skip_spaces(&kbuf);
2160
2161 err = proc_get_long(&kbuf, &left, &val, &neg,
2162 proc_wspace_sep,
2163 sizeof(proc_wspace_sep), NULL);
2164 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165 break;
2166 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167 continue;
2168 if ((min && val < *min) || (max && val > *max))
2169 continue;
2170 *i = val;
2171 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002174 err = proc_put_char(&buffer, &left, '\t');
2175 err = proc_put_long(&buffer, &left, val, false);
2176 if (err)
2177 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 }
2179 }
2180
Amerigo Wang00b7c332010-05-05 00:26:45 +00002181 if (!write && !first && left && !err)
2182 err = proc_put_char(&buffer, &left, '\n');
2183 if (write && !err)
2184 left -= proc_skip_spaces(&kbuf);
2185free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187 free_page(page);
2188 if (first)
2189 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 *lenp -= left;
2192 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002193 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194}
2195
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002196static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002197 void __user *buffer,
2198 size_t *lenp, loff_t *ppos,
2199 unsigned long convmul,
2200 unsigned long convdiv)
2201{
2202 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002203 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002204}
2205
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206/**
2207 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2208 * @table: the sysctl table
2209 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 * @buffer: the user buffer
2211 * @lenp: the size of the user buffer
2212 * @ppos: file position
2213 *
2214 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2215 * values from/to the user buffer, treated as an ASCII string.
2216 *
2217 * This routine will ensure the values are within the range specified by
2218 * table->extra1 (min) and table->extra2 (max).
2219 *
2220 * Returns 0 on success.
2221 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002222int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223 void __user *buffer, size_t *lenp, loff_t *ppos)
2224{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002225 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002226}
2227
2228/**
2229 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2230 * @table: the sysctl table
2231 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 * @buffer: the user buffer
2233 * @lenp: the size of the user buffer
2234 * @ppos: file position
2235 *
2236 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2237 * values from/to the user buffer, treated as an ASCII string. The values
2238 * are treated as milliseconds, and converted to jiffies when they are stored.
2239 *
2240 * This routine will ensure the values are within the range specified by
2241 * table->extra1 (min) and table->extra2 (max).
2242 *
2243 * Returns 0 on success.
2244 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002245int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 void __user *buffer,
2247 size_t *lenp, loff_t *ppos)
2248{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002249 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 lenp, ppos, HZ, 1000l);
2251}
2252
2253
Amerigo Wang00b7c332010-05-05 00:26:45 +00002254static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 int *valp,
2256 int write, void *data)
2257{
2258 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002259 if (*lvalp > LONG_MAX / HZ)
2260 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2262 } else {
2263 int val = *valp;
2264 unsigned long lval;
2265 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002266 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 lval = (unsigned long)-val;
2268 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 lval = (unsigned long)val;
2271 }
2272 *lvalp = lval / HZ;
2273 }
2274 return 0;
2275}
2276
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 int *valp,
2279 int write, void *data)
2280{
2281 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002282 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2283 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2285 } else {
2286 int val = *valp;
2287 unsigned long lval;
2288 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002289 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 lval = (unsigned long)-val;
2291 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002292 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293 lval = (unsigned long)val;
2294 }
2295 *lvalp = jiffies_to_clock_t(lval);
2296 }
2297 return 0;
2298}
2299
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 int *valp,
2302 int write, void *data)
2303{
2304 if (write) {
2305 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2306 } else {
2307 int val = *valp;
2308 unsigned long lval;
2309 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002310 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311 lval = (unsigned long)-val;
2312 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002313 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 lval = (unsigned long)val;
2315 }
2316 *lvalp = jiffies_to_msecs(lval);
2317 }
2318 return 0;
2319}
2320
2321/**
2322 * proc_dointvec_jiffies - read a vector of integers as seconds
2323 * @table: the sysctl table
2324 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 * @buffer: the user buffer
2326 * @lenp: the size of the user buffer
2327 * @ppos: file position
2328 *
2329 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2330 * values from/to the user buffer, treated as an ASCII string.
2331 * The values read are assumed to be in seconds, and are converted into
2332 * jiffies.
2333 *
2334 * Returns 0 on success.
2335 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002336int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 void __user *buffer, size_t *lenp, loff_t *ppos)
2338{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002339 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 do_proc_dointvec_jiffies_conv,NULL);
2341}
2342
2343/**
2344 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2345 * @table: the sysctl table
2346 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 * @buffer: the user buffer
2348 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002349 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 *
2351 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2352 * values from/to the user buffer, treated as an ASCII string.
2353 * The values read are assumed to be in 1/USER_HZ seconds, and
2354 * are converted into jiffies.
2355 *
2356 * Returns 0 on success.
2357 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002358int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359 void __user *buffer, size_t *lenp, loff_t *ppos)
2360{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002361 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 do_proc_dointvec_userhz_jiffies_conv,NULL);
2363}
2364
2365/**
2366 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2367 * @table: the sysctl table
2368 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 * @buffer: the user buffer
2370 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002371 * @ppos: file position
2372 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373 *
2374 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2375 * values from/to the user buffer, treated as an ASCII string.
2376 * The values read are assumed to be in 1/1000 seconds, and
2377 * are converted into jiffies.
2378 *
2379 * Returns 0 on success.
2380 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002381int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382 void __user *buffer, size_t *lenp, loff_t *ppos)
2383{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002384 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 do_proc_dointvec_ms_jiffies_conv, NULL);
2386}
2387
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002388static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002389 void __user *buffer, size_t *lenp, loff_t *ppos)
2390{
2391 struct pid *new_pid;
2392 pid_t tmp;
2393 int r;
2394
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002395 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002396
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002397 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002398 lenp, ppos, NULL, NULL);
2399 if (r || !write)
2400 return r;
2401
2402 new_pid = find_get_pid(tmp);
2403 if (!new_pid)
2404 return -ESRCH;
2405
2406 put_pid(xchg(&cad_pid, new_pid));
2407 return 0;
2408}
2409
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002410/**
2411 * proc_do_large_bitmap - read/write from/to a large bitmap
2412 * @table: the sysctl table
2413 * @write: %TRUE if this is a write to the sysctl file
2414 * @buffer: the user buffer
2415 * @lenp: the size of the user buffer
2416 * @ppos: file position
2417 *
2418 * The bitmap is stored at table->data and the bitmap length (in bits)
2419 * in table->maxlen.
2420 *
2421 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2422 * large bitmaps may be represented in a compact manner. Writing into
2423 * the file will clear the bitmap then update it with the given input.
2424 *
2425 * Returns 0 on success.
2426 */
2427int proc_do_large_bitmap(struct ctl_table *table, int write,
2428 void __user *buffer, size_t *lenp, loff_t *ppos)
2429{
2430 int err = 0;
2431 bool first = 1;
2432 size_t left = *lenp;
2433 unsigned long bitmap_len = table->maxlen;
2434 unsigned long *bitmap = (unsigned long *) table->data;
2435 unsigned long *tmp_bitmap = NULL;
2436 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2437
2438 if (!bitmap_len || !left || (*ppos && !write)) {
2439 *lenp = 0;
2440 return 0;
2441 }
2442
2443 if (write) {
2444 unsigned long page = 0;
2445 char *kbuf;
2446
2447 if (left > PAGE_SIZE - 1)
2448 left = PAGE_SIZE - 1;
2449
2450 page = __get_free_page(GFP_TEMPORARY);
2451 kbuf = (char *) page;
2452 if (!kbuf)
2453 return -ENOMEM;
2454 if (copy_from_user(kbuf, buffer, left)) {
2455 free_page(page);
2456 return -EFAULT;
2457 }
2458 kbuf[left] = 0;
2459
2460 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2461 GFP_KERNEL);
2462 if (!tmp_bitmap) {
2463 free_page(page);
2464 return -ENOMEM;
2465 }
2466 proc_skip_char(&kbuf, &left, '\n');
2467 while (!err && left) {
2468 unsigned long val_a, val_b;
2469 bool neg;
2470
2471 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2472 sizeof(tr_a), &c);
2473 if (err)
2474 break;
2475 if (val_a >= bitmap_len || neg) {
2476 err = -EINVAL;
2477 break;
2478 }
2479
2480 val_b = val_a;
2481 if (left) {
2482 kbuf++;
2483 left--;
2484 }
2485
2486 if (c == '-') {
2487 err = proc_get_long(&kbuf, &left, &val_b,
2488 &neg, tr_b, sizeof(tr_b),
2489 &c);
2490 if (err)
2491 break;
2492 if (val_b >= bitmap_len || neg ||
2493 val_a > val_b) {
2494 err = -EINVAL;
2495 break;
2496 }
2497 if (left) {
2498 kbuf++;
2499 left--;
2500 }
2501 }
2502
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002503 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002504 first = 0;
2505 proc_skip_char(&kbuf, &left, '\n');
2506 }
2507 free_page(page);
2508 } else {
2509 unsigned long bit_a, bit_b = 0;
2510
2511 while (left) {
2512 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2513 if (bit_a >= bitmap_len)
2514 break;
2515 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2516 bit_a + 1) - 1;
2517
2518 if (!first) {
2519 err = proc_put_char(&buffer, &left, ',');
2520 if (err)
2521 break;
2522 }
2523 err = proc_put_long(&buffer, &left, bit_a, false);
2524 if (err)
2525 break;
2526 if (bit_a != bit_b) {
2527 err = proc_put_char(&buffer, &left, '-');
2528 if (err)
2529 break;
2530 err = proc_put_long(&buffer, &left, bit_b, false);
2531 if (err)
2532 break;
2533 }
2534
2535 first = 0; bit_b++;
2536 }
2537 if (!err)
2538 err = proc_put_char(&buffer, &left, '\n');
2539 }
2540
2541 if (!err) {
2542 if (write) {
2543 if (*ppos)
2544 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2545 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002546 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002547 }
2548 kfree(tmp_bitmap);
2549 *lenp -= left;
2550 *ppos += *lenp;
2551 return 0;
2552 } else {
2553 kfree(tmp_bitmap);
2554 return err;
2555 }
2556}
2557
Jovi Zhang55610502011-01-12 17:00:45 -08002558#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002560int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 void __user *buffer, size_t *lenp, loff_t *ppos)
2562{
2563 return -ENOSYS;
2564}
2565
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002566int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567 void __user *buffer, size_t *lenp, loff_t *ppos)
2568{
2569 return -ENOSYS;
2570}
2571
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002572int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002573 void __user *buffer, size_t *lenp, loff_t *ppos)
2574{
2575 return -ENOSYS;
2576}
2577
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002578int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579 void __user *buffer, size_t *lenp, loff_t *ppos)
2580{
2581 return -ENOSYS;
2582}
2583
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002584int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 void __user *buffer, size_t *lenp, loff_t *ppos)
2586{
2587 return -ENOSYS;
2588}
2589
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002590int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002591 void __user *buffer, size_t *lenp, loff_t *ppos)
2592{
2593 return -ENOSYS;
2594}
2595
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002596int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 void __user *buffer, size_t *lenp, loff_t *ppos)
2598{
2599 return -ENOSYS;
2600}
2601
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002602int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603 void __user *buffer,
2604 size_t *lenp, loff_t *ppos)
2605{
2606 return -ENOSYS;
2607}
2608
2609
Jovi Zhang55610502011-01-12 17:00:45 -08002610#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612/*
2613 * No sense putting this after each symbol definition, twice,
2614 * exception granted :-)
2615 */
2616EXPORT_SYMBOL(proc_dointvec);
2617EXPORT_SYMBOL(proc_dointvec_jiffies);
2618EXPORT_SYMBOL(proc_dointvec_minmax);
2619EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2620EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2621EXPORT_SYMBOL(proc_dostring);
2622EXPORT_SYMBOL(proc_doulongvec_minmax);
2623EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);