blob: 4fc9be955c712ca4b68c25b18d1ac9599df2a3ae [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 Zijlstra4b96a29b2012-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 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600407 {
408 .procname = "sched_rr_timeslice_ms",
409 .data = &sched_rr_timeslice,
410 .maxlen = sizeof(int),
411 .mode = 0644,
412 .proc_handler = sched_rr_handler,
413 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100414#ifdef CONFIG_SCHED_AUTOGROUP
415 {
416 .procname = "sched_autogroup_enabled",
417 .data = &sysctl_sched_autogroup_enabled,
418 .maxlen = sizeof(unsigned int),
419 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800420 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100421 .extra1 = &zero,
422 .extra2 = &one,
423 },
424#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700425#ifdef CONFIG_CFS_BANDWIDTH
426 {
427 .procname = "sched_cfs_bandwidth_slice_us",
428 .data = &sysctl_sched_cfs_bandwidth_slice,
429 .maxlen = sizeof(unsigned int),
430 .mode = 0644,
431 .proc_handler = proc_dointvec_minmax,
432 .extra1 = &one,
433 },
434#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700435#ifdef CONFIG_PROVE_LOCKING
436 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700437 .procname = "prove_locking",
438 .data = &prove_locking,
439 .maxlen = sizeof(int),
440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800441 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700442 },
443#endif
444#ifdef CONFIG_LOCK_STAT
445 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446 .procname = "lock_stat",
447 .data = &lock_stat,
448 .maxlen = sizeof(int),
449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800450 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700451 },
452#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200453 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 .procname = "panic",
455 .data = &panic_timeout,
456 .maxlen = sizeof(int),
457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800458 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 },
Alex Kelly046d6622012-10-04 17:15:23 -0700460#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "core_uses_pid",
463 .data = &core_uses_pid,
464 .maxlen = sizeof(int),
465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 .procname = "core_pattern",
470 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700471 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700473 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 },
Neil Hormana2939802009-09-23 15:56:56 -0700475 {
Neil Hormana2939802009-09-23 15:56:56 -0700476 .procname = "core_pipe_limit",
477 .data = &core_pipe_limit,
478 .maxlen = sizeof(unsigned int),
479 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800480 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700481 },
Alex Kelly046d6622012-10-04 17:15:23 -0700482#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800483#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700486 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800488 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800490#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100491#ifdef CONFIG_LATENCYTOP
492 {
493 .procname = "latencytop",
494 .data = &latencytop_enabled,
495 .maxlen = sizeof(int),
496 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800497 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100498 },
499#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500#ifdef CONFIG_BLK_DEV_INITRD
501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 .procname = "real-root-dev",
503 .data = &real_root_dev,
504 .maxlen = sizeof(int),
505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 },
508#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700509 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700510 .procname = "print-fatal-signals",
511 .data = &print_fatal_signals,
512 .maxlen = sizeof(int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700515 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700516#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .procname = "reboot-cmd",
519 .data = reboot_command,
520 .maxlen = 256,
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 },
524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 .procname = "stop-a",
526 .data = &stop_a_enabled,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 .procname = "scons-poweroff",
533 .data = &scons_pwroff,
534 .maxlen = sizeof (int),
535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800536 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 },
538#endif
David S. Miller08714202008-11-16 23:49:24 -0800539#ifdef CONFIG_SPARC64
540 {
David S. Miller08714202008-11-16 23:49:24 -0800541 .procname = "tsb-ratio",
542 .data = &sysctl_tsb_ratio,
543 .maxlen = sizeof (int),
544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800545 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800546 },
547#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548#ifdef __hppa__
549 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 .procname = "soft-power",
551 .data = &pwrsw_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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 .procname = "unaligned-trap",
558 .data = &unaligned_enabled,
559 .maxlen = sizeof (int),
560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800561 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 },
563#endif
564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 .procname = "ctrl-alt-del",
566 .data = &C_A_D,
567 .maxlen = sizeof(int),
568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800569 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400571#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200572 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200573 .procname = "ftrace_enabled",
574 .data = &ftrace_enabled,
575 .maxlen = sizeof(int),
576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800577 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200578 },
579#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500580#ifdef CONFIG_STACK_TRACER
581 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500582 .procname = "stack_tracer_enabled",
583 .data = &stack_tracer_enabled,
584 .maxlen = sizeof(int),
585 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800586 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500587 },
588#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400589#ifdef CONFIG_TRACING
590 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100591 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400592 .data = &ftrace_dump_on_oops,
593 .maxlen = sizeof(int),
594 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800595 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400596 },
597#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200598#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .procname = "modprobe",
601 .data = &modprobe_path,
602 .maxlen = KMOD_PATH_LEN,
603 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800604 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 },
Kees Cook3d433212009-04-02 15:49:29 -0700606 {
Kees Cook3d433212009-04-02 15:49:29 -0700607 .procname = "modules_disabled",
608 .data = &modules_disabled,
609 .maxlen = sizeof(int),
610 .mode = 0644,
611 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800612 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700613 .extra1 = &one,
614 .extra2 = &one,
615 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500617
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100620 .data = &uevent_helper,
621 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800623 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500625
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626#ifdef CONFIG_CHR_DEV_SG
627 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 .procname = "sg-big-buff",
629 .data = &sg_big_buff,
630 .maxlen = sizeof (int),
631 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800632 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 },
634#endif
635#ifdef CONFIG_BSD_PROCESS_ACCT
636 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 .procname = "acct",
638 .data = &acct_parm,
639 .maxlen = 3*sizeof(int),
640 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 },
643#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644#ifdef CONFIG_MAGIC_SYSRQ
645 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800647 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .maxlen = sizeof (int),
649 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700650 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 },
652#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700653#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700656 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .maxlen = sizeof (int),
658 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700661#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .procname = "threads-max",
664 .data = &max_threads,
665 .maxlen = sizeof(int),
666 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800667 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 },
669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .procname = "random",
671 .mode = 0555,
672 .child = random_table,
673 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 {
Eric Paris17f60a72011-04-01 17:07:50 -0400675 .procname = "usermodehelper",
676 .mode = 0555,
677 .child = usermodehelper_table,
678 },
679 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 .procname = "overflowuid",
681 .data = &overflowuid,
682 .maxlen = sizeof(int),
683 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800684 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .extra1 = &minolduid,
686 .extra2 = &maxolduid,
687 },
688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .procname = "overflowgid",
690 .data = &overflowgid,
691 .maxlen = sizeof(int),
692 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800693 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .extra1 = &minolduid,
695 .extra2 = &maxolduid,
696 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800697#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698#ifdef CONFIG_MATHEMU
699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .procname = "ieee_emulation_warnings",
701 .data = &sysctl_ieee_emulation_warnings,
702 .maxlen = sizeof(int),
703 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800704 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 },
706#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200709 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .maxlen = sizeof(int),
711 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800712 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 },
714#endif
715 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .procname = "pid_max",
717 .data = &pid_max,
718 .maxlen = sizeof (int),
719 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800720 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .extra1 = &pid_max_min,
722 .extra2 = &pid_max_max,
723 },
724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "panic_on_oops",
726 .data = &panic_on_oops,
727 .maxlen = sizeof(int),
728 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800729 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800731#if defined CONFIG_PRINTK
732 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800733 .procname = "printk",
734 .data = &console_loglevel,
735 .maxlen = 4*sizeof(int),
736 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800737 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800738 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700741 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 },
746 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700748 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .maxlen = sizeof(int),
750 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800751 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 },
Dave Youngaf913222009-09-22 16:43:33 -0700753 {
Dave Youngaf913222009-09-22 16:43:33 -0700754 .procname = "printk_delay",
755 .data = &printk_delay_msec,
756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700759 .extra1 = &zero,
760 .extra2 = &ten_thousand,
761 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800763 .procname = "dmesg_restrict",
764 .data = &dmesg_restrict,
765 .maxlen = sizeof(int),
766 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700767 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800768 .extra1 = &zero,
769 .extra2 = &one,
770 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800771 {
772 .procname = "kptr_restrict",
773 .data = &kptr_restrict,
774 .maxlen = sizeof(int),
775 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700776 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800777 .extra1 = &zero,
778 .extra2 = &two,
779 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800780#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800781 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 .procname = "ngroups_max",
783 .data = &ngroups_max,
784 .maxlen = sizeof (int),
785 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800786 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 },
Dan Ballard73efc032011-10-31 17:11:20 -0700788 {
789 .procname = "cap_last_cap",
790 .data = (void *)&cap_last_cap,
791 .maxlen = sizeof(int),
792 .mode = 0444,
793 .proc_handler = proc_dointvec,
794 },
Don Zickus58687ac2010-05-07 17:11:44 -0400795#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500796 {
Don Zickus58687ac2010-05-07 17:11:44 -0400797 .procname = "watchdog",
798 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500799 .maxlen = sizeof (int),
800 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700801 .proc_handler = proc_dowatchdog,
802 .extra1 = &zero,
803 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400804 },
805 {
806 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700807 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400808 .maxlen = sizeof(int),
809 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700810 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400811 .extra1 = &neg_one,
812 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500813 },
Don Zickus2508ce12010-05-07 17:11:46 -0400814 {
815 .procname = "softlockup_panic",
816 .data = &softlockup_panic,
817 .maxlen = sizeof(int),
818 .mode = 0644,
819 .proc_handler = proc_dointvec_minmax,
820 .extra1 = &zero,
821 .extra2 = &one,
822 },
Don Zickus5dc30552010-11-29 17:07:17 -0500823 {
824 .procname = "nmi_watchdog",
825 .data = &watchdog_enabled,
826 .maxlen = sizeof (int),
827 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700828 .proc_handler = proc_dowatchdog,
829 .extra1 = &zero,
830 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500831 },
832#endif
833#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
834 {
835 .procname = "unknown_nmi_panic",
836 .data = &unknown_nmi_panic,
837 .maxlen = sizeof (int),
838 .mode = 0644,
839 .proc_handler = proc_dointvec,
840 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500841#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842#if defined(CONFIG_X86)
843 {
Don Zickus8da5add2006-09-26 10:52:27 +0200844 .procname = "panic_on_unrecovered_nmi",
845 .data = &panic_on_unrecovered_nmi,
846 .maxlen = sizeof(int),
847 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200849 },
850 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700851 .procname = "panic_on_io_nmi",
852 .data = &panic_on_io_nmi,
853 .maxlen = sizeof(int),
854 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800855 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700856 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900857#ifdef CONFIG_DEBUG_STACKOVERFLOW
858 {
859 .procname = "panic_on_stackoverflow",
860 .data = &sysctl_panic_on_stackoverflow,
861 .maxlen = sizeof(int),
862 .mode = 0644,
863 .proc_handler = proc_dointvec,
864 },
865#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700866 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 .procname = "bootloader_type",
868 .data = &bootloader_type,
869 .maxlen = sizeof (int),
870 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800871 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100873 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700874 .procname = "bootloader_version",
875 .data = &bootloader_version,
876 .maxlen = sizeof (int),
877 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800878 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700879 },
880 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100881 .procname = "kstack_depth_to_print",
882 .data = &kstack_depth_to_print,
883 .maxlen = sizeof(int),
884 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800885 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100886 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100887 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100888 .procname = "io_delay_type",
889 .data = &io_delay_type,
890 .maxlen = sizeof(int),
891 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800892 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100893 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800895#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .procname = "randomize_va_space",
898 .data = &randomize_va_space,
899 .maxlen = sizeof(int),
900 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800903#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800904#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700905 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700906 .procname = "spin_retry",
907 .data = &spin_retry,
908 .maxlen = sizeof (int),
909 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800910 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700911 },
912#endif
Len Brown673d5b42007-07-28 03:33:16 -0400913#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800914 {
Pavel Machekc255d842006-02-20 18:27:58 -0800915 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700916 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800917 .maxlen = sizeof (unsigned long),
918 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800919 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800920 },
921#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800922#ifdef CONFIG_IA64
923 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800924 .procname = "ignore-unaligned-usertrap",
925 .data = &no_unaligned_warning,
926 .maxlen = sizeof (int),
927 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800928 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800929 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800930 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800931 .procname = "unaligned-dump-stack",
932 .data = &unaligned_dump_stack,
933 .maxlen = sizeof (int),
934 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800935 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800936 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800937#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800938#ifdef CONFIG_DETECT_HUNG_TASK
939 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800940 .procname = "hung_task_panic",
941 .data = &sysctl_hung_task_panic,
942 .maxlen = sizeof(int),
943 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800944 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800945 .extra1 = &zero,
946 .extra2 = &one,
947 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100948 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100949 .procname = "hung_task_check_count",
950 .data = &sysctl_hung_task_check_count,
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_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100954 },
955 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100956 .procname = "hung_task_timeout_secs",
957 .data = &sysctl_hung_task_timeout_secs,
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_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100961 },
962 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100963 .procname = "hung_task_warnings",
964 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100965 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100966 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800967 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100968 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700969#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200970#ifdef CONFIG_COMPAT
971 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200972 .procname = "compat-log",
973 .data = &compat_log,
974 .maxlen = sizeof (int),
975 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800976 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200977 },
978#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700979#ifdef CONFIG_RT_MUTEXES
980 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700981 .procname = "max_lock_depth",
982 .data = &max_lock_depth,
983 .maxlen = sizeof(int),
984 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800985 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700986 },
987#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700988 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700989 .procname = "poweroff_cmd",
990 .data = &poweroff_cmd,
991 .maxlen = POWEROFF_CMD_PATH_LEN,
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700994 },
David Howells0b77f5b2008-04-29 01:01:32 -0700995#ifdef CONFIG_KEYS
996 {
David Howells0b77f5b2008-04-29 01:01:32 -0700997 .procname = "keys",
998 .mode = 0555,
999 .child = key_sysctls,
1000 },
1001#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001002#ifdef CONFIG_RCU_TORTURE_TEST
1003 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001004 .procname = "rcutorture_runnable",
1005 .data = &rcutorture_runnable,
1006 .maxlen = sizeof(int),
1007 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001008 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001009 },
1010#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001011#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001012 /*
1013 * User-space scripts rely on the existence of this file
1014 * as a feature check for perf_events being enabled.
1015 *
1016 * So it's an ABI, do not remove!
1017 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001018 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001019 .procname = "perf_event_paranoid",
1020 .data = &sysctl_perf_event_paranoid,
1021 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001024 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001025 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001026 .procname = "perf_event_mlock_kb",
1027 .data = &sysctl_perf_event_mlock,
1028 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001029 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001030 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001031 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001032 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001033 .procname = "perf_event_max_sample_rate",
1034 .data = &sysctl_perf_event_sample_rate,
1035 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001036 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001037 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001038 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001039#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001040#ifdef CONFIG_KMEMCHECK
1041 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001042 .procname = "kmemcheck",
1043 .data = &kmemcheck_enabled,
1044 .maxlen = sizeof(int),
1045 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001046 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001047 },
1048#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001049#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001050 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001051 .procname = "blk_iopoll",
1052 .data = &blk_iopoll_enabled,
1053 .maxlen = sizeof(int),
1054 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001055 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001056 },
Jens Axboecb684b52009-09-15 21:53:11 +02001057#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001058 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059};
1060
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001061static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 .procname = "overcommit_memory",
1064 .data = &sysctl_overcommit_memory,
1065 .maxlen = sizeof(sysctl_overcommit_memory),
1066 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001067 .proc_handler = proc_dointvec_minmax,
1068 .extra1 = &zero,
1069 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 },
1071 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001072 .procname = "panic_on_oom",
1073 .data = &sysctl_panic_on_oom,
1074 .maxlen = sizeof(sysctl_panic_on_oom),
1075 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001076 .proc_handler = proc_dointvec_minmax,
1077 .extra1 = &zero,
1078 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001079 },
1080 {
David Rientjesfe071d72007-10-16 23:25:56 -07001081 .procname = "oom_kill_allocating_task",
1082 .data = &sysctl_oom_kill_allocating_task,
1083 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1084 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001085 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001086 },
1087 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001088 .procname = "oom_dump_tasks",
1089 .data = &sysctl_oom_dump_tasks,
1090 .maxlen = sizeof(sysctl_oom_dump_tasks),
1091 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001092 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001093 },
1094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "overcommit_ratio",
1096 .data = &sysctl_overcommit_ratio,
1097 .maxlen = sizeof(sysctl_overcommit_ratio),
1098 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 },
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .procname = "page-cluster",
1103 .data = &page_cluster,
1104 .maxlen = sizeof(int),
1105 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001106 .proc_handler = proc_dointvec_minmax,
1107 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 },
1109 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .procname = "dirty_background_ratio",
1111 .data = &dirty_background_ratio,
1112 .maxlen = sizeof(dirty_background_ratio),
1113 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001114 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .extra1 = &zero,
1116 .extra2 = &one_hundred,
1117 },
1118 {
David Rientjes2da02992009-01-06 14:39:31 -08001119 .procname = "dirty_background_bytes",
1120 .data = &dirty_background_bytes,
1121 .maxlen = sizeof(dirty_background_bytes),
1122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001124 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001125 },
1126 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 .procname = "dirty_ratio",
1128 .data = &vm_dirty_ratio,
1129 .maxlen = sizeof(vm_dirty_ratio),
1130 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001131 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 .extra1 = &zero,
1133 .extra2 = &one_hundred,
1134 },
1135 {
David Rientjes2da02992009-01-06 14:39:31 -08001136 .procname = "dirty_bytes",
1137 .data = &vm_dirty_bytes,
1138 .maxlen = sizeof(vm_dirty_bytes),
1139 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001140 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001141 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001142 },
1143 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001145 .data = &dirty_writeback_interval,
1146 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001148 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 },
1150 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001152 .data = &dirty_expire_interval,
1153 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001155 .proc_handler = proc_dointvec_minmax,
1156 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 },
1158 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001159 .procname = "nr_pdflush_threads",
1160 .mode = 0444 /* read-only */,
1161 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 },
1163 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 .procname = "swappiness",
1165 .data = &vm_swappiness,
1166 .maxlen = sizeof(vm_swappiness),
1167 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001168 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .extra1 = &zero,
1170 .extra2 = &one_hundred,
1171 },
1172#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001173 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001175 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 .maxlen = sizeof(unsigned long),
1177 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001178 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .extra1 = (void *)&hugetlb_zero,
1180 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001181 },
1182#ifdef CONFIG_NUMA
1183 {
1184 .procname = "nr_hugepages_mempolicy",
1185 .data = NULL,
1186 .maxlen = sizeof(unsigned long),
1187 .mode = 0644,
1188 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1189 .extra1 = (void *)&hugetlb_zero,
1190 .extra2 = (void *)&hugetlb_infinity,
1191 },
1192#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 .procname = "hugetlb_shm_group",
1195 .data = &sysctl_hugetlb_shm_group,
1196 .maxlen = sizeof(gid_t),
1197 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001198 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 },
Mel Gorman396faf02007-07-17 04:03:13 -07001200 {
Mel Gorman396faf02007-07-17 04:03:13 -07001201 .procname = "hugepages_treat_as_movable",
1202 .data = &hugepages_treat_as_movable,
1203 .maxlen = sizeof(int),
1204 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001205 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001206 },
Adam Litke54f9f802007-10-16 01:26:20 -07001207 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001208 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001209 .data = NULL,
1210 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001211 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001212 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001213 .extra1 = (void *)&hugetlb_zero,
1214 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001215 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216#endif
1217 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 .procname = "lowmem_reserve_ratio",
1219 .data = &sysctl_lowmem_reserve_ratio,
1220 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1221 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001222 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223 },
1224 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001225 .procname = "drop_caches",
1226 .data = &sysctl_drop_caches,
1227 .maxlen = sizeof(int),
1228 .mode = 0644,
1229 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001230 .extra1 = &one,
1231 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001232 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001233#ifdef CONFIG_COMPACTION
1234 {
1235 .procname = "compact_memory",
1236 .data = &sysctl_compact_memory,
1237 .maxlen = sizeof(int),
1238 .mode = 0200,
1239 .proc_handler = sysctl_compaction_handler,
1240 },
Mel Gorman5e771902010-05-24 14:32:31 -07001241 {
1242 .procname = "extfrag_threshold",
1243 .data = &sysctl_extfrag_threshold,
1244 .maxlen = sizeof(int),
1245 .mode = 0644,
1246 .proc_handler = sysctl_extfrag_handler,
1247 .extra1 = &min_extfrag_threshold,
1248 .extra2 = &max_extfrag_threshold,
1249 },
1250
Mel Gorman76ab0f52010-05-24 14:32:28 -07001251#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 .procname = "min_free_kbytes",
1254 .data = &min_free_kbytes,
1255 .maxlen = sizeof(min_free_kbytes),
1256 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001257 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 .extra1 = &zero,
1259 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001260 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001261 .procname = "percpu_pagelist_fraction",
1262 .data = &percpu_pagelist_fraction,
1263 .maxlen = sizeof(percpu_pagelist_fraction),
1264 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001265 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001266 .extra1 = &min_percpu_pagelist_fract,
1267 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268#ifdef CONFIG_MMU
1269 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 .procname = "max_map_count",
1271 .data = &sysctl_max_map_count,
1272 .maxlen = sizeof(sysctl_max_map_count),
1273 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001274 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001275 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001277#else
1278 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001279 .procname = "nr_trim_pages",
1280 .data = &sysctl_nr_trim_pages,
1281 .maxlen = sizeof(sysctl_nr_trim_pages),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001284 .extra1 = &zero,
1285 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286#endif
1287 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288 .procname = "laptop_mode",
1289 .data = &laptop_mode,
1290 .maxlen = sizeof(laptop_mode),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 },
1294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .procname = "block_dump",
1296 .data = &block_dump,
1297 .maxlen = sizeof(block_dump),
1298 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001299 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .extra1 = &zero,
1301 },
1302 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 .procname = "vfs_cache_pressure",
1304 .data = &sysctl_vfs_cache_pressure,
1305 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1306 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 .extra1 = &zero,
1309 },
1310#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .procname = "legacy_va_layout",
1313 .data = &sysctl_legacy_va_layout,
1314 .maxlen = sizeof(sysctl_legacy_va_layout),
1315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001316 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .extra1 = &zero,
1318 },
1319#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001320#ifdef CONFIG_NUMA
1321 {
Christoph Lameter17436602006-01-18 17:42:32 -08001322 .procname = "zone_reclaim_mode",
1323 .data = &zone_reclaim_mode,
1324 .maxlen = sizeof(zone_reclaim_mode),
1325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001326 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001327 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001328 },
Christoph Lameter96146342006-07-03 00:24:13 -07001329 {
Christoph Lameter96146342006-07-03 00:24:13 -07001330 .procname = "min_unmapped_ratio",
1331 .data = &sysctl_min_unmapped_ratio,
1332 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001335 .extra1 = &zero,
1336 .extra2 = &one_hundred,
1337 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001338 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001339 .procname = "min_slab_ratio",
1340 .data = &sysctl_min_slab_ratio,
1341 .maxlen = sizeof(sysctl_min_slab_ratio),
1342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001344 .extra1 = &zero,
1345 .extra2 = &one_hundred,
1346 },
Christoph Lameter17436602006-01-18 17:42:32 -08001347#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001348#ifdef CONFIG_SMP
1349 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001350 .procname = "stat_interval",
1351 .data = &sysctl_stat_interval,
1352 .maxlen = sizeof(sysctl_stat_interval),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001355 },
1356#endif
David Howells6e141542009-12-15 19:27:45 +00001357#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001358 {
Eric Parised032182007-06-28 15:55:21 -04001359 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001360 .data = &dac_mmap_min_addr,
1361 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001362 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001363 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001364 },
David Howells6e141542009-12-15 19:27:45 +00001365#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001366#ifdef CONFIG_NUMA
1367 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001368 .procname = "numa_zonelist_order",
1369 .data = &numa_zonelist_order,
1370 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1371 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001372 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001373 },
1374#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001375#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001376 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001377 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001378 .procname = "vdso_enabled",
1379 .data = &vdso_enabled,
1380 .maxlen = sizeof(vdso_enabled),
1381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001382 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001383 .extra1 = &zero,
1384 },
1385#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001386#ifdef CONFIG_HIGHMEM
1387 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001388 .procname = "highmem_is_dirtyable",
1389 .data = &vm_highmem_is_dirtyable,
1390 .maxlen = sizeof(vm_highmem_is_dirtyable),
1391 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001392 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001393 .extra1 = &zero,
1394 .extra2 = &one,
1395 },
1396#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001397 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001398 .procname = "scan_unevictable_pages",
1399 .data = &scan_unevictable_pages,
1400 .maxlen = sizeof(scan_unevictable_pages),
1401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001402 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001403 },
Andi Kleen6a460792009-09-16 11:50:15 +02001404#ifdef CONFIG_MEMORY_FAILURE
1405 {
Andi Kleen6a460792009-09-16 11:50:15 +02001406 .procname = "memory_failure_early_kill",
1407 .data = &sysctl_memory_failure_early_kill,
1408 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001410 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001411 .extra1 = &zero,
1412 .extra2 = &one,
1413 },
1414 {
Andi Kleen6a460792009-09-16 11:50:15 +02001415 .procname = "memory_failure_recovery",
1416 .data = &sysctl_memory_failure_recovery,
1417 .maxlen = sizeof(sysctl_memory_failure_recovery),
1418 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001419 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001420 .extra1 = &zero,
1421 .extra2 = &one,
1422 },
1423#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001424 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425};
1426
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001427#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001428static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001429 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001430};
1431#endif
1432
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001433static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 .procname = "inode-nr",
1436 .data = &inodes_stat,
1437 .maxlen = 2*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 = "inode-state",
1443 .data = &inodes_stat,
1444 .maxlen = 7*sizeof(int),
1445 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001446 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 },
1448 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 .procname = "file-nr",
1450 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001451 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001453 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 },
1455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .procname = "file-max",
1457 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001458 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001460 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 },
1462 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001463 .procname = "nr_open",
1464 .data = &sysctl_nr_open,
1465 .maxlen = sizeof(int),
1466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001467 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001468 .extra1 = &sysctl_nr_open_min,
1469 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001470 },
1471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 .procname = "dentry-state",
1473 .data = &dentry_stat,
1474 .maxlen = 6*sizeof(int),
1475 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001476 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 },
1478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 .procname = "overflowuid",
1480 .data = &fs_overflowuid,
1481 .maxlen = sizeof(int),
1482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001483 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .extra1 = &minolduid,
1485 .extra2 = &maxolduid,
1486 },
1487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "overflowgid",
1489 .data = &fs_overflowgid,
1490 .maxlen = sizeof(int),
1491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001492 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 .extra1 = &minolduid,
1494 .extra2 = &maxolduid,
1495 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001496#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .procname = "leases-enable",
1499 .data = &leases_enable,
1500 .maxlen = sizeof(int),
1501 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001502 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001504#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505#ifdef CONFIG_DNOTIFY
1506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .procname = "dir-notify-enable",
1508 .data = &dir_notify_enable,
1509 .maxlen = sizeof(int),
1510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001511 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 },
1513#endif
1514#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001515#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .procname = "lease-break-time",
1518 .data = &lease_break_time,
1519 .maxlen = sizeof(int),
1520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001521 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001523#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001524#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 .procname = "aio-nr",
1527 .data = &aio_nr,
1528 .maxlen = sizeof(aio_nr),
1529 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001530 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531 },
1532 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 .procname = "aio-max-nr",
1534 .data = &aio_max_nr,
1535 .maxlen = sizeof(aio_max_nr),
1536 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001537 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001539#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001540#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001541 {
Robert Love0399cb02005-07-13 12:38:18 -04001542 .procname = "inotify",
1543 .mode = 0555,
1544 .child = inotify_table,
1545 },
1546#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001547#ifdef CONFIG_EPOLL
1548 {
1549 .procname = "epoll",
1550 .mode = 0555,
1551 .child = epoll_table,
1552 },
1553#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001555 {
Kees Cook800179c2012-07-25 17:29:07 -07001556 .procname = "protected_symlinks",
1557 .data = &sysctl_protected_symlinks,
1558 .maxlen = sizeof(int),
1559 .mode = 0600,
1560 .proc_handler = proc_dointvec_minmax,
1561 .extra1 = &zero,
1562 .extra2 = &one,
1563 },
1564 {
1565 .procname = "protected_hardlinks",
1566 .data = &sysctl_protected_hardlinks,
1567 .maxlen = sizeof(int),
1568 .mode = 0600,
1569 .proc_handler = proc_dointvec_minmax,
1570 .extra1 = &zero,
1571 .extra2 = &one,
1572 },
1573 {
Alan Coxd6e71142005-06-23 00:09:43 -07001574 .procname = "suid_dumpable",
1575 .data = &suid_dumpable,
1576 .maxlen = sizeof(int),
1577 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001578 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001579 .extra1 = &zero,
1580 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001581 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001582#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1583 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001584 .procname = "binfmt_misc",
1585 .mode = 0555,
1586 .child = binfmt_misc_table,
1587 },
1588#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001589 {
Jens Axboeff9da692010-06-03 14:54:39 +02001590 .procname = "pipe-max-size",
1591 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001592 .maxlen = sizeof(int),
1593 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001594 .proc_handler = &pipe_proc_fn,
1595 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001596 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001597 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598};
1599
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001600static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001601#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001602 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001603 .procname = "exception-trace",
1604 .data = &show_unhandled_signals,
1605 .maxlen = sizeof(int),
1606 .mode = 0644,
1607 .proc_handler = proc_dointvec
1608 },
1609#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001610#if defined(CONFIG_OPTPROBES)
1611 {
1612 .procname = "kprobes-optimization",
1613 .data = &sysctl_kprobes_optimization,
1614 .maxlen = sizeof(int),
1615 .mode = 0644,
1616 .proc_handler = proc_kprobes_optimization_handler,
1617 .extra1 = &zero,
1618 .extra2 = &one,
1619 },
1620#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001621 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622};
1623
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001624static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001625 { }
Robert Love0eeca282005-07-12 17:06:03 -04001626};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001628int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001629{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001630 struct ctl_table_header *hdr;
1631
1632 hdr = register_sysctl_table(sysctl_base_table);
1633 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001634 return 0;
1635}
1636
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001637#endif /* CONFIG_SYSCTL */
1638
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639/*
1640 * /proc/sys support
1641 */
1642
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001643#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001645static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001646 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001647 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001648{
1649 size_t len;
1650 char __user *p;
1651 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001652
1653 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001654 *lenp = 0;
1655 return 0;
1656 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001657
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001658 if (write) {
1659 len = 0;
1660 p = buffer;
1661 while (len < *lenp) {
1662 if (get_user(c, p++))
1663 return -EFAULT;
1664 if (c == 0 || c == '\n')
1665 break;
1666 len++;
1667 }
1668 if (len >= maxlen)
1669 len = maxlen-1;
1670 if(copy_from_user(data, buffer, len))
1671 return -EFAULT;
1672 ((char *) data)[len] = 0;
1673 *ppos += *lenp;
1674 } else {
1675 len = strlen(data);
1676 if (len > maxlen)
1677 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001678
1679 if (*ppos > len) {
1680 *lenp = 0;
1681 return 0;
1682 }
1683
1684 data += *ppos;
1685 len -= *ppos;
1686
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001687 if (len > *lenp)
1688 len = *lenp;
1689 if (len)
1690 if(copy_to_user(buffer, data, len))
1691 return -EFAULT;
1692 if (len < *lenp) {
1693 if(put_user('\n', ((char __user *) buffer) + len))
1694 return -EFAULT;
1695 len++;
1696 }
1697 *lenp = len;
1698 *ppos += len;
1699 }
1700 return 0;
1701}
1702
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703/**
1704 * proc_dostring - read a string sysctl
1705 * @table: the sysctl table
1706 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707 * @buffer: the user buffer
1708 * @lenp: the size of the user buffer
1709 * @ppos: file position
1710 *
1711 * Reads/writes a string from/to the user buffer. If the kernel
1712 * buffer provided is not large enough to hold the string, the
1713 * string is truncated. The copied string is %NULL-terminated.
1714 * If the string is being read by the user process, it is copied
1715 * and a newline '\n' is added. It is truncated if the buffer is
1716 * not large enough.
1717 *
1718 * Returns 0 on success.
1719 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001720int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 void __user *buffer, size_t *lenp, loff_t *ppos)
1722{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001723 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001724 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725}
1726
Amerigo Wang00b7c332010-05-05 00:26:45 +00001727static size_t proc_skip_spaces(char **buf)
1728{
1729 size_t ret;
1730 char *tmp = skip_spaces(*buf);
1731 ret = tmp - *buf;
1732 *buf = tmp;
1733 return ret;
1734}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001736static void proc_skip_char(char **buf, size_t *size, const char v)
1737{
1738 while (*size) {
1739 if (**buf != v)
1740 break;
1741 (*size)--;
1742 (*buf)++;
1743 }
1744}
1745
Amerigo Wang00b7c332010-05-05 00:26:45 +00001746#define TMPBUFLEN 22
1747/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001748 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001749 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001750 * @buf: a kernel buffer
1751 * @size: size of the kernel buffer
1752 * @val: this is where the number will be stored
1753 * @neg: set to %TRUE if number is negative
1754 * @perm_tr: a vector which contains the allowed trailers
1755 * @perm_tr_len: size of the perm_tr vector
1756 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001757 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001758 * In case of success %0 is returned and @buf and @size are updated with
1759 * the amount of bytes read. If @tr is non-NULL and a trailing
1760 * character exists (size is non-zero after returning from this
1761 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001762 */
1763static int proc_get_long(char **buf, size_t *size,
1764 unsigned long *val, bool *neg,
1765 const char *perm_tr, unsigned perm_tr_len, char *tr)
1766{
1767 int len;
1768 char *p, tmp[TMPBUFLEN];
1769
1770 if (!*size)
1771 return -EINVAL;
1772
1773 len = *size;
1774 if (len > TMPBUFLEN - 1)
1775 len = TMPBUFLEN - 1;
1776
1777 memcpy(tmp, *buf, len);
1778
1779 tmp[len] = 0;
1780 p = tmp;
1781 if (*p == '-' && *size > 1) {
1782 *neg = true;
1783 p++;
1784 } else
1785 *neg = false;
1786 if (!isdigit(*p))
1787 return -EINVAL;
1788
1789 *val = simple_strtoul(p, &p, 0);
1790
1791 len = p - tmp;
1792
1793 /* We don't know if the next char is whitespace thus we may accept
1794 * invalid integers (e.g. 1234...a) or two integers instead of one
1795 * (e.g. 123...1). So lets not allow such large numbers. */
1796 if (len == TMPBUFLEN - 1)
1797 return -EINVAL;
1798
1799 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1800 return -EINVAL;
1801
1802 if (tr && (len < *size))
1803 *tr = *p;
1804
1805 *buf += len;
1806 *size -= len;
1807
1808 return 0;
1809}
1810
1811/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001812 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001813 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001814 * @buf: the user buffer
1815 * @size: the size of the user buffer
1816 * @val: the integer to be converted
1817 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001818 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001819 * In case of success %0 is returned and @buf and @size are updated with
1820 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001821 */
1822static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1823 bool neg)
1824{
1825 int len;
1826 char tmp[TMPBUFLEN], *p = tmp;
1827
1828 sprintf(p, "%s%lu", neg ? "-" : "", val);
1829 len = strlen(tmp);
1830 if (len > *size)
1831 len = *size;
1832 if (copy_to_user(*buf, tmp, len))
1833 return -EFAULT;
1834 *size -= len;
1835 *buf += len;
1836 return 0;
1837}
1838#undef TMPBUFLEN
1839
1840static int proc_put_char(void __user **buf, size_t *size, char c)
1841{
1842 if (*size) {
1843 char __user **buffer = (char __user **)buf;
1844 if (put_user(c, *buffer))
1845 return -EFAULT;
1846 (*size)--, (*buffer)++;
1847 *buf = *buffer;
1848 }
1849 return 0;
1850}
1851
1852static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 int *valp,
1854 int write, void *data)
1855{
1856 if (write) {
1857 *valp = *negp ? -*lvalp : *lvalp;
1858 } else {
1859 int val = *valp;
1860 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 *lvalp = (unsigned long)-val;
1863 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001864 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865 *lvalp = (unsigned long)val;
1866 }
1867 }
1868 return 0;
1869}
1870
Amerigo Wang00b7c332010-05-05 00:26:45 +00001871static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1872
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001873static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001874 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001875 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001876 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 int write, void *data),
1878 void *data)
1879{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001880 int *i, vleft, first = 1, err = 0;
1881 unsigned long page = 0;
1882 size_t left;
1883 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884
Amerigo Wang00b7c332010-05-05 00:26:45 +00001885 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 *lenp = 0;
1887 return 0;
1888 }
1889
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001890 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891 vleft = table->maxlen / sizeof(*i);
1892 left = *lenp;
1893
1894 if (!conv)
1895 conv = do_proc_dointvec_conv;
1896
Linus Torvalds1da177e2005-04-16 15:20:36 -07001897 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001898 if (left > PAGE_SIZE - 1)
1899 left = PAGE_SIZE - 1;
1900 page = __get_free_page(GFP_TEMPORARY);
1901 kbuf = (char *) page;
1902 if (!kbuf)
1903 return -ENOMEM;
1904 if (copy_from_user(kbuf, buffer, left)) {
1905 err = -EFAULT;
1906 goto free;
1907 }
1908 kbuf[left] = 0;
1909 }
1910
1911 for (; left && vleft--; i++, first=0) {
1912 unsigned long lval;
1913 bool neg;
1914
1915 if (write) {
1916 left -= proc_skip_spaces(&kbuf);
1917
J. R. Okajima563b0462010-05-25 16:10:14 -07001918 if (!left)
1919 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001920 err = proc_get_long(&kbuf, &left, &lval, &neg,
1921 proc_wspace_sep,
1922 sizeof(proc_wspace_sep), NULL);
1923 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001925 if (conv(&neg, &lval, i, 1, data)) {
1926 err = -EINVAL;
1927 break;
1928 }
1929 } else {
1930 if (conv(&neg, &lval, i, 0, data)) {
1931 err = -EINVAL;
1932 break;
1933 }
1934 if (!first)
1935 err = proc_put_char(&buffer, &left, '\t');
1936 if (err)
1937 break;
1938 err = proc_put_long(&buffer, &left, lval, neg);
1939 if (err)
1940 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941 }
1942 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001943
1944 if (!write && !first && left && !err)
1945 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001946 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001947 left -= proc_skip_spaces(&kbuf);
1948free:
1949 if (write) {
1950 free_page(page);
1951 if (first)
1952 return err ? : -EINVAL;
1953 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954 *lenp -= left;
1955 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001956 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957}
1958
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001959static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001960 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001961 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001962 int write, void *data),
1963 void *data)
1964{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001965 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001966 buffer, lenp, ppos, conv, data);
1967}
1968
Linus Torvalds1da177e2005-04-16 15:20:36 -07001969/**
1970 * proc_dointvec - read a vector of integers
1971 * @table: the sysctl table
1972 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973 * @buffer: the user buffer
1974 * @lenp: the size of the user buffer
1975 * @ppos: file position
1976 *
1977 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1978 * values from/to the user buffer, treated as an ASCII string.
1979 *
1980 * Returns 0 on success.
1981 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001982int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001983 void __user *buffer, size_t *lenp, loff_t *ppos)
1984{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001985 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 NULL,NULL);
1987}
1988
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001989/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001990 * Taint values can only be increased
1991 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001992 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001993static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001994 void __user *buffer, size_t *lenp, loff_t *ppos)
1995{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001996 struct ctl_table t;
1997 unsigned long tmptaint = get_taint();
1998 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001999
Bastian Blank91fcd412007-04-23 14:41:14 -07002000 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002001 return -EPERM;
2002
Andi Kleen25ddbb12008-10-15 22:01:41 -07002003 t = *table;
2004 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002005 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002006 if (err < 0)
2007 return err;
2008
2009 if (write) {
2010 /*
2011 * Poor man's atomic or. Not worth adding a primitive
2012 * to everyone's atomic.h for this
2013 */
2014 int i;
2015 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2016 if ((tmptaint >> i) & 1)
2017 add_taint(i);
2018 }
2019 }
2020
2021 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002022}
2023
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002024#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002025static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002026 void __user *buffer, size_t *lenp, loff_t *ppos)
2027{
2028 if (write && !capable(CAP_SYS_ADMIN))
2029 return -EPERM;
2030
2031 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2032}
2033#endif
2034
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035struct do_proc_dointvec_minmax_conv_param {
2036 int *min;
2037 int *max;
2038};
2039
Amerigo Wang00b7c332010-05-05 00:26:45 +00002040static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2041 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042 int write, void *data)
2043{
2044 struct do_proc_dointvec_minmax_conv_param *param = data;
2045 if (write) {
2046 int val = *negp ? -*lvalp : *lvalp;
2047 if ((param->min && *param->min > val) ||
2048 (param->max && *param->max < val))
2049 return -EINVAL;
2050 *valp = val;
2051 } else {
2052 int val = *valp;
2053 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002054 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055 *lvalp = (unsigned long)-val;
2056 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002057 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058 *lvalp = (unsigned long)val;
2059 }
2060 }
2061 return 0;
2062}
2063
2064/**
2065 * proc_dointvec_minmax - read a vector of integers with min/max values
2066 * @table: the sysctl table
2067 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002068 * @buffer: the user buffer
2069 * @lenp: the size of the user buffer
2070 * @ppos: file position
2071 *
2072 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2073 * values from/to the user buffer, treated as an ASCII string.
2074 *
2075 * This routine will ensure the values are within the range specified by
2076 * table->extra1 (min) and table->extra2 (max).
2077 *
2078 * Returns 0 on success.
2079 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002080int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081 void __user *buffer, size_t *lenp, loff_t *ppos)
2082{
2083 struct do_proc_dointvec_minmax_conv_param param = {
2084 .min = (int *) table->extra1,
2085 .max = (int *) table->extra2,
2086 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002087 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088 do_proc_dointvec_minmax_conv, &param);
2089}
2090
Kees Cook54b50192012-07-30 14:39:18 -07002091static void validate_coredump_safety(void)
2092{
Alex Kelly046d6622012-10-04 17:15:23 -07002093#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002094 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2095 core_pattern[0] != '/' && core_pattern[0] != '|') {
2096 printk(KERN_WARNING "Unsafe core_pattern used with "\
2097 "suid_dumpable=2. Pipe handler or fully qualified "\
2098 "core dump path required.\n");
2099 }
Alex Kelly046d6622012-10-04 17:15:23 -07002100#endif
Kees Cook54b50192012-07-30 14:39:18 -07002101}
2102
2103static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2104 void __user *buffer, size_t *lenp, loff_t *ppos)
2105{
2106 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2107 if (!error)
2108 validate_coredump_safety();
2109 return error;
2110}
2111
Alex Kelly046d6622012-10-04 17:15:23 -07002112#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002113static int proc_dostring_coredump(struct ctl_table *table, int write,
2114 void __user *buffer, size_t *lenp, loff_t *ppos)
2115{
2116 int error = proc_dostring(table, write, buffer, lenp, ppos);
2117 if (!error)
2118 validate_coredump_safety();
2119 return error;
2120}
Alex Kelly046d6622012-10-04 17:15:23 -07002121#endif
Kees Cook54b50192012-07-30 14:39:18 -07002122
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002123static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124 void __user *buffer,
2125 size_t *lenp, loff_t *ppos,
2126 unsigned long convmul,
2127 unsigned long convdiv)
2128{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002129 unsigned long *i, *min, *max;
2130 int vleft, first = 1, err = 0;
2131 unsigned long page = 0;
2132 size_t left;
2133 char *kbuf;
2134
2135 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 *lenp = 0;
2137 return 0;
2138 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002139
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002140 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141 min = (unsigned long *) table->extra1;
2142 max = (unsigned long *) table->extra2;
2143 vleft = table->maxlen / sizeof(unsigned long);
2144 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002145
2146 if (write) {
2147 if (left > PAGE_SIZE - 1)
2148 left = PAGE_SIZE - 1;
2149 page = __get_free_page(GFP_TEMPORARY);
2150 kbuf = (char *) page;
2151 if (!kbuf)
2152 return -ENOMEM;
2153 if (copy_from_user(kbuf, buffer, left)) {
2154 err = -EFAULT;
2155 goto free;
2156 }
2157 kbuf[left] = 0;
2158 }
2159
Eric Dumazet27b3d802010-10-07 12:59:29 -07002160 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002161 unsigned long val;
2162
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002164 bool neg;
2165
2166 left -= proc_skip_spaces(&kbuf);
2167
2168 err = proc_get_long(&kbuf, &left, &val, &neg,
2169 proc_wspace_sep,
2170 sizeof(proc_wspace_sep), NULL);
2171 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 break;
2173 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 continue;
2175 if ((min && val < *min) || (max && val > *max))
2176 continue;
2177 *i = val;
2178 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002179 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002181 err = proc_put_char(&buffer, &left, '\t');
2182 err = proc_put_long(&buffer, &left, val, false);
2183 if (err)
2184 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 }
2186 }
2187
Amerigo Wang00b7c332010-05-05 00:26:45 +00002188 if (!write && !first && left && !err)
2189 err = proc_put_char(&buffer, &left, '\n');
2190 if (write && !err)
2191 left -= proc_skip_spaces(&kbuf);
2192free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194 free_page(page);
2195 if (first)
2196 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 *lenp -= left;
2199 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002200 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201}
2202
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002203static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002204 void __user *buffer,
2205 size_t *lenp, loff_t *ppos,
2206 unsigned long convmul,
2207 unsigned long convdiv)
2208{
2209 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002210 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002211}
2212
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213/**
2214 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2215 * @table: the sysctl table
2216 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217 * @buffer: the user buffer
2218 * @lenp: the size of the user buffer
2219 * @ppos: file position
2220 *
2221 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2222 * values from/to the user buffer, treated as an ASCII string.
2223 *
2224 * This routine will ensure the values are within the range specified by
2225 * table->extra1 (min) and table->extra2 (max).
2226 *
2227 * Returns 0 on success.
2228 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002229int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 void __user *buffer, size_t *lenp, loff_t *ppos)
2231{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002232 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233}
2234
2235/**
2236 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2237 * @table: the sysctl table
2238 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 * @buffer: the user buffer
2240 * @lenp: the size of the user buffer
2241 * @ppos: file position
2242 *
2243 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2244 * values from/to the user buffer, treated as an ASCII string. The values
2245 * are treated as milliseconds, and converted to jiffies when they are stored.
2246 *
2247 * This routine will ensure the values are within the range specified by
2248 * table->extra1 (min) and table->extra2 (max).
2249 *
2250 * Returns 0 on success.
2251 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002252int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 void __user *buffer,
2254 size_t *lenp, loff_t *ppos)
2255{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002256 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 lenp, ppos, HZ, 1000l);
2258}
2259
2260
Amerigo Wang00b7c332010-05-05 00:26:45 +00002261static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 int *valp,
2263 int write, void *data)
2264{
2265 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002266 if (*lvalp > LONG_MAX / HZ)
2267 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2269 } else {
2270 int val = *valp;
2271 unsigned long lval;
2272 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002273 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 lval = (unsigned long)-val;
2275 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 lval = (unsigned long)val;
2278 }
2279 *lvalp = lval / HZ;
2280 }
2281 return 0;
2282}
2283
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 int *valp,
2286 int write, void *data)
2287{
2288 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002289 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2290 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2292 } else {
2293 int val = *valp;
2294 unsigned long lval;
2295 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002296 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297 lval = (unsigned long)-val;
2298 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002299 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 lval = (unsigned long)val;
2301 }
2302 *lvalp = jiffies_to_clock_t(lval);
2303 }
2304 return 0;
2305}
2306
Amerigo Wang00b7c332010-05-05 00:26:45 +00002307static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002308 int *valp,
2309 int write, void *data)
2310{
2311 if (write) {
2312 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2313 } else {
2314 int val = *valp;
2315 unsigned long lval;
2316 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002317 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 lval = (unsigned long)-val;
2319 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002320 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 lval = (unsigned long)val;
2322 }
2323 *lvalp = jiffies_to_msecs(lval);
2324 }
2325 return 0;
2326}
2327
2328/**
2329 * proc_dointvec_jiffies - read a vector of integers as seconds
2330 * @table: the sysctl table
2331 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 * @buffer: the user buffer
2333 * @lenp: the size of the user buffer
2334 * @ppos: file position
2335 *
2336 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2337 * values from/to the user buffer, treated as an ASCII string.
2338 * The values read are assumed to be in seconds, and are converted into
2339 * jiffies.
2340 *
2341 * Returns 0 on success.
2342 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002343int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 void __user *buffer, size_t *lenp, loff_t *ppos)
2345{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002346 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 do_proc_dointvec_jiffies_conv,NULL);
2348}
2349
2350/**
2351 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2352 * @table: the sysctl table
2353 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 * @buffer: the user buffer
2355 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002356 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 *
2358 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2359 * values from/to the user buffer, treated as an ASCII string.
2360 * The values read are assumed to be in 1/USER_HZ seconds, and
2361 * are converted into jiffies.
2362 *
2363 * Returns 0 on success.
2364 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002365int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 void __user *buffer, size_t *lenp, loff_t *ppos)
2367{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002368 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 do_proc_dointvec_userhz_jiffies_conv,NULL);
2370}
2371
2372/**
2373 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2374 * @table: the sysctl table
2375 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 * @buffer: the user buffer
2377 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002378 * @ppos: file position
2379 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 *
2381 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2382 * values from/to the user buffer, treated as an ASCII string.
2383 * The values read are assumed to be in 1/1000 seconds, and
2384 * are converted into jiffies.
2385 *
2386 * Returns 0 on success.
2387 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002388int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 void __user *buffer, size_t *lenp, loff_t *ppos)
2390{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002391 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392 do_proc_dointvec_ms_jiffies_conv, NULL);
2393}
2394
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002395static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002396 void __user *buffer, size_t *lenp, loff_t *ppos)
2397{
2398 struct pid *new_pid;
2399 pid_t tmp;
2400 int r;
2401
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002402 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002403
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002404 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002405 lenp, ppos, NULL, NULL);
2406 if (r || !write)
2407 return r;
2408
2409 new_pid = find_get_pid(tmp);
2410 if (!new_pid)
2411 return -ESRCH;
2412
2413 put_pid(xchg(&cad_pid, new_pid));
2414 return 0;
2415}
2416
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002417/**
2418 * proc_do_large_bitmap - read/write from/to a large bitmap
2419 * @table: the sysctl table
2420 * @write: %TRUE if this is a write to the sysctl file
2421 * @buffer: the user buffer
2422 * @lenp: the size of the user buffer
2423 * @ppos: file position
2424 *
2425 * The bitmap is stored at table->data and the bitmap length (in bits)
2426 * in table->maxlen.
2427 *
2428 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2429 * large bitmaps may be represented in a compact manner. Writing into
2430 * the file will clear the bitmap then update it with the given input.
2431 *
2432 * Returns 0 on success.
2433 */
2434int proc_do_large_bitmap(struct ctl_table *table, int write,
2435 void __user *buffer, size_t *lenp, loff_t *ppos)
2436{
2437 int err = 0;
2438 bool first = 1;
2439 size_t left = *lenp;
2440 unsigned long bitmap_len = table->maxlen;
2441 unsigned long *bitmap = (unsigned long *) table->data;
2442 unsigned long *tmp_bitmap = NULL;
2443 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2444
2445 if (!bitmap_len || !left || (*ppos && !write)) {
2446 *lenp = 0;
2447 return 0;
2448 }
2449
2450 if (write) {
2451 unsigned long page = 0;
2452 char *kbuf;
2453
2454 if (left > PAGE_SIZE - 1)
2455 left = PAGE_SIZE - 1;
2456
2457 page = __get_free_page(GFP_TEMPORARY);
2458 kbuf = (char *) page;
2459 if (!kbuf)
2460 return -ENOMEM;
2461 if (copy_from_user(kbuf, buffer, left)) {
2462 free_page(page);
2463 return -EFAULT;
2464 }
2465 kbuf[left] = 0;
2466
2467 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2468 GFP_KERNEL);
2469 if (!tmp_bitmap) {
2470 free_page(page);
2471 return -ENOMEM;
2472 }
2473 proc_skip_char(&kbuf, &left, '\n');
2474 while (!err && left) {
2475 unsigned long val_a, val_b;
2476 bool neg;
2477
2478 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2479 sizeof(tr_a), &c);
2480 if (err)
2481 break;
2482 if (val_a >= bitmap_len || neg) {
2483 err = -EINVAL;
2484 break;
2485 }
2486
2487 val_b = val_a;
2488 if (left) {
2489 kbuf++;
2490 left--;
2491 }
2492
2493 if (c == '-') {
2494 err = proc_get_long(&kbuf, &left, &val_b,
2495 &neg, tr_b, sizeof(tr_b),
2496 &c);
2497 if (err)
2498 break;
2499 if (val_b >= bitmap_len || neg ||
2500 val_a > val_b) {
2501 err = -EINVAL;
2502 break;
2503 }
2504 if (left) {
2505 kbuf++;
2506 left--;
2507 }
2508 }
2509
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002510 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002511 first = 0;
2512 proc_skip_char(&kbuf, &left, '\n');
2513 }
2514 free_page(page);
2515 } else {
2516 unsigned long bit_a, bit_b = 0;
2517
2518 while (left) {
2519 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2520 if (bit_a >= bitmap_len)
2521 break;
2522 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2523 bit_a + 1) - 1;
2524
2525 if (!first) {
2526 err = proc_put_char(&buffer, &left, ',');
2527 if (err)
2528 break;
2529 }
2530 err = proc_put_long(&buffer, &left, bit_a, false);
2531 if (err)
2532 break;
2533 if (bit_a != bit_b) {
2534 err = proc_put_char(&buffer, &left, '-');
2535 if (err)
2536 break;
2537 err = proc_put_long(&buffer, &left, bit_b, false);
2538 if (err)
2539 break;
2540 }
2541
2542 first = 0; bit_b++;
2543 }
2544 if (!err)
2545 err = proc_put_char(&buffer, &left, '\n');
2546 }
2547
2548 if (!err) {
2549 if (write) {
2550 if (*ppos)
2551 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2552 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002553 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002554 }
2555 kfree(tmp_bitmap);
2556 *lenp -= left;
2557 *ppos += *lenp;
2558 return 0;
2559 } else {
2560 kfree(tmp_bitmap);
2561 return err;
2562 }
2563}
2564
Jovi Zhang55610502011-01-12 17:00:45 -08002565#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002567int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 void __user *buffer, size_t *lenp, loff_t *ppos)
2569{
2570 return -ENOSYS;
2571}
2572
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002573int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 void __user *buffer, size_t *lenp, loff_t *ppos)
2575{
2576 return -ENOSYS;
2577}
2578
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002579int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580 void __user *buffer, size_t *lenp, loff_t *ppos)
2581{
2582 return -ENOSYS;
2583}
2584
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002585int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 void __user *buffer, size_t *lenp, loff_t *ppos)
2587{
2588 return -ENOSYS;
2589}
2590
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002591int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592 void __user *buffer, size_t *lenp, loff_t *ppos)
2593{
2594 return -ENOSYS;
2595}
2596
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002597int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 void __user *buffer, size_t *lenp, loff_t *ppos)
2599{
2600 return -ENOSYS;
2601}
2602
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002603int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604 void __user *buffer, size_t *lenp, loff_t *ppos)
2605{
2606 return -ENOSYS;
2607}
2608
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002609int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610 void __user *buffer,
2611 size_t *lenp, loff_t *ppos)
2612{
2613 return -ENOSYS;
2614}
2615
2616
Jovi Zhang55610502011-01-12 17:00:45 -08002617#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619/*
2620 * No sense putting this after each symbol definition, twice,
2621 * exception granted :-)
2622 */
2623EXPORT_SYMBOL(proc_dointvec);
2624EXPORT_SYMBOL(proc_dointvec_jiffies);
2625EXPORT_SYMBOL(proc_dointvec_minmax);
2626EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2627EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2628EXPORT_SYMBOL(proc_dostring);
2629EXPORT_SYMBOL(proc_doulongvec_minmax);
2630EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);