blob: 15f2511a1b7c6e04a48f99c1b6a402f008607ba3 [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
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001107 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108};
1109
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001110static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .procname = "overcommit_memory",
1113 .data = &sysctl_overcommit_memory,
1114 .maxlen = sizeof(sysctl_overcommit_memory),
1115 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001116 .proc_handler = proc_dointvec_minmax,
1117 .extra1 = &zero,
1118 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 },
1120 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001121 .procname = "panic_on_oom",
1122 .data = &sysctl_panic_on_oom,
1123 .maxlen = sizeof(sysctl_panic_on_oom),
1124 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001125 .proc_handler = proc_dointvec_minmax,
1126 .extra1 = &zero,
1127 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001128 },
1129 {
David Rientjesfe071d72007-10-16 23:25:56 -07001130 .procname = "oom_kill_allocating_task",
1131 .data = &sysctl_oom_kill_allocating_task,
1132 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1133 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001134 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001135 },
1136 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001137 .procname = "oom_dump_tasks",
1138 .data = &sysctl_oom_dump_tasks,
1139 .maxlen = sizeof(sysctl_oom_dump_tasks),
1140 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001141 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001142 },
1143 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .procname = "overcommit_ratio",
1145 .data = &sysctl_overcommit_ratio,
1146 .maxlen = sizeof(sysctl_overcommit_ratio),
1147 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001148 .proc_handler = overcommit_ratio_handler,
1149 },
1150 {
1151 .procname = "overcommit_kbytes",
1152 .data = &sysctl_overcommit_kbytes,
1153 .maxlen = sizeof(sysctl_overcommit_kbytes),
1154 .mode = 0644,
1155 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 },
1157 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .procname = "page-cluster",
1159 .data = &page_cluster,
1160 .maxlen = sizeof(int),
1161 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001162 .proc_handler = proc_dointvec_minmax,
1163 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 },
1165 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 .procname = "dirty_background_ratio",
1167 .data = &dirty_background_ratio,
1168 .maxlen = sizeof(dirty_background_ratio),
1169 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001170 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 .extra1 = &zero,
1172 .extra2 = &one_hundred,
1173 },
1174 {
David Rientjes2da02992009-01-06 14:39:31 -08001175 .procname = "dirty_background_bytes",
1176 .data = &dirty_background_bytes,
1177 .maxlen = sizeof(dirty_background_bytes),
1178 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001179 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001180 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001181 },
1182 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .procname = "dirty_ratio",
1184 .data = &vm_dirty_ratio,
1185 .maxlen = sizeof(vm_dirty_ratio),
1186 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001187 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 .extra1 = &zero,
1189 .extra2 = &one_hundred,
1190 },
1191 {
David Rientjes2da02992009-01-06 14:39:31 -08001192 .procname = "dirty_bytes",
1193 .data = &vm_dirty_bytes,
1194 .maxlen = sizeof(vm_dirty_bytes),
1195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001197 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001198 },
1199 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001201 .data = &dirty_writeback_interval,
1202 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001204 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 },
1206 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001208 .data = &dirty_expire_interval,
1209 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001211 .proc_handler = proc_dointvec_minmax,
1212 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213 },
1214 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001215 .procname = "nr_pdflush_threads",
1216 .mode = 0444 /* read-only */,
1217 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 },
1219 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 .procname = "swappiness",
1221 .data = &vm_swappiness,
1222 .maxlen = sizeof(vm_swappiness),
1223 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001224 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 .extra1 = &zero,
1226 .extra2 = &one_hundred,
1227 },
1228#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001229 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001231 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 .maxlen = sizeof(unsigned long),
1233 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001234 .proc_handler = hugetlb_sysctl_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001235 .extra1 = &zero,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001236 },
1237#ifdef CONFIG_NUMA
1238 {
1239 .procname = "nr_hugepages_mempolicy",
1240 .data = NULL,
1241 .maxlen = sizeof(unsigned long),
1242 .mode = 0644,
1243 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001244 .extra1 = &zero,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001245 },
1246#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 .procname = "hugetlb_shm_group",
1249 .data = &sysctl_hugetlb_shm_group,
1250 .maxlen = sizeof(gid_t),
1251 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001252 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 },
Mel Gorman396faf02007-07-17 04:03:13 -07001254 {
Mel Gorman396faf02007-07-17 04:03:13 -07001255 .procname = "hugepages_treat_as_movable",
1256 .data = &hugepages_treat_as_movable,
1257 .maxlen = sizeof(int),
1258 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001259 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001260 },
Adam Litke54f9f802007-10-16 01:26:20 -07001261 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001262 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001263 .data = NULL,
1264 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001265 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001266 .proc_handler = hugetlb_overcommit_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001267 .extra1 = &zero,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001268 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269#endif
1270 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 .procname = "lowmem_reserve_ratio",
1272 .data = &sysctl_lowmem_reserve_ratio,
1273 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1274 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001275 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 },
1277 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001278 .procname = "drop_caches",
1279 .data = &sysctl_drop_caches,
1280 .maxlen = sizeof(int),
1281 .mode = 0644,
1282 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001283 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001284 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001285 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001286#ifdef CONFIG_COMPACTION
1287 {
1288 .procname = "compact_memory",
1289 .data = &sysctl_compact_memory,
1290 .maxlen = sizeof(int),
1291 .mode = 0200,
1292 .proc_handler = sysctl_compaction_handler,
1293 },
Mel Gorman5e771902010-05-24 14:32:31 -07001294 {
1295 .procname = "extfrag_threshold",
1296 .data = &sysctl_extfrag_threshold,
1297 .maxlen = sizeof(int),
1298 .mode = 0644,
1299 .proc_handler = sysctl_extfrag_handler,
1300 .extra1 = &min_extfrag_threshold,
1301 .extra2 = &max_extfrag_threshold,
1302 },
1303
Mel Gorman76ab0f52010-05-24 14:32:28 -07001304#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001305 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001306 .procname = "min_free_kbytes",
1307 .data = &min_free_kbytes,
1308 .maxlen = sizeof(min_free_kbytes),
1309 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001310 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 .extra1 = &zero,
1312 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001313 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001314 .procname = "percpu_pagelist_fraction",
1315 .data = &percpu_pagelist_fraction,
1316 .maxlen = sizeof(percpu_pagelist_fraction),
1317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001319 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001320 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321#ifdef CONFIG_MMU
1322 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 .procname = "max_map_count",
1324 .data = &sysctl_max_map_count,
1325 .maxlen = sizeof(sysctl_max_map_count),
1326 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001327 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001328 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001330#else
1331 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001332 .procname = "nr_trim_pages",
1333 .data = &sysctl_nr_trim_pages,
1334 .maxlen = sizeof(sysctl_nr_trim_pages),
1335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001336 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001337 .extra1 = &zero,
1338 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339#endif
1340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 .procname = "laptop_mode",
1342 .data = &laptop_mode,
1343 .maxlen = sizeof(laptop_mode),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 },
1347 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 .procname = "block_dump",
1349 .data = &block_dump,
1350 .maxlen = sizeof(block_dump),
1351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001352 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .extra1 = &zero,
1354 },
1355 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 .procname = "vfs_cache_pressure",
1357 .data = &sysctl_vfs_cache_pressure,
1358 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 .extra1 = &zero,
1362 },
1363#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1364 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 .procname = "legacy_va_layout",
1366 .data = &sysctl_legacy_va_layout,
1367 .maxlen = sizeof(sysctl_legacy_va_layout),
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#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001373#ifdef CONFIG_NUMA
1374 {
Christoph Lameter17436602006-01-18 17:42:32 -08001375 .procname = "zone_reclaim_mode",
1376 .data = &zone_reclaim_mode,
1377 .maxlen = sizeof(zone_reclaim_mode),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001380 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001381 },
Christoph Lameter96146342006-07-03 00:24:13 -07001382 {
Christoph Lameter96146342006-07-03 00:24:13 -07001383 .procname = "min_unmapped_ratio",
1384 .data = &sysctl_min_unmapped_ratio,
1385 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001388 .extra1 = &zero,
1389 .extra2 = &one_hundred,
1390 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001391 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001392 .procname = "min_slab_ratio",
1393 .data = &sysctl_min_slab_ratio,
1394 .maxlen = sizeof(sysctl_min_slab_ratio),
1395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001396 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001397 .extra1 = &zero,
1398 .extra2 = &one_hundred,
1399 },
Christoph Lameter17436602006-01-18 17:42:32 -08001400#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001401#ifdef CONFIG_SMP
1402 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001403 .procname = "stat_interval",
1404 .data = &sysctl_stat_interval,
1405 .maxlen = sizeof(sysctl_stat_interval),
1406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001407 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001408 },
1409#endif
David Howells6e141542009-12-15 19:27:45 +00001410#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001411 {
Eric Parised032182007-06-28 15:55:21 -04001412 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001413 .data = &dac_mmap_min_addr,
1414 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001416 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001417 },
David Howells6e141542009-12-15 19:27:45 +00001418#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001419#ifdef CONFIG_NUMA
1420 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001421 .procname = "numa_zonelist_order",
1422 .data = &numa_zonelist_order,
1423 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001425 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001426 },
1427#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001428#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001429 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001430 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001431 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001432#ifdef CONFIG_X86_32
1433 .data = &vdso32_enabled,
1434 .maxlen = sizeof(vdso32_enabled),
1435#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001436 .data = &vdso_enabled,
1437 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001438#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001439 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001440 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001441 .extra1 = &zero,
1442 },
1443#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001444#ifdef CONFIG_HIGHMEM
1445 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001446 .procname = "highmem_is_dirtyable",
1447 .data = &vm_highmem_is_dirtyable,
1448 .maxlen = sizeof(vm_highmem_is_dirtyable),
1449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001450 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001451 .extra1 = &zero,
1452 .extra2 = &one,
1453 },
1454#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001455#ifdef CONFIG_MEMORY_FAILURE
1456 {
Andi Kleen6a460792009-09-16 11:50:15 +02001457 .procname = "memory_failure_early_kill",
1458 .data = &sysctl_memory_failure_early_kill,
1459 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001461 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001462 .extra1 = &zero,
1463 .extra2 = &one,
1464 },
1465 {
Andi Kleen6a460792009-09-16 11:50:15 +02001466 .procname = "memory_failure_recovery",
1467 .data = &sysctl_memory_failure_recovery,
1468 .maxlen = sizeof(sysctl_memory_failure_recovery),
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#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001475 {
1476 .procname = "user_reserve_kbytes",
1477 .data = &sysctl_user_reserve_kbytes,
1478 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1479 .mode = 0644,
1480 .proc_handler = proc_doulongvec_minmax,
1481 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001482 {
1483 .procname = "admin_reserve_kbytes",
1484 .data = &sysctl_admin_reserve_kbytes,
1485 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1486 .mode = 0644,
1487 .proc_handler = proc_doulongvec_minmax,
1488 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001489 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490};
1491
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001492#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001493static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001494 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001495};
1496#endif
1497
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001498static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 .procname = "inode-nr",
1501 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001502 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001504 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 },
1506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .procname = "inode-state",
1508 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001509 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001511 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 },
1513 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .procname = "file-nr",
1515 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001516 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001518 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 },
1520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 .procname = "file-max",
1522 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001523 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001525 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 },
1527 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001528 .procname = "nr_open",
1529 .data = &sysctl_nr_open,
1530 .maxlen = sizeof(int),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001533 .extra1 = &sysctl_nr_open_min,
1534 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001535 },
1536 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 .procname = "dentry-state",
1538 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001539 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001541 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 },
1543 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 .procname = "overflowuid",
1545 .data = &fs_overflowuid,
1546 .maxlen = sizeof(int),
1547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001548 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .extra1 = &minolduid,
1550 .extra2 = &maxolduid,
1551 },
1552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 .procname = "overflowgid",
1554 .data = &fs_overflowgid,
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 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001561#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 .procname = "leases-enable",
1564 .data = &leases_enable,
1565 .maxlen = sizeof(int),
1566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001569#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001570#ifdef CONFIG_DNOTIFY
1571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 .procname = "dir-notify-enable",
1573 .data = &dir_notify_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 },
1578#endif
1579#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001580#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 .procname = "lease-break-time",
1583 .data = &lease_break_time,
1584 .maxlen = sizeof(int),
1585 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001586 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001588#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001589#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001590 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 .procname = "aio-nr",
1592 .data = &aio_nr,
1593 .maxlen = sizeof(aio_nr),
1594 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001595 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 },
1597 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598 .procname = "aio-max-nr",
1599 .data = &aio_max_nr,
1600 .maxlen = sizeof(aio_max_nr),
1601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001602 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001603 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001604#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001605#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001606 {
Robert Love0399cb02005-07-13 12:38:18 -04001607 .procname = "inotify",
1608 .mode = 0555,
1609 .child = inotify_table,
1610 },
1611#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001612#ifdef CONFIG_EPOLL
1613 {
1614 .procname = "epoll",
1615 .mode = 0555,
1616 .child = epoll_table,
1617 },
1618#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001620 {
Kees Cook800179c2012-07-25 17:29:07 -07001621 .procname = "protected_symlinks",
1622 .data = &sysctl_protected_symlinks,
1623 .maxlen = sizeof(int),
1624 .mode = 0600,
1625 .proc_handler = proc_dointvec_minmax,
1626 .extra1 = &zero,
1627 .extra2 = &one,
1628 },
1629 {
1630 .procname = "protected_hardlinks",
1631 .data = &sysctl_protected_hardlinks,
1632 .maxlen = sizeof(int),
1633 .mode = 0600,
1634 .proc_handler = proc_dointvec_minmax,
1635 .extra1 = &zero,
1636 .extra2 = &one,
1637 },
1638 {
Alan Coxd6e71142005-06-23 00:09:43 -07001639 .procname = "suid_dumpable",
1640 .data = &suid_dumpable,
1641 .maxlen = sizeof(int),
1642 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001643 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001644 .extra1 = &zero,
1645 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001646 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001647#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1648 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001649 .procname = "binfmt_misc",
1650 .mode = 0555,
1651 .child = binfmt_misc_table,
1652 },
1653#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001654 {
Jens Axboeff9da692010-06-03 14:54:39 +02001655 .procname = "pipe-max-size",
1656 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001657 .maxlen = sizeof(int),
1658 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001659 .proc_handler = &pipe_proc_fn,
1660 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001661 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001662 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663};
1664
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001665static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001666#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001667 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001668 .procname = "exception-trace",
1669 .data = &show_unhandled_signals,
1670 .maxlen = sizeof(int),
1671 .mode = 0644,
1672 .proc_handler = proc_dointvec
1673 },
1674#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001675#if defined(CONFIG_OPTPROBES)
1676 {
1677 .procname = "kprobes-optimization",
1678 .data = &sysctl_kprobes_optimization,
1679 .maxlen = sizeof(int),
1680 .mode = 0644,
1681 .proc_handler = proc_kprobes_optimization_handler,
1682 .extra1 = &zero,
1683 .extra2 = &one,
1684 },
1685#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001686 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687};
1688
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001689static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001690 { }
Robert Love0eeca282005-07-12 17:06:03 -04001691};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001693int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001694{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001695 struct ctl_table_header *hdr;
1696
1697 hdr = register_sysctl_table(sysctl_base_table);
1698 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001699 return 0;
1700}
1701
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001702#endif /* CONFIG_SYSCTL */
1703
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704/*
1705 * /proc/sys support
1706 */
1707
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001708#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709
Kees Cookf8808302014-06-06 14:37:17 -07001710static int _proc_do_string(char *data, int maxlen, int write,
1711 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001712 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001713{
1714 size_t len;
1715 char __user *p;
1716 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001717
1718 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001719 *lenp = 0;
1720 return 0;
1721 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001722
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001723 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001724 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1725 /* Only continue writes not past the end of buffer. */
1726 len = strlen(data);
1727 if (len > maxlen - 1)
1728 len = maxlen - 1;
1729
1730 if (*ppos > len)
1731 return 0;
1732 len = *ppos;
1733 } else {
1734 /* Start writing from beginning of buffer. */
1735 len = 0;
1736 }
1737
Kees Cook2ca9bb42014-06-06 14:37:18 -07001738 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001739 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001740 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001741 if (get_user(c, p++))
1742 return -EFAULT;
1743 if (c == 0 || c == '\n')
1744 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001745 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001746 }
Kees Cookf8808302014-06-06 14:37:17 -07001747 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001748 } else {
1749 len = strlen(data);
1750 if (len > maxlen)
1751 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001752
1753 if (*ppos > len) {
1754 *lenp = 0;
1755 return 0;
1756 }
1757
1758 data += *ppos;
1759 len -= *ppos;
1760
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001761 if (len > *lenp)
1762 len = *lenp;
1763 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001764 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001765 return -EFAULT;
1766 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001767 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001768 return -EFAULT;
1769 len++;
1770 }
1771 *lenp = len;
1772 *ppos += len;
1773 }
1774 return 0;
1775}
1776
Kees Cookf4aacea2014-06-06 14:37:19 -07001777static void warn_sysctl_write(struct ctl_table *table)
1778{
1779 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1780 "This will not be supported in the future. To silence this\n"
1781 "warning, set kernel.sysctl_writes_strict = -1\n",
1782 current->comm, table->procname);
1783}
1784
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785/**
1786 * proc_dostring - read a string sysctl
1787 * @table: the sysctl table
1788 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001789 * @buffer: the user buffer
1790 * @lenp: the size of the user buffer
1791 * @ppos: file position
1792 *
1793 * Reads/writes a string from/to the user buffer. If the kernel
1794 * buffer provided is not large enough to hold the string, the
1795 * string is truncated. The copied string is %NULL-terminated.
1796 * If the string is being read by the user process, it is copied
1797 * and a newline '\n' is added. It is truncated if the buffer is
1798 * not large enough.
1799 *
1800 * Returns 0 on success.
1801 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001802int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803 void __user *buffer, size_t *lenp, loff_t *ppos)
1804{
Kees Cookf4aacea2014-06-06 14:37:19 -07001805 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1806 warn_sysctl_write(table);
1807
Kees Cookf8808302014-06-06 14:37:17 -07001808 return _proc_do_string((char *)(table->data), table->maxlen, write,
1809 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001810}
1811
Amerigo Wang00b7c332010-05-05 00:26:45 +00001812static size_t proc_skip_spaces(char **buf)
1813{
1814 size_t ret;
1815 char *tmp = skip_spaces(*buf);
1816 ret = tmp - *buf;
1817 *buf = tmp;
1818 return ret;
1819}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001821static void proc_skip_char(char **buf, size_t *size, const char v)
1822{
1823 while (*size) {
1824 if (**buf != v)
1825 break;
1826 (*size)--;
1827 (*buf)++;
1828 }
1829}
1830
Amerigo Wang00b7c332010-05-05 00:26:45 +00001831#define TMPBUFLEN 22
1832/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001833 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001834 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001835 * @buf: a kernel buffer
1836 * @size: size of the kernel buffer
1837 * @val: this is where the number will be stored
1838 * @neg: set to %TRUE if number is negative
1839 * @perm_tr: a vector which contains the allowed trailers
1840 * @perm_tr_len: size of the perm_tr vector
1841 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001842 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001843 * In case of success %0 is returned and @buf and @size are updated with
1844 * the amount of bytes read. If @tr is non-NULL and a trailing
1845 * character exists (size is non-zero after returning from this
1846 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001847 */
1848static int proc_get_long(char **buf, size_t *size,
1849 unsigned long *val, bool *neg,
1850 const char *perm_tr, unsigned perm_tr_len, char *tr)
1851{
1852 int len;
1853 char *p, tmp[TMPBUFLEN];
1854
1855 if (!*size)
1856 return -EINVAL;
1857
1858 len = *size;
1859 if (len > TMPBUFLEN - 1)
1860 len = TMPBUFLEN - 1;
1861
1862 memcpy(tmp, *buf, len);
1863
1864 tmp[len] = 0;
1865 p = tmp;
1866 if (*p == '-' && *size > 1) {
1867 *neg = true;
1868 p++;
1869 } else
1870 *neg = false;
1871 if (!isdigit(*p))
1872 return -EINVAL;
1873
1874 *val = simple_strtoul(p, &p, 0);
1875
1876 len = p - tmp;
1877
1878 /* We don't know if the next char is whitespace thus we may accept
1879 * invalid integers (e.g. 1234...a) or two integers instead of one
1880 * (e.g. 123...1). So lets not allow such large numbers. */
1881 if (len == TMPBUFLEN - 1)
1882 return -EINVAL;
1883
1884 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1885 return -EINVAL;
1886
1887 if (tr && (len < *size))
1888 *tr = *p;
1889
1890 *buf += len;
1891 *size -= len;
1892
1893 return 0;
1894}
1895
1896/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001897 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001898 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001899 * @buf: the user buffer
1900 * @size: the size of the user buffer
1901 * @val: the integer to be converted
1902 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001903 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001904 * In case of success %0 is returned and @buf and @size are updated with
1905 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001906 */
1907static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1908 bool neg)
1909{
1910 int len;
1911 char tmp[TMPBUFLEN], *p = tmp;
1912
1913 sprintf(p, "%s%lu", neg ? "-" : "", val);
1914 len = strlen(tmp);
1915 if (len > *size)
1916 len = *size;
1917 if (copy_to_user(*buf, tmp, len))
1918 return -EFAULT;
1919 *size -= len;
1920 *buf += len;
1921 return 0;
1922}
1923#undef TMPBUFLEN
1924
1925static int proc_put_char(void __user **buf, size_t *size, char c)
1926{
1927 if (*size) {
1928 char __user **buffer = (char __user **)buf;
1929 if (put_user(c, *buffer))
1930 return -EFAULT;
1931 (*size)--, (*buffer)++;
1932 *buf = *buffer;
1933 }
1934 return 0;
1935}
1936
1937static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 int *valp,
1939 int write, void *data)
1940{
1941 if (write) {
1942 *valp = *negp ? -*lvalp : *lvalp;
1943 } else {
1944 int val = *valp;
1945 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001946 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 *lvalp = (unsigned long)-val;
1948 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001949 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950 *lvalp = (unsigned long)val;
1951 }
1952 }
1953 return 0;
1954}
1955
Amerigo Wang00b7c332010-05-05 00:26:45 +00001956static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1957
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001958static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001959 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001960 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001961 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962 int write, void *data),
1963 void *data)
1964{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001965 int *i, vleft, first = 1, err = 0;
1966 unsigned long page = 0;
1967 size_t left;
1968 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001969
Amerigo Wang00b7c332010-05-05 00:26:45 +00001970 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001971 *lenp = 0;
1972 return 0;
1973 }
1974
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001975 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 vleft = table->maxlen / sizeof(*i);
1977 left = *lenp;
1978
1979 if (!conv)
1980 conv = do_proc_dointvec_conv;
1981
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001983 if (*ppos) {
1984 switch (sysctl_writes_strict) {
1985 case SYSCTL_WRITES_STRICT:
1986 goto out;
1987 case SYSCTL_WRITES_WARN:
1988 warn_sysctl_write(table);
1989 break;
1990 default:
1991 break;
1992 }
1993 }
1994
Amerigo Wang00b7c332010-05-05 00:26:45 +00001995 if (left > PAGE_SIZE - 1)
1996 left = PAGE_SIZE - 1;
1997 page = __get_free_page(GFP_TEMPORARY);
1998 kbuf = (char *) page;
1999 if (!kbuf)
2000 return -ENOMEM;
2001 if (copy_from_user(kbuf, buffer, left)) {
2002 err = -EFAULT;
2003 goto free;
2004 }
2005 kbuf[left] = 0;
2006 }
2007
2008 for (; left && vleft--; i++, first=0) {
2009 unsigned long lval;
2010 bool neg;
2011
2012 if (write) {
2013 left -= proc_skip_spaces(&kbuf);
2014
J. R. Okajima563b0462010-05-25 16:10:14 -07002015 if (!left)
2016 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002017 err = proc_get_long(&kbuf, &left, &lval, &neg,
2018 proc_wspace_sep,
2019 sizeof(proc_wspace_sep), NULL);
2020 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002022 if (conv(&neg, &lval, i, 1, data)) {
2023 err = -EINVAL;
2024 break;
2025 }
2026 } else {
2027 if (conv(&neg, &lval, i, 0, data)) {
2028 err = -EINVAL;
2029 break;
2030 }
2031 if (!first)
2032 err = proc_put_char(&buffer, &left, '\t');
2033 if (err)
2034 break;
2035 err = proc_put_long(&buffer, &left, lval, neg);
2036 if (err)
2037 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038 }
2039 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002040
2041 if (!write && !first && left && !err)
2042 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002043 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002044 left -= proc_skip_spaces(&kbuf);
2045free:
2046 if (write) {
2047 free_page(page);
2048 if (first)
2049 return err ? : -EINVAL;
2050 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002052out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002054 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055}
2056
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002057static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002058 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002059 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002060 int write, void *data),
2061 void *data)
2062{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002063 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002064 buffer, lenp, ppos, conv, data);
2065}
2066
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067/**
2068 * proc_dointvec - read a vector of integers
2069 * @table: the sysctl table
2070 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071 * @buffer: the user buffer
2072 * @lenp: the size of the user buffer
2073 * @ppos: file position
2074 *
2075 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2076 * values from/to the user buffer, treated as an ASCII string.
2077 *
2078 * Returns 0 on success.
2079 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002080int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081 void __user *buffer, size_t *lenp, loff_t *ppos)
2082{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002083 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 NULL,NULL);
2085}
2086
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002087/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002088 * Taint values can only be increased
2089 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002090 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002091static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002092 void __user *buffer, size_t *lenp, loff_t *ppos)
2093{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002094 struct ctl_table t;
2095 unsigned long tmptaint = get_taint();
2096 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002097
Bastian Blank91fcd412007-04-23 14:41:14 -07002098 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002099 return -EPERM;
2100
Andi Kleen25ddbb12008-10-15 22:01:41 -07002101 t = *table;
2102 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002103 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002104 if (err < 0)
2105 return err;
2106
2107 if (write) {
2108 /*
2109 * Poor man's atomic or. Not worth adding a primitive
2110 * to everyone's atomic.h for this
2111 */
2112 int i;
2113 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2114 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302115 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002116 }
2117 }
2118
2119 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002120}
2121
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002122#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002123static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002124 void __user *buffer, size_t *lenp, loff_t *ppos)
2125{
2126 if (write && !capable(CAP_SYS_ADMIN))
2127 return -EPERM;
2128
2129 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2130}
2131#endif
2132
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133struct do_proc_dointvec_minmax_conv_param {
2134 int *min;
2135 int *max;
2136};
2137
Amerigo Wang00b7c332010-05-05 00:26:45 +00002138static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2139 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140 int write, void *data)
2141{
2142 struct do_proc_dointvec_minmax_conv_param *param = data;
2143 if (write) {
2144 int val = *negp ? -*lvalp : *lvalp;
2145 if ((param->min && *param->min > val) ||
2146 (param->max && *param->max < val))
2147 return -EINVAL;
2148 *valp = val;
2149 } else {
2150 int val = *valp;
2151 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002152 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153 *lvalp = (unsigned long)-val;
2154 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002155 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 *lvalp = (unsigned long)val;
2157 }
2158 }
2159 return 0;
2160}
2161
2162/**
2163 * proc_dointvec_minmax - read a vector of integers with min/max values
2164 * @table: the sysctl table
2165 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166 * @buffer: the user buffer
2167 * @lenp: the size of the user buffer
2168 * @ppos: file position
2169 *
2170 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2171 * values from/to the user buffer, treated as an ASCII string.
2172 *
2173 * This routine will ensure the values are within the range specified by
2174 * table->extra1 (min) and table->extra2 (max).
2175 *
2176 * Returns 0 on success.
2177 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002178int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179 void __user *buffer, size_t *lenp, loff_t *ppos)
2180{
2181 struct do_proc_dointvec_minmax_conv_param param = {
2182 .min = (int *) table->extra1,
2183 .max = (int *) table->extra2,
2184 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002185 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 do_proc_dointvec_minmax_conv, &param);
2187}
2188
Kees Cook54b50192012-07-30 14:39:18 -07002189static void validate_coredump_safety(void)
2190{
Alex Kelly046d6622012-10-04 17:15:23 -07002191#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002192 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002193 core_pattern[0] != '/' && core_pattern[0] != '|') {
2194 printk(KERN_WARNING "Unsafe core_pattern used with "\
2195 "suid_dumpable=2. Pipe handler or fully qualified "\
2196 "core dump path required.\n");
2197 }
Alex Kelly046d6622012-10-04 17:15:23 -07002198#endif
Kees Cook54b50192012-07-30 14:39:18 -07002199}
2200
2201static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2202 void __user *buffer, size_t *lenp, loff_t *ppos)
2203{
2204 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2205 if (!error)
2206 validate_coredump_safety();
2207 return error;
2208}
2209
Alex Kelly046d6622012-10-04 17:15:23 -07002210#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002211static int proc_dostring_coredump(struct ctl_table *table, int write,
2212 void __user *buffer, size_t *lenp, loff_t *ppos)
2213{
2214 int error = proc_dostring(table, write, buffer, lenp, ppos);
2215 if (!error)
2216 validate_coredump_safety();
2217 return error;
2218}
Alex Kelly046d6622012-10-04 17:15:23 -07002219#endif
Kees Cook54b50192012-07-30 14:39:18 -07002220
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002221static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 void __user *buffer,
2223 size_t *lenp, loff_t *ppos,
2224 unsigned long convmul,
2225 unsigned long convdiv)
2226{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002227 unsigned long *i, *min, *max;
2228 int vleft, first = 1, err = 0;
2229 unsigned long page = 0;
2230 size_t left;
2231 char *kbuf;
2232
2233 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 *lenp = 0;
2235 return 0;
2236 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002237
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002238 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 min = (unsigned long *) table->extra1;
2240 max = (unsigned long *) table->extra2;
2241 vleft = table->maxlen / sizeof(unsigned long);
2242 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002243
2244 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002245 if (*ppos) {
2246 switch (sysctl_writes_strict) {
2247 case SYSCTL_WRITES_STRICT:
2248 goto out;
2249 case SYSCTL_WRITES_WARN:
2250 warn_sysctl_write(table);
2251 break;
2252 default:
2253 break;
2254 }
2255 }
2256
Amerigo Wang00b7c332010-05-05 00:26:45 +00002257 if (left > PAGE_SIZE - 1)
2258 left = PAGE_SIZE - 1;
2259 page = __get_free_page(GFP_TEMPORARY);
2260 kbuf = (char *) page;
2261 if (!kbuf)
2262 return -ENOMEM;
2263 if (copy_from_user(kbuf, buffer, left)) {
2264 err = -EFAULT;
2265 goto free;
2266 }
2267 kbuf[left] = 0;
2268 }
2269
Eric Dumazet27b3d802010-10-07 12:59:29 -07002270 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002271 unsigned long val;
2272
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002274 bool neg;
2275
2276 left -= proc_skip_spaces(&kbuf);
2277
2278 err = proc_get_long(&kbuf, &left, &val, &neg,
2279 proc_wspace_sep,
2280 sizeof(proc_wspace_sep), NULL);
2281 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 break;
2283 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 continue;
2285 if ((min && val < *min) || (max && val > *max))
2286 continue;
2287 *i = val;
2288 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002289 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002290 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002291 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002292 if (err)
2293 break;
2294 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002295 err = proc_put_long(&buffer, &left, val, false);
2296 if (err)
2297 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 }
2299 }
2300
Amerigo Wang00b7c332010-05-05 00:26:45 +00002301 if (!write && !first && left && !err)
2302 err = proc_put_char(&buffer, &left, '\n');
2303 if (write && !err)
2304 left -= proc_skip_spaces(&kbuf);
2305free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002307 free_page(page);
2308 if (first)
2309 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002312out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002314 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315}
2316
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002317static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002318 void __user *buffer,
2319 size_t *lenp, loff_t *ppos,
2320 unsigned long convmul,
2321 unsigned long convdiv)
2322{
2323 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002324 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002325}
2326
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327/**
2328 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2329 * @table: the sysctl table
2330 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 * @buffer: the user buffer
2332 * @lenp: the size of the user buffer
2333 * @ppos: file position
2334 *
2335 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2336 * values from/to the user buffer, treated as an ASCII string.
2337 *
2338 * This routine will ensure the values are within the range specified by
2339 * table->extra1 (min) and table->extra2 (max).
2340 *
2341 * Returns 0 on success.
2342 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002343int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 void __user *buffer, size_t *lenp, loff_t *ppos)
2345{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002346 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347}
2348
2349/**
2350 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2351 * @table: the sysctl table
2352 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 * @buffer: the user buffer
2354 * @lenp: the size of the user buffer
2355 * @ppos: file position
2356 *
2357 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2358 * values from/to the user buffer, treated as an ASCII string. The values
2359 * are treated as milliseconds, and converted to jiffies when they are stored.
2360 *
2361 * This routine will ensure the values are within the range specified by
2362 * table->extra1 (min) and table->extra2 (max).
2363 *
2364 * Returns 0 on success.
2365 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002366int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 void __user *buffer,
2368 size_t *lenp, loff_t *ppos)
2369{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002370 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371 lenp, ppos, HZ, 1000l);
2372}
2373
2374
Amerigo Wang00b7c332010-05-05 00:26:45 +00002375static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 int *valp,
2377 int write, void *data)
2378{
2379 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002380 if (*lvalp > LONG_MAX / HZ)
2381 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2383 } else {
2384 int val = *valp;
2385 unsigned long lval;
2386 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002387 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 lval = (unsigned long)-val;
2389 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002390 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 lval = (unsigned long)val;
2392 }
2393 *lvalp = lval / HZ;
2394 }
2395 return 0;
2396}
2397
Amerigo Wang00b7c332010-05-05 00:26:45 +00002398static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 int *valp,
2400 int write, void *data)
2401{
2402 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002403 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2404 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2406 } else {
2407 int val = *valp;
2408 unsigned long lval;
2409 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002410 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 lval = (unsigned long)-val;
2412 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002413 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 lval = (unsigned long)val;
2415 }
2416 *lvalp = jiffies_to_clock_t(lval);
2417 }
2418 return 0;
2419}
2420
Amerigo Wang00b7c332010-05-05 00:26:45 +00002421static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 int *valp,
2423 int write, void *data)
2424{
2425 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002426 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2427
2428 if (jif > INT_MAX)
2429 return 1;
2430 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 } else {
2432 int val = *valp;
2433 unsigned long lval;
2434 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002435 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 lval = (unsigned long)-val;
2437 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002438 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 lval = (unsigned long)val;
2440 }
2441 *lvalp = jiffies_to_msecs(lval);
2442 }
2443 return 0;
2444}
2445
2446/**
2447 * proc_dointvec_jiffies - read a vector of integers as seconds
2448 * @table: the sysctl table
2449 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 * @buffer: the user buffer
2451 * @lenp: the size of the user buffer
2452 * @ppos: file position
2453 *
2454 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2455 * values from/to the user buffer, treated as an ASCII string.
2456 * The values read are assumed to be in seconds, and are converted into
2457 * jiffies.
2458 *
2459 * Returns 0 on success.
2460 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002461int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 void __user *buffer, size_t *lenp, loff_t *ppos)
2463{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002464 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 do_proc_dointvec_jiffies_conv,NULL);
2466}
2467
2468/**
2469 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2470 * @table: the sysctl table
2471 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 * @buffer: the user buffer
2473 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002474 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475 *
2476 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2477 * values from/to the user buffer, treated as an ASCII string.
2478 * The values read are assumed to be in 1/USER_HZ seconds, and
2479 * are converted into jiffies.
2480 *
2481 * Returns 0 on success.
2482 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002483int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484 void __user *buffer, size_t *lenp, loff_t *ppos)
2485{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002486 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 do_proc_dointvec_userhz_jiffies_conv,NULL);
2488}
2489
2490/**
2491 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2492 * @table: the sysctl table
2493 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 * @buffer: the user buffer
2495 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002496 * @ppos: file position
2497 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 *
2499 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2500 * values from/to the user buffer, treated as an ASCII string.
2501 * The values read are assumed to be in 1/1000 seconds, and
2502 * are converted into jiffies.
2503 *
2504 * Returns 0 on success.
2505 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002506int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 void __user *buffer, size_t *lenp, loff_t *ppos)
2508{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002509 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 do_proc_dointvec_ms_jiffies_conv, NULL);
2511}
2512
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002513static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002514 void __user *buffer, size_t *lenp, loff_t *ppos)
2515{
2516 struct pid *new_pid;
2517 pid_t tmp;
2518 int r;
2519
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002520 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002521
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002522 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002523 lenp, ppos, NULL, NULL);
2524 if (r || !write)
2525 return r;
2526
2527 new_pid = find_get_pid(tmp);
2528 if (!new_pid)
2529 return -ESRCH;
2530
2531 put_pid(xchg(&cad_pid, new_pid));
2532 return 0;
2533}
2534
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002535/**
2536 * proc_do_large_bitmap - read/write from/to a large bitmap
2537 * @table: the sysctl table
2538 * @write: %TRUE if this is a write to the sysctl file
2539 * @buffer: the user buffer
2540 * @lenp: the size of the user buffer
2541 * @ppos: file position
2542 *
2543 * The bitmap is stored at table->data and the bitmap length (in bits)
2544 * in table->maxlen.
2545 *
2546 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2547 * large bitmaps may be represented in a compact manner. Writing into
2548 * the file will clear the bitmap then update it with the given input.
2549 *
2550 * Returns 0 on success.
2551 */
2552int proc_do_large_bitmap(struct ctl_table *table, int write,
2553 void __user *buffer, size_t *lenp, loff_t *ppos)
2554{
2555 int err = 0;
2556 bool first = 1;
2557 size_t left = *lenp;
2558 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002559 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002560 unsigned long *tmp_bitmap = NULL;
2561 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2562
WANG Cong122ff242014-05-12 16:04:53 -07002563 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002564 *lenp = 0;
2565 return 0;
2566 }
2567
2568 if (write) {
2569 unsigned long page = 0;
2570 char *kbuf;
2571
2572 if (left > PAGE_SIZE - 1)
2573 left = PAGE_SIZE - 1;
2574
2575 page = __get_free_page(GFP_TEMPORARY);
2576 kbuf = (char *) page;
2577 if (!kbuf)
2578 return -ENOMEM;
2579 if (copy_from_user(kbuf, buffer, left)) {
2580 free_page(page);
2581 return -EFAULT;
2582 }
2583 kbuf[left] = 0;
2584
2585 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2586 GFP_KERNEL);
2587 if (!tmp_bitmap) {
2588 free_page(page);
2589 return -ENOMEM;
2590 }
2591 proc_skip_char(&kbuf, &left, '\n');
2592 while (!err && left) {
2593 unsigned long val_a, val_b;
2594 bool neg;
2595
2596 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2597 sizeof(tr_a), &c);
2598 if (err)
2599 break;
2600 if (val_a >= bitmap_len || neg) {
2601 err = -EINVAL;
2602 break;
2603 }
2604
2605 val_b = val_a;
2606 if (left) {
2607 kbuf++;
2608 left--;
2609 }
2610
2611 if (c == '-') {
2612 err = proc_get_long(&kbuf, &left, &val_b,
2613 &neg, tr_b, sizeof(tr_b),
2614 &c);
2615 if (err)
2616 break;
2617 if (val_b >= bitmap_len || neg ||
2618 val_a > val_b) {
2619 err = -EINVAL;
2620 break;
2621 }
2622 if (left) {
2623 kbuf++;
2624 left--;
2625 }
2626 }
2627
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002628 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002629 first = 0;
2630 proc_skip_char(&kbuf, &left, '\n');
2631 }
2632 free_page(page);
2633 } else {
2634 unsigned long bit_a, bit_b = 0;
2635
2636 while (left) {
2637 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2638 if (bit_a >= bitmap_len)
2639 break;
2640 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2641 bit_a + 1) - 1;
2642
2643 if (!first) {
2644 err = proc_put_char(&buffer, &left, ',');
2645 if (err)
2646 break;
2647 }
2648 err = proc_put_long(&buffer, &left, bit_a, false);
2649 if (err)
2650 break;
2651 if (bit_a != bit_b) {
2652 err = proc_put_char(&buffer, &left, '-');
2653 if (err)
2654 break;
2655 err = proc_put_long(&buffer, &left, bit_b, false);
2656 if (err)
2657 break;
2658 }
2659
2660 first = 0; bit_b++;
2661 }
2662 if (!err)
2663 err = proc_put_char(&buffer, &left, '\n');
2664 }
2665
2666 if (!err) {
2667 if (write) {
2668 if (*ppos)
2669 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2670 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002671 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002672 }
2673 kfree(tmp_bitmap);
2674 *lenp -= left;
2675 *ppos += *lenp;
2676 return 0;
2677 } else {
2678 kfree(tmp_bitmap);
2679 return err;
2680 }
2681}
2682
Jovi Zhang55610502011-01-12 17:00:45 -08002683#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002685int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 void __user *buffer, size_t *lenp, loff_t *ppos)
2687{
2688 return -ENOSYS;
2689}
2690
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002691int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002692 void __user *buffer, size_t *lenp, loff_t *ppos)
2693{
2694 return -ENOSYS;
2695}
2696
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002697int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002698 void __user *buffer, size_t *lenp, loff_t *ppos)
2699{
2700 return -ENOSYS;
2701}
2702
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002703int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704 void __user *buffer, size_t *lenp, loff_t *ppos)
2705{
2706 return -ENOSYS;
2707}
2708
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002709int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002710 void __user *buffer, size_t *lenp, loff_t *ppos)
2711{
2712 return -ENOSYS;
2713}
2714
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002715int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002716 void __user *buffer, size_t *lenp, loff_t *ppos)
2717{
2718 return -ENOSYS;
2719}
2720
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002721int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722 void __user *buffer, size_t *lenp, loff_t *ppos)
2723{
2724 return -ENOSYS;
2725}
2726
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002727int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 void __user *buffer,
2729 size_t *lenp, loff_t *ppos)
2730{
2731 return -ENOSYS;
2732}
2733
2734
Jovi Zhang55610502011-01-12 17:00:45 -08002735#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737/*
2738 * No sense putting this after each symbol definition, twice,
2739 * exception granted :-)
2740 */
2741EXPORT_SYMBOL(proc_dointvec);
2742EXPORT_SYMBOL(proc_dointvec_jiffies);
2743EXPORT_SYMBOL(proc_dointvec_minmax);
2744EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2745EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2746EXPORT_SYMBOL(proc_dostring);
2747EXPORT_SYMBOL(proc_doulongvec_minmax);
2748EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);