blob: bb50c21871945eff049d834aa725627933ce5e1c [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 Zijlstra4b96a292012-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,
390 .proc_handler = proc_dointvec,
391 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100392 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800393 .procname = "numa_balancing",
394 .data = NULL, /* filled in by handler */
395 .maxlen = sizeof(unsigned int),
396 .mode = 0644,
397 .proc_handler = sysctl_numa_balancing,
398 .extra1 = &zero,
399 .extra2 = &one,
400 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200401#endif /* CONFIG_NUMA_BALANCING */
402#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200403 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100404 .procname = "sched_rt_period_us",
405 .data = &sysctl_sched_rt_period,
406 .maxlen = sizeof(unsigned int),
407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100409 },
410 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100411 .procname = "sched_rt_runtime_us",
412 .data = &sysctl_sched_rt_runtime,
413 .maxlen = sizeof(int),
414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800415 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100416 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600417 {
418 .procname = "sched_rr_timeslice_ms",
419 .data = &sched_rr_timeslice,
420 .maxlen = sizeof(int),
421 .mode = 0644,
422 .proc_handler = sched_rr_handler,
423 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100424#ifdef CONFIG_SCHED_AUTOGROUP
425 {
426 .procname = "sched_autogroup_enabled",
427 .data = &sysctl_sched_autogroup_enabled,
428 .maxlen = sizeof(unsigned int),
429 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800430 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100431 .extra1 = &zero,
432 .extra2 = &one,
433 },
434#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700435#ifdef CONFIG_CFS_BANDWIDTH
436 {
437 .procname = "sched_cfs_bandwidth_slice_us",
438 .data = &sysctl_sched_cfs_bandwidth_slice,
439 .maxlen = sizeof(unsigned int),
440 .mode = 0644,
441 .proc_handler = proc_dointvec_minmax,
442 .extra1 = &one,
443 },
444#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700445#ifdef CONFIG_PROVE_LOCKING
446 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700447 .procname = "prove_locking",
448 .data = &prove_locking,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700452 },
453#endif
454#ifdef CONFIG_LOCK_STAT
455 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700456 .procname = "lock_stat",
457 .data = &lock_stat,
458 .maxlen = sizeof(int),
459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700461 },
462#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "panic",
465 .data = &panic_timeout,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
Alex Kelly046d6622012-10-04 17:15:23 -0700470#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "core_uses_pid",
473 .data = &core_uses_pid,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800476 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 .procname = "core_pattern",
480 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700481 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700483 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 },
Neil Hormana2939802009-09-23 15:56:56 -0700485 {
Neil Hormana2939802009-09-23 15:56:56 -0700486 .procname = "core_pipe_limit",
487 .data = &core_pipe_limit,
488 .maxlen = sizeof(unsigned int),
489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800490 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700491 },
Alex Kelly046d6622012-10-04 17:15:23 -0700492#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800493#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700496 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700500 {
501 .procname = "sysctl_writes_strict",
502 .data = &sysctl_writes_strict,
503 .maxlen = sizeof(int),
504 .mode = 0644,
505 .proc_handler = proc_dointvec_minmax,
506 .extra1 = &neg_one,
507 .extra2 = &one,
508 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800509#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100510#ifdef CONFIG_LATENCYTOP
511 {
512 .procname = "latencytop",
513 .data = &latencytop_enabled,
514 .maxlen = sizeof(int),
515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800516 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100517 },
518#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519#ifdef CONFIG_BLK_DEV_INITRD
520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 .procname = "real-root-dev",
522 .data = &real_root_dev,
523 .maxlen = sizeof(int),
524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 },
527#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700528 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700529 .procname = "print-fatal-signals",
530 .data = &print_fatal_signals,
531 .maxlen = sizeof(int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700534 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700535#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 .procname = "reboot-cmd",
538 .data = reboot_command,
539 .maxlen = 256,
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 },
543 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 .procname = "stop-a",
545 .data = &stop_a_enabled,
546 .maxlen = sizeof (int),
547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 },
550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 .procname = "scons-poweroff",
552 .data = &scons_pwroff,
553 .maxlen = sizeof (int),
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 },
557#endif
David S. Miller08714202008-11-16 23:49:24 -0800558#ifdef CONFIG_SPARC64
559 {
David S. Miller08714202008-11-16 23:49:24 -0800560 .procname = "tsb-ratio",
561 .data = &sysctl_tsb_ratio,
562 .maxlen = sizeof (int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800565 },
566#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567#ifdef __hppa__
568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "soft-power",
570 .data = &pwrsw_enabled,
571 .maxlen = sizeof (int),
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530575#endif
576#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "unaligned-trap",
579 .data = &unaligned_enabled,
580 .maxlen = sizeof (int),
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
584#endif
585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 .procname = "ctrl-alt-del",
587 .data = &C_A_D,
588 .maxlen = sizeof(int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400592#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200593 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200594 .procname = "ftrace_enabled",
595 .data = &ftrace_enabled,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200599 },
600#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500601#ifdef CONFIG_STACK_TRACER
602 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500603 .procname = "stack_tracer_enabled",
604 .data = &stack_tracer_enabled,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500608 },
609#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400610#ifdef CONFIG_TRACING
611 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100612 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400613 .data = &ftrace_dump_on_oops,
614 .maxlen = sizeof(int),
615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400617 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400618 {
619 .procname = "traceoff_on_warning",
620 .data = &__disable_trace_on_warning,
621 .maxlen = sizeof(__disable_trace_on_warning),
622 .mode = 0644,
623 .proc_handler = proc_dointvec,
624 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500625 {
626 .procname = "tracepoint_printk",
627 .data = &tracepoint_printk,
628 .maxlen = sizeof(tracepoint_printk),
629 .mode = 0644,
630 .proc_handler = proc_dointvec,
631 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400632#endif
Kees Cook79847542014-01-23 15:55:59 -0800633#ifdef CONFIG_KEXEC
634 {
635 .procname = "kexec_load_disabled",
636 .data = &kexec_load_disabled,
637 .maxlen = sizeof(int),
638 .mode = 0644,
639 /* only handle a transition from default "0" to "1" */
640 .proc_handler = proc_dointvec_minmax,
641 .extra1 = &one,
642 .extra2 = &one,
643 },
644#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200645#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .procname = "modprobe",
648 .data = &modprobe_path,
649 .maxlen = KMOD_PATH_LEN,
650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 },
Kees Cook3d433212009-04-02 15:49:29 -0700653 {
Kees Cook3d433212009-04-02 15:49:29 -0700654 .procname = "modules_disabled",
655 .data = &modules_disabled,
656 .maxlen = sizeof(int),
657 .mode = 0644,
658 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700660 .extra1 = &one,
661 .extra2 = &one,
662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700664#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100667 .data = &uevent_helper,
668 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800670 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 },
Michael Marineau86d56132014-04-10 14:09:31 -0700672#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673#ifdef CONFIG_CHR_DEV_SG
674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "sg-big-buff",
676 .data = &sg_big_buff,
677 .maxlen = sizeof (int),
678 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800679 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 },
681#endif
682#ifdef CONFIG_BSD_PROCESS_ACCT
683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "acct",
685 .data = &acct_parm,
686 .maxlen = 3*sizeof(int),
687 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800688 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 },
690#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691#ifdef CONFIG_MAGIC_SYSRQ
692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800694 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .maxlen = sizeof (int),
696 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700697 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700700#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700703 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .maxlen = sizeof (int),
705 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700708#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "threads-max",
711 .data = &max_threads,
712 .maxlen = sizeof(int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
716 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 .procname = "random",
718 .mode = 0555,
719 .child = random_table,
720 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 {
Eric Paris17f60a72011-04-01 17:07:50 -0400722 .procname = "usermodehelper",
723 .mode = 0555,
724 .child = usermodehelper_table,
725 },
726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "overflowuid",
728 .data = &overflowuid,
729 .maxlen = sizeof(int),
730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 .extra1 = &minolduid,
733 .extra2 = &maxolduid,
734 },
735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 .procname = "overflowgid",
737 .data = &overflowgid,
738 .maxlen = sizeof(int),
739 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800740 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 .extra1 = &minolduid,
742 .extra2 = &maxolduid,
743 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800744#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745#ifdef CONFIG_MATHEMU
746 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 .procname = "ieee_emulation_warnings",
748 .data = &sysctl_ieee_emulation_warnings,
749 .maxlen = sizeof(int),
750 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800751 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 },
753#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200756 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .maxlen = sizeof(int),
758 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800759 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 },
761#endif
762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "pid_max",
764 .data = &pid_max,
765 .maxlen = sizeof (int),
766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800767 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 .extra1 = &pid_max_min,
769 .extra2 = &pid_max_max,
770 },
771 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 .procname = "panic_on_oops",
773 .data = &panic_on_oops,
774 .maxlen = sizeof(int),
775 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800776 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800778#if defined CONFIG_PRINTK
779 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800780 .procname = "printk",
781 .data = &console_loglevel,
782 .maxlen = 4*sizeof(int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800785 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700788 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 .maxlen = sizeof(int),
790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 },
793 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700795 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .maxlen = sizeof(int),
797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 },
Dave Youngaf913222009-09-22 16:43:33 -0700800 {
Dave Youngaf913222009-09-22 16:43:33 -0700801 .procname = "printk_delay",
802 .data = &printk_delay_msec,
803 .maxlen = sizeof(int),
804 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800805 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700806 .extra1 = &zero,
807 .extra2 = &ten_thousand,
808 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800810 .procname = "dmesg_restrict",
811 .data = &dmesg_restrict,
812 .maxlen = sizeof(int),
813 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700814 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800815 .extra1 = &zero,
816 .extra2 = &one,
817 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800818 {
819 .procname = "kptr_restrict",
820 .data = &kptr_restrict,
821 .maxlen = sizeof(int),
822 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700823 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800824 .extra1 = &zero,
825 .extra2 = &two,
826 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800827#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800828 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 .procname = "ngroups_max",
830 .data = &ngroups_max,
831 .maxlen = sizeof (int),
832 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800833 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 },
Dan Ballard73efc032011-10-31 17:11:20 -0700835 {
836 .procname = "cap_last_cap",
837 .data = (void *)&cap_last_cap,
838 .maxlen = sizeof(int),
839 .mode = 0444,
840 .proc_handler = proc_dointvec,
841 },
Don Zickus58687ac2010-05-07 17:11:44 -0400842#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500843 {
Don Zickus58687ac2010-05-07 17:11:44 -0400844 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200845 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500846 .maxlen = sizeof (int),
847 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700848 .proc_handler = proc_dowatchdog,
849 .extra1 = &zero,
850 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400851 },
852 {
853 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700854 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400855 .maxlen = sizeof(int),
856 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700857 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800858 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400859 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500860 },
Don Zickus2508ce12010-05-07 17:11:46 -0400861 {
862 .procname = "softlockup_panic",
863 .data = &softlockup_panic,
864 .maxlen = sizeof(int),
865 .mode = 0644,
866 .proc_handler = proc_dointvec_minmax,
867 .extra1 = &zero,
868 .extra2 = &one,
869 },
Aaron Tomlined235872014-06-23 13:22:05 -0700870#ifdef CONFIG_SMP
871 {
872 .procname = "softlockup_all_cpu_backtrace",
873 .data = &sysctl_softlockup_all_cpu_backtrace,
874 .maxlen = sizeof(int),
875 .mode = 0644,
876 .proc_handler = proc_dointvec_minmax,
877 .extra1 = &zero,
878 .extra2 = &one,
879 },
880#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500881 {
882 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200883 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500884 .maxlen = sizeof (int),
885 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700886 .proc_handler = proc_dowatchdog,
887 .extra1 = &zero,
888 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500889 },
890#endif
891#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
892 {
893 .procname = "unknown_nmi_panic",
894 .data = &unknown_nmi_panic,
895 .maxlen = sizeof (int),
896 .mode = 0644,
897 .proc_handler = proc_dointvec,
898 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500899#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900#if defined(CONFIG_X86)
901 {
Don Zickus8da5add2006-09-26 10:52:27 +0200902 .procname = "panic_on_unrecovered_nmi",
903 .data = &panic_on_unrecovered_nmi,
904 .maxlen = sizeof(int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200907 },
908 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700909 .procname = "panic_on_io_nmi",
910 .data = &panic_on_io_nmi,
911 .maxlen = sizeof(int),
912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700914 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900915#ifdef CONFIG_DEBUG_STACKOVERFLOW
916 {
917 .procname = "panic_on_stackoverflow",
918 .data = &sysctl_panic_on_stackoverflow,
919 .maxlen = sizeof(int),
920 .mode = 0644,
921 .proc_handler = proc_dointvec,
922 },
923#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700924 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 .procname = "bootloader_type",
926 .data = &bootloader_type,
927 .maxlen = sizeof (int),
928 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100931 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700932 .procname = "bootloader_version",
933 .data = &bootloader_version,
934 .maxlen = sizeof (int),
935 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800936 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700937 },
938 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100939 .procname = "kstack_depth_to_print",
940 .data = &kstack_depth_to_print,
941 .maxlen = sizeof(int),
942 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800943 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100944 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100945 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100946 .procname = "io_delay_type",
947 .data = &io_delay_type,
948 .maxlen = sizeof(int),
949 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800950 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100951 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800953#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 .procname = "randomize_va_space",
956 .data = &randomize_va_space,
957 .maxlen = sizeof(int),
958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800961#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800962#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700963 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700964 .procname = "spin_retry",
965 .data = &spin_retry,
966 .maxlen = sizeof (int),
967 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800968 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700969 },
970#endif
Len Brown673d5b42007-07-28 03:33:16 -0400971#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800972 {
Pavel Machekc255d842006-02-20 18:27:58 -0800973 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700974 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800975 .maxlen = sizeof (unsigned long),
976 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800978 },
979#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530980#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800981 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800982 .procname = "ignore-unaligned-usertrap",
983 .data = &no_unaligned_warning,
984 .maxlen = sizeof (int),
985 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800986 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800987 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530988#endif
989#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800990 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800991 .procname = "unaligned-dump-stack",
992 .data = &unaligned_dump_stack,
993 .maxlen = sizeof (int),
994 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800995 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800996 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800997#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800998#ifdef CONFIG_DETECT_HUNG_TASK
999 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001000 .procname = "hung_task_panic",
1001 .data = &sysctl_hung_task_panic,
1002 .maxlen = sizeof(int),
1003 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001004 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001005 .extra1 = &zero,
1006 .extra2 = &one,
1007 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001008 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001009 .procname = "hung_task_check_count",
1010 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001011 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001012 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001013 .proc_handler = proc_dointvec_minmax,
1014 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001015 },
1016 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001017 .procname = "hung_task_timeout_secs",
1018 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001019 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001020 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001021 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001022 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001023 },
1024 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001025 .procname = "hung_task_warnings",
1026 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001027 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001028 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001029 .proc_handler = proc_dointvec_minmax,
1030 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001031 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001032#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001033#ifdef CONFIG_COMPAT
1034 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001035 .procname = "compat-log",
1036 .data = &compat_log,
1037 .maxlen = sizeof (int),
1038 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001039 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001040 },
1041#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001042#ifdef CONFIG_RT_MUTEXES
1043 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001044 .procname = "max_lock_depth",
1045 .data = &max_lock_depth,
1046 .maxlen = sizeof(int),
1047 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001048 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001049 },
1050#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001051 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001052 .procname = "poweroff_cmd",
1053 .data = &poweroff_cmd,
1054 .maxlen = POWEROFF_CMD_PATH_LEN,
1055 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001056 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001057 },
David Howells0b77f5b2008-04-29 01:01:32 -07001058#ifdef CONFIG_KEYS
1059 {
David Howells0b77f5b2008-04-29 01:01:32 -07001060 .procname = "keys",
1061 .mode = 0555,
1062 .child = key_sysctls,
1063 },
1064#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001065#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001066 /*
1067 * User-space scripts rely on the existence of this file
1068 * as a feature check for perf_events being enabled.
1069 *
1070 * So it's an ABI, do not remove!
1071 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001072 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001073 .procname = "perf_event_paranoid",
1074 .data = &sysctl_perf_event_paranoid,
1075 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001076 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001077 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001078 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001079 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001080 .procname = "perf_event_mlock_kb",
1081 .data = &sysctl_perf_event_mlock,
1082 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001083 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001084 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001085 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001086 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001087 .procname = "perf_event_max_sample_rate",
1088 .data = &sysctl_perf_event_sample_rate,
1089 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001090 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001091 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001092 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001093 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001094 {
1095 .procname = "perf_cpu_time_max_percent",
1096 .data = &sysctl_perf_cpu_time_max_percent,
1097 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1098 .mode = 0644,
1099 .proc_handler = perf_cpu_time_max_percent_handler,
1100 .extra1 = &zero,
1101 .extra2 = &one_hundred,
1102 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001103#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001104#ifdef CONFIG_KMEMCHECK
1105 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001106 .procname = "kmemcheck",
1107 .data = &kmemcheck_enabled,
1108 .maxlen = sizeof(int),
1109 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001110 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001111 },
1112#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001113 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114};
1115
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001116static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 .procname = "overcommit_memory",
1119 .data = &sysctl_overcommit_memory,
1120 .maxlen = sizeof(sysctl_overcommit_memory),
1121 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001122 .proc_handler = proc_dointvec_minmax,
1123 .extra1 = &zero,
1124 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 },
1126 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001127 .procname = "panic_on_oom",
1128 .data = &sysctl_panic_on_oom,
1129 .maxlen = sizeof(sysctl_panic_on_oom),
1130 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001131 .proc_handler = proc_dointvec_minmax,
1132 .extra1 = &zero,
1133 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001134 },
1135 {
David Rientjesfe071d72007-10-16 23:25:56 -07001136 .procname = "oom_kill_allocating_task",
1137 .data = &sysctl_oom_kill_allocating_task,
1138 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1139 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001140 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001141 },
1142 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001143 .procname = "oom_dump_tasks",
1144 .data = &sysctl_oom_dump_tasks,
1145 .maxlen = sizeof(sysctl_oom_dump_tasks),
1146 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001147 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001148 },
1149 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 .procname = "overcommit_ratio",
1151 .data = &sysctl_overcommit_ratio,
1152 .maxlen = sizeof(sysctl_overcommit_ratio),
1153 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001154 .proc_handler = overcommit_ratio_handler,
1155 },
1156 {
1157 .procname = "overcommit_kbytes",
1158 .data = &sysctl_overcommit_kbytes,
1159 .maxlen = sizeof(sysctl_overcommit_kbytes),
1160 .mode = 0644,
1161 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 },
1163 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 .procname = "page-cluster",
1165 .data = &page_cluster,
1166 .maxlen = sizeof(int),
1167 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001168 .proc_handler = proc_dointvec_minmax,
1169 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 },
1171 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .procname = "dirty_background_ratio",
1173 .data = &dirty_background_ratio,
1174 .maxlen = sizeof(dirty_background_ratio),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 .extra1 = &zero,
1178 .extra2 = &one_hundred,
1179 },
1180 {
David Rientjes2da02992009-01-06 14:39:31 -08001181 .procname = "dirty_background_bytes",
1182 .data = &dirty_background_bytes,
1183 .maxlen = sizeof(dirty_background_bytes),
1184 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001185 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001186 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001187 },
1188 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 .procname = "dirty_ratio",
1190 .data = &vm_dirty_ratio,
1191 .maxlen = sizeof(vm_dirty_ratio),
1192 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001193 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 .extra1 = &zero,
1195 .extra2 = &one_hundred,
1196 },
1197 {
David Rientjes2da02992009-01-06 14:39:31 -08001198 .procname = "dirty_bytes",
1199 .data = &vm_dirty_bytes,
1200 .maxlen = sizeof(vm_dirty_bytes),
1201 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001202 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001203 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001204 },
1205 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001207 .data = &dirty_writeback_interval,
1208 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001210 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 },
1212 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001214 .data = &dirty_expire_interval,
1215 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001217 .proc_handler = proc_dointvec_minmax,
1218 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 },
1220 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001221 .procname = "nr_pdflush_threads",
1222 .mode = 0444 /* read-only */,
1223 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 },
1225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 .procname = "swappiness",
1227 .data = &vm_swappiness,
1228 .maxlen = sizeof(vm_swappiness),
1229 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001230 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 .extra1 = &zero,
1232 .extra2 = &one_hundred,
1233 },
1234#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001235 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001237 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 .maxlen = sizeof(unsigned long),
1239 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001240 .proc_handler = hugetlb_sysctl_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001241 .extra1 = &zero,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001242 },
1243#ifdef CONFIG_NUMA
1244 {
1245 .procname = "nr_hugepages_mempolicy",
1246 .data = NULL,
1247 .maxlen = sizeof(unsigned long),
1248 .mode = 0644,
1249 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001250 .extra1 = &zero,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001251 },
1252#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 .procname = "hugetlb_shm_group",
1255 .data = &sysctl_hugetlb_shm_group,
1256 .maxlen = sizeof(gid_t),
1257 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001258 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 },
Mel Gorman396faf02007-07-17 04:03:13 -07001260 {
Mel Gorman396faf02007-07-17 04:03:13 -07001261 .procname = "hugepages_treat_as_movable",
1262 .data = &hugepages_treat_as_movable,
1263 .maxlen = sizeof(int),
1264 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001265 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001266 },
Adam Litke54f9f802007-10-16 01:26:20 -07001267 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001268 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001269 .data = NULL,
1270 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001271 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001272 .proc_handler = hugetlb_overcommit_handler,
David Rientjesed4d4902014-08-06 16:06:54 -07001273 .extra1 = &zero,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001274 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275#endif
1276 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 .procname = "lowmem_reserve_ratio",
1278 .data = &sysctl_lowmem_reserve_ratio,
1279 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 },
1283 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001284 .procname = "drop_caches",
1285 .data = &sysctl_drop_caches,
1286 .maxlen = sizeof(int),
1287 .mode = 0644,
1288 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001289 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001290 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001291 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001292#ifdef CONFIG_COMPACTION
1293 {
1294 .procname = "compact_memory",
1295 .data = &sysctl_compact_memory,
1296 .maxlen = sizeof(int),
1297 .mode = 0200,
1298 .proc_handler = sysctl_compaction_handler,
1299 },
Mel Gorman5e771902010-05-24 14:32:31 -07001300 {
1301 .procname = "extfrag_threshold",
1302 .data = &sysctl_extfrag_threshold,
1303 .maxlen = sizeof(int),
1304 .mode = 0644,
1305 .proc_handler = sysctl_extfrag_handler,
1306 .extra1 = &min_extfrag_threshold,
1307 .extra2 = &max_extfrag_threshold,
1308 },
1309
Mel Gorman76ab0f52010-05-24 14:32:28 -07001310#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .procname = "min_free_kbytes",
1313 .data = &min_free_kbytes,
1314 .maxlen = sizeof(min_free_kbytes),
1315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001316 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .extra1 = &zero,
1318 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001319 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001320 .procname = "percpu_pagelist_fraction",
1321 .data = &percpu_pagelist_fraction,
1322 .maxlen = sizeof(percpu_pagelist_fraction),
1323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001325 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001326 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327#ifdef CONFIG_MMU
1328 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 .procname = "max_map_count",
1330 .data = &sysctl_max_map_count,
1331 .maxlen = sizeof(sysctl_max_map_count),
1332 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001333 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001334 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001336#else
1337 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001338 .procname = "nr_trim_pages",
1339 .data = &sysctl_nr_trim_pages,
1340 .maxlen = sizeof(sysctl_nr_trim_pages),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001343 .extra1 = &zero,
1344 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345#endif
1346 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .procname = "laptop_mode",
1348 .data = &laptop_mode,
1349 .maxlen = sizeof(laptop_mode),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 },
1353 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001354 .procname = "block_dump",
1355 .data = &block_dump,
1356 .maxlen = sizeof(block_dump),
1357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001358 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 .extra1 = &zero,
1360 },
1361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 .procname = "vfs_cache_pressure",
1363 .data = &sysctl_vfs_cache_pressure,
1364 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1365 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001366 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .extra1 = &zero,
1368 },
1369#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1370 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 .procname = "legacy_va_layout",
1372 .data = &sysctl_legacy_va_layout,
1373 .maxlen = sizeof(sysctl_legacy_va_layout),
1374 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001375 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376 .extra1 = &zero,
1377 },
1378#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001379#ifdef CONFIG_NUMA
1380 {
Christoph Lameter17436602006-01-18 17:42:32 -08001381 .procname = "zone_reclaim_mode",
1382 .data = &zone_reclaim_mode,
1383 .maxlen = sizeof(zone_reclaim_mode),
1384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001386 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001387 },
Christoph Lameter96146342006-07-03 00:24:13 -07001388 {
Christoph Lameter96146342006-07-03 00:24:13 -07001389 .procname = "min_unmapped_ratio",
1390 .data = &sysctl_min_unmapped_ratio,
1391 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001393 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001394 .extra1 = &zero,
1395 .extra2 = &one_hundred,
1396 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001397 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001398 .procname = "min_slab_ratio",
1399 .data = &sysctl_min_slab_ratio,
1400 .maxlen = sizeof(sysctl_min_slab_ratio),
1401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001402 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001403 .extra1 = &zero,
1404 .extra2 = &one_hundred,
1405 },
Christoph Lameter17436602006-01-18 17:42:32 -08001406#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001407#ifdef CONFIG_SMP
1408 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001409 .procname = "stat_interval",
1410 .data = &sysctl_stat_interval,
1411 .maxlen = sizeof(sysctl_stat_interval),
1412 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001413 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001414 },
1415#endif
David Howells6e141542009-12-15 19:27:45 +00001416#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001417 {
Eric Parised032182007-06-28 15:55:21 -04001418 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001419 .data = &dac_mmap_min_addr,
1420 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001422 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001423 },
David Howells6e141542009-12-15 19:27:45 +00001424#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001425#ifdef CONFIG_NUMA
1426 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001427 .procname = "numa_zonelist_order",
1428 .data = &numa_zonelist_order,
1429 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001431 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001432 },
1433#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001434#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001435 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001436 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001437 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001438#ifdef CONFIG_X86_32
1439 .data = &vdso32_enabled,
1440 .maxlen = sizeof(vdso32_enabled),
1441#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001442 .data = &vdso_enabled,
1443 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001444#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001446 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001447 .extra1 = &zero,
1448 },
1449#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001450#ifdef CONFIG_HIGHMEM
1451 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001452 .procname = "highmem_is_dirtyable",
1453 .data = &vm_highmem_is_dirtyable,
1454 .maxlen = sizeof(vm_highmem_is_dirtyable),
1455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001456 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001457 .extra1 = &zero,
1458 .extra2 = &one,
1459 },
1460#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001461#ifdef CONFIG_MEMORY_FAILURE
1462 {
Andi Kleen6a460792009-09-16 11:50:15 +02001463 .procname = "memory_failure_early_kill",
1464 .data = &sysctl_memory_failure_early_kill,
1465 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001467 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001468 .extra1 = &zero,
1469 .extra2 = &one,
1470 },
1471 {
Andi Kleen6a460792009-09-16 11:50:15 +02001472 .procname = "memory_failure_recovery",
1473 .data = &sysctl_memory_failure_recovery,
1474 .maxlen = sizeof(sysctl_memory_failure_recovery),
1475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001476 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001477 .extra1 = &zero,
1478 .extra2 = &one,
1479 },
1480#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001481 {
1482 .procname = "user_reserve_kbytes",
1483 .data = &sysctl_user_reserve_kbytes,
1484 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1485 .mode = 0644,
1486 .proc_handler = proc_doulongvec_minmax,
1487 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001488 {
1489 .procname = "admin_reserve_kbytes",
1490 .data = &sysctl_admin_reserve_kbytes,
1491 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1492 .mode = 0644,
1493 .proc_handler = proc_doulongvec_minmax,
1494 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001495 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496};
1497
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001498#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001499static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001500 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001501};
1502#endif
1503
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001504static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .procname = "inode-nr",
1507 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001508 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001510 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 },
1512 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 .procname = "inode-state",
1514 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001515 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001517 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 },
1519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 .procname = "file-nr",
1521 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001522 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001524 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 },
1526 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 .procname = "file-max",
1528 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001529 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001531 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 },
1533 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001534 .procname = "nr_open",
1535 .data = &sysctl_nr_open,
1536 .maxlen = sizeof(int),
1537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001538 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001539 .extra1 = &sysctl_nr_open_min,
1540 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001541 },
1542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 .procname = "dentry-state",
1544 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001545 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001547 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 },
1549 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 .procname = "overflowuid",
1551 .data = &fs_overflowuid,
1552 .maxlen = sizeof(int),
1553 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001554 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 .extra1 = &minolduid,
1556 .extra2 = &maxolduid,
1557 },
1558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .procname = "overflowgid",
1560 .data = &fs_overflowgid,
1561 .maxlen = sizeof(int),
1562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001563 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 .extra1 = &minolduid,
1565 .extra2 = &maxolduid,
1566 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001567#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569 .procname = "leases-enable",
1570 .data = &leases_enable,
1571 .maxlen = sizeof(int),
1572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001575#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576#ifdef CONFIG_DNOTIFY
1577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 .procname = "dir-notify-enable",
1579 .data = &dir_notify_enable,
1580 .maxlen = sizeof(int),
1581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583 },
1584#endif
1585#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001586#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588 .procname = "lease-break-time",
1589 .data = &lease_break_time,
1590 .maxlen = sizeof(int),
1591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001592 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001594#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001595#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597 .procname = "aio-nr",
1598 .data = &aio_nr,
1599 .maxlen = sizeof(aio_nr),
1600 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001601 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 },
1603 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604 .procname = "aio-max-nr",
1605 .data = &aio_max_nr,
1606 .maxlen = sizeof(aio_max_nr),
1607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001608 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001609 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001610#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001611#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001612 {
Robert Love0399cb02005-07-13 12:38:18 -04001613 .procname = "inotify",
1614 .mode = 0555,
1615 .child = inotify_table,
1616 },
1617#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001618#ifdef CONFIG_EPOLL
1619 {
1620 .procname = "epoll",
1621 .mode = 0555,
1622 .child = epoll_table,
1623 },
1624#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001626 {
Kees Cook800179c2012-07-25 17:29:07 -07001627 .procname = "protected_symlinks",
1628 .data = &sysctl_protected_symlinks,
1629 .maxlen = sizeof(int),
1630 .mode = 0600,
1631 .proc_handler = proc_dointvec_minmax,
1632 .extra1 = &zero,
1633 .extra2 = &one,
1634 },
1635 {
1636 .procname = "protected_hardlinks",
1637 .data = &sysctl_protected_hardlinks,
1638 .maxlen = sizeof(int),
1639 .mode = 0600,
1640 .proc_handler = proc_dointvec_minmax,
1641 .extra1 = &zero,
1642 .extra2 = &one,
1643 },
1644 {
Alan Coxd6e71142005-06-23 00:09:43 -07001645 .procname = "suid_dumpable",
1646 .data = &suid_dumpable,
1647 .maxlen = sizeof(int),
1648 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001649 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001650 .extra1 = &zero,
1651 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001652 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001653#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1654 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001655 .procname = "binfmt_misc",
1656 .mode = 0555,
1657 .child = binfmt_misc_table,
1658 },
1659#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001660 {
Jens Axboeff9da692010-06-03 14:54:39 +02001661 .procname = "pipe-max-size",
1662 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001663 .maxlen = sizeof(int),
1664 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001665 .proc_handler = &pipe_proc_fn,
1666 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001667 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001668 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669};
1670
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001671static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001672#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001673 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001674 .procname = "exception-trace",
1675 .data = &show_unhandled_signals,
1676 .maxlen = sizeof(int),
1677 .mode = 0644,
1678 .proc_handler = proc_dointvec
1679 },
1680#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001681#if defined(CONFIG_OPTPROBES)
1682 {
1683 .procname = "kprobes-optimization",
1684 .data = &sysctl_kprobes_optimization,
1685 .maxlen = sizeof(int),
1686 .mode = 0644,
1687 .proc_handler = proc_kprobes_optimization_handler,
1688 .extra1 = &zero,
1689 .extra2 = &one,
1690 },
1691#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001692 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693};
1694
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001695static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001696 { }
Robert Love0eeca282005-07-12 17:06:03 -04001697};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001699int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001700{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001701 struct ctl_table_header *hdr;
1702
1703 hdr = register_sysctl_table(sysctl_base_table);
1704 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001705 return 0;
1706}
1707
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001708#endif /* CONFIG_SYSCTL */
1709
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710/*
1711 * /proc/sys support
1712 */
1713
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001714#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715
Kees Cookf8808302014-06-06 14:37:17 -07001716static int _proc_do_string(char *data, int maxlen, int write,
1717 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001718 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001719{
1720 size_t len;
1721 char __user *p;
1722 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001723
1724 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001725 *lenp = 0;
1726 return 0;
1727 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001728
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001729 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001730 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1731 /* Only continue writes not past the end of buffer. */
1732 len = strlen(data);
1733 if (len > maxlen - 1)
1734 len = maxlen - 1;
1735
1736 if (*ppos > len)
1737 return 0;
1738 len = *ppos;
1739 } else {
1740 /* Start writing from beginning of buffer. */
1741 len = 0;
1742 }
1743
Kees Cook2ca9bb42014-06-06 14:37:18 -07001744 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001745 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001746 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001747 if (get_user(c, p++))
1748 return -EFAULT;
1749 if (c == 0 || c == '\n')
1750 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001751 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001752 }
Kees Cookf8808302014-06-06 14:37:17 -07001753 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001754 } else {
1755 len = strlen(data);
1756 if (len > maxlen)
1757 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001758
1759 if (*ppos > len) {
1760 *lenp = 0;
1761 return 0;
1762 }
1763
1764 data += *ppos;
1765 len -= *ppos;
1766
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001767 if (len > *lenp)
1768 len = *lenp;
1769 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001770 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001771 return -EFAULT;
1772 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001773 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001774 return -EFAULT;
1775 len++;
1776 }
1777 *lenp = len;
1778 *ppos += len;
1779 }
1780 return 0;
1781}
1782
Kees Cookf4aacea2014-06-06 14:37:19 -07001783static void warn_sysctl_write(struct ctl_table *table)
1784{
1785 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1786 "This will not be supported in the future. To silence this\n"
1787 "warning, set kernel.sysctl_writes_strict = -1\n",
1788 current->comm, table->procname);
1789}
1790
Linus Torvalds1da177e2005-04-16 15:20:36 -07001791/**
1792 * proc_dostring - read a string sysctl
1793 * @table: the sysctl table
1794 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795 * @buffer: the user buffer
1796 * @lenp: the size of the user buffer
1797 * @ppos: file position
1798 *
1799 * Reads/writes a string from/to the user buffer. If the kernel
1800 * buffer provided is not large enough to hold the string, the
1801 * string is truncated. The copied string is %NULL-terminated.
1802 * If the string is being read by the user process, it is copied
1803 * and a newline '\n' is added. It is truncated if the buffer is
1804 * not large enough.
1805 *
1806 * Returns 0 on success.
1807 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001808int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809 void __user *buffer, size_t *lenp, loff_t *ppos)
1810{
Kees Cookf4aacea2014-06-06 14:37:19 -07001811 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1812 warn_sysctl_write(table);
1813
Kees Cookf8808302014-06-06 14:37:17 -07001814 return _proc_do_string((char *)(table->data), table->maxlen, write,
1815 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816}
1817
Amerigo Wang00b7c332010-05-05 00:26:45 +00001818static size_t proc_skip_spaces(char **buf)
1819{
1820 size_t ret;
1821 char *tmp = skip_spaces(*buf);
1822 ret = tmp - *buf;
1823 *buf = tmp;
1824 return ret;
1825}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001827static void proc_skip_char(char **buf, size_t *size, const char v)
1828{
1829 while (*size) {
1830 if (**buf != v)
1831 break;
1832 (*size)--;
1833 (*buf)++;
1834 }
1835}
1836
Amerigo Wang00b7c332010-05-05 00:26:45 +00001837#define TMPBUFLEN 22
1838/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001839 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001840 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001841 * @buf: a kernel buffer
1842 * @size: size of the kernel buffer
1843 * @val: this is where the number will be stored
1844 * @neg: set to %TRUE if number is negative
1845 * @perm_tr: a vector which contains the allowed trailers
1846 * @perm_tr_len: size of the perm_tr vector
1847 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001848 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001849 * In case of success %0 is returned and @buf and @size are updated with
1850 * the amount of bytes read. If @tr is non-NULL and a trailing
1851 * character exists (size is non-zero after returning from this
1852 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001853 */
1854static int proc_get_long(char **buf, size_t *size,
1855 unsigned long *val, bool *neg,
1856 const char *perm_tr, unsigned perm_tr_len, char *tr)
1857{
1858 int len;
1859 char *p, tmp[TMPBUFLEN];
1860
1861 if (!*size)
1862 return -EINVAL;
1863
1864 len = *size;
1865 if (len > TMPBUFLEN - 1)
1866 len = TMPBUFLEN - 1;
1867
1868 memcpy(tmp, *buf, len);
1869
1870 tmp[len] = 0;
1871 p = tmp;
1872 if (*p == '-' && *size > 1) {
1873 *neg = true;
1874 p++;
1875 } else
1876 *neg = false;
1877 if (!isdigit(*p))
1878 return -EINVAL;
1879
1880 *val = simple_strtoul(p, &p, 0);
1881
1882 len = p - tmp;
1883
1884 /* We don't know if the next char is whitespace thus we may accept
1885 * invalid integers (e.g. 1234...a) or two integers instead of one
1886 * (e.g. 123...1). So lets not allow such large numbers. */
1887 if (len == TMPBUFLEN - 1)
1888 return -EINVAL;
1889
1890 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1891 return -EINVAL;
1892
1893 if (tr && (len < *size))
1894 *tr = *p;
1895
1896 *buf += len;
1897 *size -= len;
1898
1899 return 0;
1900}
1901
1902/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001903 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001904 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001905 * @buf: the user buffer
1906 * @size: the size of the user buffer
1907 * @val: the integer to be converted
1908 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001909 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001910 * In case of success %0 is returned and @buf and @size are updated with
1911 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001912 */
1913static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1914 bool neg)
1915{
1916 int len;
1917 char tmp[TMPBUFLEN], *p = tmp;
1918
1919 sprintf(p, "%s%lu", neg ? "-" : "", val);
1920 len = strlen(tmp);
1921 if (len > *size)
1922 len = *size;
1923 if (copy_to_user(*buf, tmp, len))
1924 return -EFAULT;
1925 *size -= len;
1926 *buf += len;
1927 return 0;
1928}
1929#undef TMPBUFLEN
1930
1931static int proc_put_char(void __user **buf, size_t *size, char c)
1932{
1933 if (*size) {
1934 char __user **buffer = (char __user **)buf;
1935 if (put_user(c, *buffer))
1936 return -EFAULT;
1937 (*size)--, (*buffer)++;
1938 *buf = *buffer;
1939 }
1940 return 0;
1941}
1942
1943static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 int *valp,
1945 int write, void *data)
1946{
1947 if (write) {
1948 *valp = *negp ? -*lvalp : *lvalp;
1949 } else {
1950 int val = *valp;
1951 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001952 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953 *lvalp = (unsigned long)-val;
1954 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001955 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956 *lvalp = (unsigned long)val;
1957 }
1958 }
1959 return 0;
1960}
1961
Amerigo Wang00b7c332010-05-05 00:26:45 +00001962static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1963
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001964static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001965 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001966 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001967 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 int write, void *data),
1969 void *data)
1970{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001971 int *i, vleft, first = 1, err = 0;
1972 unsigned long page = 0;
1973 size_t left;
1974 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975
Amerigo Wang00b7c332010-05-05 00:26:45 +00001976 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 *lenp = 0;
1978 return 0;
1979 }
1980
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001981 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982 vleft = table->maxlen / sizeof(*i);
1983 left = *lenp;
1984
1985 if (!conv)
1986 conv = do_proc_dointvec_conv;
1987
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001989 if (*ppos) {
1990 switch (sysctl_writes_strict) {
1991 case SYSCTL_WRITES_STRICT:
1992 goto out;
1993 case SYSCTL_WRITES_WARN:
1994 warn_sysctl_write(table);
1995 break;
1996 default:
1997 break;
1998 }
1999 }
2000
Amerigo Wang00b7c332010-05-05 00:26:45 +00002001 if (left > PAGE_SIZE - 1)
2002 left = PAGE_SIZE - 1;
2003 page = __get_free_page(GFP_TEMPORARY);
2004 kbuf = (char *) page;
2005 if (!kbuf)
2006 return -ENOMEM;
2007 if (copy_from_user(kbuf, buffer, left)) {
2008 err = -EFAULT;
2009 goto free;
2010 }
2011 kbuf[left] = 0;
2012 }
2013
2014 for (; left && vleft--; i++, first=0) {
2015 unsigned long lval;
2016 bool neg;
2017
2018 if (write) {
2019 left -= proc_skip_spaces(&kbuf);
2020
J. R. Okajima563b0462010-05-25 16:10:14 -07002021 if (!left)
2022 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002023 err = proc_get_long(&kbuf, &left, &lval, &neg,
2024 proc_wspace_sep,
2025 sizeof(proc_wspace_sep), NULL);
2026 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002028 if (conv(&neg, &lval, i, 1, data)) {
2029 err = -EINVAL;
2030 break;
2031 }
2032 } else {
2033 if (conv(&neg, &lval, i, 0, data)) {
2034 err = -EINVAL;
2035 break;
2036 }
2037 if (!first)
2038 err = proc_put_char(&buffer, &left, '\t');
2039 if (err)
2040 break;
2041 err = proc_put_long(&buffer, &left, lval, neg);
2042 if (err)
2043 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044 }
2045 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002046
2047 if (!write && !first && left && !err)
2048 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002049 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002050 left -= proc_skip_spaces(&kbuf);
2051free:
2052 if (write) {
2053 free_page(page);
2054 if (first)
2055 return err ? : -EINVAL;
2056 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002058out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002060 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002061}
2062
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002063static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002064 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002065 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002066 int write, void *data),
2067 void *data)
2068{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002069 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002070 buffer, lenp, ppos, conv, data);
2071}
2072
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073/**
2074 * proc_dointvec - read a vector of integers
2075 * @table: the sysctl table
2076 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077 * @buffer: the user buffer
2078 * @lenp: the size of the user buffer
2079 * @ppos: file position
2080 *
2081 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2082 * values from/to the user buffer, treated as an ASCII string.
2083 *
2084 * Returns 0 on success.
2085 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002086int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087 void __user *buffer, size_t *lenp, loff_t *ppos)
2088{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002089 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090 NULL,NULL);
2091}
2092
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002093/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002094 * Taint values can only be increased
2095 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002096 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002097static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002098 void __user *buffer, size_t *lenp, loff_t *ppos)
2099{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002100 struct ctl_table t;
2101 unsigned long tmptaint = get_taint();
2102 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002103
Bastian Blank91fcd412007-04-23 14:41:14 -07002104 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002105 return -EPERM;
2106
Andi Kleen25ddbb12008-10-15 22:01:41 -07002107 t = *table;
2108 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002109 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002110 if (err < 0)
2111 return err;
2112
2113 if (write) {
2114 /*
2115 * Poor man's atomic or. Not worth adding a primitive
2116 * to everyone's atomic.h for this
2117 */
2118 int i;
2119 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2120 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302121 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002122 }
2123 }
2124
2125 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002126}
2127
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002128#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002129static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002130 void __user *buffer, size_t *lenp, loff_t *ppos)
2131{
2132 if (write && !capable(CAP_SYS_ADMIN))
2133 return -EPERM;
2134
2135 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2136}
2137#endif
2138
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139struct do_proc_dointvec_minmax_conv_param {
2140 int *min;
2141 int *max;
2142};
2143
Amerigo Wang00b7c332010-05-05 00:26:45 +00002144static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2145 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146 int write, void *data)
2147{
2148 struct do_proc_dointvec_minmax_conv_param *param = data;
2149 if (write) {
2150 int val = *negp ? -*lvalp : *lvalp;
2151 if ((param->min && *param->min > val) ||
2152 (param->max && *param->max < val))
2153 return -EINVAL;
2154 *valp = val;
2155 } else {
2156 int val = *valp;
2157 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002158 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 *lvalp = (unsigned long)-val;
2160 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002161 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002162 *lvalp = (unsigned long)val;
2163 }
2164 }
2165 return 0;
2166}
2167
2168/**
2169 * proc_dointvec_minmax - read a vector of integers with min/max values
2170 * @table: the sysctl table
2171 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 * @buffer: the user buffer
2173 * @lenp: the size of the user buffer
2174 * @ppos: file position
2175 *
2176 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2177 * values from/to the user buffer, treated as an ASCII string.
2178 *
2179 * This routine will ensure the values are within the range specified by
2180 * table->extra1 (min) and table->extra2 (max).
2181 *
2182 * Returns 0 on success.
2183 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002184int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 void __user *buffer, size_t *lenp, loff_t *ppos)
2186{
2187 struct do_proc_dointvec_minmax_conv_param param = {
2188 .min = (int *) table->extra1,
2189 .max = (int *) table->extra2,
2190 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002191 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192 do_proc_dointvec_minmax_conv, &param);
2193}
2194
Kees Cook54b50192012-07-30 14:39:18 -07002195static void validate_coredump_safety(void)
2196{
Alex Kelly046d6622012-10-04 17:15:23 -07002197#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002198 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002199 core_pattern[0] != '/' && core_pattern[0] != '|') {
2200 printk(KERN_WARNING "Unsafe core_pattern used with "\
2201 "suid_dumpable=2. Pipe handler or fully qualified "\
2202 "core dump path required.\n");
2203 }
Alex Kelly046d6622012-10-04 17:15:23 -07002204#endif
Kees Cook54b50192012-07-30 14:39:18 -07002205}
2206
2207static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2208 void __user *buffer, size_t *lenp, loff_t *ppos)
2209{
2210 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2211 if (!error)
2212 validate_coredump_safety();
2213 return error;
2214}
2215
Alex Kelly046d6622012-10-04 17:15:23 -07002216#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002217static int proc_dostring_coredump(struct ctl_table *table, int write,
2218 void __user *buffer, size_t *lenp, loff_t *ppos)
2219{
2220 int error = proc_dostring(table, write, buffer, lenp, ppos);
2221 if (!error)
2222 validate_coredump_safety();
2223 return error;
2224}
Alex Kelly046d6622012-10-04 17:15:23 -07002225#endif
Kees Cook54b50192012-07-30 14:39:18 -07002226
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002227static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 void __user *buffer,
2229 size_t *lenp, loff_t *ppos,
2230 unsigned long convmul,
2231 unsigned long convdiv)
2232{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002233 unsigned long *i, *min, *max;
2234 int vleft, first = 1, err = 0;
2235 unsigned long page = 0;
2236 size_t left;
2237 char *kbuf;
2238
2239 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 *lenp = 0;
2241 return 0;
2242 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002243
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002244 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 min = (unsigned long *) table->extra1;
2246 max = (unsigned long *) table->extra2;
2247 vleft = table->maxlen / sizeof(unsigned long);
2248 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002249
2250 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002251 if (*ppos) {
2252 switch (sysctl_writes_strict) {
2253 case SYSCTL_WRITES_STRICT:
2254 goto out;
2255 case SYSCTL_WRITES_WARN:
2256 warn_sysctl_write(table);
2257 break;
2258 default:
2259 break;
2260 }
2261 }
2262
Amerigo Wang00b7c332010-05-05 00:26:45 +00002263 if (left > PAGE_SIZE - 1)
2264 left = PAGE_SIZE - 1;
2265 page = __get_free_page(GFP_TEMPORARY);
2266 kbuf = (char *) page;
2267 if (!kbuf)
2268 return -ENOMEM;
2269 if (copy_from_user(kbuf, buffer, left)) {
2270 err = -EFAULT;
2271 goto free;
2272 }
2273 kbuf[left] = 0;
2274 }
2275
Eric Dumazet27b3d802010-10-07 12:59:29 -07002276 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277 unsigned long val;
2278
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002280 bool neg;
2281
2282 left -= proc_skip_spaces(&kbuf);
2283
2284 err = proc_get_long(&kbuf, &left, &val, &neg,
2285 proc_wspace_sep,
2286 sizeof(proc_wspace_sep), NULL);
2287 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288 break;
2289 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 continue;
2291 if ((min && val < *min) || (max && val > *max))
2292 continue;
2293 *i = val;
2294 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002295 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002296 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002297 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002298 if (err)
2299 break;
2300 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002301 err = proc_put_long(&buffer, &left, val, false);
2302 if (err)
2303 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304 }
2305 }
2306
Amerigo Wang00b7c332010-05-05 00:26:45 +00002307 if (!write && !first && left && !err)
2308 err = proc_put_char(&buffer, &left, '\n');
2309 if (write && !err)
2310 left -= proc_skip_spaces(&kbuf);
2311free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002313 free_page(page);
2314 if (first)
2315 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002318out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002320 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321}
2322
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002323static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002324 void __user *buffer,
2325 size_t *lenp, loff_t *ppos,
2326 unsigned long convmul,
2327 unsigned long convdiv)
2328{
2329 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002330 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002331}
2332
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333/**
2334 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2335 * @table: the sysctl table
2336 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 * @buffer: the user buffer
2338 * @lenp: the size of the user buffer
2339 * @ppos: file position
2340 *
2341 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2342 * values from/to the user buffer, treated as an ASCII string.
2343 *
2344 * This routine will ensure the values are within the range specified by
2345 * table->extra1 (min) and table->extra2 (max).
2346 *
2347 * Returns 0 on success.
2348 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002349int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 void __user *buffer, size_t *lenp, loff_t *ppos)
2351{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002352 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353}
2354
2355/**
2356 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2357 * @table: the sysctl table
2358 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359 * @buffer: the user buffer
2360 * @lenp: the size of the user buffer
2361 * @ppos: file position
2362 *
2363 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2364 * values from/to the user buffer, treated as an ASCII string. The values
2365 * are treated as milliseconds, and converted to jiffies when they are stored.
2366 *
2367 * This routine will ensure the values are within the range specified by
2368 * table->extra1 (min) and table->extra2 (max).
2369 *
2370 * Returns 0 on success.
2371 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002372int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373 void __user *buffer,
2374 size_t *lenp, loff_t *ppos)
2375{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002376 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 lenp, ppos, HZ, 1000l);
2378}
2379
2380
Amerigo Wang00b7c332010-05-05 00:26:45 +00002381static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382 int *valp,
2383 int write, void *data)
2384{
2385 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002386 if (*lvalp > LONG_MAX / HZ)
2387 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2389 } else {
2390 int val = *valp;
2391 unsigned long lval;
2392 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002393 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 lval = (unsigned long)-val;
2395 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002396 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 lval = (unsigned long)val;
2398 }
2399 *lvalp = lval / HZ;
2400 }
2401 return 0;
2402}
2403
Amerigo Wang00b7c332010-05-05 00:26:45 +00002404static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 int *valp,
2406 int write, void *data)
2407{
2408 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002409 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2410 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2412 } else {
2413 int val = *valp;
2414 unsigned long lval;
2415 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002416 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 lval = (unsigned long)-val;
2418 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002419 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 lval = (unsigned long)val;
2421 }
2422 *lvalp = jiffies_to_clock_t(lval);
2423 }
2424 return 0;
2425}
2426
Amerigo Wang00b7c332010-05-05 00:26:45 +00002427static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 int *valp,
2429 int write, void *data)
2430{
2431 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002432 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2433
2434 if (jif > INT_MAX)
2435 return 1;
2436 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 } else {
2438 int val = *valp;
2439 unsigned long lval;
2440 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002441 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 lval = (unsigned long)-val;
2443 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002444 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 lval = (unsigned long)val;
2446 }
2447 *lvalp = jiffies_to_msecs(lval);
2448 }
2449 return 0;
2450}
2451
2452/**
2453 * proc_dointvec_jiffies - read a vector of integers as seconds
2454 * @table: the sysctl table
2455 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 * @buffer: the user buffer
2457 * @lenp: the size of the user buffer
2458 * @ppos: file position
2459 *
2460 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2461 * values from/to the user buffer, treated as an ASCII string.
2462 * The values read are assumed to be in seconds, and are converted into
2463 * jiffies.
2464 *
2465 * Returns 0 on success.
2466 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002467int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 void __user *buffer, size_t *lenp, loff_t *ppos)
2469{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002470 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 do_proc_dointvec_jiffies_conv,NULL);
2472}
2473
2474/**
2475 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2476 * @table: the sysctl table
2477 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 * @buffer: the user buffer
2479 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002480 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 *
2482 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2483 * values from/to the user buffer, treated as an ASCII string.
2484 * The values read are assumed to be in 1/USER_HZ seconds, and
2485 * are converted into jiffies.
2486 *
2487 * Returns 0 on success.
2488 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002489int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 void __user *buffer, size_t *lenp, loff_t *ppos)
2491{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002492 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 do_proc_dointvec_userhz_jiffies_conv,NULL);
2494}
2495
2496/**
2497 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2498 * @table: the sysctl table
2499 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 * @buffer: the user buffer
2501 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002502 * @ppos: file position
2503 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002504 *
2505 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2506 * values from/to the user buffer, treated as an ASCII string.
2507 * The values read are assumed to be in 1/1000 seconds, and
2508 * are converted into jiffies.
2509 *
2510 * Returns 0 on success.
2511 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002512int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 void __user *buffer, size_t *lenp, loff_t *ppos)
2514{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002515 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 do_proc_dointvec_ms_jiffies_conv, NULL);
2517}
2518
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002519static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002520 void __user *buffer, size_t *lenp, loff_t *ppos)
2521{
2522 struct pid *new_pid;
2523 pid_t tmp;
2524 int r;
2525
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002526 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002527
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002528 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002529 lenp, ppos, NULL, NULL);
2530 if (r || !write)
2531 return r;
2532
2533 new_pid = find_get_pid(tmp);
2534 if (!new_pid)
2535 return -ESRCH;
2536
2537 put_pid(xchg(&cad_pid, new_pid));
2538 return 0;
2539}
2540
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002541/**
2542 * proc_do_large_bitmap - read/write from/to a large bitmap
2543 * @table: the sysctl table
2544 * @write: %TRUE if this is a write to the sysctl file
2545 * @buffer: the user buffer
2546 * @lenp: the size of the user buffer
2547 * @ppos: file position
2548 *
2549 * The bitmap is stored at table->data and the bitmap length (in bits)
2550 * in table->maxlen.
2551 *
2552 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2553 * large bitmaps may be represented in a compact manner. Writing into
2554 * the file will clear the bitmap then update it with the given input.
2555 *
2556 * Returns 0 on success.
2557 */
2558int proc_do_large_bitmap(struct ctl_table *table, int write,
2559 void __user *buffer, size_t *lenp, loff_t *ppos)
2560{
2561 int err = 0;
2562 bool first = 1;
2563 size_t left = *lenp;
2564 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002565 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002566 unsigned long *tmp_bitmap = NULL;
2567 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2568
WANG Cong122ff242014-05-12 16:04:53 -07002569 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002570 *lenp = 0;
2571 return 0;
2572 }
2573
2574 if (write) {
2575 unsigned long page = 0;
2576 char *kbuf;
2577
2578 if (left > PAGE_SIZE - 1)
2579 left = PAGE_SIZE - 1;
2580
2581 page = __get_free_page(GFP_TEMPORARY);
2582 kbuf = (char *) page;
2583 if (!kbuf)
2584 return -ENOMEM;
2585 if (copy_from_user(kbuf, buffer, left)) {
2586 free_page(page);
2587 return -EFAULT;
2588 }
2589 kbuf[left] = 0;
2590
2591 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2592 GFP_KERNEL);
2593 if (!tmp_bitmap) {
2594 free_page(page);
2595 return -ENOMEM;
2596 }
2597 proc_skip_char(&kbuf, &left, '\n');
2598 while (!err && left) {
2599 unsigned long val_a, val_b;
2600 bool neg;
2601
2602 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2603 sizeof(tr_a), &c);
2604 if (err)
2605 break;
2606 if (val_a >= bitmap_len || neg) {
2607 err = -EINVAL;
2608 break;
2609 }
2610
2611 val_b = val_a;
2612 if (left) {
2613 kbuf++;
2614 left--;
2615 }
2616
2617 if (c == '-') {
2618 err = proc_get_long(&kbuf, &left, &val_b,
2619 &neg, tr_b, sizeof(tr_b),
2620 &c);
2621 if (err)
2622 break;
2623 if (val_b >= bitmap_len || neg ||
2624 val_a > val_b) {
2625 err = -EINVAL;
2626 break;
2627 }
2628 if (left) {
2629 kbuf++;
2630 left--;
2631 }
2632 }
2633
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002634 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002635 first = 0;
2636 proc_skip_char(&kbuf, &left, '\n');
2637 }
2638 free_page(page);
2639 } else {
2640 unsigned long bit_a, bit_b = 0;
2641
2642 while (left) {
2643 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2644 if (bit_a >= bitmap_len)
2645 break;
2646 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2647 bit_a + 1) - 1;
2648
2649 if (!first) {
2650 err = proc_put_char(&buffer, &left, ',');
2651 if (err)
2652 break;
2653 }
2654 err = proc_put_long(&buffer, &left, bit_a, false);
2655 if (err)
2656 break;
2657 if (bit_a != bit_b) {
2658 err = proc_put_char(&buffer, &left, '-');
2659 if (err)
2660 break;
2661 err = proc_put_long(&buffer, &left, bit_b, false);
2662 if (err)
2663 break;
2664 }
2665
2666 first = 0; bit_b++;
2667 }
2668 if (!err)
2669 err = proc_put_char(&buffer, &left, '\n');
2670 }
2671
2672 if (!err) {
2673 if (write) {
2674 if (*ppos)
2675 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2676 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002677 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002678 }
2679 kfree(tmp_bitmap);
2680 *lenp -= left;
2681 *ppos += *lenp;
2682 return 0;
2683 } else {
2684 kfree(tmp_bitmap);
2685 return err;
2686 }
2687}
2688
Jovi Zhang55610502011-01-12 17:00:45 -08002689#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002691int proc_dostring(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(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_minmax(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_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_userhz_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_dointvec_ms_jiffies(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
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002727int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 void __user *buffer, size_t *lenp, loff_t *ppos)
2729{
2730 return -ENOSYS;
2731}
2732
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002733int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734 void __user *buffer,
2735 size_t *lenp, loff_t *ppos)
2736{
2737 return -ENOSYS;
2738}
2739
2740
Jovi Zhang55610502011-01-12 17:00:45 -08002741#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743/*
2744 * No sense putting this after each symbol definition, twice,
2745 * exception granted :-)
2746 */
2747EXPORT_SYMBOL(proc_dointvec);
2748EXPORT_SYMBOL(proc_dointvec_jiffies);
2749EXPORT_SYMBOL(proc_dointvec_minmax);
2750EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2751EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2752EXPORT_SYMBOL(proc_dostring);
2753EXPORT_SYMBOL(proc_doulongvec_minmax);
2754EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);