blob: d1b4ee67d2df696475479a9bb595b8008a580dd3 [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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800109extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200111extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100112extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400113extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000114#ifndef CONFIG_MMU
115extern int sysctl_nr_trim_pages;
116#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200117#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200118extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400122#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200124static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125#endif
126
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700127static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700128static int __maybe_unused one = 1;
129static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700130static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800131static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800143static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Dave Youngd14f1722010-02-25 20:28:57 -0500148#ifdef CONFIG_INOTIFY_USER
149#include <linux/inotify.h>
150#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700151#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif
153
David S. Miller08714202008-11-16 23:49:24 -0800154#ifdef CONFIG_SPARC64
155extern int sysctl_tsb_ratio;
156#endif
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#ifdef __hppa__
159extern int pwrsw_enabled;
160extern int unaligned_enabled;
161#endif
162
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800164extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800165#endif
166
Vineet Guptab6fca722013-01-09 20:06:28 +0530167#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
168extern int no_unaligned_warning;
169#endif
170
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700171#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700172static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700173 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700174static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800175 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700176#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700177
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700178#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700179static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700180 void __user *buffer, size_t *lenp, loff_t *ppos);
181#endif
182
Kees Cook54b50192012-07-30 14:39:18 -0700183static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
184 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700185#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700186static int proc_dostring_coredump(struct ctl_table *table, int write,
187 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700188#endif
Kees Cook54b50192012-07-30 14:39:18 -0700189
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700190#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800191/* Note: sysrq code uses it's own private copy */
192static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700193
194static int sysrq_sysctl_handler(ctl_table *table, int write,
195 void __user *buffer, size_t *lenp,
196 loff_t *ppos)
197{
198 int error;
199
200 error = proc_dointvec(table, write, buffer, lenp, ppos);
201 if (error)
202 return error;
203
204 if (write)
205 sysrq_toggle_support(__sysrq_enabled);
206
207 return 0;
208}
209
210#endif
211
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700212static struct ctl_table kern_table[];
213static struct ctl_table vm_table[];
214static struct ctl_table fs_table[];
215static struct ctl_table debug_table[];
216static struct ctl_table dev_table[];
217extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800218#ifdef CONFIG_EPOLL
219extern struct ctl_table epoll_table[];
220#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
223int sysctl_legacy_va_layout;
224#endif
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226/* The default sysctl tables: */
227
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800228static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 .procname = "kernel",
231 .mode = 0555,
232 .child = kern_table,
233 },
234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .procname = "vm",
236 .mode = 0555,
237 .child = vm_table,
238 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "fs",
241 .mode = 0555,
242 .child = fs_table,
243 },
244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "debug",
246 .mode = 0555,
247 .child = debug_table,
248 },
249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "dev",
251 .mode = 0555,
252 .child = dev_table,
253 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700254 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255};
256
Ingo Molnar77e54a12007-07-09 18:52:00 +0200257#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100258static int min_sched_granularity_ns = 100000; /* 100 usecs */
259static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
260static int min_wakeup_granularity_ns; /* 0 usecs */
261static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200262#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100263static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
264static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200265#endif /* CONFIG_SMP */
266#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267
Mel Gorman5e771902010-05-24 14:32:31 -0700268#ifdef CONFIG_COMPACTION
269static int min_extfrag_threshold;
270static int max_extfrag_threshold = 1000;
271#endif
272
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700273static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200274 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200275 .procname = "sched_child_runs_first",
276 .data = &sysctl_sched_child_runs_first,
277 .maxlen = sizeof(unsigned int),
278 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800279 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200280 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281#ifdef CONFIG_SCHED_DEBUG
282 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100283 .procname = "sched_min_granularity_ns",
284 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800287 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100288 .extra1 = &min_sched_granularity_ns,
289 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200290 },
291 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200292 .procname = "sched_latency_ns",
293 .data = &sysctl_sched_latency,
294 .maxlen = sizeof(unsigned int),
295 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800296 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200297 .extra1 = &min_sched_granularity_ns,
298 .extra2 = &max_sched_granularity_ns,
299 },
300 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200301 .procname = "sched_wakeup_granularity_ns",
302 .data = &sysctl_sched_wakeup_granularity,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800305 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200306 .extra1 = &min_wakeup_granularity_ns,
307 .extra2 = &max_wakeup_granularity_ns,
308 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200309#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200310 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100311 .procname = "sched_tunable_scaling",
312 .data = &sysctl_sched_tunable_scaling,
313 .maxlen = sizeof(enum sched_tunable_scaling),
314 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800315 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100316 .extra1 = &min_sched_tunable_scaling,
317 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200318 },
319 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900320 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200321 .data = &sysctl_sched_migration_cost,
322 .maxlen = sizeof(unsigned int),
323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800324 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200325 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100326 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100327 .procname = "sched_nr_migrate",
328 .data = &sysctl_sched_nr_migrate,
329 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100332 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530333 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900334 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200335 .data = &sysctl_sched_time_avg,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200339 },
340 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900341 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800342 .data = &sysctl_sched_shares_window,
343 .maxlen = sizeof(unsigned int),
344 .mode = 0644,
345 .proc_handler = proc_dointvec,
346 },
347 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530348 .procname = "timer_migration",
349 .data = &sysctl_timer_migration,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800352 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530353 .extra1 = &zero,
354 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530355 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200356#endif /* CONFIG_SMP */
357#ifdef CONFIG_NUMA_BALANCING
358 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200359 .procname = "numa_balancing_scan_delay_ms",
360 .data = &sysctl_numa_balancing_scan_delay,
361 .maxlen = sizeof(unsigned int),
362 .mode = 0644,
363 .proc_handler = proc_dointvec,
364 },
365 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200366 .procname = "numa_balancing_scan_period_min_ms",
367 .data = &sysctl_numa_balancing_scan_period_min,
368 .maxlen = sizeof(unsigned int),
369 .mode = 0644,
370 .proc_handler = proc_dointvec,
371 },
372 {
Mel Gormanb8593bf2012-11-21 01:18:23 +0000373 .procname = "numa_balancing_scan_period_reset",
374 .data = &sysctl_numa_balancing_scan_period_reset,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = proc_dointvec,
378 },
379 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200380 .procname = "numa_balancing_scan_period_max_ms",
381 .data = &sysctl_numa_balancing_scan_period_max,
382 .maxlen = sizeof(unsigned int),
383 .mode = 0644,
384 .proc_handler = proc_dointvec,
385 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200386 {
387 .procname = "numa_balancing_scan_size_mb",
388 .data = &sysctl_numa_balancing_scan_size,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = proc_dointvec,
392 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200393#endif /* CONFIG_NUMA_BALANCING */
394#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200395 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100396 .procname = "sched_rt_period_us",
397 .data = &sysctl_sched_rt_period,
398 .maxlen = sizeof(unsigned int),
399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800400 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100401 },
402 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100403 .procname = "sched_rt_runtime_us",
404 .data = &sysctl_sched_rt_runtime,
405 .maxlen = sizeof(int),
406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800407 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100408 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600409 {
410 .procname = "sched_rr_timeslice_ms",
411 .data = &sched_rr_timeslice,
412 .maxlen = sizeof(int),
413 .mode = 0644,
414 .proc_handler = sched_rr_handler,
415 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100416#ifdef CONFIG_SCHED_AUTOGROUP
417 {
418 .procname = "sched_autogroup_enabled",
419 .data = &sysctl_sched_autogroup_enabled,
420 .maxlen = sizeof(unsigned int),
421 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800422 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100423 .extra1 = &zero,
424 .extra2 = &one,
425 },
426#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700427#ifdef CONFIG_CFS_BANDWIDTH
428 {
429 .procname = "sched_cfs_bandwidth_slice_us",
430 .data = &sysctl_sched_cfs_bandwidth_slice,
431 .maxlen = sizeof(unsigned int),
432 .mode = 0644,
433 .proc_handler = proc_dointvec_minmax,
434 .extra1 = &one,
435 },
436#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700437#ifdef CONFIG_PROVE_LOCKING
438 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700439 .procname = "prove_locking",
440 .data = &prove_locking,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700444 },
445#endif
446#ifdef CONFIG_LOCK_STAT
447 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700448 .procname = "lock_stat",
449 .data = &lock_stat,
450 .maxlen = sizeof(int),
451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800452 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700453 },
454#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 .procname = "panic",
457 .data = &panic_timeout,
458 .maxlen = sizeof(int),
459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 },
Alex Kelly046d6622012-10-04 17:15:23 -0700462#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "core_uses_pid",
465 .data = &core_uses_pid,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "core_pattern",
472 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700473 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700475 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
Neil Hormana2939802009-09-23 15:56:56 -0700477 {
Neil Hormana2939802009-09-23 15:56:56 -0700478 .procname = "core_pipe_limit",
479 .data = &core_pipe_limit,
480 .maxlen = sizeof(unsigned int),
481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800482 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700483 },
Alex Kelly046d6622012-10-04 17:15:23 -0700484#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800485#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700488 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800490 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800492#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100493#ifdef CONFIG_LATENCYTOP
494 {
495 .procname = "latencytop",
496 .data = &latencytop_enabled,
497 .maxlen = sizeof(int),
498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100500 },
501#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502#ifdef CONFIG_BLK_DEV_INITRD
503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 .procname = "real-root-dev",
505 .data = &real_root_dev,
506 .maxlen = sizeof(int),
507 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800508 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 },
510#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700511 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700512 .procname = "print-fatal-signals",
513 .data = &print_fatal_signals,
514 .maxlen = sizeof(int),
515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800516 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700517 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700518#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 .procname = "reboot-cmd",
521 .data = reboot_command,
522 .maxlen = 256,
523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800524 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 },
526 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 .procname = "stop-a",
528 .data = &stop_a_enabled,
529 .maxlen = sizeof (int),
530 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800531 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 },
533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 .procname = "scons-poweroff",
535 .data = &scons_pwroff,
536 .maxlen = sizeof (int),
537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800538 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 },
540#endif
David S. Miller08714202008-11-16 23:49:24 -0800541#ifdef CONFIG_SPARC64
542 {
David S. Miller08714202008-11-16 23:49:24 -0800543 .procname = "tsb-ratio",
544 .data = &sysctl_tsb_ratio,
545 .maxlen = sizeof (int),
546 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800547 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800548 },
549#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550#ifdef __hppa__
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "soft-power",
553 .data = &pwrsw_enabled,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 .procname = "unaligned-trap",
560 .data = &unaligned_enabled,
561 .maxlen = sizeof (int),
562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800563 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 },
565#endif
566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .procname = "ctrl-alt-del",
568 .data = &C_A_D,
569 .maxlen = sizeof(int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400573#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200574 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200575 .procname = "ftrace_enabled",
576 .data = &ftrace_enabled,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200580 },
581#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500582#ifdef CONFIG_STACK_TRACER
583 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500584 .procname = "stack_tracer_enabled",
585 .data = &stack_tracer_enabled,
586 .maxlen = sizeof(int),
587 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800588 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500589 },
590#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400591#ifdef CONFIG_TRACING
592 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100593 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400594 .data = &ftrace_dump_on_oops,
595 .maxlen = sizeof(int),
596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400598 },
599#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200600#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 .procname = "modprobe",
603 .data = &modprobe_path,
604 .maxlen = KMOD_PATH_LEN,
605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800606 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 },
Kees Cook3d433212009-04-02 15:49:29 -0700608 {
Kees Cook3d433212009-04-02 15:49:29 -0700609 .procname = "modules_disabled",
610 .data = &modules_disabled,
611 .maxlen = sizeof(int),
612 .mode = 0644,
613 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800614 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700615 .extra1 = &one,
616 .extra2 = &one,
617 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500619
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100622 .data = &uevent_helper,
623 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800625 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500627
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628#ifdef CONFIG_CHR_DEV_SG
629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .procname = "sg-big-buff",
631 .data = &sg_big_buff,
632 .maxlen = sizeof (int),
633 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800634 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 },
636#endif
637#ifdef CONFIG_BSD_PROCESS_ACCT
638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "acct",
640 .data = &acct_parm,
641 .maxlen = 3*sizeof(int),
642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800643 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 },
645#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646#ifdef CONFIG_MAGIC_SYSRQ
647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800649 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .maxlen = sizeof (int),
651 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700652 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 },
654#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700655#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700658 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 .maxlen = sizeof (int),
660 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700663#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "threads-max",
666 .data = &max_threads,
667 .maxlen = sizeof(int),
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .procname = "random",
673 .mode = 0555,
674 .child = random_table,
675 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 {
Eric Paris17f60a72011-04-01 17:07:50 -0400677 .procname = "usermodehelper",
678 .mode = 0555,
679 .child = usermodehelper_table,
680 },
681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "overflowuid",
683 .data = &overflowuid,
684 .maxlen = sizeof(int),
685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .extra1 = &minolduid,
688 .extra2 = &maxolduid,
689 },
690 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 .procname = "overflowgid",
692 .data = &overflowgid,
693 .maxlen = sizeof(int),
694 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800695 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .extra1 = &minolduid,
697 .extra2 = &maxolduid,
698 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800699#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700#ifdef CONFIG_MATHEMU
701 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .procname = "ieee_emulation_warnings",
703 .data = &sysctl_ieee_emulation_warnings,
704 .maxlen = sizeof(int),
705 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 },
708#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200711 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .maxlen = sizeof(int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
716#endif
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "pid_max",
719 .data = &pid_max,
720 .maxlen = sizeof (int),
721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 .extra1 = &pid_max_min,
724 .extra2 = &pid_max_max,
725 },
726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "panic_on_oops",
728 .data = &panic_on_oops,
729 .maxlen = sizeof(int),
730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800733#if defined CONFIG_PRINTK
734 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800735 .procname = "printk",
736 .data = &console_loglevel,
737 .maxlen = 4*sizeof(int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800740 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700743 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .maxlen = sizeof(int),
745 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800746 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 },
748 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700750 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 .maxlen = sizeof(int),
752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 },
Dave Youngaf913222009-09-22 16:43:33 -0700755 {
Dave Youngaf913222009-09-22 16:43:33 -0700756 .procname = "printk_delay",
757 .data = &printk_delay_msec,
758 .maxlen = sizeof(int),
759 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800760 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700761 .extra1 = &zero,
762 .extra2 = &ten_thousand,
763 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800765 .procname = "dmesg_restrict",
766 .data = &dmesg_restrict,
767 .maxlen = sizeof(int),
768 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700769 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800770 .extra1 = &zero,
771 .extra2 = &one,
772 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800773 {
774 .procname = "kptr_restrict",
775 .data = &kptr_restrict,
776 .maxlen = sizeof(int),
777 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700778 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800779 .extra1 = &zero,
780 .extra2 = &two,
781 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800782#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800783 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 .procname = "ngroups_max",
785 .data = &ngroups_max,
786 .maxlen = sizeof (int),
787 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800788 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 },
Dan Ballard73efc032011-10-31 17:11:20 -0700790 {
791 .procname = "cap_last_cap",
792 .data = (void *)&cap_last_cap,
793 .maxlen = sizeof(int),
794 .mode = 0444,
795 .proc_handler = proc_dointvec,
796 },
Don Zickus58687ac2010-05-07 17:11:44 -0400797#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500798 {
Don Zickus58687ac2010-05-07 17:11:44 -0400799 .procname = "watchdog",
800 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500801 .maxlen = sizeof (int),
802 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700803 .proc_handler = proc_dowatchdog,
804 .extra1 = &zero,
805 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400806 },
807 {
808 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700809 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400810 .maxlen = sizeof(int),
811 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700812 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400813 .extra1 = &neg_one,
814 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500815 },
Don Zickus2508ce12010-05-07 17:11:46 -0400816 {
817 .procname = "softlockup_panic",
818 .data = &softlockup_panic,
819 .maxlen = sizeof(int),
820 .mode = 0644,
821 .proc_handler = proc_dointvec_minmax,
822 .extra1 = &zero,
823 .extra2 = &one,
824 },
Don Zickus5dc30552010-11-29 17:07:17 -0500825 {
826 .procname = "nmi_watchdog",
827 .data = &watchdog_enabled,
828 .maxlen = sizeof (int),
829 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700830 .proc_handler = proc_dowatchdog,
831 .extra1 = &zero,
832 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500833 },
834#endif
835#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
836 {
837 .procname = "unknown_nmi_panic",
838 .data = &unknown_nmi_panic,
839 .maxlen = sizeof (int),
840 .mode = 0644,
841 .proc_handler = proc_dointvec,
842 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500843#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844#if defined(CONFIG_X86)
845 {
Don Zickus8da5add2006-09-26 10:52:27 +0200846 .procname = "panic_on_unrecovered_nmi",
847 .data = &panic_on_unrecovered_nmi,
848 .maxlen = sizeof(int),
849 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800850 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200851 },
852 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700853 .procname = "panic_on_io_nmi",
854 .data = &panic_on_io_nmi,
855 .maxlen = sizeof(int),
856 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800857 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700858 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900859#ifdef CONFIG_DEBUG_STACKOVERFLOW
860 {
861 .procname = "panic_on_stackoverflow",
862 .data = &sysctl_panic_on_stackoverflow,
863 .maxlen = sizeof(int),
864 .mode = 0644,
865 .proc_handler = proc_dointvec,
866 },
867#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700868 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 .procname = "bootloader_type",
870 .data = &bootloader_type,
871 .maxlen = sizeof (int),
872 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800873 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100875 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700876 .procname = "bootloader_version",
877 .data = &bootloader_version,
878 .maxlen = sizeof (int),
879 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800880 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700881 },
882 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100883 .procname = "kstack_depth_to_print",
884 .data = &kstack_depth_to_print,
885 .maxlen = sizeof(int),
886 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800887 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100888 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100889 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100890 .procname = "io_delay_type",
891 .data = &io_delay_type,
892 .maxlen = sizeof(int),
893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800894 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100895 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800897#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 .procname = "randomize_va_space",
900 .data = &randomize_va_space,
901 .maxlen = sizeof(int),
902 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800903 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800905#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800906#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700907 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700908 .procname = "spin_retry",
909 .data = &spin_retry,
910 .maxlen = sizeof (int),
911 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700913 },
914#endif
Len Brown673d5b42007-07-28 03:33:16 -0400915#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800916 {
Pavel Machekc255d842006-02-20 18:27:58 -0800917 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700918 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800919 .maxlen = sizeof (unsigned long),
920 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800921 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800922 },
923#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530924#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800925 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800926 .procname = "ignore-unaligned-usertrap",
927 .data = &no_unaligned_warning,
928 .maxlen = sizeof (int),
929 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800930 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800931 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530932#endif
933#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800934 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800935 .procname = "unaligned-dump-stack",
936 .data = &unaligned_dump_stack,
937 .maxlen = sizeof (int),
938 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800939 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800940 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800941#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800942#ifdef CONFIG_DETECT_HUNG_TASK
943 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800944 .procname = "hung_task_panic",
945 .data = &sysctl_hung_task_panic,
946 .maxlen = sizeof(int),
947 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800948 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800949 .extra1 = &zero,
950 .extra2 = &one,
951 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100952 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100953 .procname = "hung_task_check_count",
954 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100955 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100956 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800957 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100958 },
959 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100960 .procname = "hung_task_timeout_secs",
961 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100962 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100963 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800964 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100965 },
966 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100967 .procname = "hung_task_warnings",
968 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100969 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100970 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800971 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100972 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700973#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200974#ifdef CONFIG_COMPAT
975 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200976 .procname = "compat-log",
977 .data = &compat_log,
978 .maxlen = sizeof (int),
979 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800980 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200981 },
982#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700983#ifdef CONFIG_RT_MUTEXES
984 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700985 .procname = "max_lock_depth",
986 .data = &max_lock_depth,
987 .maxlen = sizeof(int),
988 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800989 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700990 },
991#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700992 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700993 .procname = "poweroff_cmd",
994 .data = &poweroff_cmd,
995 .maxlen = POWEROFF_CMD_PATH_LEN,
996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700998 },
David Howells0b77f5b2008-04-29 01:01:32 -0700999#ifdef CONFIG_KEYS
1000 {
David Howells0b77f5b2008-04-29 01:01:32 -07001001 .procname = "keys",
1002 .mode = 0555,
1003 .child = key_sysctls,
1004 },
1005#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001006#ifdef CONFIG_RCU_TORTURE_TEST
1007 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001008 .procname = "rcutorture_runnable",
1009 .data = &rcutorture_runnable,
1010 .maxlen = sizeof(int),
1011 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001012 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001013 },
1014#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001015#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001016 /*
1017 * User-space scripts rely on the existence of this file
1018 * as a feature check for perf_events being enabled.
1019 *
1020 * So it's an ABI, do not remove!
1021 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001022 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001023 .procname = "perf_event_paranoid",
1024 .data = &sysctl_perf_event_paranoid,
1025 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001026 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001027 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001028 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001029 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001030 .procname = "perf_event_mlock_kb",
1031 .data = &sysctl_perf_event_mlock,
1032 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001033 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001034 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001035 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001036 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001037 .procname = "perf_event_max_sample_rate",
1038 .data = &sysctl_perf_event_sample_rate,
1039 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001040 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001041 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001042 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001043#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001044#ifdef CONFIG_KMEMCHECK
1045 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001046 .procname = "kmemcheck",
1047 .data = &kmemcheck_enabled,
1048 .maxlen = sizeof(int),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001051 },
1052#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001053#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001054 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001055 .procname = "blk_iopoll",
1056 .data = &blk_iopoll_enabled,
1057 .maxlen = sizeof(int),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001060 },
Jens Axboecb684b52009-09-15 21:53:11 +02001061#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001062 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063};
1064
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001065static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 .procname = "overcommit_memory",
1068 .data = &sysctl_overcommit_memory,
1069 .maxlen = sizeof(sysctl_overcommit_memory),
1070 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001071 .proc_handler = proc_dointvec_minmax,
1072 .extra1 = &zero,
1073 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 },
1075 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001076 .procname = "panic_on_oom",
1077 .data = &sysctl_panic_on_oom,
1078 .maxlen = sizeof(sysctl_panic_on_oom),
1079 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001080 .proc_handler = proc_dointvec_minmax,
1081 .extra1 = &zero,
1082 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001083 },
1084 {
David Rientjesfe071d72007-10-16 23:25:56 -07001085 .procname = "oom_kill_allocating_task",
1086 .data = &sysctl_oom_kill_allocating_task,
1087 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1088 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001089 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001090 },
1091 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001092 .procname = "oom_dump_tasks",
1093 .data = &sysctl_oom_dump_tasks,
1094 .maxlen = sizeof(sysctl_oom_dump_tasks),
1095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001097 },
1098 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 .procname = "overcommit_ratio",
1100 .data = &sysctl_overcommit_ratio,
1101 .maxlen = sizeof(sysctl_overcommit_ratio),
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 },
1105 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 .procname = "page-cluster",
1107 .data = &page_cluster,
1108 .maxlen = sizeof(int),
1109 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001110 .proc_handler = proc_dointvec_minmax,
1111 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 },
1113 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 .procname = "dirty_background_ratio",
1115 .data = &dirty_background_ratio,
1116 .maxlen = sizeof(dirty_background_ratio),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 .extra1 = &zero,
1120 .extra2 = &one_hundred,
1121 },
1122 {
David Rientjes2da02992009-01-06 14:39:31 -08001123 .procname = "dirty_background_bytes",
1124 .data = &dirty_background_bytes,
1125 .maxlen = sizeof(dirty_background_bytes),
1126 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001127 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001128 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001129 },
1130 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 .procname = "dirty_ratio",
1132 .data = &vm_dirty_ratio,
1133 .maxlen = sizeof(vm_dirty_ratio),
1134 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001135 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 .extra1 = &zero,
1137 .extra2 = &one_hundred,
1138 },
1139 {
David Rientjes2da02992009-01-06 14:39:31 -08001140 .procname = "dirty_bytes",
1141 .data = &vm_dirty_bytes,
1142 .maxlen = sizeof(vm_dirty_bytes),
1143 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001144 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001145 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001146 },
1147 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001149 .data = &dirty_writeback_interval,
1150 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001152 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 },
1154 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001156 .data = &dirty_expire_interval,
1157 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001159 .proc_handler = proc_dointvec_minmax,
1160 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 },
1162 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001163 .procname = "nr_pdflush_threads",
1164 .mode = 0444 /* read-only */,
1165 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 },
1167 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 .procname = "swappiness",
1169 .data = &vm_swappiness,
1170 .maxlen = sizeof(vm_swappiness),
1171 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001172 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 .extra1 = &zero,
1174 .extra2 = &one_hundred,
1175 },
1176#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001177 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001179 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 .maxlen = sizeof(unsigned long),
1181 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001182 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .extra1 = (void *)&hugetlb_zero,
1184 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001185 },
1186#ifdef CONFIG_NUMA
1187 {
1188 .procname = "nr_hugepages_mempolicy",
1189 .data = NULL,
1190 .maxlen = sizeof(unsigned long),
1191 .mode = 0644,
1192 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1193 .extra1 = (void *)&hugetlb_zero,
1194 .extra2 = (void *)&hugetlb_infinity,
1195 },
1196#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 .procname = "hugetlb_shm_group",
1199 .data = &sysctl_hugetlb_shm_group,
1200 .maxlen = sizeof(gid_t),
1201 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001202 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 },
Mel Gorman396faf02007-07-17 04:03:13 -07001204 {
Mel Gorman396faf02007-07-17 04:03:13 -07001205 .procname = "hugepages_treat_as_movable",
1206 .data = &hugepages_treat_as_movable,
1207 .maxlen = sizeof(int),
1208 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001209 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001210 },
Adam Litke54f9f802007-10-16 01:26:20 -07001211 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001212 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001213 .data = NULL,
1214 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001215 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001216 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001217 .extra1 = (void *)&hugetlb_zero,
1218 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001219 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220#endif
1221 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 .procname = "lowmem_reserve_ratio",
1223 .data = &sysctl_lowmem_reserve_ratio,
1224 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1225 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001226 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 },
1228 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001229 .procname = "drop_caches",
1230 .data = &sysctl_drop_caches,
1231 .maxlen = sizeof(int),
1232 .mode = 0644,
1233 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001234 .extra1 = &one,
1235 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001236 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001237#ifdef CONFIG_COMPACTION
1238 {
1239 .procname = "compact_memory",
1240 .data = &sysctl_compact_memory,
1241 .maxlen = sizeof(int),
1242 .mode = 0200,
1243 .proc_handler = sysctl_compaction_handler,
1244 },
Mel Gorman5e771902010-05-24 14:32:31 -07001245 {
1246 .procname = "extfrag_threshold",
1247 .data = &sysctl_extfrag_threshold,
1248 .maxlen = sizeof(int),
1249 .mode = 0644,
1250 .proc_handler = sysctl_extfrag_handler,
1251 .extra1 = &min_extfrag_threshold,
1252 .extra2 = &max_extfrag_threshold,
1253 },
1254
Mel Gorman76ab0f52010-05-24 14:32:28 -07001255#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "min_free_kbytes",
1258 .data = &min_free_kbytes,
1259 .maxlen = sizeof(min_free_kbytes),
1260 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001261 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 .extra1 = &zero,
1263 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001264 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001265 .procname = "percpu_pagelist_fraction",
1266 .data = &percpu_pagelist_fraction,
1267 .maxlen = sizeof(percpu_pagelist_fraction),
1268 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001269 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001270 .extra1 = &min_percpu_pagelist_fract,
1271 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272#ifdef CONFIG_MMU
1273 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 .procname = "max_map_count",
1275 .data = &sysctl_max_map_count,
1276 .maxlen = sizeof(sysctl_max_map_count),
1277 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001278 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001279 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001281#else
1282 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001283 .procname = "nr_trim_pages",
1284 .data = &sysctl_nr_trim_pages,
1285 .maxlen = sizeof(sysctl_nr_trim_pages),
1286 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001287 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001288 .extra1 = &zero,
1289 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290#endif
1291 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001292 .procname = "laptop_mode",
1293 .data = &laptop_mode,
1294 .maxlen = sizeof(laptop_mode),
1295 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001296 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 },
1298 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 .procname = "block_dump",
1300 .data = &block_dump,
1301 .maxlen = sizeof(block_dump),
1302 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001303 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 .extra1 = &zero,
1305 },
1306 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 .procname = "vfs_cache_pressure",
1308 .data = &sysctl_vfs_cache_pressure,
1309 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1310 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .extra1 = &zero,
1313 },
1314#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1315 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 .procname = "legacy_va_layout",
1317 .data = &sysctl_legacy_va_layout,
1318 .maxlen = sizeof(sysctl_legacy_va_layout),
1319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001320 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 .extra1 = &zero,
1322 },
1323#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001324#ifdef CONFIG_NUMA
1325 {
Christoph Lameter17436602006-01-18 17:42:32 -08001326 .procname = "zone_reclaim_mode",
1327 .data = &zone_reclaim_mode,
1328 .maxlen = sizeof(zone_reclaim_mode),
1329 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001330 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001331 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001332 },
Christoph Lameter96146342006-07-03 00:24:13 -07001333 {
Christoph Lameter96146342006-07-03 00:24:13 -07001334 .procname = "min_unmapped_ratio",
1335 .data = &sysctl_min_unmapped_ratio,
1336 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001338 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001339 .extra1 = &zero,
1340 .extra2 = &one_hundred,
1341 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001342 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001343 .procname = "min_slab_ratio",
1344 .data = &sysctl_min_slab_ratio,
1345 .maxlen = sizeof(sysctl_min_slab_ratio),
1346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001347 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001348 .extra1 = &zero,
1349 .extra2 = &one_hundred,
1350 },
Christoph Lameter17436602006-01-18 17:42:32 -08001351#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001352#ifdef CONFIG_SMP
1353 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001354 .procname = "stat_interval",
1355 .data = &sysctl_stat_interval,
1356 .maxlen = sizeof(sysctl_stat_interval),
1357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001358 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001359 },
1360#endif
David Howells6e141542009-12-15 19:27:45 +00001361#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001362 {
Eric Parised032182007-06-28 15:55:21 -04001363 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001364 .data = &dac_mmap_min_addr,
1365 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001366 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001367 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001368 },
David Howells6e141542009-12-15 19:27:45 +00001369#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001370#ifdef CONFIG_NUMA
1371 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001372 .procname = "numa_zonelist_order",
1373 .data = &numa_zonelist_order,
1374 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001376 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001377 },
1378#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001379#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001380 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001381 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001382 .procname = "vdso_enabled",
1383 .data = &vdso_enabled,
1384 .maxlen = sizeof(vdso_enabled),
1385 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001386 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001387 .extra1 = &zero,
1388 },
1389#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001390#ifdef CONFIG_HIGHMEM
1391 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001392 .procname = "highmem_is_dirtyable",
1393 .data = &vm_highmem_is_dirtyable,
1394 .maxlen = sizeof(vm_highmem_is_dirtyable),
1395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001396 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001397 .extra1 = &zero,
1398 .extra2 = &one,
1399 },
1400#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001401 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001402 .procname = "scan_unevictable_pages",
1403 .data = &scan_unevictable_pages,
1404 .maxlen = sizeof(scan_unevictable_pages),
1405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001406 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001407 },
Andi Kleen6a460792009-09-16 11:50:15 +02001408#ifdef CONFIG_MEMORY_FAILURE
1409 {
Andi Kleen6a460792009-09-16 11:50:15 +02001410 .procname = "memory_failure_early_kill",
1411 .data = &sysctl_memory_failure_early_kill,
1412 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1413 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001414 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001415 .extra1 = &zero,
1416 .extra2 = &one,
1417 },
1418 {
Andi Kleen6a460792009-09-16 11:50:15 +02001419 .procname = "memory_failure_recovery",
1420 .data = &sysctl_memory_failure_recovery,
1421 .maxlen = sizeof(sysctl_memory_failure_recovery),
1422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001423 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001424 .extra1 = &zero,
1425 .extra2 = &one,
1426 },
1427#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001428 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429};
1430
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001431#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001432static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001433 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001434};
1435#endif
1436
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001437static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .procname = "inode-nr",
1440 .data = &inodes_stat,
1441 .maxlen = 2*sizeof(int),
1442 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001443 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 },
1445 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 .procname = "inode-state",
1447 .data = &inodes_stat,
1448 .maxlen = 7*sizeof(int),
1449 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001450 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 },
1452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 .procname = "file-nr",
1454 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001455 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001457 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 },
1459 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .procname = "file-max",
1461 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001462 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001464 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 },
1466 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001467 .procname = "nr_open",
1468 .data = &sysctl_nr_open,
1469 .maxlen = sizeof(int),
1470 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001471 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001472 .extra1 = &sysctl_nr_open_min,
1473 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001474 },
1475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 .procname = "dentry-state",
1477 .data = &dentry_stat,
1478 .maxlen = 6*sizeof(int),
1479 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001480 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 },
1482 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 .procname = "overflowuid",
1484 .data = &fs_overflowuid,
1485 .maxlen = sizeof(int),
1486 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001487 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .extra1 = &minolduid,
1489 .extra2 = &maxolduid,
1490 },
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "overflowgid",
1493 .data = &fs_overflowgid,
1494 .maxlen = sizeof(int),
1495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001496 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 .extra1 = &minolduid,
1498 .extra2 = &maxolduid,
1499 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001500#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 .procname = "leases-enable",
1503 .data = &leases_enable,
1504 .maxlen = sizeof(int),
1505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001506 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001508#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509#ifdef CONFIG_DNOTIFY
1510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .procname = "dir-notify-enable",
1512 .data = &dir_notify_enable,
1513 .maxlen = sizeof(int),
1514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 },
1517#endif
1518#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001519#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 .procname = "lease-break-time",
1522 .data = &lease_break_time,
1523 .maxlen = sizeof(int),
1524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001525 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001527#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001528#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .procname = "aio-nr",
1531 .data = &aio_nr,
1532 .maxlen = sizeof(aio_nr),
1533 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001534 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 },
1536 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 .procname = "aio-max-nr",
1538 .data = &aio_max_nr,
1539 .maxlen = sizeof(aio_max_nr),
1540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001541 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001543#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001544#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001545 {
Robert Love0399cb02005-07-13 12:38:18 -04001546 .procname = "inotify",
1547 .mode = 0555,
1548 .child = inotify_table,
1549 },
1550#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001551#ifdef CONFIG_EPOLL
1552 {
1553 .procname = "epoll",
1554 .mode = 0555,
1555 .child = epoll_table,
1556 },
1557#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001559 {
Kees Cook800179c2012-07-25 17:29:07 -07001560 .procname = "protected_symlinks",
1561 .data = &sysctl_protected_symlinks,
1562 .maxlen = sizeof(int),
1563 .mode = 0600,
1564 .proc_handler = proc_dointvec_minmax,
1565 .extra1 = &zero,
1566 .extra2 = &one,
1567 },
1568 {
1569 .procname = "protected_hardlinks",
1570 .data = &sysctl_protected_hardlinks,
1571 .maxlen = sizeof(int),
1572 .mode = 0600,
1573 .proc_handler = proc_dointvec_minmax,
1574 .extra1 = &zero,
1575 .extra2 = &one,
1576 },
1577 {
Alan Coxd6e71142005-06-23 00:09:43 -07001578 .procname = "suid_dumpable",
1579 .data = &suid_dumpable,
1580 .maxlen = sizeof(int),
1581 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001582 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001583 .extra1 = &zero,
1584 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001585 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001586#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1587 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001588 .procname = "binfmt_misc",
1589 .mode = 0555,
1590 .child = binfmt_misc_table,
1591 },
1592#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001593 {
Jens Axboeff9da692010-06-03 14:54:39 +02001594 .procname = "pipe-max-size",
1595 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001596 .maxlen = sizeof(int),
1597 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001598 .proc_handler = &pipe_proc_fn,
1599 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001600 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001601 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602};
1603
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001604static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001605#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001606 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001607 .procname = "exception-trace",
1608 .data = &show_unhandled_signals,
1609 .maxlen = sizeof(int),
1610 .mode = 0644,
1611 .proc_handler = proc_dointvec
1612 },
1613#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001614#if defined(CONFIG_OPTPROBES)
1615 {
1616 .procname = "kprobes-optimization",
1617 .data = &sysctl_kprobes_optimization,
1618 .maxlen = sizeof(int),
1619 .mode = 0644,
1620 .proc_handler = proc_kprobes_optimization_handler,
1621 .extra1 = &zero,
1622 .extra2 = &one,
1623 },
1624#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001625 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626};
1627
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001628static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001629 { }
Robert Love0eeca282005-07-12 17:06:03 -04001630};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001632int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001633{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001634 struct ctl_table_header *hdr;
1635
1636 hdr = register_sysctl_table(sysctl_base_table);
1637 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001638 return 0;
1639}
1640
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001641#endif /* CONFIG_SYSCTL */
1642
Linus Torvalds1da177e2005-04-16 15:20:36 -07001643/*
1644 * /proc/sys support
1645 */
1646
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001647#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001649static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001650 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001651 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001652{
1653 size_t len;
1654 char __user *p;
1655 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001656
1657 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001658 *lenp = 0;
1659 return 0;
1660 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001661
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001662 if (write) {
1663 len = 0;
1664 p = buffer;
1665 while (len < *lenp) {
1666 if (get_user(c, p++))
1667 return -EFAULT;
1668 if (c == 0 || c == '\n')
1669 break;
1670 len++;
1671 }
1672 if (len >= maxlen)
1673 len = maxlen-1;
1674 if(copy_from_user(data, buffer, len))
1675 return -EFAULT;
1676 ((char *) data)[len] = 0;
1677 *ppos += *lenp;
1678 } else {
1679 len = strlen(data);
1680 if (len > maxlen)
1681 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001682
1683 if (*ppos > len) {
1684 *lenp = 0;
1685 return 0;
1686 }
1687
1688 data += *ppos;
1689 len -= *ppos;
1690
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001691 if (len > *lenp)
1692 len = *lenp;
1693 if (len)
1694 if(copy_to_user(buffer, data, len))
1695 return -EFAULT;
1696 if (len < *lenp) {
1697 if(put_user('\n', ((char __user *) buffer) + len))
1698 return -EFAULT;
1699 len++;
1700 }
1701 *lenp = len;
1702 *ppos += len;
1703 }
1704 return 0;
1705}
1706
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707/**
1708 * proc_dostring - read a string sysctl
1709 * @table: the sysctl table
1710 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 * @buffer: the user buffer
1712 * @lenp: the size of the user buffer
1713 * @ppos: file position
1714 *
1715 * Reads/writes a string from/to the user buffer. If the kernel
1716 * buffer provided is not large enough to hold the string, the
1717 * string is truncated. The copied string is %NULL-terminated.
1718 * If the string is being read by the user process, it is copied
1719 * and a newline '\n' is added. It is truncated if the buffer is
1720 * not large enough.
1721 *
1722 * Returns 0 on success.
1723 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001724int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 void __user *buffer, size_t *lenp, loff_t *ppos)
1726{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001727 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001728 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729}
1730
Amerigo Wang00b7c332010-05-05 00:26:45 +00001731static size_t proc_skip_spaces(char **buf)
1732{
1733 size_t ret;
1734 char *tmp = skip_spaces(*buf);
1735 ret = tmp - *buf;
1736 *buf = tmp;
1737 return ret;
1738}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001740static void proc_skip_char(char **buf, size_t *size, const char v)
1741{
1742 while (*size) {
1743 if (**buf != v)
1744 break;
1745 (*size)--;
1746 (*buf)++;
1747 }
1748}
1749
Amerigo Wang00b7c332010-05-05 00:26:45 +00001750#define TMPBUFLEN 22
1751/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001752 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001753 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001754 * @buf: a kernel buffer
1755 * @size: size of the kernel buffer
1756 * @val: this is where the number will be stored
1757 * @neg: set to %TRUE if number is negative
1758 * @perm_tr: a vector which contains the allowed trailers
1759 * @perm_tr_len: size of the perm_tr vector
1760 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001761 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001762 * In case of success %0 is returned and @buf and @size are updated with
1763 * the amount of bytes read. If @tr is non-NULL and a trailing
1764 * character exists (size is non-zero after returning from this
1765 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001766 */
1767static int proc_get_long(char **buf, size_t *size,
1768 unsigned long *val, bool *neg,
1769 const char *perm_tr, unsigned perm_tr_len, char *tr)
1770{
1771 int len;
1772 char *p, tmp[TMPBUFLEN];
1773
1774 if (!*size)
1775 return -EINVAL;
1776
1777 len = *size;
1778 if (len > TMPBUFLEN - 1)
1779 len = TMPBUFLEN - 1;
1780
1781 memcpy(tmp, *buf, len);
1782
1783 tmp[len] = 0;
1784 p = tmp;
1785 if (*p == '-' && *size > 1) {
1786 *neg = true;
1787 p++;
1788 } else
1789 *neg = false;
1790 if (!isdigit(*p))
1791 return -EINVAL;
1792
1793 *val = simple_strtoul(p, &p, 0);
1794
1795 len = p - tmp;
1796
1797 /* We don't know if the next char is whitespace thus we may accept
1798 * invalid integers (e.g. 1234...a) or two integers instead of one
1799 * (e.g. 123...1). So lets not allow such large numbers. */
1800 if (len == TMPBUFLEN - 1)
1801 return -EINVAL;
1802
1803 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1804 return -EINVAL;
1805
1806 if (tr && (len < *size))
1807 *tr = *p;
1808
1809 *buf += len;
1810 *size -= len;
1811
1812 return 0;
1813}
1814
1815/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001816 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001817 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001818 * @buf: the user buffer
1819 * @size: the size of the user buffer
1820 * @val: the integer to be converted
1821 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001822 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001823 * In case of success %0 is returned and @buf and @size are updated with
1824 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001825 */
1826static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1827 bool neg)
1828{
1829 int len;
1830 char tmp[TMPBUFLEN], *p = tmp;
1831
1832 sprintf(p, "%s%lu", neg ? "-" : "", val);
1833 len = strlen(tmp);
1834 if (len > *size)
1835 len = *size;
1836 if (copy_to_user(*buf, tmp, len))
1837 return -EFAULT;
1838 *size -= len;
1839 *buf += len;
1840 return 0;
1841}
1842#undef TMPBUFLEN
1843
1844static int proc_put_char(void __user **buf, size_t *size, char c)
1845{
1846 if (*size) {
1847 char __user **buffer = (char __user **)buf;
1848 if (put_user(c, *buffer))
1849 return -EFAULT;
1850 (*size)--, (*buffer)++;
1851 *buf = *buffer;
1852 }
1853 return 0;
1854}
1855
1856static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857 int *valp,
1858 int write, void *data)
1859{
1860 if (write) {
1861 *valp = *negp ? -*lvalp : *lvalp;
1862 } else {
1863 int val = *valp;
1864 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001865 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866 *lvalp = (unsigned long)-val;
1867 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001868 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 *lvalp = (unsigned long)val;
1870 }
1871 }
1872 return 0;
1873}
1874
Amerigo Wang00b7c332010-05-05 00:26:45 +00001875static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1876
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001877static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001878 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001879 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001880 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 int write, void *data),
1882 void *data)
1883{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001884 int *i, vleft, first = 1, err = 0;
1885 unsigned long page = 0;
1886 size_t left;
1887 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888
Amerigo Wang00b7c332010-05-05 00:26:45 +00001889 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890 *lenp = 0;
1891 return 0;
1892 }
1893
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001894 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 vleft = table->maxlen / sizeof(*i);
1896 left = *lenp;
1897
1898 if (!conv)
1899 conv = do_proc_dointvec_conv;
1900
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001902 if (left > PAGE_SIZE - 1)
1903 left = PAGE_SIZE - 1;
1904 page = __get_free_page(GFP_TEMPORARY);
1905 kbuf = (char *) page;
1906 if (!kbuf)
1907 return -ENOMEM;
1908 if (copy_from_user(kbuf, buffer, left)) {
1909 err = -EFAULT;
1910 goto free;
1911 }
1912 kbuf[left] = 0;
1913 }
1914
1915 for (; left && vleft--; i++, first=0) {
1916 unsigned long lval;
1917 bool neg;
1918
1919 if (write) {
1920 left -= proc_skip_spaces(&kbuf);
1921
J. R. Okajima563b0462010-05-25 16:10:14 -07001922 if (!left)
1923 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001924 err = proc_get_long(&kbuf, &left, &lval, &neg,
1925 proc_wspace_sep,
1926 sizeof(proc_wspace_sep), NULL);
1927 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001929 if (conv(&neg, &lval, i, 1, data)) {
1930 err = -EINVAL;
1931 break;
1932 }
1933 } else {
1934 if (conv(&neg, &lval, i, 0, data)) {
1935 err = -EINVAL;
1936 break;
1937 }
1938 if (!first)
1939 err = proc_put_char(&buffer, &left, '\t');
1940 if (err)
1941 break;
1942 err = proc_put_long(&buffer, &left, lval, neg);
1943 if (err)
1944 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001945 }
1946 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001947
1948 if (!write && !first && left && !err)
1949 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001950 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001951 left -= proc_skip_spaces(&kbuf);
1952free:
1953 if (write) {
1954 free_page(page);
1955 if (first)
1956 return err ? : -EINVAL;
1957 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 *lenp -= left;
1959 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001960 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961}
1962
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001963static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001964 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001965 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001966 int write, void *data),
1967 void *data)
1968{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001969 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001970 buffer, lenp, ppos, conv, data);
1971}
1972
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973/**
1974 * proc_dointvec - read a vector of integers
1975 * @table: the sysctl table
1976 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 * @buffer: the user buffer
1978 * @lenp: the size of the user buffer
1979 * @ppos: file position
1980 *
1981 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1982 * values from/to the user buffer, treated as an ASCII string.
1983 *
1984 * Returns 0 on success.
1985 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001986int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987 void __user *buffer, size_t *lenp, loff_t *ppos)
1988{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001989 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990 NULL,NULL);
1991}
1992
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001993/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001994 * Taint values can only be increased
1995 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001996 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001997static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001998 void __user *buffer, size_t *lenp, loff_t *ppos)
1999{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002000 struct ctl_table t;
2001 unsigned long tmptaint = get_taint();
2002 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002003
Bastian Blank91fcd412007-04-23 14:41:14 -07002004 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002005 return -EPERM;
2006
Andi Kleen25ddbb12008-10-15 22:01:41 -07002007 t = *table;
2008 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002009 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002010 if (err < 0)
2011 return err;
2012
2013 if (write) {
2014 /*
2015 * Poor man's atomic or. Not worth adding a primitive
2016 * to everyone's atomic.h for this
2017 */
2018 int i;
2019 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2020 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302021 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002022 }
2023 }
2024
2025 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002026}
2027
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002028#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002029static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002030 void __user *buffer, size_t *lenp, loff_t *ppos)
2031{
2032 if (write && !capable(CAP_SYS_ADMIN))
2033 return -EPERM;
2034
2035 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2036}
2037#endif
2038
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039struct do_proc_dointvec_minmax_conv_param {
2040 int *min;
2041 int *max;
2042};
2043
Amerigo Wang00b7c332010-05-05 00:26:45 +00002044static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2045 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046 int write, void *data)
2047{
2048 struct do_proc_dointvec_minmax_conv_param *param = data;
2049 if (write) {
2050 int val = *negp ? -*lvalp : *lvalp;
2051 if ((param->min && *param->min > val) ||
2052 (param->max && *param->max < val))
2053 return -EINVAL;
2054 *valp = val;
2055 } else {
2056 int val = *valp;
2057 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002058 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 *lvalp = (unsigned long)-val;
2060 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002061 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062 *lvalp = (unsigned long)val;
2063 }
2064 }
2065 return 0;
2066}
2067
2068/**
2069 * proc_dointvec_minmax - read a vector of integers with min/max values
2070 * @table: the sysctl table
2071 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002072 * @buffer: the user buffer
2073 * @lenp: the size of the user buffer
2074 * @ppos: file position
2075 *
2076 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2077 * values from/to the user buffer, treated as an ASCII string.
2078 *
2079 * This routine will ensure the values are within the range specified by
2080 * table->extra1 (min) and table->extra2 (max).
2081 *
2082 * Returns 0 on success.
2083 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002084int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 void __user *buffer, size_t *lenp, loff_t *ppos)
2086{
2087 struct do_proc_dointvec_minmax_conv_param param = {
2088 .min = (int *) table->extra1,
2089 .max = (int *) table->extra2,
2090 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002091 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092 do_proc_dointvec_minmax_conv, &param);
2093}
2094
Kees Cook54b50192012-07-30 14:39:18 -07002095static void validate_coredump_safety(void)
2096{
Alex Kelly046d6622012-10-04 17:15:23 -07002097#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002098 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002099 core_pattern[0] != '/' && core_pattern[0] != '|') {
2100 printk(KERN_WARNING "Unsafe core_pattern used with "\
2101 "suid_dumpable=2. Pipe handler or fully qualified "\
2102 "core dump path required.\n");
2103 }
Alex Kelly046d6622012-10-04 17:15:23 -07002104#endif
Kees Cook54b50192012-07-30 14:39:18 -07002105}
2106
2107static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2108 void __user *buffer, size_t *lenp, loff_t *ppos)
2109{
2110 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2111 if (!error)
2112 validate_coredump_safety();
2113 return error;
2114}
2115
Alex Kelly046d6622012-10-04 17:15:23 -07002116#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002117static int proc_dostring_coredump(struct ctl_table *table, int write,
2118 void __user *buffer, size_t *lenp, loff_t *ppos)
2119{
2120 int error = proc_dostring(table, write, buffer, lenp, ppos);
2121 if (!error)
2122 validate_coredump_safety();
2123 return error;
2124}
Alex Kelly046d6622012-10-04 17:15:23 -07002125#endif
Kees Cook54b50192012-07-30 14:39:18 -07002126
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002127static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128 void __user *buffer,
2129 size_t *lenp, loff_t *ppos,
2130 unsigned long convmul,
2131 unsigned long convdiv)
2132{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002133 unsigned long *i, *min, *max;
2134 int vleft, first = 1, err = 0;
2135 unsigned long page = 0;
2136 size_t left;
2137 char *kbuf;
2138
2139 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140 *lenp = 0;
2141 return 0;
2142 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002143
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002144 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145 min = (unsigned long *) table->extra1;
2146 max = (unsigned long *) table->extra2;
2147 vleft = table->maxlen / sizeof(unsigned long);
2148 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002149
2150 if (write) {
2151 if (left > PAGE_SIZE - 1)
2152 left = PAGE_SIZE - 1;
2153 page = __get_free_page(GFP_TEMPORARY);
2154 kbuf = (char *) page;
2155 if (!kbuf)
2156 return -ENOMEM;
2157 if (copy_from_user(kbuf, buffer, left)) {
2158 err = -EFAULT;
2159 goto free;
2160 }
2161 kbuf[left] = 0;
2162 }
2163
Eric Dumazet27b3d802010-10-07 12:59:29 -07002164 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002165 unsigned long val;
2166
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002168 bool neg;
2169
2170 left -= proc_skip_spaces(&kbuf);
2171
2172 err = proc_get_long(&kbuf, &left, &val, &neg,
2173 proc_wspace_sep,
2174 sizeof(proc_wspace_sep), NULL);
2175 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176 break;
2177 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 continue;
2179 if ((min && val < *min) || (max && val > *max))
2180 continue;
2181 *i = val;
2182 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002183 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 err = proc_put_char(&buffer, &left, '\t');
2186 err = proc_put_long(&buffer, &left, val, false);
2187 if (err)
2188 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189 }
2190 }
2191
Amerigo Wang00b7c332010-05-05 00:26:45 +00002192 if (!write && !first && left && !err)
2193 err = proc_put_char(&buffer, &left, '\n');
2194 if (write && !err)
2195 left -= proc_skip_spaces(&kbuf);
2196free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002198 free_page(page);
2199 if (first)
2200 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 *lenp -= left;
2203 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002204 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205}
2206
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002207static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002208 void __user *buffer,
2209 size_t *lenp, loff_t *ppos,
2210 unsigned long convmul,
2211 unsigned long convdiv)
2212{
2213 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002214 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002215}
2216
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217/**
2218 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2219 * @table: the sysctl table
2220 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 * @buffer: the user buffer
2222 * @lenp: the size of the user buffer
2223 * @ppos: file position
2224 *
2225 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2226 * values from/to the user buffer, treated as an ASCII string.
2227 *
2228 * This routine will ensure the values are within the range specified by
2229 * table->extra1 (min) and table->extra2 (max).
2230 *
2231 * Returns 0 on success.
2232 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002233int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 void __user *buffer, size_t *lenp, loff_t *ppos)
2235{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002236 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002237}
2238
2239/**
2240 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2241 * @table: the sysctl table
2242 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 * @buffer: the user buffer
2244 * @lenp: the size of the user buffer
2245 * @ppos: file position
2246 *
2247 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2248 * values from/to the user buffer, treated as an ASCII string. The values
2249 * are treated as milliseconds, and converted to jiffies when they are stored.
2250 *
2251 * This routine will ensure the values are within the range specified by
2252 * table->extra1 (min) and table->extra2 (max).
2253 *
2254 * Returns 0 on success.
2255 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002256int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 void __user *buffer,
2258 size_t *lenp, loff_t *ppos)
2259{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002260 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 lenp, ppos, HZ, 1000l);
2262}
2263
2264
Amerigo Wang00b7c332010-05-05 00:26:45 +00002265static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266 int *valp,
2267 int write, void *data)
2268{
2269 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002270 if (*lvalp > LONG_MAX / HZ)
2271 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2273 } else {
2274 int val = *valp;
2275 unsigned long lval;
2276 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 lval = (unsigned long)-val;
2279 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002280 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 lval = (unsigned long)val;
2282 }
2283 *lvalp = lval / HZ;
2284 }
2285 return 0;
2286}
2287
Amerigo Wang00b7c332010-05-05 00:26:45 +00002288static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 int *valp,
2290 int write, void *data)
2291{
2292 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002293 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2294 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2296 } else {
2297 int val = *valp;
2298 unsigned long lval;
2299 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 lval = (unsigned long)-val;
2302 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002303 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304 lval = (unsigned long)val;
2305 }
2306 *lvalp = jiffies_to_clock_t(lval);
2307 }
2308 return 0;
2309}
2310
Amerigo Wang00b7c332010-05-05 00:26:45 +00002311static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 int *valp,
2313 int write, void *data)
2314{
2315 if (write) {
2316 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2317 } else {
2318 int val = *valp;
2319 unsigned long lval;
2320 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002321 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 lval = (unsigned long)-val;
2323 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002324 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 lval = (unsigned long)val;
2326 }
2327 *lvalp = jiffies_to_msecs(lval);
2328 }
2329 return 0;
2330}
2331
2332/**
2333 * proc_dointvec_jiffies - read a vector of integers as seconds
2334 * @table: the sysctl table
2335 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 * @buffer: the user buffer
2337 * @lenp: the size of the user buffer
2338 * @ppos: file position
2339 *
2340 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2341 * values from/to the user buffer, treated as an ASCII string.
2342 * The values read are assumed to be in seconds, and are converted into
2343 * jiffies.
2344 *
2345 * Returns 0 on success.
2346 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002347int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 void __user *buffer, size_t *lenp, loff_t *ppos)
2349{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002350 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 do_proc_dointvec_jiffies_conv,NULL);
2352}
2353
2354/**
2355 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2356 * @table: the sysctl table
2357 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 * @buffer: the user buffer
2359 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002360 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361 *
2362 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2363 * values from/to the user buffer, treated as an ASCII string.
2364 * The values read are assumed to be in 1/USER_HZ seconds, and
2365 * are converted into jiffies.
2366 *
2367 * Returns 0 on success.
2368 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002369int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 void __user *buffer, size_t *lenp, loff_t *ppos)
2371{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002372 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373 do_proc_dointvec_userhz_jiffies_conv,NULL);
2374}
2375
2376/**
2377 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2378 * @table: the sysctl table
2379 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 * @buffer: the user buffer
2381 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002382 * @ppos: file position
2383 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 *
2385 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2386 * values from/to the user buffer, treated as an ASCII string.
2387 * The values read are assumed to be in 1/1000 seconds, and
2388 * are converted into jiffies.
2389 *
2390 * Returns 0 on success.
2391 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002392int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 void __user *buffer, size_t *lenp, loff_t *ppos)
2394{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002395 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 do_proc_dointvec_ms_jiffies_conv, NULL);
2397}
2398
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002399static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002400 void __user *buffer, size_t *lenp, loff_t *ppos)
2401{
2402 struct pid *new_pid;
2403 pid_t tmp;
2404 int r;
2405
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002406 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002407
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002408 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002409 lenp, ppos, NULL, NULL);
2410 if (r || !write)
2411 return r;
2412
2413 new_pid = find_get_pid(tmp);
2414 if (!new_pid)
2415 return -ESRCH;
2416
2417 put_pid(xchg(&cad_pid, new_pid));
2418 return 0;
2419}
2420
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002421/**
2422 * proc_do_large_bitmap - read/write from/to a large bitmap
2423 * @table: the sysctl table
2424 * @write: %TRUE if this is a write to the sysctl file
2425 * @buffer: the user buffer
2426 * @lenp: the size of the user buffer
2427 * @ppos: file position
2428 *
2429 * The bitmap is stored at table->data and the bitmap length (in bits)
2430 * in table->maxlen.
2431 *
2432 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2433 * large bitmaps may be represented in a compact manner. Writing into
2434 * the file will clear the bitmap then update it with the given input.
2435 *
2436 * Returns 0 on success.
2437 */
2438int proc_do_large_bitmap(struct ctl_table *table, int write,
2439 void __user *buffer, size_t *lenp, loff_t *ppos)
2440{
2441 int err = 0;
2442 bool first = 1;
2443 size_t left = *lenp;
2444 unsigned long bitmap_len = table->maxlen;
2445 unsigned long *bitmap = (unsigned long *) table->data;
2446 unsigned long *tmp_bitmap = NULL;
2447 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2448
2449 if (!bitmap_len || !left || (*ppos && !write)) {
2450 *lenp = 0;
2451 return 0;
2452 }
2453
2454 if (write) {
2455 unsigned long page = 0;
2456 char *kbuf;
2457
2458 if (left > PAGE_SIZE - 1)
2459 left = PAGE_SIZE - 1;
2460
2461 page = __get_free_page(GFP_TEMPORARY);
2462 kbuf = (char *) page;
2463 if (!kbuf)
2464 return -ENOMEM;
2465 if (copy_from_user(kbuf, buffer, left)) {
2466 free_page(page);
2467 return -EFAULT;
2468 }
2469 kbuf[left] = 0;
2470
2471 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2472 GFP_KERNEL);
2473 if (!tmp_bitmap) {
2474 free_page(page);
2475 return -ENOMEM;
2476 }
2477 proc_skip_char(&kbuf, &left, '\n');
2478 while (!err && left) {
2479 unsigned long val_a, val_b;
2480 bool neg;
2481
2482 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2483 sizeof(tr_a), &c);
2484 if (err)
2485 break;
2486 if (val_a >= bitmap_len || neg) {
2487 err = -EINVAL;
2488 break;
2489 }
2490
2491 val_b = val_a;
2492 if (left) {
2493 kbuf++;
2494 left--;
2495 }
2496
2497 if (c == '-') {
2498 err = proc_get_long(&kbuf, &left, &val_b,
2499 &neg, tr_b, sizeof(tr_b),
2500 &c);
2501 if (err)
2502 break;
2503 if (val_b >= bitmap_len || neg ||
2504 val_a > val_b) {
2505 err = -EINVAL;
2506 break;
2507 }
2508 if (left) {
2509 kbuf++;
2510 left--;
2511 }
2512 }
2513
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002514 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002515 first = 0;
2516 proc_skip_char(&kbuf, &left, '\n');
2517 }
2518 free_page(page);
2519 } else {
2520 unsigned long bit_a, bit_b = 0;
2521
2522 while (left) {
2523 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2524 if (bit_a >= bitmap_len)
2525 break;
2526 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2527 bit_a + 1) - 1;
2528
2529 if (!first) {
2530 err = proc_put_char(&buffer, &left, ',');
2531 if (err)
2532 break;
2533 }
2534 err = proc_put_long(&buffer, &left, bit_a, false);
2535 if (err)
2536 break;
2537 if (bit_a != bit_b) {
2538 err = proc_put_char(&buffer, &left, '-');
2539 if (err)
2540 break;
2541 err = proc_put_long(&buffer, &left, bit_b, false);
2542 if (err)
2543 break;
2544 }
2545
2546 first = 0; bit_b++;
2547 }
2548 if (!err)
2549 err = proc_put_char(&buffer, &left, '\n');
2550 }
2551
2552 if (!err) {
2553 if (write) {
2554 if (*ppos)
2555 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2556 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002557 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002558 }
2559 kfree(tmp_bitmap);
2560 *lenp -= left;
2561 *ppos += *lenp;
2562 return 0;
2563 } else {
2564 kfree(tmp_bitmap);
2565 return err;
2566 }
2567}
2568
Jovi Zhang55610502011-01-12 17:00:45 -08002569#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002571int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 void __user *buffer, size_t *lenp, loff_t *ppos)
2573{
2574 return -ENOSYS;
2575}
2576
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002577int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002578 void __user *buffer, size_t *lenp, loff_t *ppos)
2579{
2580 return -ENOSYS;
2581}
2582
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002583int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 void __user *buffer, size_t *lenp, loff_t *ppos)
2585{
2586 return -ENOSYS;
2587}
2588
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002589int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 void __user *buffer, size_t *lenp, loff_t *ppos)
2591{
2592 return -ENOSYS;
2593}
2594
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002595int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 void __user *buffer, size_t *lenp, loff_t *ppos)
2597{
2598 return -ENOSYS;
2599}
2600
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002601int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 void __user *buffer, size_t *lenp, loff_t *ppos)
2603{
2604 return -ENOSYS;
2605}
2606
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002607int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 void __user *buffer, size_t *lenp, loff_t *ppos)
2609{
2610 return -ENOSYS;
2611}
2612
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002613int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 void __user *buffer,
2615 size_t *lenp, loff_t *ppos)
2616{
2617 return -ENOSYS;
2618}
2619
2620
Jovi Zhang55610502011-01-12 17:00:45 -08002621#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623/*
2624 * No sense putting this after each symbol definition, twice,
2625 * exception granted :-)
2626 */
2627EXPORT_SYMBOL(proc_dointvec);
2628EXPORT_SYMBOL(proc_dointvec_jiffies);
2629EXPORT_SYMBOL(proc_dointvec_minmax);
2630EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2631EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2632EXPORT_SYMBOL(proc_dostring);
2633EXPORT_SYMBOL(proc_doulongvec_minmax);
2634EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);