blob: 096db7452cbd29c8250a49741d3c8b210b82cf74 [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>
Kees Cook79847542014-01-23 15:55:59 -080065#include <linux/kexec.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67#include <asm/uaccess.h>
68#include <asm/processor.h>
69
Andi Kleen29cbc782006-09-30 01:47:55 +020070#ifdef CONFIG_X86
71#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010072#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010073#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020074#endif
David Howellsd550bbd2012-03-28 18:30:03 +010075#ifdef CONFIG_SPARC
76#include <asm/setup.h>
77#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080078#ifdef CONFIG_BSD_PROCESS_ACCT
79#include <linux/acct.h>
80#endif
Dave Young4f0e0562010-03-10 15:24:09 -080081#ifdef CONFIG_RT_MUTEXES
82#include <linux/rtmutex.h>
83#endif
Dave Young2edf5e42010-03-10 15:24:10 -080084#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
85#include <linux/lockdep.h>
86#endif
Dave Young15485a42010-03-10 15:24:07 -080087#ifdef CONFIG_CHR_DEV_SG
88#include <scsi/sg.h>
89#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020090
Don Zickus58687ac2010-05-07 17:11:44 -040091#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050092#include <linux/nmi.h>
93#endif
94
Eric W. Biederman7058cb02007-10-18 03:05:58 -070095
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#if defined(CONFIG_SYSCTL)
97
98/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700100extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700101#ifdef CONFIG_COREDUMP
102extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700104extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700105#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800108extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200109extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400111extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200115#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200116extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200117#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400120#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121static int sixty = 60;
122#endif
123
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700125static int __maybe_unused one = 1;
126static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700127static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700133
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700134/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
135static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
138static int maxolduid = 65535;
139static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800140static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700143static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Dave Youngd14f1722010-02-25 20:28:57 -0500145#ifdef CONFIG_INOTIFY_USER
146#include <linux/inotify.h>
147#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700148#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#endif
150
David S. Miller08714202008-11-16 23:49:24 -0800151#ifdef CONFIG_SPARC64
152extern int sysctl_tsb_ratio;
153#endif
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#ifdef __hppa__
156extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530157#endif
158
159#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160extern 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 */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100192static int __sysrq_enabled = CONFIG_MAGIC_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 Zijlstra4b96a292012-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 {
373 .procname = "numa_balancing_scan_period_max_ms",
374 .data = &sysctl_numa_balancing_scan_period_max,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = proc_dointvec,
378 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200379 {
380 .procname = "numa_balancing_scan_size_mb",
381 .data = &sysctl_numa_balancing_scan_size,
382 .maxlen = sizeof(unsigned int),
383 .mode = 0644,
384 .proc_handler = proc_dointvec,
385 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100386 {
Rik van Rielde1c9ce62013-10-07 11:29:39 +0100387 .procname = "numa_balancing_migrate_deferred",
388 .data = &sysctl_numa_balancing_migrate_deferred,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = proc_dointvec,
392 },
Andi Kleen54a43d52014-01-23 15:53:13 -0800393 {
394 .procname = "numa_balancing",
395 .data = NULL, /* filled in by handler */
396 .maxlen = sizeof(unsigned int),
397 .mode = 0644,
398 .proc_handler = sysctl_numa_balancing,
399 .extra1 = &zero,
400 .extra2 = &one,
401 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200402#endif /* CONFIG_NUMA_BALANCING */
403#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200404 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100405 .procname = "sched_rt_period_us",
406 .data = &sysctl_sched_rt_period,
407 .maxlen = sizeof(unsigned int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100410 },
411 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100412 .procname = "sched_rt_runtime_us",
413 .data = &sysctl_sched_rt_runtime,
414 .maxlen = sizeof(int),
415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800416 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100417 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600418 {
419 .procname = "sched_rr_timeslice_ms",
420 .data = &sched_rr_timeslice,
421 .maxlen = sizeof(int),
422 .mode = 0644,
423 .proc_handler = sched_rr_handler,
424 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100425#ifdef CONFIG_SCHED_AUTOGROUP
426 {
427 .procname = "sched_autogroup_enabled",
428 .data = &sysctl_sched_autogroup_enabled,
429 .maxlen = sizeof(unsigned int),
430 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800431 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100432 .extra1 = &zero,
433 .extra2 = &one,
434 },
435#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700436#ifdef CONFIG_CFS_BANDWIDTH
437 {
438 .procname = "sched_cfs_bandwidth_slice_us",
439 .data = &sysctl_sched_cfs_bandwidth_slice,
440 .maxlen = sizeof(unsigned int),
441 .mode = 0644,
442 .proc_handler = proc_dointvec_minmax,
443 .extra1 = &one,
444 },
445#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446#ifdef CONFIG_PROVE_LOCKING
447 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700448 .procname = "prove_locking",
449 .data = &prove_locking,
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
455#ifdef CONFIG_LOCK_STAT
456 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700457 .procname = "lock_stat",
458 .data = &lock_stat,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700462 },
463#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 .procname = "panic",
466 .data = &panic_timeout,
467 .maxlen = sizeof(int),
468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800469 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 },
Alex Kelly046d6622012-10-04 17:15:23 -0700471#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "core_uses_pid",
474 .data = &core_uses_pid,
475 .maxlen = sizeof(int),
476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800477 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "core_pattern",
481 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700482 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700484 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
Neil Hormana2939802009-09-23 15:56:56 -0700486 {
Neil Hormana2939802009-09-23 15:56:56 -0700487 .procname = "core_pipe_limit",
488 .data = &core_pipe_limit,
489 .maxlen = sizeof(unsigned int),
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700492 },
Alex Kelly046d6622012-10-04 17:15:23 -0700493#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800494#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700497 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800501#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100502#ifdef CONFIG_LATENCYTOP
503 {
504 .procname = "latencytop",
505 .data = &latencytop_enabled,
506 .maxlen = sizeof(int),
507 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800508 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100509 },
510#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511#ifdef CONFIG_BLK_DEV_INITRD
512 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 .procname = "real-root-dev",
514 .data = &real_root_dev,
515 .maxlen = sizeof(int),
516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800517 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 },
519#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700520 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700521 .procname = "print-fatal-signals",
522 .data = &print_fatal_signals,
523 .maxlen = sizeof(int),
524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700526 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700527#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .procname = "reboot-cmd",
530 .data = reboot_command,
531 .maxlen = 256,
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 .procname = "stop-a",
537 .data = &stop_a_enabled,
538 .maxlen = sizeof (int),
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 },
542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .procname = "scons-poweroff",
544 .data = &scons_pwroff,
545 .maxlen = sizeof (int),
546 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800547 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 },
549#endif
David S. Miller08714202008-11-16 23:49:24 -0800550#ifdef CONFIG_SPARC64
551 {
David S. Miller08714202008-11-16 23:49:24 -0800552 .procname = "tsb-ratio",
553 .data = &sysctl_tsb_ratio,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800557 },
558#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559#ifdef __hppa__
560 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 .procname = "soft-power",
562 .data = &pwrsw_enabled,
563 .maxlen = sizeof (int),
564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800565 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530567#endif
568#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "unaligned-trap",
571 .data = &unaligned_enabled,
572 .maxlen = sizeof (int),
573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 },
576#endif
577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "ctrl-alt-del",
579 .data = &C_A_D,
580 .maxlen = sizeof(int),
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400584#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200585 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200586 .procname = "ftrace_enabled",
587 .data = &ftrace_enabled,
588 .maxlen = sizeof(int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200591 },
592#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500593#ifdef CONFIG_STACK_TRACER
594 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500595 .procname = "stack_tracer_enabled",
596 .data = &stack_tracer_enabled,
597 .maxlen = sizeof(int),
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500600 },
601#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400602#ifdef CONFIG_TRACING
603 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100604 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400605 .data = &ftrace_dump_on_oops,
606 .maxlen = sizeof(int),
607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400609 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400610 {
611 .procname = "traceoff_on_warning",
612 .data = &__disable_trace_on_warning,
613 .maxlen = sizeof(__disable_trace_on_warning),
614 .mode = 0644,
615 .proc_handler = proc_dointvec,
616 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400617#endif
Kees Cook79847542014-01-23 15:55:59 -0800618#ifdef CONFIG_KEXEC
619 {
620 .procname = "kexec_load_disabled",
621 .data = &kexec_load_disabled,
622 .maxlen = sizeof(int),
623 .mode = 0644,
624 /* only handle a transition from default "0" to "1" */
625 .proc_handler = proc_dointvec_minmax,
626 .extra1 = &one,
627 .extra2 = &one,
628 },
629#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200630#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 .procname = "modprobe",
633 .data = &modprobe_path,
634 .maxlen = KMOD_PATH_LEN,
635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800636 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 },
Kees Cook3d433212009-04-02 15:49:29 -0700638 {
Kees Cook3d433212009-04-02 15:49:29 -0700639 .procname = "modules_disabled",
640 .data = &modules_disabled,
641 .maxlen = sizeof(int),
642 .mode = 0644,
643 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800644 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700645 .extra1 = &one,
646 .extra2 = &one,
647 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500649
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100652 .data = &uevent_helper,
653 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800655 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500657
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658#ifdef CONFIG_CHR_DEV_SG
659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .procname = "sg-big-buff",
661 .data = &sg_big_buff,
662 .maxlen = sizeof (int),
663 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800664 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 },
666#endif
667#ifdef CONFIG_BSD_PROCESS_ACCT
668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "acct",
670 .data = &acct_parm,
671 .maxlen = 3*sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676#ifdef CONFIG_MAGIC_SYSRQ
677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800679 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 .maxlen = sizeof (int),
681 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700682 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 },
684#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700685#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700688 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .maxlen = sizeof (int),
690 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800691 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700693#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .procname = "threads-max",
696 .data = &max_threads,
697 .maxlen = sizeof(int),
698 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800699 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 },
701 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .procname = "random",
703 .mode = 0555,
704 .child = random_table,
705 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 {
Eric Paris17f60a72011-04-01 17:07:50 -0400707 .procname = "usermodehelper",
708 .mode = 0555,
709 .child = usermodehelper_table,
710 },
711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "overflowuid",
713 .data = &overflowuid,
714 .maxlen = sizeof(int),
715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 .extra1 = &minolduid,
718 .extra2 = &maxolduid,
719 },
720 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .procname = "overflowgid",
722 .data = &overflowgid,
723 .maxlen = sizeof(int),
724 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800725 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 .extra1 = &minolduid,
727 .extra2 = &maxolduid,
728 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800729#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730#ifdef CONFIG_MATHEMU
731 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 .procname = "ieee_emulation_warnings",
733 .data = &sysctl_ieee_emulation_warnings,
734 .maxlen = sizeof(int),
735 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800736 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 },
738#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200741 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .maxlen = sizeof(int),
743 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800744 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 },
746#endif
747 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .procname = "pid_max",
749 .data = &pid_max,
750 .maxlen = sizeof (int),
751 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800752 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .extra1 = &pid_max_min,
754 .extra2 = &pid_max_max,
755 },
756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "panic_on_oops",
758 .data = &panic_on_oops,
759 .maxlen = sizeof(int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800763#if defined CONFIG_PRINTK
764 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800765 .procname = "printk",
766 .data = &console_loglevel,
767 .maxlen = 4*sizeof(int),
768 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800769 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800770 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700773 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 .maxlen = sizeof(int),
775 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800776 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 },
778 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700780 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 .maxlen = sizeof(int),
782 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800783 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 },
Dave Youngaf913222009-09-22 16:43:33 -0700785 {
Dave Youngaf913222009-09-22 16:43:33 -0700786 .procname = "printk_delay",
787 .data = &printk_delay_msec,
788 .maxlen = sizeof(int),
789 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800790 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700791 .extra1 = &zero,
792 .extra2 = &ten_thousand,
793 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800795 .procname = "dmesg_restrict",
796 .data = &dmesg_restrict,
797 .maxlen = sizeof(int),
798 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700799 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800800 .extra1 = &zero,
801 .extra2 = &one,
802 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800803 {
804 .procname = "kptr_restrict",
805 .data = &kptr_restrict,
806 .maxlen = sizeof(int),
807 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700808 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800809 .extra1 = &zero,
810 .extra2 = &two,
811 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800812#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800813 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 .procname = "ngroups_max",
815 .data = &ngroups_max,
816 .maxlen = sizeof (int),
817 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800818 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 },
Dan Ballard73efc032011-10-31 17:11:20 -0700820 {
821 .procname = "cap_last_cap",
822 .data = (void *)&cap_last_cap,
823 .maxlen = sizeof(int),
824 .mode = 0444,
825 .proc_handler = proc_dointvec,
826 },
Don Zickus58687ac2010-05-07 17:11:44 -0400827#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500828 {
Don Zickus58687ac2010-05-07 17:11:44 -0400829 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200830 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500831 .maxlen = sizeof (int),
832 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700833 .proc_handler = proc_dowatchdog,
834 .extra1 = &zero,
835 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400836 },
837 {
838 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700839 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400840 .maxlen = sizeof(int),
841 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700842 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800843 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400844 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500845 },
Don Zickus2508ce12010-05-07 17:11:46 -0400846 {
847 .procname = "softlockup_panic",
848 .data = &softlockup_panic,
849 .maxlen = sizeof(int),
850 .mode = 0644,
851 .proc_handler = proc_dointvec_minmax,
852 .extra1 = &zero,
853 .extra2 = &one,
854 },
Don Zickus5dc30552010-11-29 17:07:17 -0500855 {
856 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200857 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500858 .maxlen = sizeof (int),
859 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700860 .proc_handler = proc_dowatchdog,
861 .extra1 = &zero,
862 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500863 },
864#endif
865#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
866 {
867 .procname = "unknown_nmi_panic",
868 .data = &unknown_nmi_panic,
869 .maxlen = sizeof (int),
870 .mode = 0644,
871 .proc_handler = proc_dointvec,
872 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500873#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874#if defined(CONFIG_X86)
875 {
Don Zickus8da5add2006-09-26 10:52:27 +0200876 .procname = "panic_on_unrecovered_nmi",
877 .data = &panic_on_unrecovered_nmi,
878 .maxlen = sizeof(int),
879 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800880 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200881 },
882 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700883 .procname = "panic_on_io_nmi",
884 .data = &panic_on_io_nmi,
885 .maxlen = sizeof(int),
886 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800887 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700888 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900889#ifdef CONFIG_DEBUG_STACKOVERFLOW
890 {
891 .procname = "panic_on_stackoverflow",
892 .data = &sysctl_panic_on_stackoverflow,
893 .maxlen = sizeof(int),
894 .mode = 0644,
895 .proc_handler = proc_dointvec,
896 },
897#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700898 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 .procname = "bootloader_type",
900 .data = &bootloader_type,
901 .maxlen = sizeof (int),
902 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800903 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100905 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700906 .procname = "bootloader_version",
907 .data = &bootloader_version,
908 .maxlen = sizeof (int),
909 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800910 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700911 },
912 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100913 .procname = "kstack_depth_to_print",
914 .data = &kstack_depth_to_print,
915 .maxlen = sizeof(int),
916 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800917 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100918 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100919 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100920 .procname = "io_delay_type",
921 .data = &io_delay_type,
922 .maxlen = sizeof(int),
923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100925 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800927#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 .procname = "randomize_va_space",
930 .data = &randomize_va_space,
931 .maxlen = sizeof(int),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800935#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800936#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700937 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700938 .procname = "spin_retry",
939 .data = &spin_retry,
940 .maxlen = sizeof (int),
941 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800942 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700943 },
944#endif
Len Brown673d5b42007-07-28 03:33:16 -0400945#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800946 {
Pavel Machekc255d842006-02-20 18:27:58 -0800947 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700948 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800949 .maxlen = sizeof (unsigned long),
950 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800951 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800952 },
953#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530954#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800955 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800956 .procname = "ignore-unaligned-usertrap",
957 .data = &no_unaligned_warning,
958 .maxlen = sizeof (int),
959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800961 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530962#endif
963#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800964 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800965 .procname = "unaligned-dump-stack",
966 .data = &unaligned_dump_stack,
967 .maxlen = sizeof (int),
968 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800969 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800970 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800971#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800972#ifdef CONFIG_DETECT_HUNG_TASK
973 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800974 .procname = "hung_task_panic",
975 .data = &sysctl_hung_task_panic,
976 .maxlen = sizeof(int),
977 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800978 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800979 .extra1 = &zero,
980 .extra2 = &one,
981 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100982 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100983 .procname = "hung_task_check_count",
984 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800985 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100986 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800987 .proc_handler = proc_dointvec_minmax,
988 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100989 },
990 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100991 .procname = "hung_task_timeout_secs",
992 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100993 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100994 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800995 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100996 },
997 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100998 .procname = "hung_task_warnings",
999 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +01001000 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001001 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001002 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001003 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001004#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001005#ifdef CONFIG_COMPAT
1006 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001007 .procname = "compat-log",
1008 .data = &compat_log,
1009 .maxlen = sizeof (int),
1010 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001011 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001012 },
1013#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001014#ifdef CONFIG_RT_MUTEXES
1015 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001016 .procname = "max_lock_depth",
1017 .data = &max_lock_depth,
1018 .maxlen = sizeof(int),
1019 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001020 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001021 },
1022#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001023 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001024 .procname = "poweroff_cmd",
1025 .data = &poweroff_cmd,
1026 .maxlen = POWEROFF_CMD_PATH_LEN,
1027 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001028 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001029 },
David Howells0b77f5b2008-04-29 01:01:32 -07001030#ifdef CONFIG_KEYS
1031 {
David Howells0b77f5b2008-04-29 01:01:32 -07001032 .procname = "keys",
1033 .mode = 0555,
1034 .child = key_sysctls,
1035 },
1036#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001037#ifdef CONFIG_RCU_TORTURE_TEST
1038 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001039 .procname = "rcutorture_runnable",
1040 .data = &rcutorture_runnable,
1041 .maxlen = sizeof(int),
1042 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001043 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001044 },
1045#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001046#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001047 /*
1048 * User-space scripts rely on the existence of this file
1049 * as a feature check for perf_events being enabled.
1050 *
1051 * So it's an ABI, do not remove!
1052 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001053 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001054 .procname = "perf_event_paranoid",
1055 .data = &sysctl_perf_event_paranoid,
1056 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001057 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001058 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001059 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001060 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001061 .procname = "perf_event_mlock_kb",
1062 .data = &sysctl_perf_event_mlock,
1063 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001064 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001065 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001066 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001067 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001068 .procname = "perf_event_max_sample_rate",
1069 .data = &sysctl_perf_event_sample_rate,
1070 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001071 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001072 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001073 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001074 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001075 {
1076 .procname = "perf_cpu_time_max_percent",
1077 .data = &sysctl_perf_cpu_time_max_percent,
1078 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1079 .mode = 0644,
1080 .proc_handler = perf_cpu_time_max_percent_handler,
1081 .extra1 = &zero,
1082 .extra2 = &one_hundred,
1083 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001084#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001085#ifdef CONFIG_KMEMCHECK
1086 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001087 .procname = "kmemcheck",
1088 .data = &kmemcheck_enabled,
1089 .maxlen = sizeof(int),
1090 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001091 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001092 },
1093#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001094#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001095 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001096 .procname = "blk_iopoll",
1097 .data = &blk_iopoll_enabled,
1098 .maxlen = sizeof(int),
1099 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001100 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001101 },
Jens Axboecb684b52009-09-15 21:53:11 +02001102#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001103 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104};
1105
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001106static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 .procname = "overcommit_memory",
1109 .data = &sysctl_overcommit_memory,
1110 .maxlen = sizeof(sysctl_overcommit_memory),
1111 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001112 .proc_handler = proc_dointvec_minmax,
1113 .extra1 = &zero,
1114 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 },
1116 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001117 .procname = "panic_on_oom",
1118 .data = &sysctl_panic_on_oom,
1119 .maxlen = sizeof(sysctl_panic_on_oom),
1120 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001121 .proc_handler = proc_dointvec_minmax,
1122 .extra1 = &zero,
1123 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001124 },
1125 {
David Rientjesfe071d72007-10-16 23:25:56 -07001126 .procname = "oom_kill_allocating_task",
1127 .data = &sysctl_oom_kill_allocating_task,
1128 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001131 },
1132 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001133 .procname = "oom_dump_tasks",
1134 .data = &sysctl_oom_dump_tasks,
1135 .maxlen = sizeof(sysctl_oom_dump_tasks),
1136 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001137 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001138 },
1139 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .procname = "overcommit_ratio",
1141 .data = &sysctl_overcommit_ratio,
1142 .maxlen = sizeof(sysctl_overcommit_ratio),
1143 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001144 .proc_handler = overcommit_ratio_handler,
1145 },
1146 {
1147 .procname = "overcommit_kbytes",
1148 .data = &sysctl_overcommit_kbytes,
1149 .maxlen = sizeof(sysctl_overcommit_kbytes),
1150 .mode = 0644,
1151 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 },
1153 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .procname = "page-cluster",
1155 .data = &page_cluster,
1156 .maxlen = sizeof(int),
1157 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001158 .proc_handler = proc_dointvec_minmax,
1159 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 },
1161 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 .procname = "dirty_background_ratio",
1163 .data = &dirty_background_ratio,
1164 .maxlen = sizeof(dirty_background_ratio),
1165 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001166 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 .extra1 = &zero,
1168 .extra2 = &one_hundred,
1169 },
1170 {
David Rientjes2da02992009-01-06 14:39:31 -08001171 .procname = "dirty_background_bytes",
1172 .data = &dirty_background_bytes,
1173 .maxlen = sizeof(dirty_background_bytes),
1174 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001175 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001176 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001177 },
1178 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .procname = "dirty_ratio",
1180 .data = &vm_dirty_ratio,
1181 .maxlen = sizeof(vm_dirty_ratio),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 .extra1 = &zero,
1185 .extra2 = &one_hundred,
1186 },
1187 {
David Rientjes2da02992009-01-06 14:39:31 -08001188 .procname = "dirty_bytes",
1189 .data = &vm_dirty_bytes,
1190 .maxlen = sizeof(vm_dirty_bytes),
1191 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001192 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001193 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001194 },
1195 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001197 .data = &dirty_writeback_interval,
1198 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001200 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 },
1202 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001204 .data = &dirty_expire_interval,
1205 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001207 .proc_handler = proc_dointvec_minmax,
1208 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 },
1210 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001211 .procname = "nr_pdflush_threads",
1212 .mode = 0444 /* read-only */,
1213 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214 },
1215 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 .procname = "swappiness",
1217 .data = &vm_swappiness,
1218 .maxlen = sizeof(vm_swappiness),
1219 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001220 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 .extra1 = &zero,
1222 .extra2 = &one_hundred,
1223 },
1224#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001227 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 .maxlen = sizeof(unsigned long),
1229 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001230 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 .extra1 = (void *)&hugetlb_zero,
1232 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001233 },
1234#ifdef CONFIG_NUMA
1235 {
1236 .procname = "nr_hugepages_mempolicy",
1237 .data = NULL,
1238 .maxlen = sizeof(unsigned long),
1239 .mode = 0644,
1240 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1241 .extra1 = (void *)&hugetlb_zero,
1242 .extra2 = (void *)&hugetlb_infinity,
1243 },
1244#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 .procname = "hugetlb_shm_group",
1247 .data = &sysctl_hugetlb_shm_group,
1248 .maxlen = sizeof(gid_t),
1249 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001250 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 },
Mel Gorman396faf02007-07-17 04:03:13 -07001252 {
Mel Gorman396faf02007-07-17 04:03:13 -07001253 .procname = "hugepages_treat_as_movable",
1254 .data = &hugepages_treat_as_movable,
1255 .maxlen = sizeof(int),
1256 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001257 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001258 },
Adam Litke54f9f802007-10-16 01:26:20 -07001259 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001260 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001261 .data = NULL,
1262 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001263 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001264 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001265 .extra1 = (void *)&hugetlb_zero,
1266 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001267 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268#endif
1269 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 .procname = "lowmem_reserve_ratio",
1271 .data = &sysctl_lowmem_reserve_ratio,
1272 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1273 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001274 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 },
1276 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001277 .procname = "drop_caches",
1278 .data = &sysctl_drop_caches,
1279 .maxlen = sizeof(int),
1280 .mode = 0644,
1281 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001282 .extra1 = &one,
1283 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001284 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001285#ifdef CONFIG_COMPACTION
1286 {
1287 .procname = "compact_memory",
1288 .data = &sysctl_compact_memory,
1289 .maxlen = sizeof(int),
1290 .mode = 0200,
1291 .proc_handler = sysctl_compaction_handler,
1292 },
Mel Gorman5e771902010-05-24 14:32:31 -07001293 {
1294 .procname = "extfrag_threshold",
1295 .data = &sysctl_extfrag_threshold,
1296 .maxlen = sizeof(int),
1297 .mode = 0644,
1298 .proc_handler = sysctl_extfrag_handler,
1299 .extra1 = &min_extfrag_threshold,
1300 .extra2 = &max_extfrag_threshold,
1301 },
1302
Mel Gorman76ab0f52010-05-24 14:32:28 -07001303#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001304 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 .procname = "min_free_kbytes",
1306 .data = &min_free_kbytes,
1307 .maxlen = sizeof(min_free_kbytes),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 .extra1 = &zero,
1311 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001312 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001313 .procname = "percpu_pagelist_fraction",
1314 .data = &percpu_pagelist_fraction,
1315 .maxlen = sizeof(percpu_pagelist_fraction),
1316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001317 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001318 .extra1 = &min_percpu_pagelist_fract,
1319 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320#ifdef CONFIG_MMU
1321 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 .procname = "max_map_count",
1323 .data = &sysctl_max_map_count,
1324 .maxlen = sizeof(sysctl_max_map_count),
1325 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001326 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001327 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001329#else
1330 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001331 .procname = "nr_trim_pages",
1332 .data = &sysctl_nr_trim_pages,
1333 .maxlen = sizeof(sysctl_nr_trim_pages),
1334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001335 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001336 .extra1 = &zero,
1337 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338#endif
1339 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340 .procname = "laptop_mode",
1341 .data = &laptop_mode,
1342 .maxlen = sizeof(laptop_mode),
1343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001344 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 },
1346 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .procname = "block_dump",
1348 .data = &block_dump,
1349 .maxlen = sizeof(block_dump),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 .extra1 = &zero,
1353 },
1354 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .procname = "vfs_cache_pressure",
1356 .data = &sysctl_vfs_cache_pressure,
1357 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001359 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 .extra1 = &zero,
1361 },
1362#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1363 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364 .procname = "legacy_va_layout",
1365 .data = &sysctl_legacy_va_layout,
1366 .maxlen = sizeof(sysctl_legacy_va_layout),
1367 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001368 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369 .extra1 = &zero,
1370 },
1371#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001372#ifdef CONFIG_NUMA
1373 {
Christoph Lameter17436602006-01-18 17:42:32 -08001374 .procname = "zone_reclaim_mode",
1375 .data = &zone_reclaim_mode,
1376 .maxlen = sizeof(zone_reclaim_mode),
1377 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001378 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001379 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001380 },
Christoph Lameter96146342006-07-03 00:24:13 -07001381 {
Christoph Lameter96146342006-07-03 00:24:13 -07001382 .procname = "min_unmapped_ratio",
1383 .data = &sysctl_min_unmapped_ratio,
1384 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1385 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001386 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001387 .extra1 = &zero,
1388 .extra2 = &one_hundred,
1389 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001390 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001391 .procname = "min_slab_ratio",
1392 .data = &sysctl_min_slab_ratio,
1393 .maxlen = sizeof(sysctl_min_slab_ratio),
1394 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001395 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001396 .extra1 = &zero,
1397 .extra2 = &one_hundred,
1398 },
Christoph Lameter17436602006-01-18 17:42:32 -08001399#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001400#ifdef CONFIG_SMP
1401 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001402 .procname = "stat_interval",
1403 .data = &sysctl_stat_interval,
1404 .maxlen = sizeof(sysctl_stat_interval),
1405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001406 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001407 },
1408#endif
David Howells6e141542009-12-15 19:27:45 +00001409#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001410 {
Eric Parised032182007-06-28 15:55:21 -04001411 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001412 .data = &dac_mmap_min_addr,
1413 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001415 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001416 },
David Howells6e141542009-12-15 19:27:45 +00001417#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001418#ifdef CONFIG_NUMA
1419 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001420 .procname = "numa_zonelist_order",
1421 .data = &numa_zonelist_order,
1422 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001424 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001425 },
1426#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001427#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001428 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001429 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001430 .procname = "vdso_enabled",
1431 .data = &vdso_enabled,
1432 .maxlen = sizeof(vdso_enabled),
1433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001434 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001435 .extra1 = &zero,
1436 },
1437#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001438#ifdef CONFIG_HIGHMEM
1439 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001440 .procname = "highmem_is_dirtyable",
1441 .data = &vm_highmem_is_dirtyable,
1442 .maxlen = sizeof(vm_highmem_is_dirtyable),
1443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001444 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001445 .extra1 = &zero,
1446 .extra2 = &one,
1447 },
1448#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001449 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001450 .procname = "scan_unevictable_pages",
1451 .data = &scan_unevictable_pages,
1452 .maxlen = sizeof(scan_unevictable_pages),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001455 },
Andi Kleen6a460792009-09-16 11:50:15 +02001456#ifdef CONFIG_MEMORY_FAILURE
1457 {
Andi Kleen6a460792009-09-16 11:50:15 +02001458 .procname = "memory_failure_early_kill",
1459 .data = &sysctl_memory_failure_early_kill,
1460 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1461 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001462 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001463 .extra1 = &zero,
1464 .extra2 = &one,
1465 },
1466 {
Andi Kleen6a460792009-09-16 11:50:15 +02001467 .procname = "memory_failure_recovery",
1468 .data = &sysctl_memory_failure_recovery,
1469 .maxlen = sizeof(sysctl_memory_failure_recovery),
1470 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001471 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001472 .extra1 = &zero,
1473 .extra2 = &one,
1474 },
1475#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001476 {
1477 .procname = "user_reserve_kbytes",
1478 .data = &sysctl_user_reserve_kbytes,
1479 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1480 .mode = 0644,
1481 .proc_handler = proc_doulongvec_minmax,
1482 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001483 {
1484 .procname = "admin_reserve_kbytes",
1485 .data = &sysctl_admin_reserve_kbytes,
1486 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1487 .mode = 0644,
1488 .proc_handler = proc_doulongvec_minmax,
1489 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001490 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491};
1492
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001493#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001494static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001495 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001496};
1497#endif
1498
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001499static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .procname = "inode-nr",
1502 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001503 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001505 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 },
1507 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 .procname = "inode-state",
1509 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001510 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001512 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 },
1514 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 .procname = "file-nr",
1516 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001517 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001519 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 },
1521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 .procname = "file-max",
1523 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001524 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001526 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 },
1528 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001529 .procname = "nr_open",
1530 .data = &sysctl_nr_open,
1531 .maxlen = sizeof(int),
1532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001533 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001534 .extra1 = &sysctl_nr_open_min,
1535 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001536 },
1537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 .procname = "dentry-state",
1539 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001540 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001542 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 },
1544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545 .procname = "overflowuid",
1546 .data = &fs_overflowuid,
1547 .maxlen = sizeof(int),
1548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001549 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 .extra1 = &minolduid,
1551 .extra2 = &maxolduid,
1552 },
1553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 .procname = "overflowgid",
1555 .data = &fs_overflowgid,
1556 .maxlen = sizeof(int),
1557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001558 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .extra1 = &minolduid,
1560 .extra2 = &maxolduid,
1561 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001562#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 .procname = "leases-enable",
1565 .data = &leases_enable,
1566 .maxlen = sizeof(int),
1567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001568 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001570#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571#ifdef CONFIG_DNOTIFY
1572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 .procname = "dir-notify-enable",
1574 .data = &dir_notify_enable,
1575 .maxlen = sizeof(int),
1576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001577 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 },
1579#endif
1580#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001581#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583 .procname = "lease-break-time",
1584 .data = &lease_break_time,
1585 .maxlen = sizeof(int),
1586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001587 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001589#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001590#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 .procname = "aio-nr",
1593 .data = &aio_nr,
1594 .maxlen = sizeof(aio_nr),
1595 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001596 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597 },
1598 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599 .procname = "aio-max-nr",
1600 .data = &aio_max_nr,
1601 .maxlen = sizeof(aio_max_nr),
1602 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001603 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001605#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001606#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001607 {
Robert Love0399cb02005-07-13 12:38:18 -04001608 .procname = "inotify",
1609 .mode = 0555,
1610 .child = inotify_table,
1611 },
1612#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001613#ifdef CONFIG_EPOLL
1614 {
1615 .procname = "epoll",
1616 .mode = 0555,
1617 .child = epoll_table,
1618 },
1619#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001621 {
Kees Cook800179c2012-07-25 17:29:07 -07001622 .procname = "protected_symlinks",
1623 .data = &sysctl_protected_symlinks,
1624 .maxlen = sizeof(int),
1625 .mode = 0600,
1626 .proc_handler = proc_dointvec_minmax,
1627 .extra1 = &zero,
1628 .extra2 = &one,
1629 },
1630 {
1631 .procname = "protected_hardlinks",
1632 .data = &sysctl_protected_hardlinks,
1633 .maxlen = sizeof(int),
1634 .mode = 0600,
1635 .proc_handler = proc_dointvec_minmax,
1636 .extra1 = &zero,
1637 .extra2 = &one,
1638 },
1639 {
Alan Coxd6e71142005-06-23 00:09:43 -07001640 .procname = "suid_dumpable",
1641 .data = &suid_dumpable,
1642 .maxlen = sizeof(int),
1643 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001644 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001645 .extra1 = &zero,
1646 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001647 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001648#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1649 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001650 .procname = "binfmt_misc",
1651 .mode = 0555,
1652 .child = binfmt_misc_table,
1653 },
1654#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001655 {
Jens Axboeff9da692010-06-03 14:54:39 +02001656 .procname = "pipe-max-size",
1657 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001658 .maxlen = sizeof(int),
1659 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001660 .proc_handler = &pipe_proc_fn,
1661 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001662 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001663 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664};
1665
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001666static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001667#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001668 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001669 .procname = "exception-trace",
1670 .data = &show_unhandled_signals,
1671 .maxlen = sizeof(int),
1672 .mode = 0644,
1673 .proc_handler = proc_dointvec
1674 },
1675#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001676#if defined(CONFIG_OPTPROBES)
1677 {
1678 .procname = "kprobes-optimization",
1679 .data = &sysctl_kprobes_optimization,
1680 .maxlen = sizeof(int),
1681 .mode = 0644,
1682 .proc_handler = proc_kprobes_optimization_handler,
1683 .extra1 = &zero,
1684 .extra2 = &one,
1685 },
1686#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001687 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688};
1689
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001690static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001691 { }
Robert Love0eeca282005-07-12 17:06:03 -04001692};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001694int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001695{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001696 struct ctl_table_header *hdr;
1697
1698 hdr = register_sysctl_table(sysctl_base_table);
1699 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001700 return 0;
1701}
1702
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001703#endif /* CONFIG_SYSCTL */
1704
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705/*
1706 * /proc/sys support
1707 */
1708
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001709#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001711static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001712 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001713 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001714{
1715 size_t len;
1716 char __user *p;
1717 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001718
1719 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001720 *lenp = 0;
1721 return 0;
1722 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001723
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001724 if (write) {
1725 len = 0;
1726 p = buffer;
1727 while (len < *lenp) {
1728 if (get_user(c, p++))
1729 return -EFAULT;
1730 if (c == 0 || c == '\n')
1731 break;
1732 len++;
1733 }
1734 if (len >= maxlen)
1735 len = maxlen-1;
1736 if(copy_from_user(data, buffer, len))
1737 return -EFAULT;
1738 ((char *) data)[len] = 0;
1739 *ppos += *lenp;
1740 } else {
1741 len = strlen(data);
1742 if (len > maxlen)
1743 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001744
1745 if (*ppos > len) {
1746 *lenp = 0;
1747 return 0;
1748 }
1749
1750 data += *ppos;
1751 len -= *ppos;
1752
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001753 if (len > *lenp)
1754 len = *lenp;
1755 if (len)
1756 if(copy_to_user(buffer, data, len))
1757 return -EFAULT;
1758 if (len < *lenp) {
1759 if(put_user('\n', ((char __user *) buffer) + len))
1760 return -EFAULT;
1761 len++;
1762 }
1763 *lenp = len;
1764 *ppos += len;
1765 }
1766 return 0;
1767}
1768
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769/**
1770 * proc_dostring - read a string sysctl
1771 * @table: the sysctl table
1772 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001773 * @buffer: the user buffer
1774 * @lenp: the size of the user buffer
1775 * @ppos: file position
1776 *
1777 * Reads/writes a string from/to the user buffer. If the kernel
1778 * buffer provided is not large enough to hold the string, the
1779 * string is truncated. The copied string is %NULL-terminated.
1780 * If the string is being read by the user process, it is copied
1781 * and a newline '\n' is added. It is truncated if the buffer is
1782 * not large enough.
1783 *
1784 * Returns 0 on success.
1785 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001786int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001787 void __user *buffer, size_t *lenp, loff_t *ppos)
1788{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001789 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001790 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001791}
1792
Amerigo Wang00b7c332010-05-05 00:26:45 +00001793static size_t proc_skip_spaces(char **buf)
1794{
1795 size_t ret;
1796 char *tmp = skip_spaces(*buf);
1797 ret = tmp - *buf;
1798 *buf = tmp;
1799 return ret;
1800}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001802static void proc_skip_char(char **buf, size_t *size, const char v)
1803{
1804 while (*size) {
1805 if (**buf != v)
1806 break;
1807 (*size)--;
1808 (*buf)++;
1809 }
1810}
1811
Amerigo Wang00b7c332010-05-05 00:26:45 +00001812#define TMPBUFLEN 22
1813/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001814 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001815 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001816 * @buf: a kernel buffer
1817 * @size: size of the kernel buffer
1818 * @val: this is where the number will be stored
1819 * @neg: set to %TRUE if number is negative
1820 * @perm_tr: a vector which contains the allowed trailers
1821 * @perm_tr_len: size of the perm_tr vector
1822 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001823 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001824 * In case of success %0 is returned and @buf and @size are updated with
1825 * the amount of bytes read. If @tr is non-NULL and a trailing
1826 * character exists (size is non-zero after returning from this
1827 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001828 */
1829static int proc_get_long(char **buf, size_t *size,
1830 unsigned long *val, bool *neg,
1831 const char *perm_tr, unsigned perm_tr_len, char *tr)
1832{
1833 int len;
1834 char *p, tmp[TMPBUFLEN];
1835
1836 if (!*size)
1837 return -EINVAL;
1838
1839 len = *size;
1840 if (len > TMPBUFLEN - 1)
1841 len = TMPBUFLEN - 1;
1842
1843 memcpy(tmp, *buf, len);
1844
1845 tmp[len] = 0;
1846 p = tmp;
1847 if (*p == '-' && *size > 1) {
1848 *neg = true;
1849 p++;
1850 } else
1851 *neg = false;
1852 if (!isdigit(*p))
1853 return -EINVAL;
1854
1855 *val = simple_strtoul(p, &p, 0);
1856
1857 len = p - tmp;
1858
1859 /* We don't know if the next char is whitespace thus we may accept
1860 * invalid integers (e.g. 1234...a) or two integers instead of one
1861 * (e.g. 123...1). So lets not allow such large numbers. */
1862 if (len == TMPBUFLEN - 1)
1863 return -EINVAL;
1864
1865 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1866 return -EINVAL;
1867
1868 if (tr && (len < *size))
1869 *tr = *p;
1870
1871 *buf += len;
1872 *size -= len;
1873
1874 return 0;
1875}
1876
1877/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001878 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001879 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001880 * @buf: the user buffer
1881 * @size: the size of the user buffer
1882 * @val: the integer to be converted
1883 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001884 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001885 * In case of success %0 is returned and @buf and @size are updated with
1886 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001887 */
1888static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1889 bool neg)
1890{
1891 int len;
1892 char tmp[TMPBUFLEN], *p = tmp;
1893
1894 sprintf(p, "%s%lu", neg ? "-" : "", val);
1895 len = strlen(tmp);
1896 if (len > *size)
1897 len = *size;
1898 if (copy_to_user(*buf, tmp, len))
1899 return -EFAULT;
1900 *size -= len;
1901 *buf += len;
1902 return 0;
1903}
1904#undef TMPBUFLEN
1905
1906static int proc_put_char(void __user **buf, size_t *size, char c)
1907{
1908 if (*size) {
1909 char __user **buffer = (char __user **)buf;
1910 if (put_user(c, *buffer))
1911 return -EFAULT;
1912 (*size)--, (*buffer)++;
1913 *buf = *buffer;
1914 }
1915 return 0;
1916}
1917
1918static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 int *valp,
1920 int write, void *data)
1921{
1922 if (write) {
1923 *valp = *negp ? -*lvalp : *lvalp;
1924 } else {
1925 int val = *valp;
1926 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001927 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 *lvalp = (unsigned long)-val;
1929 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001930 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931 *lvalp = (unsigned long)val;
1932 }
1933 }
1934 return 0;
1935}
1936
Amerigo Wang00b7c332010-05-05 00:26:45 +00001937static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1938
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001939static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001940 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001941 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001942 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001943 int write, void *data),
1944 void *data)
1945{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001946 int *i, vleft, first = 1, err = 0;
1947 unsigned long page = 0;
1948 size_t left;
1949 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950
Amerigo Wang00b7c332010-05-05 00:26:45 +00001951 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 *lenp = 0;
1953 return 0;
1954 }
1955
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001956 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 vleft = table->maxlen / sizeof(*i);
1958 left = *lenp;
1959
1960 if (!conv)
1961 conv = do_proc_dointvec_conv;
1962
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001964 if (left > PAGE_SIZE - 1)
1965 left = PAGE_SIZE - 1;
1966 page = __get_free_page(GFP_TEMPORARY);
1967 kbuf = (char *) page;
1968 if (!kbuf)
1969 return -ENOMEM;
1970 if (copy_from_user(kbuf, buffer, left)) {
1971 err = -EFAULT;
1972 goto free;
1973 }
1974 kbuf[left] = 0;
1975 }
1976
1977 for (; left && vleft--; i++, first=0) {
1978 unsigned long lval;
1979 bool neg;
1980
1981 if (write) {
1982 left -= proc_skip_spaces(&kbuf);
1983
J. R. Okajima563b0462010-05-25 16:10:14 -07001984 if (!left)
1985 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001986 err = proc_get_long(&kbuf, &left, &lval, &neg,
1987 proc_wspace_sep,
1988 sizeof(proc_wspace_sep), NULL);
1989 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001991 if (conv(&neg, &lval, i, 1, data)) {
1992 err = -EINVAL;
1993 break;
1994 }
1995 } else {
1996 if (conv(&neg, &lval, i, 0, data)) {
1997 err = -EINVAL;
1998 break;
1999 }
2000 if (!first)
2001 err = proc_put_char(&buffer, &left, '\t');
2002 if (err)
2003 break;
2004 err = proc_put_long(&buffer, &left, lval, neg);
2005 if (err)
2006 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 }
2008 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002009
2010 if (!write && !first && left && !err)
2011 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002012 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002013 left -= proc_skip_spaces(&kbuf);
2014free:
2015 if (write) {
2016 free_page(page);
2017 if (first)
2018 return err ? : -EINVAL;
2019 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020 *lenp -= left;
2021 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002022 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023}
2024
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002025static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002026 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002027 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002028 int write, void *data),
2029 void *data)
2030{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002031 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002032 buffer, lenp, ppos, conv, data);
2033}
2034
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035/**
2036 * proc_dointvec - read a vector of integers
2037 * @table: the sysctl table
2038 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 * @buffer: the user buffer
2040 * @lenp: the size of the user buffer
2041 * @ppos: file position
2042 *
2043 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2044 * values from/to the user buffer, treated as an ASCII string.
2045 *
2046 * Returns 0 on success.
2047 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002048int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049 void __user *buffer, size_t *lenp, loff_t *ppos)
2050{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002051 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 NULL,NULL);
2053}
2054
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002055/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002056 * Taint values can only be increased
2057 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002058 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002059static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002060 void __user *buffer, size_t *lenp, loff_t *ppos)
2061{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002062 struct ctl_table t;
2063 unsigned long tmptaint = get_taint();
2064 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002065
Bastian Blank91fcd412007-04-23 14:41:14 -07002066 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002067 return -EPERM;
2068
Andi Kleen25ddbb12008-10-15 22:01:41 -07002069 t = *table;
2070 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002071 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002072 if (err < 0)
2073 return err;
2074
2075 if (write) {
2076 /*
2077 * Poor man's atomic or. Not worth adding a primitive
2078 * to everyone's atomic.h for this
2079 */
2080 int i;
2081 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2082 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302083 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002084 }
2085 }
2086
2087 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002088}
2089
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002090#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002091static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002092 void __user *buffer, size_t *lenp, loff_t *ppos)
2093{
2094 if (write && !capable(CAP_SYS_ADMIN))
2095 return -EPERM;
2096
2097 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2098}
2099#endif
2100
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101struct do_proc_dointvec_minmax_conv_param {
2102 int *min;
2103 int *max;
2104};
2105
Amerigo Wang00b7c332010-05-05 00:26:45 +00002106static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2107 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 int write, void *data)
2109{
2110 struct do_proc_dointvec_minmax_conv_param *param = data;
2111 if (write) {
2112 int val = *negp ? -*lvalp : *lvalp;
2113 if ((param->min && *param->min > val) ||
2114 (param->max && *param->max < val))
2115 return -EINVAL;
2116 *valp = val;
2117 } else {
2118 int val = *valp;
2119 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002120 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 *lvalp = (unsigned long)-val;
2122 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002123 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124 *lvalp = (unsigned long)val;
2125 }
2126 }
2127 return 0;
2128}
2129
2130/**
2131 * proc_dointvec_minmax - read a vector of integers with min/max values
2132 * @table: the sysctl table
2133 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 * @buffer: the user buffer
2135 * @lenp: the size of the user buffer
2136 * @ppos: file position
2137 *
2138 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2139 * values from/to the user buffer, treated as an ASCII string.
2140 *
2141 * This routine will ensure the values are within the range specified by
2142 * table->extra1 (min) and table->extra2 (max).
2143 *
2144 * Returns 0 on success.
2145 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002146int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147 void __user *buffer, size_t *lenp, loff_t *ppos)
2148{
2149 struct do_proc_dointvec_minmax_conv_param param = {
2150 .min = (int *) table->extra1,
2151 .max = (int *) table->extra2,
2152 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002153 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 do_proc_dointvec_minmax_conv, &param);
2155}
2156
Kees Cook54b50192012-07-30 14:39:18 -07002157static void validate_coredump_safety(void)
2158{
Alex Kelly046d6622012-10-04 17:15:23 -07002159#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002160 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002161 core_pattern[0] != '/' && core_pattern[0] != '|') {
2162 printk(KERN_WARNING "Unsafe core_pattern used with "\
2163 "suid_dumpable=2. Pipe handler or fully qualified "\
2164 "core dump path required.\n");
2165 }
Alex Kelly046d6622012-10-04 17:15:23 -07002166#endif
Kees Cook54b50192012-07-30 14:39:18 -07002167}
2168
2169static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2170 void __user *buffer, size_t *lenp, loff_t *ppos)
2171{
2172 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2173 if (!error)
2174 validate_coredump_safety();
2175 return error;
2176}
2177
Alex Kelly046d6622012-10-04 17:15:23 -07002178#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002179static int proc_dostring_coredump(struct ctl_table *table, int write,
2180 void __user *buffer, size_t *lenp, loff_t *ppos)
2181{
2182 int error = proc_dostring(table, write, buffer, lenp, ppos);
2183 if (!error)
2184 validate_coredump_safety();
2185 return error;
2186}
Alex Kelly046d6622012-10-04 17:15:23 -07002187#endif
Kees Cook54b50192012-07-30 14:39:18 -07002188
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002189static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190 void __user *buffer,
2191 size_t *lenp, loff_t *ppos,
2192 unsigned long convmul,
2193 unsigned long convdiv)
2194{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195 unsigned long *i, *min, *max;
2196 int vleft, first = 1, err = 0;
2197 unsigned long page = 0;
2198 size_t left;
2199 char *kbuf;
2200
2201 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 *lenp = 0;
2203 return 0;
2204 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002205
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002206 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 min = (unsigned long *) table->extra1;
2208 max = (unsigned long *) table->extra2;
2209 vleft = table->maxlen / sizeof(unsigned long);
2210 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002211
2212 if (write) {
2213 if (left > PAGE_SIZE - 1)
2214 left = PAGE_SIZE - 1;
2215 page = __get_free_page(GFP_TEMPORARY);
2216 kbuf = (char *) page;
2217 if (!kbuf)
2218 return -ENOMEM;
2219 if (copy_from_user(kbuf, buffer, left)) {
2220 err = -EFAULT;
2221 goto free;
2222 }
2223 kbuf[left] = 0;
2224 }
2225
Eric Dumazet27b3d802010-10-07 12:59:29 -07002226 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002227 unsigned long val;
2228
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002230 bool neg;
2231
2232 left -= proc_skip_spaces(&kbuf);
2233
2234 err = proc_get_long(&kbuf, &left, &val, &neg,
2235 proc_wspace_sep,
2236 sizeof(proc_wspace_sep), NULL);
2237 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 break;
2239 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 continue;
2241 if ((min && val < *min) || (max && val > *max))
2242 continue;
2243 *i = val;
2244 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002245 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002246 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002247 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002248 if (err)
2249 break;
2250 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002251 err = proc_put_long(&buffer, &left, val, false);
2252 if (err)
2253 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254 }
2255 }
2256
Amerigo Wang00b7c332010-05-05 00:26:45 +00002257 if (!write && !first && left && !err)
2258 err = proc_put_char(&buffer, &left, '\n');
2259 if (write && !err)
2260 left -= proc_skip_spaces(&kbuf);
2261free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002263 free_page(page);
2264 if (first)
2265 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 *lenp -= left;
2268 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270}
2271
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002272static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002273 void __user *buffer,
2274 size_t *lenp, loff_t *ppos,
2275 unsigned long convmul,
2276 unsigned long convdiv)
2277{
2278 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002279 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002280}
2281
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282/**
2283 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2284 * @table: the sysctl table
2285 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286 * @buffer: the user buffer
2287 * @lenp: the size of the user buffer
2288 * @ppos: file position
2289 *
2290 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2291 * values from/to the user buffer, treated as an ASCII string.
2292 *
2293 * This routine will ensure the values are within the range specified by
2294 * table->extra1 (min) and table->extra2 (max).
2295 *
2296 * Returns 0 on success.
2297 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002298int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 void __user *buffer, size_t *lenp, loff_t *ppos)
2300{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002301 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302}
2303
2304/**
2305 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2306 * @table: the sysctl table
2307 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002308 * @buffer: the user buffer
2309 * @lenp: the size of the user buffer
2310 * @ppos: file position
2311 *
2312 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2313 * values from/to the user buffer, treated as an ASCII string. The values
2314 * are treated as milliseconds, and converted to jiffies when they are stored.
2315 *
2316 * This routine will ensure the values are within the range specified by
2317 * table->extra1 (min) and table->extra2 (max).
2318 *
2319 * Returns 0 on success.
2320 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002321int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 void __user *buffer,
2323 size_t *lenp, loff_t *ppos)
2324{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002325 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326 lenp, ppos, HZ, 1000l);
2327}
2328
2329
Amerigo Wang00b7c332010-05-05 00:26:45 +00002330static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 int *valp,
2332 int write, void *data)
2333{
2334 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002335 if (*lvalp > LONG_MAX / HZ)
2336 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2338 } else {
2339 int val = *valp;
2340 unsigned long lval;
2341 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002342 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002343 lval = (unsigned long)-val;
2344 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002345 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346 lval = (unsigned long)val;
2347 }
2348 *lvalp = lval / HZ;
2349 }
2350 return 0;
2351}
2352
Amerigo Wang00b7c332010-05-05 00:26:45 +00002353static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 int *valp,
2355 int write, void *data)
2356{
2357 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002358 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2359 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2361 } else {
2362 int val = *valp;
2363 unsigned long lval;
2364 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002365 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 lval = (unsigned long)-val;
2367 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002368 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 lval = (unsigned long)val;
2370 }
2371 *lvalp = jiffies_to_clock_t(lval);
2372 }
2373 return 0;
2374}
2375
Amerigo Wang00b7c332010-05-05 00:26:45 +00002376static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 int *valp,
2378 int write, void *data)
2379{
2380 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002381 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2382
2383 if (jif > INT_MAX)
2384 return 1;
2385 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 } else {
2387 int val = *valp;
2388 unsigned long lval;
2389 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002390 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 lval = (unsigned long)-val;
2392 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002393 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 lval = (unsigned long)val;
2395 }
2396 *lvalp = jiffies_to_msecs(lval);
2397 }
2398 return 0;
2399}
2400
2401/**
2402 * proc_dointvec_jiffies - read a vector of integers as seconds
2403 * @table: the sysctl table
2404 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 * @buffer: the user buffer
2406 * @lenp: the size of the user buffer
2407 * @ppos: file position
2408 *
2409 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2410 * values from/to the user buffer, treated as an ASCII string.
2411 * The values read are assumed to be in seconds, and are converted into
2412 * jiffies.
2413 *
2414 * Returns 0 on success.
2415 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002416int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 void __user *buffer, size_t *lenp, loff_t *ppos)
2418{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002419 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 do_proc_dointvec_jiffies_conv,NULL);
2421}
2422
2423/**
2424 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2425 * @table: the sysctl table
2426 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 * @buffer: the user buffer
2428 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002429 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 *
2431 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2432 * values from/to the user buffer, treated as an ASCII string.
2433 * The values read are assumed to be in 1/USER_HZ seconds, and
2434 * are converted into jiffies.
2435 *
2436 * Returns 0 on success.
2437 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002438int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 void __user *buffer, size_t *lenp, loff_t *ppos)
2440{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002441 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 do_proc_dointvec_userhz_jiffies_conv,NULL);
2443}
2444
2445/**
2446 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2447 * @table: the sysctl table
2448 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 * @buffer: the user buffer
2450 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002451 * @ppos: file position
2452 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 *
2454 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2455 * values from/to the user buffer, treated as an ASCII string.
2456 * The values read are assumed to be in 1/1000 seconds, and
2457 * are converted into jiffies.
2458 *
2459 * Returns 0 on success.
2460 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002461int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 void __user *buffer, size_t *lenp, loff_t *ppos)
2463{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002464 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 do_proc_dointvec_ms_jiffies_conv, NULL);
2466}
2467
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002468static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002469 void __user *buffer, size_t *lenp, loff_t *ppos)
2470{
2471 struct pid *new_pid;
2472 pid_t tmp;
2473 int r;
2474
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002475 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002476
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002477 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002478 lenp, ppos, NULL, NULL);
2479 if (r || !write)
2480 return r;
2481
2482 new_pid = find_get_pid(tmp);
2483 if (!new_pid)
2484 return -ESRCH;
2485
2486 put_pid(xchg(&cad_pid, new_pid));
2487 return 0;
2488}
2489
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002490/**
2491 * proc_do_large_bitmap - read/write from/to a large bitmap
2492 * @table: the sysctl table
2493 * @write: %TRUE if this is a write to the sysctl file
2494 * @buffer: the user buffer
2495 * @lenp: the size of the user buffer
2496 * @ppos: file position
2497 *
2498 * The bitmap is stored at table->data and the bitmap length (in bits)
2499 * in table->maxlen.
2500 *
2501 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2502 * large bitmaps may be represented in a compact manner. Writing into
2503 * the file will clear the bitmap then update it with the given input.
2504 *
2505 * Returns 0 on success.
2506 */
2507int proc_do_large_bitmap(struct ctl_table *table, int write,
2508 void __user *buffer, size_t *lenp, loff_t *ppos)
2509{
2510 int err = 0;
2511 bool first = 1;
2512 size_t left = *lenp;
2513 unsigned long bitmap_len = table->maxlen;
2514 unsigned long *bitmap = (unsigned long *) table->data;
2515 unsigned long *tmp_bitmap = NULL;
2516 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2517
2518 if (!bitmap_len || !left || (*ppos && !write)) {
2519 *lenp = 0;
2520 return 0;
2521 }
2522
2523 if (write) {
2524 unsigned long page = 0;
2525 char *kbuf;
2526
2527 if (left > PAGE_SIZE - 1)
2528 left = PAGE_SIZE - 1;
2529
2530 page = __get_free_page(GFP_TEMPORARY);
2531 kbuf = (char *) page;
2532 if (!kbuf)
2533 return -ENOMEM;
2534 if (copy_from_user(kbuf, buffer, left)) {
2535 free_page(page);
2536 return -EFAULT;
2537 }
2538 kbuf[left] = 0;
2539
2540 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2541 GFP_KERNEL);
2542 if (!tmp_bitmap) {
2543 free_page(page);
2544 return -ENOMEM;
2545 }
2546 proc_skip_char(&kbuf, &left, '\n');
2547 while (!err && left) {
2548 unsigned long val_a, val_b;
2549 bool neg;
2550
2551 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2552 sizeof(tr_a), &c);
2553 if (err)
2554 break;
2555 if (val_a >= bitmap_len || neg) {
2556 err = -EINVAL;
2557 break;
2558 }
2559
2560 val_b = val_a;
2561 if (left) {
2562 kbuf++;
2563 left--;
2564 }
2565
2566 if (c == '-') {
2567 err = proc_get_long(&kbuf, &left, &val_b,
2568 &neg, tr_b, sizeof(tr_b),
2569 &c);
2570 if (err)
2571 break;
2572 if (val_b >= bitmap_len || neg ||
2573 val_a > val_b) {
2574 err = -EINVAL;
2575 break;
2576 }
2577 if (left) {
2578 kbuf++;
2579 left--;
2580 }
2581 }
2582
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002583 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002584 first = 0;
2585 proc_skip_char(&kbuf, &left, '\n');
2586 }
2587 free_page(page);
2588 } else {
2589 unsigned long bit_a, bit_b = 0;
2590
2591 while (left) {
2592 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2593 if (bit_a >= bitmap_len)
2594 break;
2595 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2596 bit_a + 1) - 1;
2597
2598 if (!first) {
2599 err = proc_put_char(&buffer, &left, ',');
2600 if (err)
2601 break;
2602 }
2603 err = proc_put_long(&buffer, &left, bit_a, false);
2604 if (err)
2605 break;
2606 if (bit_a != bit_b) {
2607 err = proc_put_char(&buffer, &left, '-');
2608 if (err)
2609 break;
2610 err = proc_put_long(&buffer, &left, bit_b, false);
2611 if (err)
2612 break;
2613 }
2614
2615 first = 0; bit_b++;
2616 }
2617 if (!err)
2618 err = proc_put_char(&buffer, &left, '\n');
2619 }
2620
2621 if (!err) {
2622 if (write) {
2623 if (*ppos)
2624 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2625 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002626 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002627 }
2628 kfree(tmp_bitmap);
2629 *lenp -= left;
2630 *ppos += *lenp;
2631 return 0;
2632 } else {
2633 kfree(tmp_bitmap);
2634 return err;
2635 }
2636}
2637
Jovi Zhang55610502011-01-12 17:00:45 -08002638#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002640int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 void __user *buffer, size_t *lenp, loff_t *ppos)
2642{
2643 return -ENOSYS;
2644}
2645
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002646int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647 void __user *buffer, size_t *lenp, loff_t *ppos)
2648{
2649 return -ENOSYS;
2650}
2651
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002652int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653 void __user *buffer, size_t *lenp, loff_t *ppos)
2654{
2655 return -ENOSYS;
2656}
2657
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002658int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659 void __user *buffer, size_t *lenp, loff_t *ppos)
2660{
2661 return -ENOSYS;
2662}
2663
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002664int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665 void __user *buffer, size_t *lenp, loff_t *ppos)
2666{
2667 return -ENOSYS;
2668}
2669
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002670int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 void __user *buffer, size_t *lenp, loff_t *ppos)
2672{
2673 return -ENOSYS;
2674}
2675
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002676int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 void __user *buffer, size_t *lenp, loff_t *ppos)
2678{
2679 return -ENOSYS;
2680}
2681
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002682int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 void __user *buffer,
2684 size_t *lenp, loff_t *ppos)
2685{
2686 return -ENOSYS;
2687}
2688
2689
Jovi Zhang55610502011-01-12 17:00:45 -08002690#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691
Linus Torvalds1da177e2005-04-16 15:20:36 -07002692/*
2693 * No sense putting this after each symbol definition, twice,
2694 * exception granted :-)
2695 */
2696EXPORT_SYMBOL(proc_dointvec);
2697EXPORT_SYMBOL(proc_dointvec_jiffies);
2698EXPORT_SYMBOL(proc_dointvec_minmax);
2699EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2700EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2701EXPORT_SYMBOL(proc_dostring);
2702EXPORT_SYMBOL(proc_doulongvec_minmax);
2703EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);