blob: 7c54ff79afd7f053c8ce5a943d4cf7fb9d8acb2b [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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700129#ifdef CONFIG_PRINTK
130static int ten_thousand = 10000;
131#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700133/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
134static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
137static int maxolduid = 65535;
138static int minolduid;
139
140static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700141static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Liu Hua80df2842014-04-07 15:38:57 -0700143/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
144#ifdef CONFIG_DETECT_HUNG_TASK
145static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
146#endif
147
Dave Youngd14f1722010-02-25 20:28:57 -0500148#ifdef CONFIG_INOTIFY_USER
149#include <linux/inotify.h>
150#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700151#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif
153
154#ifdef __hppa__
155extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530156#endif
157
158#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159extern int unaligned_enabled;
160#endif
161
Jes Sorensend2b176e2006-02-28 09:42:23 -0800162#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800163extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800164#endif
165
Vineet Guptab6fca722013-01-09 20:06:28 +0530166#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
167extern int no_unaligned_warning;
168#endif
169
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700170#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700171
172#define SYSCTL_WRITES_LEGACY -1
173#define SYSCTL_WRITES_WARN 0
174#define SYSCTL_WRITES_STRICT 1
175
176static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
177
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700178static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700179 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700180static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800181 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700182#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700183
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700184#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700185static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700186 void __user *buffer, size_t *lenp, loff_t *ppos);
187#endif
188
Kees Cook54b50192012-07-30 14:39:18 -0700189static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
190 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700191#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700192static int proc_dostring_coredump(struct ctl_table *table, int write,
193 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700194#endif
Kees Cook54b50192012-07-30 14:39:18 -0700195
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700196#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800197/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100198static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700199
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700200static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700201 void __user *buffer, size_t *lenp,
202 loff_t *ppos)
203{
204 int error;
205
206 error = proc_dointvec(table, write, buffer, lenp, ppos);
207 if (error)
208 return error;
209
210 if (write)
211 sysrq_toggle_support(__sysrq_enabled);
212
213 return 0;
214}
215
216#endif
217
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700218static struct ctl_table kern_table[];
219static struct ctl_table vm_table[];
220static struct ctl_table fs_table[];
221static struct ctl_table debug_table[];
222static struct ctl_table dev_table[];
223extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800224#ifdef CONFIG_EPOLL
225extern struct ctl_table epoll_table[];
226#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
228#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
229int sysctl_legacy_va_layout;
230#endif
231
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232/* The default sysctl tables: */
233
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800234static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 .procname = "kernel",
237 .mode = 0555,
238 .child = kern_table,
239 },
240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "vm",
242 .mode = 0555,
243 .child = vm_table,
244 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "fs",
247 .mode = 0555,
248 .child = fs_table,
249 },
250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "debug",
252 .mode = 0555,
253 .child = debug_table,
254 },
255 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .procname = "dev",
257 .mode = 0555,
258 .child = dev_table,
259 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700260 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261};
262
Ingo Molnar77e54a12007-07-09 18:52:00 +0200263#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100264static int min_sched_granularity_ns = 100000; /* 100 usecs */
265static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
266static int min_wakeup_granularity_ns; /* 0 usecs */
267static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200268#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100269static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
270static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200271#endif /* CONFIG_SMP */
272#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200273
Mel Gorman5e771902010-05-24 14:32:31 -0700274#ifdef CONFIG_COMPACTION
275static int min_extfrag_threshold;
276static int max_extfrag_threshold = 1000;
277#endif
278
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700279static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200280 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200281 .procname = "sched_child_runs_first",
282 .data = &sysctl_sched_child_runs_first,
283 .maxlen = sizeof(unsigned int),
284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800285 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200286 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200287#ifdef CONFIG_SCHED_DEBUG
288 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100289 .procname = "sched_min_granularity_ns",
290 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200291 .maxlen = sizeof(unsigned int),
292 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800293 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100294 .extra1 = &min_sched_granularity_ns,
295 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200296 },
297 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200298 .procname = "sched_latency_ns",
299 .data = &sysctl_sched_latency,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800302 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200303 .extra1 = &min_sched_granularity_ns,
304 .extra2 = &max_sched_granularity_ns,
305 },
306 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200307 .procname = "sched_wakeup_granularity_ns",
308 .data = &sysctl_sched_wakeup_granularity,
309 .maxlen = sizeof(unsigned int),
310 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800311 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200312 .extra1 = &min_wakeup_granularity_ns,
313 .extra2 = &max_wakeup_granularity_ns,
314 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200315#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200316 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100317 .procname = "sched_tunable_scaling",
318 .data = &sysctl_sched_tunable_scaling,
319 .maxlen = sizeof(enum sched_tunable_scaling),
320 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800321 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100322 .extra1 = &min_sched_tunable_scaling,
323 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200324 },
325 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900326 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200327 .data = &sysctl_sched_migration_cost,
328 .maxlen = sizeof(unsigned int),
329 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800330 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200331 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100332 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100333 .procname = "sched_nr_migrate",
334 .data = &sysctl_sched_nr_migrate,
335 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100336 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800337 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100338 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530339 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900340 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200341 .data = &sysctl_sched_time_avg,
342 .maxlen = sizeof(unsigned int),
343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800344 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200345 },
346 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900347 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800348 .data = &sysctl_sched_shares_window,
349 .maxlen = sizeof(unsigned int),
350 .mode = 0644,
351 .proc_handler = proc_dointvec,
352 },
353 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530354 .procname = "timer_migration",
355 .data = &sysctl_timer_migration,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800358 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530359 .extra1 = &zero,
360 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530361 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200362#endif /* CONFIG_SMP */
363#ifdef CONFIG_NUMA_BALANCING
364 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200365 .procname = "numa_balancing_scan_delay_ms",
366 .data = &sysctl_numa_balancing_scan_delay,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec,
370 },
371 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200372 .procname = "numa_balancing_scan_period_min_ms",
373 .data = &sysctl_numa_balancing_scan_period_min,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
378 {
379 .procname = "numa_balancing_scan_period_max_ms",
380 .data = &sysctl_numa_balancing_scan_period_max,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200385 {
386 .procname = "numa_balancing_scan_size_mb",
387 .data = &sysctl_numa_balancing_scan_size,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400390 .proc_handler = proc_dointvec_minmax,
391 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200392 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100393 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800394 .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 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700501 {
502 .procname = "sysctl_writes_strict",
503 .data = &sysctl_writes_strict,
504 .maxlen = sizeof(int),
505 .mode = 0644,
506 .proc_handler = proc_dointvec_minmax,
507 .extra1 = &neg_one,
508 .extra2 = &one,
509 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800510#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100511#ifdef CONFIG_LATENCYTOP
512 {
513 .procname = "latencytop",
514 .data = &latencytop_enabled,
515 .maxlen = sizeof(int),
516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800517 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100518 },
519#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520#ifdef CONFIG_BLK_DEV_INITRD
521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 .procname = "real-root-dev",
523 .data = &real_root_dev,
524 .maxlen = sizeof(int),
525 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800526 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 },
528#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700529 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700530 .procname = "print-fatal-signals",
531 .data = &print_fatal_signals,
532 .maxlen = sizeof(int),
533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800534 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700535 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700536#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .procname = "reboot-cmd",
539 .data = reboot_command,
540 .maxlen = 256,
541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 },
544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "stop-a",
546 .data = &stop_a_enabled,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "scons-poweroff",
553 .data = &scons_pwroff,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558#endif
David S. Miller08714202008-11-16 23:49:24 -0800559#ifdef CONFIG_SPARC64
560 {
David S. Miller08714202008-11-16 23:49:24 -0800561 .procname = "tsb-ratio",
562 .data = &sysctl_tsb_ratio,
563 .maxlen = sizeof (int),
564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800565 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800566 },
567#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568#ifdef __hppa__
569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "soft-power",
571 .data = &pwrsw_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 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530576#endif
577#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .procname = "unaligned-trap",
580 .data = &unaligned_enabled,
581 .maxlen = sizeof (int),
582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 },
585#endif
586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "ctrl-alt-del",
588 .data = &C_A_D,
589 .maxlen = sizeof(int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400593#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200594 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200595 .procname = "ftrace_enabled",
596 .data = &ftrace_enabled,
597 .maxlen = sizeof(int),
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200600 },
601#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500602#ifdef CONFIG_STACK_TRACER
603 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500604 .procname = "stack_tracer_enabled",
605 .data = &stack_tracer_enabled,
606 .maxlen = sizeof(int),
607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500609 },
610#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400611#ifdef CONFIG_TRACING
612 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100613 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400614 .data = &ftrace_dump_on_oops,
615 .maxlen = sizeof(int),
616 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400618 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400619 {
620 .procname = "traceoff_on_warning",
621 .data = &__disable_trace_on_warning,
622 .maxlen = sizeof(__disable_trace_on_warning),
623 .mode = 0644,
624 .proc_handler = proc_dointvec,
625 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400626#endif
Kees Cook79847542014-01-23 15:55:59 -0800627#ifdef CONFIG_KEXEC
628 {
629 .procname = "kexec_load_disabled",
630 .data = &kexec_load_disabled,
631 .maxlen = sizeof(int),
632 .mode = 0644,
633 /* only handle a transition from default "0" to "1" */
634 .proc_handler = proc_dointvec_minmax,
635 .extra1 = &one,
636 .extra2 = &one,
637 },
638#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200639#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "modprobe",
642 .data = &modprobe_path,
643 .maxlen = KMOD_PATH_LEN,
644 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800645 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 },
Kees Cook3d433212009-04-02 15:49:29 -0700647 {
Kees Cook3d433212009-04-02 15:49:29 -0700648 .procname = "modules_disabled",
649 .data = &modules_disabled,
650 .maxlen = sizeof(int),
651 .mode = 0644,
652 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700654 .extra1 = &one,
655 .extra2 = &one,
656 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700658#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100661 .data = &uevent_helper,
662 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800664 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 },
Michael Marineau86d56132014-04-10 14:09:31 -0700666#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667#ifdef CONFIG_CHR_DEV_SG
668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "sg-big-buff",
670 .data = &sg_big_buff,
671 .maxlen = sizeof (int),
672 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675#endif
676#ifdef CONFIG_BSD_PROCESS_ACCT
677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .procname = "acct",
679 .data = &acct_parm,
680 .maxlen = 3*sizeof(int),
681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800682 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 },
684#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685#ifdef CONFIG_MAGIC_SYSRQ
686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800688 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .maxlen = sizeof (int),
690 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700691 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
693#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700694#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700697 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 .maxlen = sizeof (int),
699 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800700 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700702#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .procname = "threads-max",
705 .data = &max_threads,
706 .maxlen = sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 },
710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "random",
712 .mode = 0555,
713 .child = random_table,
714 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 {
Eric Paris17f60a72011-04-01 17:07:50 -0400716 .procname = "usermodehelper",
717 .mode = 0555,
718 .child = usermodehelper_table,
719 },
720 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .procname = "overflowuid",
722 .data = &overflowuid,
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 },
729 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 .procname = "overflowgid",
731 .data = &overflowgid,
732 .maxlen = sizeof(int),
733 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800734 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .extra1 = &minolduid,
736 .extra2 = &maxolduid,
737 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800738#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739#ifdef CONFIG_MATHEMU
740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 .procname = "ieee_emulation_warnings",
742 .data = &sysctl_ieee_emulation_warnings,
743 .maxlen = sizeof(int),
744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800745 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 },
747#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200750 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 .maxlen = sizeof(int),
752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 },
755#endif
756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "pid_max",
758 .data = &pid_max,
759 .maxlen = sizeof (int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 .extra1 = &pid_max_min,
763 .extra2 = &pid_max_max,
764 },
765 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 .procname = "panic_on_oops",
767 .data = &panic_on_oops,
768 .maxlen = sizeof(int),
769 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800770 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800772#if defined CONFIG_PRINTK
773 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800774 .procname = "printk",
775 .data = &console_loglevel,
776 .maxlen = 4*sizeof(int),
777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800778 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800779 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700782 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 .maxlen = sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 },
787 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700789 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .maxlen = sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 },
Dave Youngaf913222009-09-22 16:43:33 -0700794 {
Dave Youngaf913222009-09-22 16:43:33 -0700795 .procname = "printk_delay",
796 .data = &printk_delay_msec,
797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700800 .extra1 = &zero,
801 .extra2 = &ten_thousand,
802 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800804 .procname = "dmesg_restrict",
805 .data = &dmesg_restrict,
806 .maxlen = sizeof(int),
807 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700808 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800809 .extra1 = &zero,
810 .extra2 = &one,
811 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800812 {
813 .procname = "kptr_restrict",
814 .data = &kptr_restrict,
815 .maxlen = sizeof(int),
816 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700817 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800818 .extra1 = &zero,
819 .extra2 = &two,
820 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800821#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800822 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 .procname = "ngroups_max",
824 .data = &ngroups_max,
825 .maxlen = sizeof (int),
826 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800827 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 },
Dan Ballard73efc032011-10-31 17:11:20 -0700829 {
830 .procname = "cap_last_cap",
831 .data = (void *)&cap_last_cap,
832 .maxlen = sizeof(int),
833 .mode = 0444,
834 .proc_handler = proc_dointvec,
835 },
Don Zickus58687ac2010-05-07 17:11:44 -0400836#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500837 {
Don Zickus58687ac2010-05-07 17:11:44 -0400838 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200839 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500840 .maxlen = sizeof (int),
841 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700842 .proc_handler = proc_dowatchdog,
843 .extra1 = &zero,
844 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400845 },
846 {
847 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700848 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400849 .maxlen = sizeof(int),
850 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700851 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800852 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400853 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500854 },
Don Zickus2508ce12010-05-07 17:11:46 -0400855 {
856 .procname = "softlockup_panic",
857 .data = &softlockup_panic,
858 .maxlen = sizeof(int),
859 .mode = 0644,
860 .proc_handler = proc_dointvec_minmax,
861 .extra1 = &zero,
862 .extra2 = &one,
863 },
Aaron Tomlined235872014-06-23 13:22:05 -0700864#ifdef CONFIG_SMP
865 {
866 .procname = "softlockup_all_cpu_backtrace",
867 .data = &sysctl_softlockup_all_cpu_backtrace,
868 .maxlen = sizeof(int),
869 .mode = 0644,
870 .proc_handler = proc_dointvec_minmax,
871 .extra1 = &zero,
872 .extra2 = &one,
873 },
874#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500875 {
876 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200877 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500878 .maxlen = sizeof (int),
879 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700880 .proc_handler = proc_dowatchdog,
881 .extra1 = &zero,
882 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500883 },
884#endif
885#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
886 {
887 .procname = "unknown_nmi_panic",
888 .data = &unknown_nmi_panic,
889 .maxlen = sizeof (int),
890 .mode = 0644,
891 .proc_handler = proc_dointvec,
892 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500893#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894#if defined(CONFIG_X86)
895 {
Don Zickus8da5add2006-09-26 10:52:27 +0200896 .procname = "panic_on_unrecovered_nmi",
897 .data = &panic_on_unrecovered_nmi,
898 .maxlen = sizeof(int),
899 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800900 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200901 },
902 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700903 .procname = "panic_on_io_nmi",
904 .data = &panic_on_io_nmi,
905 .maxlen = sizeof(int),
906 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800907 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700908 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900909#ifdef CONFIG_DEBUG_STACKOVERFLOW
910 {
911 .procname = "panic_on_stackoverflow",
912 .data = &sysctl_panic_on_stackoverflow,
913 .maxlen = sizeof(int),
914 .mode = 0644,
915 .proc_handler = proc_dointvec,
916 },
917#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700918 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 .procname = "bootloader_type",
920 .data = &bootloader_type,
921 .maxlen = sizeof (int),
922 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800923 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100925 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700926 .procname = "bootloader_version",
927 .data = &bootloader_version,
928 .maxlen = sizeof (int),
929 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800930 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700931 },
932 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100933 .procname = "kstack_depth_to_print",
934 .data = &kstack_depth_to_print,
935 .maxlen = sizeof(int),
936 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800937 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100938 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100939 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100940 .procname = "io_delay_type",
941 .data = &io_delay_type,
942 .maxlen = sizeof(int),
943 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800944 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100945 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800947#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 .procname = "randomize_va_space",
950 .data = &randomize_va_space,
951 .maxlen = sizeof(int),
952 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800953 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800955#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800956#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700957 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700958 .procname = "spin_retry",
959 .data = &spin_retry,
960 .maxlen = sizeof (int),
961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800962 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700963 },
964#endif
Len Brown673d5b42007-07-28 03:33:16 -0400965#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800966 {
Pavel Machekc255d842006-02-20 18:27:58 -0800967 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700968 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800969 .maxlen = sizeof (unsigned long),
970 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800971 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800972 },
973#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530974#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800975 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800976 .procname = "ignore-unaligned-usertrap",
977 .data = &no_unaligned_warning,
978 .maxlen = sizeof (int),
979 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800980 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800981 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530982#endif
983#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800984 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800985 .procname = "unaligned-dump-stack",
986 .data = &unaligned_dump_stack,
987 .maxlen = sizeof (int),
988 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800989 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800990 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800991#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800992#ifdef CONFIG_DETECT_HUNG_TASK
993 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800994 .procname = "hung_task_panic",
995 .data = &sysctl_hung_task_panic,
996 .maxlen = sizeof(int),
997 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800998 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800999 .extra1 = &zero,
1000 .extra2 = &one,
1001 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001002 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001003 .procname = "hung_task_check_count",
1004 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001005 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001006 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001007 .proc_handler = proc_dointvec_minmax,
1008 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001009 },
1010 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001011 .procname = "hung_task_timeout_secs",
1012 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001013 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001016 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001017 },
1018 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001019 .procname = "hung_task_warnings",
1020 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001021 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001022 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001023 .proc_handler = proc_dointvec_minmax,
1024 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001025 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001026#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001027#ifdef CONFIG_COMPAT
1028 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001029 .procname = "compat-log",
1030 .data = &compat_log,
1031 .maxlen = sizeof (int),
1032 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001033 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001034 },
1035#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001036#ifdef CONFIG_RT_MUTEXES
1037 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001038 .procname = "max_lock_depth",
1039 .data = &max_lock_depth,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001043 },
1044#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001045 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001046 .procname = "poweroff_cmd",
1047 .data = &poweroff_cmd,
1048 .maxlen = POWEROFF_CMD_PATH_LEN,
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001051 },
David Howells0b77f5b2008-04-29 01:01:32 -07001052#ifdef CONFIG_KEYS
1053 {
David Howells0b77f5b2008-04-29 01:01:32 -07001054 .procname = "keys",
1055 .mode = 0555,
1056 .child = key_sysctls,
1057 },
1058#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001059#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001060 /*
1061 * User-space scripts rely on the existence of this file
1062 * as a feature check for perf_events being enabled.
1063 *
1064 * So it's an ABI, do not remove!
1065 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001066 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001067 .procname = "perf_event_paranoid",
1068 .data = &sysctl_perf_event_paranoid,
1069 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001070 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001071 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001072 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001073 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001074 .procname = "perf_event_mlock_kb",
1075 .data = &sysctl_perf_event_mlock,
1076 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001077 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001078 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001079 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001080 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001081 .procname = "perf_event_max_sample_rate",
1082 .data = &sysctl_perf_event_sample_rate,
1083 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001084 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001085 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001086 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001087 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001088 {
1089 .procname = "perf_cpu_time_max_percent",
1090 .data = &sysctl_perf_cpu_time_max_percent,
1091 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1092 .mode = 0644,
1093 .proc_handler = perf_cpu_time_max_percent_handler,
1094 .extra1 = &zero,
1095 .extra2 = &one_hundred,
1096 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001097#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001098#ifdef CONFIG_KMEMCHECK
1099 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001100 .procname = "kmemcheck",
1101 .data = &kmemcheck_enabled,
1102 .maxlen = sizeof(int),
1103 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001104 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001105 },
1106#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001107 {
1108 .procname = "panic_on_warn",
1109 .data = &panic_on_warn,
1110 .maxlen = sizeof(int),
1111 .mode = 0644,
1112 .proc_handler = proc_dointvec_minmax,
1113 .extra1 = &zero,
1114 .extra2 = &one,
1115 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001116 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117};
1118
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001119static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 .procname = "overcommit_memory",
1122 .data = &sysctl_overcommit_memory,
1123 .maxlen = sizeof(sysctl_overcommit_memory),
1124 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001125 .proc_handler = proc_dointvec_minmax,
1126 .extra1 = &zero,
1127 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 },
1129 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001130 .procname = "panic_on_oom",
1131 .data = &sysctl_panic_on_oom,
1132 .maxlen = sizeof(sysctl_panic_on_oom),
1133 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001134 .proc_handler = proc_dointvec_minmax,
1135 .extra1 = &zero,
1136 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001137 },
1138 {
David Rientjesfe071d72007-10-16 23:25:56 -07001139 .procname = "oom_kill_allocating_task",
1140 .data = &sysctl_oom_kill_allocating_task,
1141 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1142 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001143 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001144 },
1145 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001146 .procname = "oom_dump_tasks",
1147 .data = &sysctl_oom_dump_tasks,
1148 .maxlen = sizeof(sysctl_oom_dump_tasks),
1149 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001150 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001151 },
1152 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 .procname = "overcommit_ratio",
1154 .data = &sysctl_overcommit_ratio,
1155 .maxlen = sizeof(sysctl_overcommit_ratio),
1156 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001157 .proc_handler = overcommit_ratio_handler,
1158 },
1159 {
1160 .procname = "overcommit_kbytes",
1161 .data = &sysctl_overcommit_kbytes,
1162 .maxlen = sizeof(sysctl_overcommit_kbytes),
1163 .mode = 0644,
1164 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 },
1166 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 .procname = "page-cluster",
1168 .data = &page_cluster,
1169 .maxlen = sizeof(int),
1170 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001171 .proc_handler = proc_dointvec_minmax,
1172 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 },
1174 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 .procname = "dirty_background_ratio",
1176 .data = &dirty_background_ratio,
1177 .maxlen = sizeof(dirty_background_ratio),
1178 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001179 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 .extra1 = &zero,
1181 .extra2 = &one_hundred,
1182 },
1183 {
David Rientjes2da02992009-01-06 14:39:31 -08001184 .procname = "dirty_background_bytes",
1185 .data = &dirty_background_bytes,
1186 .maxlen = sizeof(dirty_background_bytes),
1187 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001188 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001189 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001190 },
1191 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 .procname = "dirty_ratio",
1193 .data = &vm_dirty_ratio,
1194 .maxlen = sizeof(vm_dirty_ratio),
1195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 .extra1 = &zero,
1198 .extra2 = &one_hundred,
1199 },
1200 {
David Rientjes2da02992009-01-06 14:39:31 -08001201 .procname = "dirty_bytes",
1202 .data = &vm_dirty_bytes,
1203 .maxlen = sizeof(vm_dirty_bytes),
1204 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001205 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001206 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001207 },
1208 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001210 .data = &dirty_writeback_interval,
1211 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001213 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214 },
1215 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001217 .data = &dirty_expire_interval,
1218 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001220 .proc_handler = proc_dointvec_minmax,
1221 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 },
1223 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001224 .procname = "nr_pdflush_threads",
1225 .mode = 0444 /* read-only */,
1226 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 },
1228 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 .procname = "swappiness",
1230 .data = &vm_swappiness,
1231 .maxlen = sizeof(vm_swappiness),
1232 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001233 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 .extra1 = &zero,
1235 .extra2 = &one_hundred,
1236 },
1237#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001240 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 .maxlen = sizeof(unsigned long),
1242 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001243 .proc_handler = hugetlb_sysctl_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001244 .extra1 = &zero,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001245 },
1246#ifdef CONFIG_NUMA
1247 {
1248 .procname = "nr_hugepages_mempolicy",
1249 .data = NULL,
1250 .maxlen = sizeof(unsigned long),
1251 .mode = 0644,
1252 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001253 .extra1 = &zero,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001254 },
1255#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "hugetlb_shm_group",
1258 .data = &sysctl_hugetlb_shm_group,
1259 .maxlen = sizeof(gid_t),
1260 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001261 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 },
Mel Gorman396faf02007-07-17 04:03:13 -07001263 {
Mel Gorman396faf02007-07-17 04:03:13 -07001264 .procname = "hugepages_treat_as_movable",
1265 .data = &hugepages_treat_as_movable,
1266 .maxlen = sizeof(int),
1267 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001268 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001269 },
Adam Litke54f9f802007-10-16 01:26:20 -07001270 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001271 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001272 .data = NULL,
1273 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001274 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001275 .proc_handler = hugetlb_overcommit_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001276 .extra1 = &zero,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001277 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278#endif
1279 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 .procname = "lowmem_reserve_ratio",
1281 .data = &sysctl_lowmem_reserve_ratio,
1282 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1283 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001284 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285 },
1286 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001287 .procname = "drop_caches",
1288 .data = &sysctl_drop_caches,
1289 .maxlen = sizeof(int),
1290 .mode = 0644,
1291 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001292 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001293 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001294 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001295#ifdef CONFIG_COMPACTION
1296 {
1297 .procname = "compact_memory",
1298 .data = &sysctl_compact_memory,
1299 .maxlen = sizeof(int),
1300 .mode = 0200,
1301 .proc_handler = sysctl_compaction_handler,
1302 },
Mel Gorman5e771902010-05-24 14:32:31 -07001303 {
1304 .procname = "extfrag_threshold",
1305 .data = &sysctl_extfrag_threshold,
1306 .maxlen = sizeof(int),
1307 .mode = 0644,
1308 .proc_handler = sysctl_extfrag_handler,
1309 .extra1 = &min_extfrag_threshold,
1310 .extra2 = &max_extfrag_threshold,
1311 },
1312
Mel Gorman76ab0f52010-05-24 14:32:28 -07001313#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001314 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 .procname = "min_free_kbytes",
1316 .data = &min_free_kbytes,
1317 .maxlen = sizeof(min_free_kbytes),
1318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .extra1 = &zero,
1321 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001322 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001323 .procname = "percpu_pagelist_fraction",
1324 .data = &percpu_pagelist_fraction,
1325 .maxlen = sizeof(percpu_pagelist_fraction),
1326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001327 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001328 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001329 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330#ifdef CONFIG_MMU
1331 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 .procname = "max_map_count",
1333 .data = &sysctl_max_map_count,
1334 .maxlen = sizeof(sysctl_max_map_count),
1335 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001336 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001337 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001339#else
1340 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001341 .procname = "nr_trim_pages",
1342 .data = &sysctl_nr_trim_pages,
1343 .maxlen = sizeof(sysctl_nr_trim_pages),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001346 .extra1 = &zero,
1347 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348#endif
1349 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .procname = "laptop_mode",
1351 .data = &laptop_mode,
1352 .maxlen = sizeof(laptop_mode),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 },
1356 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001357 .procname = "block_dump",
1358 .data = &block_dump,
1359 .maxlen = sizeof(block_dump),
1360 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001361 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 .extra1 = &zero,
1363 },
1364 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 .procname = "vfs_cache_pressure",
1366 .data = &sysctl_vfs_cache_pressure,
1367 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001369 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370 .extra1 = &zero,
1371 },
1372#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1373 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 .procname = "legacy_va_layout",
1375 .data = &sysctl_legacy_va_layout,
1376 .maxlen = sizeof(sysctl_legacy_va_layout),
1377 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001378 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 .extra1 = &zero,
1380 },
1381#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001382#ifdef CONFIG_NUMA
1383 {
Christoph Lameter17436602006-01-18 17:42:32 -08001384 .procname = "zone_reclaim_mode",
1385 .data = &zone_reclaim_mode,
1386 .maxlen = sizeof(zone_reclaim_mode),
1387 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001388 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001389 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001390 },
Christoph Lameter96146342006-07-03 00:24:13 -07001391 {
Christoph Lameter96146342006-07-03 00:24:13 -07001392 .procname = "min_unmapped_ratio",
1393 .data = &sysctl_min_unmapped_ratio,
1394 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001396 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001397 .extra1 = &zero,
1398 .extra2 = &one_hundred,
1399 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001400 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001401 .procname = "min_slab_ratio",
1402 .data = &sysctl_min_slab_ratio,
1403 .maxlen = sizeof(sysctl_min_slab_ratio),
1404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001406 .extra1 = &zero,
1407 .extra2 = &one_hundred,
1408 },
Christoph Lameter17436602006-01-18 17:42:32 -08001409#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001410#ifdef CONFIG_SMP
1411 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001412 .procname = "stat_interval",
1413 .data = &sysctl_stat_interval,
1414 .maxlen = sizeof(sysctl_stat_interval),
1415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001416 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001417 },
1418#endif
David Howells6e141542009-12-15 19:27:45 +00001419#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001420 {
Eric Parised032182007-06-28 15:55:21 -04001421 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001422 .data = &dac_mmap_min_addr,
1423 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001425 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001426 },
David Howells6e141542009-12-15 19:27:45 +00001427#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001428#ifdef CONFIG_NUMA
1429 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001430 .procname = "numa_zonelist_order",
1431 .data = &numa_zonelist_order,
1432 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001434 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001435 },
1436#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001437#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001438 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001439 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001440 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001441#ifdef CONFIG_X86_32
1442 .data = &vdso32_enabled,
1443 .maxlen = sizeof(vdso32_enabled),
1444#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001445 .data = &vdso_enabled,
1446 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001447#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001449 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001450 .extra1 = &zero,
1451 },
1452#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001453#ifdef CONFIG_HIGHMEM
1454 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001455 .procname = "highmem_is_dirtyable",
1456 .data = &vm_highmem_is_dirtyable,
1457 .maxlen = sizeof(vm_highmem_is_dirtyable),
1458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001459 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001460 .extra1 = &zero,
1461 .extra2 = &one,
1462 },
1463#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001464#ifdef CONFIG_MEMORY_FAILURE
1465 {
Andi Kleen6a460792009-09-16 11:50:15 +02001466 .procname = "memory_failure_early_kill",
1467 .data = &sysctl_memory_failure_early_kill,
1468 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001470 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001471 .extra1 = &zero,
1472 .extra2 = &one,
1473 },
1474 {
Andi Kleen6a460792009-09-16 11:50:15 +02001475 .procname = "memory_failure_recovery",
1476 .data = &sysctl_memory_failure_recovery,
1477 .maxlen = sizeof(sysctl_memory_failure_recovery),
1478 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001479 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001480 .extra1 = &zero,
1481 .extra2 = &one,
1482 },
1483#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001484 {
1485 .procname = "user_reserve_kbytes",
1486 .data = &sysctl_user_reserve_kbytes,
1487 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1488 .mode = 0644,
1489 .proc_handler = proc_doulongvec_minmax,
1490 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001491 {
1492 .procname = "admin_reserve_kbytes",
1493 .data = &sysctl_admin_reserve_kbytes,
1494 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1495 .mode = 0644,
1496 .proc_handler = proc_doulongvec_minmax,
1497 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001498 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499};
1500
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001501#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001502static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001503 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001504};
1505#endif
1506
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001507static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .procname = "inode-nr",
1510 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001511 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001513 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 },
1515 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 .procname = "inode-state",
1517 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001518 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001520 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 },
1522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 .procname = "file-nr",
1524 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001525 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001527 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 },
1529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .procname = "file-max",
1531 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001532 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001534 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 },
1536 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001537 .procname = "nr_open",
1538 .data = &sysctl_nr_open,
1539 .maxlen = sizeof(int),
1540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001541 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001542 .extra1 = &sysctl_nr_open_min,
1543 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001544 },
1545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 .procname = "dentry-state",
1547 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001548 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001550 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 },
1552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 .procname = "overflowuid",
1554 .data = &fs_overflowuid,
1555 .maxlen = sizeof(int),
1556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001557 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 .extra1 = &minolduid,
1559 .extra2 = &maxolduid,
1560 },
1561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 .procname = "overflowgid",
1563 .data = &fs_overflowgid,
1564 .maxlen = sizeof(int),
1565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001566 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 .extra1 = &minolduid,
1568 .extra2 = &maxolduid,
1569 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001570#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 .procname = "leases-enable",
1573 .data = &leases_enable,
1574 .maxlen = sizeof(int),
1575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001576 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001578#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001579#ifdef CONFIG_DNOTIFY
1580 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 .procname = "dir-notify-enable",
1582 .data = &dir_notify_enable,
1583 .maxlen = sizeof(int),
1584 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001585 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 },
1587#endif
1588#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001589#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001590 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 .procname = "lease-break-time",
1592 .data = &lease_break_time,
1593 .maxlen = sizeof(int),
1594 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001595 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001597#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001598#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600 .procname = "aio-nr",
1601 .data = &aio_nr,
1602 .maxlen = sizeof(aio_nr),
1603 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001604 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605 },
1606 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607 .procname = "aio-max-nr",
1608 .data = &aio_max_nr,
1609 .maxlen = sizeof(aio_max_nr),
1610 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001611 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001612 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001613#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001614#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001615 {
Robert Love0399cb02005-07-13 12:38:18 -04001616 .procname = "inotify",
1617 .mode = 0555,
1618 .child = inotify_table,
1619 },
1620#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001621#ifdef CONFIG_EPOLL
1622 {
1623 .procname = "epoll",
1624 .mode = 0555,
1625 .child = epoll_table,
1626 },
1627#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001628#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001629 {
Kees Cook800179c2012-07-25 17:29:07 -07001630 .procname = "protected_symlinks",
1631 .data = &sysctl_protected_symlinks,
1632 .maxlen = sizeof(int),
1633 .mode = 0600,
1634 .proc_handler = proc_dointvec_minmax,
1635 .extra1 = &zero,
1636 .extra2 = &one,
1637 },
1638 {
1639 .procname = "protected_hardlinks",
1640 .data = &sysctl_protected_hardlinks,
1641 .maxlen = sizeof(int),
1642 .mode = 0600,
1643 .proc_handler = proc_dointvec_minmax,
1644 .extra1 = &zero,
1645 .extra2 = &one,
1646 },
1647 {
Alan Coxd6e71142005-06-23 00:09:43 -07001648 .procname = "suid_dumpable",
1649 .data = &suid_dumpable,
1650 .maxlen = sizeof(int),
1651 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001652 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001653 .extra1 = &zero,
1654 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001655 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001656#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1657 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001658 .procname = "binfmt_misc",
1659 .mode = 0555,
1660 .child = binfmt_misc_table,
1661 },
1662#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001663 {
Jens Axboeff9da692010-06-03 14:54:39 +02001664 .procname = "pipe-max-size",
1665 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001666 .maxlen = sizeof(int),
1667 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001668 .proc_handler = &pipe_proc_fn,
1669 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001670 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001671 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001672};
1673
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001674static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001675#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001676 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001677 .procname = "exception-trace",
1678 .data = &show_unhandled_signals,
1679 .maxlen = sizeof(int),
1680 .mode = 0644,
1681 .proc_handler = proc_dointvec
1682 },
1683#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001684#if defined(CONFIG_OPTPROBES)
1685 {
1686 .procname = "kprobes-optimization",
1687 .data = &sysctl_kprobes_optimization,
1688 .maxlen = sizeof(int),
1689 .mode = 0644,
1690 .proc_handler = proc_kprobes_optimization_handler,
1691 .extra1 = &zero,
1692 .extra2 = &one,
1693 },
1694#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001695 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696};
1697
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001698static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001699 { }
Robert Love0eeca282005-07-12 17:06:03 -04001700};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001702int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001703{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001704 struct ctl_table_header *hdr;
1705
1706 hdr = register_sysctl_table(sysctl_base_table);
1707 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001708 return 0;
1709}
1710
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001711#endif /* CONFIG_SYSCTL */
1712
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713/*
1714 * /proc/sys support
1715 */
1716
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001717#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718
Kees Cookf8808302014-06-06 14:37:17 -07001719static int _proc_do_string(char *data, int maxlen, int write,
1720 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001721 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001722{
1723 size_t len;
1724 char __user *p;
1725 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001726
1727 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001728 *lenp = 0;
1729 return 0;
1730 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001731
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001732 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001733 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1734 /* Only continue writes not past the end of buffer. */
1735 len = strlen(data);
1736 if (len > maxlen - 1)
1737 len = maxlen - 1;
1738
1739 if (*ppos > len)
1740 return 0;
1741 len = *ppos;
1742 } else {
1743 /* Start writing from beginning of buffer. */
1744 len = 0;
1745 }
1746
Kees Cook2ca9bb42014-06-06 14:37:18 -07001747 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001748 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001749 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001750 if (get_user(c, p++))
1751 return -EFAULT;
1752 if (c == 0 || c == '\n')
1753 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001754 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001755 }
Kees Cookf8808302014-06-06 14:37:17 -07001756 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001757 } else {
1758 len = strlen(data);
1759 if (len > maxlen)
1760 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001761
1762 if (*ppos > len) {
1763 *lenp = 0;
1764 return 0;
1765 }
1766
1767 data += *ppos;
1768 len -= *ppos;
1769
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001770 if (len > *lenp)
1771 len = *lenp;
1772 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001773 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001774 return -EFAULT;
1775 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001776 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001777 return -EFAULT;
1778 len++;
1779 }
1780 *lenp = len;
1781 *ppos += len;
1782 }
1783 return 0;
1784}
1785
Kees Cookf4aacea2014-06-06 14:37:19 -07001786static void warn_sysctl_write(struct ctl_table *table)
1787{
1788 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1789 "This will not be supported in the future. To silence this\n"
1790 "warning, set kernel.sysctl_writes_strict = -1\n",
1791 current->comm, table->procname);
1792}
1793
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794/**
1795 * proc_dostring - read a string sysctl
1796 * @table: the sysctl table
1797 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001798 * @buffer: the user buffer
1799 * @lenp: the size of the user buffer
1800 * @ppos: file position
1801 *
1802 * Reads/writes a string from/to the user buffer. If the kernel
1803 * buffer provided is not large enough to hold the string, the
1804 * string is truncated. The copied string is %NULL-terminated.
1805 * If the string is being read by the user process, it is copied
1806 * and a newline '\n' is added. It is truncated if the buffer is
1807 * not large enough.
1808 *
1809 * Returns 0 on success.
1810 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001811int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812 void __user *buffer, size_t *lenp, loff_t *ppos)
1813{
Kees Cookf4aacea2014-06-06 14:37:19 -07001814 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1815 warn_sysctl_write(table);
1816
Kees Cookf8808302014-06-06 14:37:17 -07001817 return _proc_do_string((char *)(table->data), table->maxlen, write,
1818 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819}
1820
Amerigo Wang00b7c332010-05-05 00:26:45 +00001821static size_t proc_skip_spaces(char **buf)
1822{
1823 size_t ret;
1824 char *tmp = skip_spaces(*buf);
1825 ret = tmp - *buf;
1826 *buf = tmp;
1827 return ret;
1828}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001830static void proc_skip_char(char **buf, size_t *size, const char v)
1831{
1832 while (*size) {
1833 if (**buf != v)
1834 break;
1835 (*size)--;
1836 (*buf)++;
1837 }
1838}
1839
Amerigo Wang00b7c332010-05-05 00:26:45 +00001840#define TMPBUFLEN 22
1841/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001842 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001843 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001844 * @buf: a kernel buffer
1845 * @size: size of the kernel buffer
1846 * @val: this is where the number will be stored
1847 * @neg: set to %TRUE if number is negative
1848 * @perm_tr: a vector which contains the allowed trailers
1849 * @perm_tr_len: size of the perm_tr vector
1850 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001851 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001852 * In case of success %0 is returned and @buf and @size are updated with
1853 * the amount of bytes read. If @tr is non-NULL and a trailing
1854 * character exists (size is non-zero after returning from this
1855 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001856 */
1857static int proc_get_long(char **buf, size_t *size,
1858 unsigned long *val, bool *neg,
1859 const char *perm_tr, unsigned perm_tr_len, char *tr)
1860{
1861 int len;
1862 char *p, tmp[TMPBUFLEN];
1863
1864 if (!*size)
1865 return -EINVAL;
1866
1867 len = *size;
1868 if (len > TMPBUFLEN - 1)
1869 len = TMPBUFLEN - 1;
1870
1871 memcpy(tmp, *buf, len);
1872
1873 tmp[len] = 0;
1874 p = tmp;
1875 if (*p == '-' && *size > 1) {
1876 *neg = true;
1877 p++;
1878 } else
1879 *neg = false;
1880 if (!isdigit(*p))
1881 return -EINVAL;
1882
1883 *val = simple_strtoul(p, &p, 0);
1884
1885 len = p - tmp;
1886
1887 /* We don't know if the next char is whitespace thus we may accept
1888 * invalid integers (e.g. 1234...a) or two integers instead of one
1889 * (e.g. 123...1). So lets not allow such large numbers. */
1890 if (len == TMPBUFLEN - 1)
1891 return -EINVAL;
1892
1893 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1894 return -EINVAL;
1895
1896 if (tr && (len < *size))
1897 *tr = *p;
1898
1899 *buf += len;
1900 *size -= len;
1901
1902 return 0;
1903}
1904
1905/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001906 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001907 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001908 * @buf: the user buffer
1909 * @size: the size of the user buffer
1910 * @val: the integer to be converted
1911 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001912 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001913 * In case of success %0 is returned and @buf and @size are updated with
1914 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001915 */
1916static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1917 bool neg)
1918{
1919 int len;
1920 char tmp[TMPBUFLEN], *p = tmp;
1921
1922 sprintf(p, "%s%lu", neg ? "-" : "", val);
1923 len = strlen(tmp);
1924 if (len > *size)
1925 len = *size;
1926 if (copy_to_user(*buf, tmp, len))
1927 return -EFAULT;
1928 *size -= len;
1929 *buf += len;
1930 return 0;
1931}
1932#undef TMPBUFLEN
1933
1934static int proc_put_char(void __user **buf, size_t *size, char c)
1935{
1936 if (*size) {
1937 char __user **buffer = (char __user **)buf;
1938 if (put_user(c, *buffer))
1939 return -EFAULT;
1940 (*size)--, (*buffer)++;
1941 *buf = *buffer;
1942 }
1943 return 0;
1944}
1945
1946static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 int *valp,
1948 int write, void *data)
1949{
1950 if (write) {
1951 *valp = *negp ? -*lvalp : *lvalp;
1952 } else {
1953 int val = *valp;
1954 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001955 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956 *lvalp = (unsigned long)-val;
1957 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001958 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001959 *lvalp = (unsigned long)val;
1960 }
1961 }
1962 return 0;
1963}
1964
Amerigo Wang00b7c332010-05-05 00:26:45 +00001965static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1966
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001967static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001968 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001969 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001970 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001971 int write, void *data),
1972 void *data)
1973{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001974 int *i, vleft, first = 1, err = 0;
1975 unsigned long page = 0;
1976 size_t left;
1977 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001978
Amerigo Wang00b7c332010-05-05 00:26:45 +00001979 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001980 *lenp = 0;
1981 return 0;
1982 }
1983
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001984 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985 vleft = table->maxlen / sizeof(*i);
1986 left = *lenp;
1987
1988 if (!conv)
1989 conv = do_proc_dointvec_conv;
1990
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001992 if (*ppos) {
1993 switch (sysctl_writes_strict) {
1994 case SYSCTL_WRITES_STRICT:
1995 goto out;
1996 case SYSCTL_WRITES_WARN:
1997 warn_sysctl_write(table);
1998 break;
1999 default:
2000 break;
2001 }
2002 }
2003
Amerigo Wang00b7c332010-05-05 00:26:45 +00002004 if (left > PAGE_SIZE - 1)
2005 left = PAGE_SIZE - 1;
2006 page = __get_free_page(GFP_TEMPORARY);
2007 kbuf = (char *) page;
2008 if (!kbuf)
2009 return -ENOMEM;
2010 if (copy_from_user(kbuf, buffer, left)) {
2011 err = -EFAULT;
2012 goto free;
2013 }
2014 kbuf[left] = 0;
2015 }
2016
2017 for (; left && vleft--; i++, first=0) {
2018 unsigned long lval;
2019 bool neg;
2020
2021 if (write) {
2022 left -= proc_skip_spaces(&kbuf);
2023
J. R. Okajima563b0462010-05-25 16:10:14 -07002024 if (!left)
2025 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002026 err = proc_get_long(&kbuf, &left, &lval, &neg,
2027 proc_wspace_sep,
2028 sizeof(proc_wspace_sep), NULL);
2029 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002031 if (conv(&neg, &lval, i, 1, data)) {
2032 err = -EINVAL;
2033 break;
2034 }
2035 } else {
2036 if (conv(&neg, &lval, i, 0, data)) {
2037 err = -EINVAL;
2038 break;
2039 }
2040 if (!first)
2041 err = proc_put_char(&buffer, &left, '\t');
2042 if (err)
2043 break;
2044 err = proc_put_long(&buffer, &left, lval, neg);
2045 if (err)
2046 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047 }
2048 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002049
2050 if (!write && !first && left && !err)
2051 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002052 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002053 left -= proc_skip_spaces(&kbuf);
2054free:
2055 if (write) {
2056 free_page(page);
2057 if (first)
2058 return err ? : -EINVAL;
2059 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002061out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002063 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064}
2065
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002066static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002067 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002068 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002069 int write, void *data),
2070 void *data)
2071{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002072 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002073 buffer, lenp, ppos, conv, data);
2074}
2075
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076/**
2077 * proc_dointvec - read a vector of integers
2078 * @table: the sysctl table
2079 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080 * @buffer: the user buffer
2081 * @lenp: the size of the user buffer
2082 * @ppos: file position
2083 *
2084 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2085 * values from/to the user buffer, treated as an ASCII string.
2086 *
2087 * Returns 0 on success.
2088 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002089int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090 void __user *buffer, size_t *lenp, loff_t *ppos)
2091{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002092 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 NULL,NULL);
2094}
2095
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002096/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002097 * Taint values can only be increased
2098 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002099 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002100static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002101 void __user *buffer, size_t *lenp, loff_t *ppos)
2102{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002103 struct ctl_table t;
2104 unsigned long tmptaint = get_taint();
2105 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002106
Bastian Blank91fcd412007-04-23 14:41:14 -07002107 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002108 return -EPERM;
2109
Andi Kleen25ddbb12008-10-15 22:01:41 -07002110 t = *table;
2111 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002112 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002113 if (err < 0)
2114 return err;
2115
2116 if (write) {
2117 /*
2118 * Poor man's atomic or. Not worth adding a primitive
2119 * to everyone's atomic.h for this
2120 */
2121 int i;
2122 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2123 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302124 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002125 }
2126 }
2127
2128 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002129}
2130
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002131#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002132static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002133 void __user *buffer, size_t *lenp, loff_t *ppos)
2134{
2135 if (write && !capable(CAP_SYS_ADMIN))
2136 return -EPERM;
2137
2138 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2139}
2140#endif
2141
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142struct do_proc_dointvec_minmax_conv_param {
2143 int *min;
2144 int *max;
2145};
2146
Amerigo Wang00b7c332010-05-05 00:26:45 +00002147static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2148 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 int write, void *data)
2150{
2151 struct do_proc_dointvec_minmax_conv_param *param = data;
2152 if (write) {
2153 int val = *negp ? -*lvalp : *lvalp;
2154 if ((param->min && *param->min > val) ||
2155 (param->max && *param->max < val))
2156 return -EINVAL;
2157 *valp = val;
2158 } else {
2159 int val = *valp;
2160 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002161 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002162 *lvalp = (unsigned long)-val;
2163 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002164 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165 *lvalp = (unsigned long)val;
2166 }
2167 }
2168 return 0;
2169}
2170
2171/**
2172 * proc_dointvec_minmax - read a vector of integers with min/max values
2173 * @table: the sysctl table
2174 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175 * @buffer: the user buffer
2176 * @lenp: the size of the user buffer
2177 * @ppos: file position
2178 *
2179 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2180 * values from/to the user buffer, treated as an ASCII string.
2181 *
2182 * This routine will ensure the values are within the range specified by
2183 * table->extra1 (min) and table->extra2 (max).
2184 *
2185 * Returns 0 on success.
2186 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002187int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 void __user *buffer, size_t *lenp, loff_t *ppos)
2189{
2190 struct do_proc_dointvec_minmax_conv_param param = {
2191 .min = (int *) table->extra1,
2192 .max = (int *) table->extra2,
2193 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002194 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 do_proc_dointvec_minmax_conv, &param);
2196}
2197
Kees Cook54b50192012-07-30 14:39:18 -07002198static void validate_coredump_safety(void)
2199{
Alex Kelly046d6622012-10-04 17:15:23 -07002200#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002201 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002202 core_pattern[0] != '/' && core_pattern[0] != '|') {
2203 printk(KERN_WARNING "Unsafe core_pattern used with "\
2204 "suid_dumpable=2. Pipe handler or fully qualified "\
2205 "core dump path required.\n");
2206 }
Alex Kelly046d6622012-10-04 17:15:23 -07002207#endif
Kees Cook54b50192012-07-30 14:39:18 -07002208}
2209
2210static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2211 void __user *buffer, size_t *lenp, loff_t *ppos)
2212{
2213 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2214 if (!error)
2215 validate_coredump_safety();
2216 return error;
2217}
2218
Alex Kelly046d6622012-10-04 17:15:23 -07002219#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002220static int proc_dostring_coredump(struct ctl_table *table, int write,
2221 void __user *buffer, size_t *lenp, loff_t *ppos)
2222{
2223 int error = proc_dostring(table, write, buffer, lenp, ppos);
2224 if (!error)
2225 validate_coredump_safety();
2226 return error;
2227}
Alex Kelly046d6622012-10-04 17:15:23 -07002228#endif
Kees Cook54b50192012-07-30 14:39:18 -07002229
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002230static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231 void __user *buffer,
2232 size_t *lenp, loff_t *ppos,
2233 unsigned long convmul,
2234 unsigned long convdiv)
2235{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 unsigned long *i, *min, *max;
2237 int vleft, first = 1, err = 0;
2238 unsigned long page = 0;
2239 size_t left;
2240 char *kbuf;
2241
2242 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 *lenp = 0;
2244 return 0;
2245 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002246
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002247 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248 min = (unsigned long *) table->extra1;
2249 max = (unsigned long *) table->extra2;
2250 vleft = table->maxlen / sizeof(unsigned long);
2251 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002252
2253 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002254 if (*ppos) {
2255 switch (sysctl_writes_strict) {
2256 case SYSCTL_WRITES_STRICT:
2257 goto out;
2258 case SYSCTL_WRITES_WARN:
2259 warn_sysctl_write(table);
2260 break;
2261 default:
2262 break;
2263 }
2264 }
2265
Amerigo Wang00b7c332010-05-05 00:26:45 +00002266 if (left > PAGE_SIZE - 1)
2267 left = PAGE_SIZE - 1;
2268 page = __get_free_page(GFP_TEMPORARY);
2269 kbuf = (char *) page;
2270 if (!kbuf)
2271 return -ENOMEM;
2272 if (copy_from_user(kbuf, buffer, left)) {
2273 err = -EFAULT;
2274 goto free;
2275 }
2276 kbuf[left] = 0;
2277 }
2278
Eric Dumazet27b3d802010-10-07 12:59:29 -07002279 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002280 unsigned long val;
2281
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002283 bool neg;
2284
2285 left -= proc_skip_spaces(&kbuf);
2286
2287 err = proc_get_long(&kbuf, &left, &val, &neg,
2288 proc_wspace_sep,
2289 sizeof(proc_wspace_sep), NULL);
2290 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 break;
2292 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293 continue;
2294 if ((min && val < *min) || (max && val > *max))
2295 continue;
2296 *i = val;
2297 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002298 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002299 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002301 if (err)
2302 break;
2303 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002304 err = proc_put_long(&buffer, &left, val, false);
2305 if (err)
2306 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 }
2308 }
2309
Amerigo Wang00b7c332010-05-05 00:26:45 +00002310 if (!write && !first && left && !err)
2311 err = proc_put_char(&buffer, &left, '\n');
2312 if (write && !err)
2313 left -= proc_skip_spaces(&kbuf);
2314free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002316 free_page(page);
2317 if (first)
2318 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002321out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002323 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324}
2325
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002326static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002327 void __user *buffer,
2328 size_t *lenp, loff_t *ppos,
2329 unsigned long convmul,
2330 unsigned long convdiv)
2331{
2332 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002333 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002334}
2335
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336/**
2337 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2338 * @table: the sysctl table
2339 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 * @buffer: the user buffer
2341 * @lenp: the size of the user buffer
2342 * @ppos: file position
2343 *
2344 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2345 * values from/to the user buffer, treated as an ASCII string.
2346 *
2347 * This routine will ensure the values are within the range specified by
2348 * table->extra1 (min) and table->extra2 (max).
2349 *
2350 * Returns 0 on success.
2351 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002352int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 void __user *buffer, size_t *lenp, loff_t *ppos)
2354{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002355 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356}
2357
2358/**
2359 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2360 * @table: the sysctl table
2361 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 * @buffer: the user buffer
2363 * @lenp: the size of the user buffer
2364 * @ppos: file position
2365 *
2366 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2367 * values from/to the user buffer, treated as an ASCII string. The values
2368 * are treated as milliseconds, and converted to jiffies when they are stored.
2369 *
2370 * This routine will ensure the values are within the range specified by
2371 * table->extra1 (min) and table->extra2 (max).
2372 *
2373 * Returns 0 on success.
2374 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002375int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 void __user *buffer,
2377 size_t *lenp, loff_t *ppos)
2378{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002379 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 lenp, ppos, HZ, 1000l);
2381}
2382
2383
Amerigo Wang00b7c332010-05-05 00:26:45 +00002384static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 int *valp,
2386 int write, void *data)
2387{
2388 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002389 if (*lvalp > LONG_MAX / HZ)
2390 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2392 } else {
2393 int val = *valp;
2394 unsigned long lval;
2395 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002396 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 lval = (unsigned long)-val;
2398 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002399 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 lval = (unsigned long)val;
2401 }
2402 *lvalp = lval / HZ;
2403 }
2404 return 0;
2405}
2406
Amerigo Wang00b7c332010-05-05 00:26:45 +00002407static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 int *valp,
2409 int write, void *data)
2410{
2411 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002412 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2413 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2415 } else {
2416 int val = *valp;
2417 unsigned long lval;
2418 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002419 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 lval = (unsigned long)-val;
2421 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002422 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 lval = (unsigned long)val;
2424 }
2425 *lvalp = jiffies_to_clock_t(lval);
2426 }
2427 return 0;
2428}
2429
Amerigo Wang00b7c332010-05-05 00:26:45 +00002430static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 int *valp,
2432 int write, void *data)
2433{
2434 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002435 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2436
2437 if (jif > INT_MAX)
2438 return 1;
2439 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002440 } else {
2441 int val = *valp;
2442 unsigned long lval;
2443 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002444 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 lval = (unsigned long)-val;
2446 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002447 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 lval = (unsigned long)val;
2449 }
2450 *lvalp = jiffies_to_msecs(lval);
2451 }
2452 return 0;
2453}
2454
2455/**
2456 * proc_dointvec_jiffies - read a vector of integers as seconds
2457 * @table: the sysctl table
2458 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 * @buffer: the user buffer
2460 * @lenp: the size of the user buffer
2461 * @ppos: file position
2462 *
2463 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2464 * values from/to the user buffer, treated as an ASCII string.
2465 * The values read are assumed to be in seconds, and are converted into
2466 * jiffies.
2467 *
2468 * Returns 0 on success.
2469 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002470int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 void __user *buffer, size_t *lenp, loff_t *ppos)
2472{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002473 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474 do_proc_dointvec_jiffies_conv,NULL);
2475}
2476
2477/**
2478 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2479 * @table: the sysctl table
2480 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 * @buffer: the user buffer
2482 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002483 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484 *
2485 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2486 * values from/to the user buffer, treated as an ASCII string.
2487 * The values read are assumed to be in 1/USER_HZ seconds, and
2488 * are converted into jiffies.
2489 *
2490 * Returns 0 on success.
2491 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002492int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 void __user *buffer, size_t *lenp, loff_t *ppos)
2494{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002495 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 do_proc_dointvec_userhz_jiffies_conv,NULL);
2497}
2498
2499/**
2500 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2501 * @table: the sysctl table
2502 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 * @buffer: the user buffer
2504 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002505 * @ppos: file position
2506 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 *
2508 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2509 * values from/to the user buffer, treated as an ASCII string.
2510 * The values read are assumed to be in 1/1000 seconds, and
2511 * are converted into jiffies.
2512 *
2513 * Returns 0 on success.
2514 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002515int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 void __user *buffer, size_t *lenp, loff_t *ppos)
2517{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002518 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 do_proc_dointvec_ms_jiffies_conv, NULL);
2520}
2521
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002522static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002523 void __user *buffer, size_t *lenp, loff_t *ppos)
2524{
2525 struct pid *new_pid;
2526 pid_t tmp;
2527 int r;
2528
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002529 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002530
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002531 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002532 lenp, ppos, NULL, NULL);
2533 if (r || !write)
2534 return r;
2535
2536 new_pid = find_get_pid(tmp);
2537 if (!new_pid)
2538 return -ESRCH;
2539
2540 put_pid(xchg(&cad_pid, new_pid));
2541 return 0;
2542}
2543
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002544/**
2545 * proc_do_large_bitmap - read/write from/to a large bitmap
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
2548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
2550 * @ppos: file position
2551 *
2552 * The bitmap is stored at table->data and the bitmap length (in bits)
2553 * in table->maxlen.
2554 *
2555 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2556 * large bitmaps may be represented in a compact manner. Writing into
2557 * the file will clear the bitmap then update it with the given input.
2558 *
2559 * Returns 0 on success.
2560 */
2561int proc_do_large_bitmap(struct ctl_table *table, int write,
2562 void __user *buffer, size_t *lenp, loff_t *ppos)
2563{
2564 int err = 0;
2565 bool first = 1;
2566 size_t left = *lenp;
2567 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002568 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002569 unsigned long *tmp_bitmap = NULL;
2570 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2571
WANG Cong122ff242014-05-12 16:04:53 -07002572 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002573 *lenp = 0;
2574 return 0;
2575 }
2576
2577 if (write) {
2578 unsigned long page = 0;
2579 char *kbuf;
2580
2581 if (left > PAGE_SIZE - 1)
2582 left = PAGE_SIZE - 1;
2583
2584 page = __get_free_page(GFP_TEMPORARY);
2585 kbuf = (char *) page;
2586 if (!kbuf)
2587 return -ENOMEM;
2588 if (copy_from_user(kbuf, buffer, left)) {
2589 free_page(page);
2590 return -EFAULT;
2591 }
2592 kbuf[left] = 0;
2593
2594 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2595 GFP_KERNEL);
2596 if (!tmp_bitmap) {
2597 free_page(page);
2598 return -ENOMEM;
2599 }
2600 proc_skip_char(&kbuf, &left, '\n');
2601 while (!err && left) {
2602 unsigned long val_a, val_b;
2603 bool neg;
2604
2605 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2606 sizeof(tr_a), &c);
2607 if (err)
2608 break;
2609 if (val_a >= bitmap_len || neg) {
2610 err = -EINVAL;
2611 break;
2612 }
2613
2614 val_b = val_a;
2615 if (left) {
2616 kbuf++;
2617 left--;
2618 }
2619
2620 if (c == '-') {
2621 err = proc_get_long(&kbuf, &left, &val_b,
2622 &neg, tr_b, sizeof(tr_b),
2623 &c);
2624 if (err)
2625 break;
2626 if (val_b >= bitmap_len || neg ||
2627 val_a > val_b) {
2628 err = -EINVAL;
2629 break;
2630 }
2631 if (left) {
2632 kbuf++;
2633 left--;
2634 }
2635 }
2636
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002637 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002638 first = 0;
2639 proc_skip_char(&kbuf, &left, '\n');
2640 }
2641 free_page(page);
2642 } else {
2643 unsigned long bit_a, bit_b = 0;
2644
2645 while (left) {
2646 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2647 if (bit_a >= bitmap_len)
2648 break;
2649 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2650 bit_a + 1) - 1;
2651
2652 if (!first) {
2653 err = proc_put_char(&buffer, &left, ',');
2654 if (err)
2655 break;
2656 }
2657 err = proc_put_long(&buffer, &left, bit_a, false);
2658 if (err)
2659 break;
2660 if (bit_a != bit_b) {
2661 err = proc_put_char(&buffer, &left, '-');
2662 if (err)
2663 break;
2664 err = proc_put_long(&buffer, &left, bit_b, false);
2665 if (err)
2666 break;
2667 }
2668
2669 first = 0; bit_b++;
2670 }
2671 if (!err)
2672 err = proc_put_char(&buffer, &left, '\n');
2673 }
2674
2675 if (!err) {
2676 if (write) {
2677 if (*ppos)
2678 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2679 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002680 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002681 }
2682 kfree(tmp_bitmap);
2683 *lenp -= left;
2684 *ppos += *lenp;
2685 return 0;
2686 } else {
2687 kfree(tmp_bitmap);
2688 return err;
2689 }
2690}
2691
Jovi Zhang55610502011-01-12 17:00:45 -08002692#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002693
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002694int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002695 void __user *buffer, size_t *lenp, loff_t *ppos)
2696{
2697 return -ENOSYS;
2698}
2699
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002700int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002701 void __user *buffer, size_t *lenp, loff_t *ppos)
2702{
2703 return -ENOSYS;
2704}
2705
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002706int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002707 void __user *buffer, size_t *lenp, loff_t *ppos)
2708{
2709 return -ENOSYS;
2710}
2711
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002712int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 void __user *buffer, size_t *lenp, loff_t *ppos)
2714{
2715 return -ENOSYS;
2716}
2717
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002718int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719 void __user *buffer, size_t *lenp, loff_t *ppos)
2720{
2721 return -ENOSYS;
2722}
2723
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002724int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002725 void __user *buffer, size_t *lenp, loff_t *ppos)
2726{
2727 return -ENOSYS;
2728}
2729
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002730int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002731 void __user *buffer, size_t *lenp, loff_t *ppos)
2732{
2733 return -ENOSYS;
2734}
2735
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002736int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 void __user *buffer,
2738 size_t *lenp, loff_t *ppos)
2739{
2740 return -ENOSYS;
2741}
2742
2743
Jovi Zhang55610502011-01-12 17:00:45 -08002744#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745
Linus Torvalds1da177e2005-04-16 15:20:36 -07002746/*
2747 * No sense putting this after each symbol definition, twice,
2748 * exception granted :-)
2749 */
2750EXPORT_SYMBOL(proc_dointvec);
2751EXPORT_SYMBOL(proc_dointvec_jiffies);
2752EXPORT_SYMBOL(proc_dointvec_minmax);
2753EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2754EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2755EXPORT_SYMBOL(proc_dostring);
2756EXPORT_SYMBOL(proc_doulongvec_minmax);
2757EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);