blob: 5c14b547882ef1dabfcd9cd80f5903e173ef4ec4 [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;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800139static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700142static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Dave Youngd14f1722010-02-25 20:28:57 -0500144#ifdef CONFIG_INOTIFY_USER
145#include <linux/inotify.h>
146#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700147#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148#endif
149
David S. Miller08714202008-11-16 23:49:24 -0800150#ifdef CONFIG_SPARC64
151extern int sysctl_tsb_ratio;
152#endif
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#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
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700171static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700172 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700173static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800174 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700176
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700177#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700178static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700179 void __user *buffer, size_t *lenp, loff_t *ppos);
180#endif
181
Kees Cook54b50192012-07-30 14:39:18 -0700182static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
183 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700184#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700185static int proc_dostring_coredump(struct ctl_table *table, int write,
186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700187#endif
Kees Cook54b50192012-07-30 14:39:18 -0700188
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700189#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800190/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100191static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700192
193static int sysrq_sysctl_handler(ctl_table *table, int write,
194 void __user *buffer, size_t *lenp,
195 loff_t *ppos)
196{
197 int error;
198
199 error = proc_dointvec(table, write, buffer, lenp, ppos);
200 if (error)
201 return error;
202
203 if (write)
204 sysrq_toggle_support(__sysrq_enabled);
205
206 return 0;
207}
208
209#endif
210
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700211static struct ctl_table kern_table[];
212static struct ctl_table vm_table[];
213static struct ctl_table fs_table[];
214static struct ctl_table debug_table[];
215static struct ctl_table dev_table[];
216extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800217#ifdef CONFIG_EPOLL
218extern struct ctl_table epoll_table[];
219#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
222int sysctl_legacy_va_layout;
223#endif
224
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225/* The default sysctl tables: */
226
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800227static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 .procname = "kernel",
230 .mode = 0555,
231 .child = kern_table,
232 },
233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "vm",
235 .mode = 0555,
236 .child = vm_table,
237 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .procname = "fs",
240 .mode = 0555,
241 .child = fs_table,
242 },
243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .procname = "debug",
245 .mode = 0555,
246 .child = debug_table,
247 },
248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .procname = "dev",
250 .mode = 0555,
251 .child = dev_table,
252 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700253 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254};
255
Ingo Molnar77e54a12007-07-09 18:52:00 +0200256#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100257static int min_sched_granularity_ns = 100000; /* 100 usecs */
258static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
259static int min_wakeup_granularity_ns; /* 0 usecs */
260static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200261#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100262static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
263static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200264#endif /* CONFIG_SMP */
265#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200266
Mel Gorman5e771902010-05-24 14:32:31 -0700267#ifdef CONFIG_COMPACTION
268static int min_extfrag_threshold;
269static int max_extfrag_threshold = 1000;
270#endif
271
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700272static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200273 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200274 .procname = "sched_child_runs_first",
275 .data = &sysctl_sched_child_runs_first,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800278 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200279 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280#ifdef CONFIG_SCHED_DEBUG
281 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100282 .procname = "sched_min_granularity_ns",
283 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800286 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100287 .extra1 = &min_sched_granularity_ns,
288 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289 },
290 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200291 .procname = "sched_latency_ns",
292 .data = &sysctl_sched_latency,
293 .maxlen = sizeof(unsigned int),
294 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800295 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200296 .extra1 = &min_sched_granularity_ns,
297 .extra2 = &max_sched_granularity_ns,
298 },
299 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 .procname = "sched_wakeup_granularity_ns",
301 .data = &sysctl_sched_wakeup_granularity,
302 .maxlen = sizeof(unsigned int),
303 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800304 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200305 .extra1 = &min_wakeup_granularity_ns,
306 .extra2 = &max_wakeup_granularity_ns,
307 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200308#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200309 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100310 .procname = "sched_tunable_scaling",
311 .data = &sysctl_sched_tunable_scaling,
312 .maxlen = sizeof(enum sched_tunable_scaling),
313 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800314 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100315 .extra1 = &min_sched_tunable_scaling,
316 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200317 },
318 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900319 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200320 .data = &sysctl_sched_migration_cost,
321 .maxlen = sizeof(unsigned int),
322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800323 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200324 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100325 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100326 .procname = "sched_nr_migrate",
327 .data = &sysctl_sched_nr_migrate,
328 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100329 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800330 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100331 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530332 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900333 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200334 .data = &sysctl_sched_time_avg,
335 .maxlen = sizeof(unsigned int),
336 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800337 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200338 },
339 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900340 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800341 .data = &sysctl_sched_shares_window,
342 .maxlen = sizeof(unsigned int),
343 .mode = 0644,
344 .proc_handler = proc_dointvec,
345 },
346 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530347 .procname = "timer_migration",
348 .data = &sysctl_timer_migration,
349 .maxlen = sizeof(unsigned int),
350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800351 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530352 .extra1 = &zero,
353 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530354 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200355#endif /* CONFIG_SMP */
356#ifdef CONFIG_NUMA_BALANCING
357 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200358 .procname = "numa_balancing_scan_delay_ms",
359 .data = &sysctl_numa_balancing_scan_delay,
360 .maxlen = sizeof(unsigned int),
361 .mode = 0644,
362 .proc_handler = proc_dointvec,
363 },
364 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200365 .procname = "numa_balancing_scan_period_min_ms",
366 .data = &sysctl_numa_balancing_scan_period_min,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec,
370 },
371 {
372 .procname = "numa_balancing_scan_period_max_ms",
373 .data = &sysctl_numa_balancing_scan_period_max,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200378 {
379 .procname = "numa_balancing_scan_size_mb",
380 .data = &sysctl_numa_balancing_scan_size,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100385 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800386 .procname = "numa_balancing",
387 .data = NULL, /* filled in by handler */
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
390 .proc_handler = sysctl_numa_balancing,
391 .extra1 = &zero,
392 .extra2 = &one,
393 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200394#endif /* CONFIG_NUMA_BALANCING */
395#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200396 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100397 .procname = "sched_rt_period_us",
398 .data = &sysctl_sched_rt_period,
399 .maxlen = sizeof(unsigned int),
400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100402 },
403 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100404 .procname = "sched_rt_runtime_us",
405 .data = &sysctl_sched_rt_runtime,
406 .maxlen = sizeof(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 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600410 {
411 .procname = "sched_rr_timeslice_ms",
412 .data = &sched_rr_timeslice,
413 .maxlen = sizeof(int),
414 .mode = 0644,
415 .proc_handler = sched_rr_handler,
416 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100417#ifdef CONFIG_SCHED_AUTOGROUP
418 {
419 .procname = "sched_autogroup_enabled",
420 .data = &sysctl_sched_autogroup_enabled,
421 .maxlen = sizeof(unsigned int),
422 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800423 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100424 .extra1 = &zero,
425 .extra2 = &one,
426 },
427#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700428#ifdef CONFIG_CFS_BANDWIDTH
429 {
430 .procname = "sched_cfs_bandwidth_slice_us",
431 .data = &sysctl_sched_cfs_bandwidth_slice,
432 .maxlen = sizeof(unsigned int),
433 .mode = 0644,
434 .proc_handler = proc_dointvec_minmax,
435 .extra1 = &one,
436 },
437#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700438#ifdef CONFIG_PROVE_LOCKING
439 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700440 .procname = "prove_locking",
441 .data = &prove_locking,
442 .maxlen = sizeof(int),
443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800444 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700445 },
446#endif
447#ifdef CONFIG_LOCK_STAT
448 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700449 .procname = "lock_stat",
450 .data = &lock_stat,
451 .maxlen = sizeof(int),
452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800453 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454 },
455#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .procname = "panic",
458 .data = &panic_timeout,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 },
Alex Kelly046d6622012-10-04 17:15:23 -0700463#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 .procname = "core_uses_pid",
466 .data = &core_uses_pid,
467 .maxlen = sizeof(int),
468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800469 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 },
471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "core_pattern",
473 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700474 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700476 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
Neil Hormana2939802009-09-23 15:56:56 -0700478 {
Neil Hormana2939802009-09-23 15:56:56 -0700479 .procname = "core_pipe_limit",
480 .data = &core_pipe_limit,
481 .maxlen = sizeof(unsigned int),
482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800483 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700484 },
Alex Kelly046d6622012-10-04 17:15:23 -0700485#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800486#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700489 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800493#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100494#ifdef CONFIG_LATENCYTOP
495 {
496 .procname = "latencytop",
497 .data = &latencytop_enabled,
498 .maxlen = sizeof(int),
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100501 },
502#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503#ifdef CONFIG_BLK_DEV_INITRD
504 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 .procname = "real-root-dev",
506 .data = &real_root_dev,
507 .maxlen = sizeof(int),
508 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800509 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 },
511#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700512 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700513 .procname = "print-fatal-signals",
514 .data = &print_fatal_signals,
515 .maxlen = sizeof(int),
516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800517 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700518 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700519#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 .procname = "reboot-cmd",
522 .data = reboot_command,
523 .maxlen = 256,
524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 },
527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "stop-a",
529 .data = &stop_a_enabled,
530 .maxlen = sizeof (int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "scons-poweroff",
536 .data = &scons_pwroff,
537 .maxlen = sizeof (int),
538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 },
541#endif
David S. Miller08714202008-11-16 23:49:24 -0800542#ifdef CONFIG_SPARC64
543 {
David S. Miller08714202008-11-16 23:49:24 -0800544 .procname = "tsb-ratio",
545 .data = &sysctl_tsb_ratio,
546 .maxlen = sizeof (int),
547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800549 },
550#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551#ifdef __hppa__
552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "soft-power",
554 .data = &pwrsw_enabled,
555 .maxlen = sizeof (int),
556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530559#endif
560#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 .procname = "unaligned-trap",
563 .data = &unaligned_enabled,
564 .maxlen = sizeof (int),
565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800566 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 },
568#endif
569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "ctrl-alt-del",
571 .data = &C_A_D,
572 .maxlen = sizeof(int),
573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400576#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200577 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200578 .procname = "ftrace_enabled",
579 .data = &ftrace_enabled,
580 .maxlen = sizeof(int),
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200583 },
584#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500585#ifdef CONFIG_STACK_TRACER
586 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500587 .procname = "stack_tracer_enabled",
588 .data = &stack_tracer_enabled,
589 .maxlen = sizeof(int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500592 },
593#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400594#ifdef CONFIG_TRACING
595 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100596 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400597 .data = &ftrace_dump_on_oops,
598 .maxlen = sizeof(int),
599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800600 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400601 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400602 {
603 .procname = "traceoff_on_warning",
604 .data = &__disable_trace_on_warning,
605 .maxlen = sizeof(__disable_trace_on_warning),
606 .mode = 0644,
607 .proc_handler = proc_dointvec,
608 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400609#endif
Kees Cook79847542014-01-23 15:55:59 -0800610#ifdef CONFIG_KEXEC
611 {
612 .procname = "kexec_load_disabled",
613 .data = &kexec_load_disabled,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 /* only handle a transition from default "0" to "1" */
617 .proc_handler = proc_dointvec_minmax,
618 .extra1 = &one,
619 .extra2 = &one,
620 },
621#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200622#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .procname = "modprobe",
625 .data = &modprobe_path,
626 .maxlen = KMOD_PATH_LEN,
627 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800628 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 },
Kees Cook3d433212009-04-02 15:49:29 -0700630 {
Kees Cook3d433212009-04-02 15:49:29 -0700631 .procname = "modules_disabled",
632 .data = &modules_disabled,
633 .maxlen = sizeof(int),
634 .mode = 0644,
635 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800636 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700637 .extra1 = &one,
638 .extra2 = &one,
639 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500641
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100644 .data = &uevent_helper,
645 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800647 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500649
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650#ifdef CONFIG_CHR_DEV_SG
651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 .procname = "sg-big-buff",
653 .data = &sg_big_buff,
654 .maxlen = sizeof (int),
655 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800656 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 },
658#endif
659#ifdef CONFIG_BSD_PROCESS_ACCT
660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "acct",
662 .data = &acct_parm,
663 .maxlen = 3*sizeof(int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
667#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668#ifdef CONFIG_MAGIC_SYSRQ
669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800671 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .maxlen = sizeof (int),
673 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700674 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 },
676#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700677#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700680 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 .maxlen = sizeof (int),
682 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700685#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "threads-max",
688 .data = &max_threads,
689 .maxlen = sizeof(int),
690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800691 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "random",
695 .mode = 0555,
696 .child = random_table,
697 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 {
Eric Paris17f60a72011-04-01 17:07:50 -0400699 .procname = "usermodehelper",
700 .mode = 0555,
701 .child = usermodehelper_table,
702 },
703 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .procname = "overflowuid",
705 .data = &overflowuid,
706 .maxlen = sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .extra1 = &minolduid,
710 .extra2 = &maxolduid,
711 },
712 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .procname = "overflowgid",
714 .data = &overflowgid,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .extra1 = &minolduid,
719 .extra2 = &maxolduid,
720 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800721#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722#ifdef CONFIG_MATHEMU
723 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 .procname = "ieee_emulation_warnings",
725 .data = &sysctl_ieee_emulation_warnings,
726 .maxlen = sizeof(int),
727 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800728 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 },
730#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200733 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .maxlen = sizeof(int),
735 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800736 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 },
738#endif
739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .procname = "pid_max",
741 .data = &pid_max,
742 .maxlen = sizeof (int),
743 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800744 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .extra1 = &pid_max_min,
746 .extra2 = &pid_max_max,
747 },
748 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .procname = "panic_on_oops",
750 .data = &panic_on_oops,
751 .maxlen = sizeof(int),
752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800755#if defined CONFIG_PRINTK
756 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800757 .procname = "printk",
758 .data = &console_loglevel,
759 .maxlen = 4*sizeof(int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800762 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700765 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 .maxlen = sizeof(int),
767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800768 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 },
770 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700772 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 .maxlen = sizeof(int),
774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800775 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 },
Dave Youngaf913222009-09-22 16:43:33 -0700777 {
Dave Youngaf913222009-09-22 16:43:33 -0700778 .procname = "printk_delay",
779 .data = &printk_delay_msec,
780 .maxlen = sizeof(int),
781 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800782 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700783 .extra1 = &zero,
784 .extra2 = &ten_thousand,
785 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800787 .procname = "dmesg_restrict",
788 .data = &dmesg_restrict,
789 .maxlen = sizeof(int),
790 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700791 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800792 .extra1 = &zero,
793 .extra2 = &one,
794 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800795 {
796 .procname = "kptr_restrict",
797 .data = &kptr_restrict,
798 .maxlen = sizeof(int),
799 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700800 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800801 .extra1 = &zero,
802 .extra2 = &two,
803 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800804#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800805 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 .procname = "ngroups_max",
807 .data = &ngroups_max,
808 .maxlen = sizeof (int),
809 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800810 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 },
Dan Ballard73efc032011-10-31 17:11:20 -0700812 {
813 .procname = "cap_last_cap",
814 .data = (void *)&cap_last_cap,
815 .maxlen = sizeof(int),
816 .mode = 0444,
817 .proc_handler = proc_dointvec,
818 },
Don Zickus58687ac2010-05-07 17:11:44 -0400819#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500820 {
Don Zickus58687ac2010-05-07 17:11:44 -0400821 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200822 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500823 .maxlen = sizeof (int),
824 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700825 .proc_handler = proc_dowatchdog,
826 .extra1 = &zero,
827 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400828 },
829 {
830 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700831 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400832 .maxlen = sizeof(int),
833 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700834 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800835 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400836 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500837 },
Don Zickus2508ce12010-05-07 17:11:46 -0400838 {
839 .procname = "softlockup_panic",
840 .data = &softlockup_panic,
841 .maxlen = sizeof(int),
842 .mode = 0644,
843 .proc_handler = proc_dointvec_minmax,
844 .extra1 = &zero,
845 .extra2 = &one,
846 },
Don Zickus5dc30552010-11-29 17:07:17 -0500847 {
848 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200849 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500850 .maxlen = sizeof (int),
851 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700852 .proc_handler = proc_dowatchdog,
853 .extra1 = &zero,
854 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500855 },
856#endif
857#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
858 {
859 .procname = "unknown_nmi_panic",
860 .data = &unknown_nmi_panic,
861 .maxlen = sizeof (int),
862 .mode = 0644,
863 .proc_handler = proc_dointvec,
864 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500865#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866#if defined(CONFIG_X86)
867 {
Don Zickus8da5add2006-09-26 10:52:27 +0200868 .procname = "panic_on_unrecovered_nmi",
869 .data = &panic_on_unrecovered_nmi,
870 .maxlen = sizeof(int),
871 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800872 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200873 },
874 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700875 .procname = "panic_on_io_nmi",
876 .data = &panic_on_io_nmi,
877 .maxlen = sizeof(int),
878 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800879 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700880 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900881#ifdef CONFIG_DEBUG_STACKOVERFLOW
882 {
883 .procname = "panic_on_stackoverflow",
884 .data = &sysctl_panic_on_stackoverflow,
885 .maxlen = sizeof(int),
886 .mode = 0644,
887 .proc_handler = proc_dointvec,
888 },
889#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700890 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 .procname = "bootloader_type",
892 .data = &bootloader_type,
893 .maxlen = sizeof (int),
894 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800895 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100897 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700898 .procname = "bootloader_version",
899 .data = &bootloader_version,
900 .maxlen = sizeof (int),
901 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800902 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700903 },
904 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100905 .procname = "kstack_depth_to_print",
906 .data = &kstack_depth_to_print,
907 .maxlen = sizeof(int),
908 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800909 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100910 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100911 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100912 .procname = "io_delay_type",
913 .data = &io_delay_type,
914 .maxlen = sizeof(int),
915 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800916 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100917 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800919#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 .procname = "randomize_va_space",
922 .data = &randomize_va_space,
923 .maxlen = sizeof(int),
924 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800925 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800927#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800928#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700929 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700930 .procname = "spin_retry",
931 .data = &spin_retry,
932 .maxlen = sizeof (int),
933 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800934 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700935 },
936#endif
Len Brown673d5b42007-07-28 03:33:16 -0400937#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800938 {
Pavel Machekc255d842006-02-20 18:27:58 -0800939 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700940 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800941 .maxlen = sizeof (unsigned long),
942 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800943 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800944 },
945#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530946#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800947 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800948 .procname = "ignore-unaligned-usertrap",
949 .data = &no_unaligned_warning,
950 .maxlen = sizeof (int),
951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800952 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800953 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530954#endif
955#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800956 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800957 .procname = "unaligned-dump-stack",
958 .data = &unaligned_dump_stack,
959 .maxlen = sizeof (int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800962 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800963#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800964#ifdef CONFIG_DETECT_HUNG_TASK
965 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800966 .procname = "hung_task_panic",
967 .data = &sysctl_hung_task_panic,
968 .maxlen = sizeof(int),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800971 .extra1 = &zero,
972 .extra2 = &one,
973 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100974 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100975 .procname = "hung_task_check_count",
976 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800977 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100978 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800979 .proc_handler = proc_dointvec_minmax,
980 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100981 },
982 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100983 .procname = "hung_task_timeout_secs",
984 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100985 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100986 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800987 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100988 },
989 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100990 .procname = "hung_task_warnings",
991 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +0000992 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100993 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +0000994 .proc_handler = proc_dointvec_minmax,
995 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100996 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700997#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200998#ifdef CONFIG_COMPAT
999 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001000 .procname = "compat-log",
1001 .data = &compat_log,
1002 .maxlen = sizeof (int),
1003 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001004 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001005 },
1006#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001007#ifdef CONFIG_RT_MUTEXES
1008 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001009 .procname = "max_lock_depth",
1010 .data = &max_lock_depth,
1011 .maxlen = sizeof(int),
1012 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001013 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001014 },
1015#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001016 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001017 .procname = "poweroff_cmd",
1018 .data = &poweroff_cmd,
1019 .maxlen = POWEROFF_CMD_PATH_LEN,
1020 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001021 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001022 },
David Howells0b77f5b2008-04-29 01:01:32 -07001023#ifdef CONFIG_KEYS
1024 {
David Howells0b77f5b2008-04-29 01:01:32 -07001025 .procname = "keys",
1026 .mode = 0555,
1027 .child = key_sysctls,
1028 },
1029#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001030#ifdef CONFIG_RCU_TORTURE_TEST
1031 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001032 .procname = "rcutorture_runnable",
1033 .data = &rcutorture_runnable,
1034 .maxlen = sizeof(int),
1035 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001036 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001037 },
1038#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001039#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001040 /*
1041 * User-space scripts rely on the existence of this file
1042 * as a feature check for perf_events being enabled.
1043 *
1044 * So it's an ABI, do not remove!
1045 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001046 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001047 .procname = "perf_event_paranoid",
1048 .data = &sysctl_perf_event_paranoid,
1049 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001050 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001051 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001052 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001053 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001054 .procname = "perf_event_mlock_kb",
1055 .data = &sysctl_perf_event_mlock,
1056 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001057 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001058 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001059 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001060 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001061 .procname = "perf_event_max_sample_rate",
1062 .data = &sysctl_perf_event_sample_rate,
1063 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001064 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001065 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001066 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001067 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001068 {
1069 .procname = "perf_cpu_time_max_percent",
1070 .data = &sysctl_perf_cpu_time_max_percent,
1071 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1072 .mode = 0644,
1073 .proc_handler = perf_cpu_time_max_percent_handler,
1074 .extra1 = &zero,
1075 .extra2 = &one_hundred,
1076 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001077#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001078#ifdef CONFIG_KMEMCHECK
1079 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001080 .procname = "kmemcheck",
1081 .data = &kmemcheck_enabled,
1082 .maxlen = sizeof(int),
1083 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001084 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001085 },
1086#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001087 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088};
1089
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001090static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 .procname = "overcommit_memory",
1093 .data = &sysctl_overcommit_memory,
1094 .maxlen = sizeof(sysctl_overcommit_memory),
1095 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001096 .proc_handler = proc_dointvec_minmax,
1097 .extra1 = &zero,
1098 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 },
1100 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001101 .procname = "panic_on_oom",
1102 .data = &sysctl_panic_on_oom,
1103 .maxlen = sizeof(sysctl_panic_on_oom),
1104 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001105 .proc_handler = proc_dointvec_minmax,
1106 .extra1 = &zero,
1107 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001108 },
1109 {
David Rientjesfe071d72007-10-16 23:25:56 -07001110 .procname = "oom_kill_allocating_task",
1111 .data = &sysctl_oom_kill_allocating_task,
1112 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1113 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001114 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001115 },
1116 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001117 .procname = "oom_dump_tasks",
1118 .data = &sysctl_oom_dump_tasks,
1119 .maxlen = sizeof(sysctl_oom_dump_tasks),
1120 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001121 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001122 },
1123 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 .procname = "overcommit_ratio",
1125 .data = &sysctl_overcommit_ratio,
1126 .maxlen = sizeof(sysctl_overcommit_ratio),
1127 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001128 .proc_handler = overcommit_ratio_handler,
1129 },
1130 {
1131 .procname = "overcommit_kbytes",
1132 .data = &sysctl_overcommit_kbytes,
1133 .maxlen = sizeof(sysctl_overcommit_kbytes),
1134 .mode = 0644,
1135 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 },
1137 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 .procname = "page-cluster",
1139 .data = &page_cluster,
1140 .maxlen = sizeof(int),
1141 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001142 .proc_handler = proc_dointvec_minmax,
1143 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 },
1145 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 .procname = "dirty_background_ratio",
1147 .data = &dirty_background_ratio,
1148 .maxlen = sizeof(dirty_background_ratio),
1149 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001150 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 .extra1 = &zero,
1152 .extra2 = &one_hundred,
1153 },
1154 {
David Rientjes2da02992009-01-06 14:39:31 -08001155 .procname = "dirty_background_bytes",
1156 .data = &dirty_background_bytes,
1157 .maxlen = sizeof(dirty_background_bytes),
1158 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001159 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001160 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001161 },
1162 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 .procname = "dirty_ratio",
1164 .data = &vm_dirty_ratio,
1165 .maxlen = sizeof(vm_dirty_ratio),
1166 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001167 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 .extra1 = &zero,
1169 .extra2 = &one_hundred,
1170 },
1171 {
David Rientjes2da02992009-01-06 14:39:31 -08001172 .procname = "dirty_bytes",
1173 .data = &vm_dirty_bytes,
1174 .maxlen = sizeof(vm_dirty_bytes),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001177 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001178 },
1179 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001181 .data = &dirty_writeback_interval,
1182 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001184 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 },
1186 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001188 .data = &dirty_expire_interval,
1189 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001191 .proc_handler = proc_dointvec_minmax,
1192 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 },
1194 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001195 .procname = "nr_pdflush_threads",
1196 .mode = 0444 /* read-only */,
1197 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 },
1199 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 .procname = "swappiness",
1201 .data = &vm_swappiness,
1202 .maxlen = sizeof(vm_swappiness),
1203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001204 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 .extra1 = &zero,
1206 .extra2 = &one_hundred,
1207 },
1208#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001209 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001211 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 .maxlen = sizeof(unsigned long),
1213 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001214 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 .extra1 = (void *)&hugetlb_zero,
1216 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001217 },
1218#ifdef CONFIG_NUMA
1219 {
1220 .procname = "nr_hugepages_mempolicy",
1221 .data = NULL,
1222 .maxlen = sizeof(unsigned long),
1223 .mode = 0644,
1224 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1225 .extra1 = (void *)&hugetlb_zero,
1226 .extra2 = (void *)&hugetlb_infinity,
1227 },
1228#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 .procname = "hugetlb_shm_group",
1231 .data = &sysctl_hugetlb_shm_group,
1232 .maxlen = sizeof(gid_t),
1233 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001234 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 },
Mel Gorman396faf02007-07-17 04:03:13 -07001236 {
Mel Gorman396faf02007-07-17 04:03:13 -07001237 .procname = "hugepages_treat_as_movable",
1238 .data = &hugepages_treat_as_movable,
1239 .maxlen = sizeof(int),
1240 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001241 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001242 },
Adam Litke54f9f802007-10-16 01:26:20 -07001243 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001244 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001245 .data = NULL,
1246 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001247 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001248 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001249 .extra1 = (void *)&hugetlb_zero,
1250 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001251 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252#endif
1253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 .procname = "lowmem_reserve_ratio",
1255 .data = &sysctl_lowmem_reserve_ratio,
1256 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1257 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001258 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 },
1260 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001261 .procname = "drop_caches",
1262 .data = &sysctl_drop_caches,
1263 .maxlen = sizeof(int),
1264 .mode = 0644,
1265 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001266 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001267 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001268 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001269#ifdef CONFIG_COMPACTION
1270 {
1271 .procname = "compact_memory",
1272 .data = &sysctl_compact_memory,
1273 .maxlen = sizeof(int),
1274 .mode = 0200,
1275 .proc_handler = sysctl_compaction_handler,
1276 },
Mel Gorman5e771902010-05-24 14:32:31 -07001277 {
1278 .procname = "extfrag_threshold",
1279 .data = &sysctl_extfrag_threshold,
1280 .maxlen = sizeof(int),
1281 .mode = 0644,
1282 .proc_handler = sysctl_extfrag_handler,
1283 .extra1 = &min_extfrag_threshold,
1284 .extra2 = &max_extfrag_threshold,
1285 },
1286
Mel Gorman76ab0f52010-05-24 14:32:28 -07001287#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001288 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 .procname = "min_free_kbytes",
1290 .data = &min_free_kbytes,
1291 .maxlen = sizeof(min_free_kbytes),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 .extra1 = &zero,
1295 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001296 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001297 .procname = "percpu_pagelist_fraction",
1298 .data = &percpu_pagelist_fraction,
1299 .maxlen = sizeof(percpu_pagelist_fraction),
1300 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001302 .extra1 = &min_percpu_pagelist_fract,
1303 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304#ifdef CONFIG_MMU
1305 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001306 .procname = "max_map_count",
1307 .data = &sysctl_max_map_count,
1308 .maxlen = sizeof(sysctl_max_map_count),
1309 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001310 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001311 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001313#else
1314 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001315 .procname = "nr_trim_pages",
1316 .data = &sysctl_nr_trim_pages,
1317 .maxlen = sizeof(sysctl_nr_trim_pages),
1318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001320 .extra1 = &zero,
1321 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322#endif
1323 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 .procname = "laptop_mode",
1325 .data = &laptop_mode,
1326 .maxlen = sizeof(laptop_mode),
1327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001328 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 },
1330 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 .procname = "block_dump",
1332 .data = &block_dump,
1333 .maxlen = sizeof(block_dump),
1334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001335 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336 .extra1 = &zero,
1337 },
1338 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 .procname = "vfs_cache_pressure",
1340 .data = &sysctl_vfs_cache_pressure,
1341 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 .extra1 = &zero,
1345 },
1346#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1347 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 .procname = "legacy_va_layout",
1349 .data = &sysctl_legacy_va_layout,
1350 .maxlen = sizeof(sysctl_legacy_va_layout),
1351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001352 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .extra1 = &zero,
1354 },
1355#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001356#ifdef CONFIG_NUMA
1357 {
Christoph Lameter17436602006-01-18 17:42:32 -08001358 .procname = "zone_reclaim_mode",
1359 .data = &zone_reclaim_mode,
1360 .maxlen = sizeof(zone_reclaim_mode),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001363 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001364 },
Christoph Lameter96146342006-07-03 00:24:13 -07001365 {
Christoph Lameter96146342006-07-03 00:24:13 -07001366 .procname = "min_unmapped_ratio",
1367 .data = &sysctl_min_unmapped_ratio,
1368 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001371 .extra1 = &zero,
1372 .extra2 = &one_hundred,
1373 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001374 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001375 .procname = "min_slab_ratio",
1376 .data = &sysctl_min_slab_ratio,
1377 .maxlen = sizeof(sysctl_min_slab_ratio),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001380 .extra1 = &zero,
1381 .extra2 = &one_hundred,
1382 },
Christoph Lameter17436602006-01-18 17:42:32 -08001383#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001384#ifdef CONFIG_SMP
1385 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001386 .procname = "stat_interval",
1387 .data = &sysctl_stat_interval,
1388 .maxlen = sizeof(sysctl_stat_interval),
1389 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001390 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001391 },
1392#endif
David Howells6e141542009-12-15 19:27:45 +00001393#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001394 {
Eric Parised032182007-06-28 15:55:21 -04001395 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001396 .data = &dac_mmap_min_addr,
1397 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001398 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001399 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001400 },
David Howells6e141542009-12-15 19:27:45 +00001401#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001402#ifdef CONFIG_NUMA
1403 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001404 .procname = "numa_zonelist_order",
1405 .data = &numa_zonelist_order,
1406 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001408 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001409 },
1410#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001411#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001412 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001413 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001414 .procname = "vdso_enabled",
1415 .data = &vdso_enabled,
1416 .maxlen = sizeof(vdso_enabled),
1417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001419 .extra1 = &zero,
1420 },
1421#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001422#ifdef CONFIG_HIGHMEM
1423 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001424 .procname = "highmem_is_dirtyable",
1425 .data = &vm_highmem_is_dirtyable,
1426 .maxlen = sizeof(vm_highmem_is_dirtyable),
1427 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001428 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001429 .extra1 = &zero,
1430 .extra2 = &one,
1431 },
1432#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001433 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001434 .procname = "scan_unevictable_pages",
1435 .data = &scan_unevictable_pages,
1436 .maxlen = sizeof(scan_unevictable_pages),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001439 },
Andi Kleen6a460792009-09-16 11:50:15 +02001440#ifdef CONFIG_MEMORY_FAILURE
1441 {
Andi Kleen6a460792009-09-16 11:50:15 +02001442 .procname = "memory_failure_early_kill",
1443 .data = &sysctl_memory_failure_early_kill,
1444 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001446 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001447 .extra1 = &zero,
1448 .extra2 = &one,
1449 },
1450 {
Andi Kleen6a460792009-09-16 11:50:15 +02001451 .procname = "memory_failure_recovery",
1452 .data = &sysctl_memory_failure_recovery,
1453 .maxlen = sizeof(sysctl_memory_failure_recovery),
1454 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001455 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001456 .extra1 = &zero,
1457 .extra2 = &one,
1458 },
1459#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001460 {
1461 .procname = "user_reserve_kbytes",
1462 .data = &sysctl_user_reserve_kbytes,
1463 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1464 .mode = 0644,
1465 .proc_handler = proc_doulongvec_minmax,
1466 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001467 {
1468 .procname = "admin_reserve_kbytes",
1469 .data = &sysctl_admin_reserve_kbytes,
1470 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1471 .mode = 0644,
1472 .proc_handler = proc_doulongvec_minmax,
1473 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001474 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475};
1476
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001477#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001478static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001479 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001480};
1481#endif
1482
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001483static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "inode-nr",
1486 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001487 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001489 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 },
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "inode-state",
1493 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001494 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001496 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 },
1498 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .procname = "file-nr",
1500 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001501 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001503 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 },
1505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .procname = "file-max",
1507 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001508 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001510 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 },
1512 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001513 .procname = "nr_open",
1514 .data = &sysctl_nr_open,
1515 .maxlen = sizeof(int),
1516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001517 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001518 .extra1 = &sysctl_nr_open_min,
1519 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001520 },
1521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 .procname = "dentry-state",
1523 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001524 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001526 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 },
1528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 .procname = "overflowuid",
1530 .data = &fs_overflowuid,
1531 .maxlen = sizeof(int),
1532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001533 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 .extra1 = &minolduid,
1535 .extra2 = &maxolduid,
1536 },
1537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 .procname = "overflowgid",
1539 .data = &fs_overflowgid,
1540 .maxlen = sizeof(int),
1541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001542 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 .extra1 = &minolduid,
1544 .extra2 = &maxolduid,
1545 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001546#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 .procname = "leases-enable",
1549 .data = &leases_enable,
1550 .maxlen = sizeof(int),
1551 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001554#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555#ifdef CONFIG_DNOTIFY
1556 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 .procname = "dir-notify-enable",
1558 .data = &dir_notify_enable,
1559 .maxlen = sizeof(int),
1560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001561 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 },
1563#endif
1564#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001565#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 .procname = "lease-break-time",
1568 .data = &lease_break_time,
1569 .maxlen = sizeof(int),
1570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001573#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001574#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576 .procname = "aio-nr",
1577 .data = &aio_nr,
1578 .maxlen = sizeof(aio_nr),
1579 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001580 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 },
1582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583 .procname = "aio-max-nr",
1584 .data = &aio_max_nr,
1585 .maxlen = sizeof(aio_max_nr),
1586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001587 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001589#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001590#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001591 {
Robert Love0399cb02005-07-13 12:38:18 -04001592 .procname = "inotify",
1593 .mode = 0555,
1594 .child = inotify_table,
1595 },
1596#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001597#ifdef CONFIG_EPOLL
1598 {
1599 .procname = "epoll",
1600 .mode = 0555,
1601 .child = epoll_table,
1602 },
1603#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001605 {
Kees Cook800179c2012-07-25 17:29:07 -07001606 .procname = "protected_symlinks",
1607 .data = &sysctl_protected_symlinks,
1608 .maxlen = sizeof(int),
1609 .mode = 0600,
1610 .proc_handler = proc_dointvec_minmax,
1611 .extra1 = &zero,
1612 .extra2 = &one,
1613 },
1614 {
1615 .procname = "protected_hardlinks",
1616 .data = &sysctl_protected_hardlinks,
1617 .maxlen = sizeof(int),
1618 .mode = 0600,
1619 .proc_handler = proc_dointvec_minmax,
1620 .extra1 = &zero,
1621 .extra2 = &one,
1622 },
1623 {
Alan Coxd6e71142005-06-23 00:09:43 -07001624 .procname = "suid_dumpable",
1625 .data = &suid_dumpable,
1626 .maxlen = sizeof(int),
1627 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001628 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001629 .extra1 = &zero,
1630 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001631 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001632#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1633 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001634 .procname = "binfmt_misc",
1635 .mode = 0555,
1636 .child = binfmt_misc_table,
1637 },
1638#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001639 {
Jens Axboeff9da692010-06-03 14:54:39 +02001640 .procname = "pipe-max-size",
1641 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001642 .maxlen = sizeof(int),
1643 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001644 .proc_handler = &pipe_proc_fn,
1645 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001646 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001647 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648};
1649
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001650static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001651#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001652 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001653 .procname = "exception-trace",
1654 .data = &show_unhandled_signals,
1655 .maxlen = sizeof(int),
1656 .mode = 0644,
1657 .proc_handler = proc_dointvec
1658 },
1659#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001660#if defined(CONFIG_OPTPROBES)
1661 {
1662 .procname = "kprobes-optimization",
1663 .data = &sysctl_kprobes_optimization,
1664 .maxlen = sizeof(int),
1665 .mode = 0644,
1666 .proc_handler = proc_kprobes_optimization_handler,
1667 .extra1 = &zero,
1668 .extra2 = &one,
1669 },
1670#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001671 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001672};
1673
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001674static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001675 { }
Robert Love0eeca282005-07-12 17:06:03 -04001676};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001678int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001679{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001680 struct ctl_table_header *hdr;
1681
1682 hdr = register_sysctl_table(sysctl_base_table);
1683 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001684 return 0;
1685}
1686
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001687#endif /* CONFIG_SYSCTL */
1688
Linus Torvalds1da177e2005-04-16 15:20:36 -07001689/*
1690 * /proc/sys support
1691 */
1692
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001693#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001695static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001696 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001697 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001698{
1699 size_t len;
1700 char __user *p;
1701 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001702
1703 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001704 *lenp = 0;
1705 return 0;
1706 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001707
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001708 if (write) {
1709 len = 0;
1710 p = buffer;
1711 while (len < *lenp) {
1712 if (get_user(c, p++))
1713 return -EFAULT;
1714 if (c == 0 || c == '\n')
1715 break;
1716 len++;
1717 }
1718 if (len >= maxlen)
1719 len = maxlen-1;
1720 if(copy_from_user(data, buffer, len))
1721 return -EFAULT;
1722 ((char *) data)[len] = 0;
1723 *ppos += *lenp;
1724 } else {
1725 len = strlen(data);
1726 if (len > maxlen)
1727 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001728
1729 if (*ppos > len) {
1730 *lenp = 0;
1731 return 0;
1732 }
1733
1734 data += *ppos;
1735 len -= *ppos;
1736
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001737 if (len > *lenp)
1738 len = *lenp;
1739 if (len)
1740 if(copy_to_user(buffer, data, len))
1741 return -EFAULT;
1742 if (len < *lenp) {
1743 if(put_user('\n', ((char __user *) buffer) + len))
1744 return -EFAULT;
1745 len++;
1746 }
1747 *lenp = len;
1748 *ppos += len;
1749 }
1750 return 0;
1751}
1752
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753/**
1754 * proc_dostring - read a string sysctl
1755 * @table: the sysctl table
1756 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 * @buffer: the user buffer
1758 * @lenp: the size of the user buffer
1759 * @ppos: file position
1760 *
1761 * Reads/writes a string from/to the user buffer. If the kernel
1762 * buffer provided is not large enough to hold the string, the
1763 * string is truncated. The copied string is %NULL-terminated.
1764 * If the string is being read by the user process, it is copied
1765 * and a newline '\n' is added. It is truncated if the buffer is
1766 * not large enough.
1767 *
1768 * Returns 0 on success.
1769 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001770int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771 void __user *buffer, size_t *lenp, loff_t *ppos)
1772{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001773 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001774 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775}
1776
Amerigo Wang00b7c332010-05-05 00:26:45 +00001777static size_t proc_skip_spaces(char **buf)
1778{
1779 size_t ret;
1780 char *tmp = skip_spaces(*buf);
1781 ret = tmp - *buf;
1782 *buf = tmp;
1783 return ret;
1784}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001786static void proc_skip_char(char **buf, size_t *size, const char v)
1787{
1788 while (*size) {
1789 if (**buf != v)
1790 break;
1791 (*size)--;
1792 (*buf)++;
1793 }
1794}
1795
Amerigo Wang00b7c332010-05-05 00:26:45 +00001796#define TMPBUFLEN 22
1797/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001798 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001799 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001800 * @buf: a kernel buffer
1801 * @size: size of the kernel buffer
1802 * @val: this is where the number will be stored
1803 * @neg: set to %TRUE if number is negative
1804 * @perm_tr: a vector which contains the allowed trailers
1805 * @perm_tr_len: size of the perm_tr vector
1806 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001807 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001808 * In case of success %0 is returned and @buf and @size are updated with
1809 * the amount of bytes read. If @tr is non-NULL and a trailing
1810 * character exists (size is non-zero after returning from this
1811 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001812 */
1813static int proc_get_long(char **buf, size_t *size,
1814 unsigned long *val, bool *neg,
1815 const char *perm_tr, unsigned perm_tr_len, char *tr)
1816{
1817 int len;
1818 char *p, tmp[TMPBUFLEN];
1819
1820 if (!*size)
1821 return -EINVAL;
1822
1823 len = *size;
1824 if (len > TMPBUFLEN - 1)
1825 len = TMPBUFLEN - 1;
1826
1827 memcpy(tmp, *buf, len);
1828
1829 tmp[len] = 0;
1830 p = tmp;
1831 if (*p == '-' && *size > 1) {
1832 *neg = true;
1833 p++;
1834 } else
1835 *neg = false;
1836 if (!isdigit(*p))
1837 return -EINVAL;
1838
1839 *val = simple_strtoul(p, &p, 0);
1840
1841 len = p - tmp;
1842
1843 /* We don't know if the next char is whitespace thus we may accept
1844 * invalid integers (e.g. 1234...a) or two integers instead of one
1845 * (e.g. 123...1). So lets not allow such large numbers. */
1846 if (len == TMPBUFLEN - 1)
1847 return -EINVAL;
1848
1849 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1850 return -EINVAL;
1851
1852 if (tr && (len < *size))
1853 *tr = *p;
1854
1855 *buf += len;
1856 *size -= len;
1857
1858 return 0;
1859}
1860
1861/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001862 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001863 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001864 * @buf: the user buffer
1865 * @size: the size of the user buffer
1866 * @val: the integer to be converted
1867 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001868 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001869 * In case of success %0 is returned and @buf and @size are updated with
1870 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001871 */
1872static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1873 bool neg)
1874{
1875 int len;
1876 char tmp[TMPBUFLEN], *p = tmp;
1877
1878 sprintf(p, "%s%lu", neg ? "-" : "", val);
1879 len = strlen(tmp);
1880 if (len > *size)
1881 len = *size;
1882 if (copy_to_user(*buf, tmp, len))
1883 return -EFAULT;
1884 *size -= len;
1885 *buf += len;
1886 return 0;
1887}
1888#undef TMPBUFLEN
1889
1890static int proc_put_char(void __user **buf, size_t *size, char c)
1891{
1892 if (*size) {
1893 char __user **buffer = (char __user **)buf;
1894 if (put_user(c, *buffer))
1895 return -EFAULT;
1896 (*size)--, (*buffer)++;
1897 *buf = *buffer;
1898 }
1899 return 0;
1900}
1901
1902static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903 int *valp,
1904 int write, void *data)
1905{
1906 if (write) {
1907 *valp = *negp ? -*lvalp : *lvalp;
1908 } else {
1909 int val = *valp;
1910 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001911 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912 *lvalp = (unsigned long)-val;
1913 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001914 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915 *lvalp = (unsigned long)val;
1916 }
1917 }
1918 return 0;
1919}
1920
Amerigo Wang00b7c332010-05-05 00:26:45 +00001921static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1922
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001923static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001924 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001925 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001926 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001927 int write, void *data),
1928 void *data)
1929{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001930 int *i, vleft, first = 1, err = 0;
1931 unsigned long page = 0;
1932 size_t left;
1933 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934
Amerigo Wang00b7c332010-05-05 00:26:45 +00001935 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001936 *lenp = 0;
1937 return 0;
1938 }
1939
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001940 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941 vleft = table->maxlen / sizeof(*i);
1942 left = *lenp;
1943
1944 if (!conv)
1945 conv = do_proc_dointvec_conv;
1946
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001948 if (left > PAGE_SIZE - 1)
1949 left = PAGE_SIZE - 1;
1950 page = __get_free_page(GFP_TEMPORARY);
1951 kbuf = (char *) page;
1952 if (!kbuf)
1953 return -ENOMEM;
1954 if (copy_from_user(kbuf, buffer, left)) {
1955 err = -EFAULT;
1956 goto free;
1957 }
1958 kbuf[left] = 0;
1959 }
1960
1961 for (; left && vleft--; i++, first=0) {
1962 unsigned long lval;
1963 bool neg;
1964
1965 if (write) {
1966 left -= proc_skip_spaces(&kbuf);
1967
J. R. Okajima563b0462010-05-25 16:10:14 -07001968 if (!left)
1969 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001970 err = proc_get_long(&kbuf, &left, &lval, &neg,
1971 proc_wspace_sep,
1972 sizeof(proc_wspace_sep), NULL);
1973 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001974 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001975 if (conv(&neg, &lval, i, 1, data)) {
1976 err = -EINVAL;
1977 break;
1978 }
1979 } else {
1980 if (conv(&neg, &lval, i, 0, data)) {
1981 err = -EINVAL;
1982 break;
1983 }
1984 if (!first)
1985 err = proc_put_char(&buffer, &left, '\t');
1986 if (err)
1987 break;
1988 err = proc_put_long(&buffer, &left, lval, neg);
1989 if (err)
1990 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991 }
1992 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001993
1994 if (!write && !first && left && !err)
1995 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001996 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001997 left -= proc_skip_spaces(&kbuf);
1998free:
1999 if (write) {
2000 free_page(page);
2001 if (first)
2002 return err ? : -EINVAL;
2003 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 *lenp -= left;
2005 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002006 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007}
2008
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002009static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002010 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002011 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002012 int write, void *data),
2013 void *data)
2014{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002015 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002016 buffer, lenp, ppos, conv, data);
2017}
2018
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019/**
2020 * proc_dointvec - read a vector of integers
2021 * @table: the sysctl table
2022 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 * @buffer: the user buffer
2024 * @lenp: the size of the user buffer
2025 * @ppos: file position
2026 *
2027 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2028 * values from/to the user buffer, treated as an ASCII string.
2029 *
2030 * Returns 0 on success.
2031 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002032int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 void __user *buffer, size_t *lenp, loff_t *ppos)
2034{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002035 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036 NULL,NULL);
2037}
2038
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002039/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002040 * Taint values can only be increased
2041 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002042 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002043static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002044 void __user *buffer, size_t *lenp, loff_t *ppos)
2045{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002046 struct ctl_table t;
2047 unsigned long tmptaint = get_taint();
2048 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002049
Bastian Blank91fcd412007-04-23 14:41:14 -07002050 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002051 return -EPERM;
2052
Andi Kleen25ddbb12008-10-15 22:01:41 -07002053 t = *table;
2054 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002055 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002056 if (err < 0)
2057 return err;
2058
2059 if (write) {
2060 /*
2061 * Poor man's atomic or. Not worth adding a primitive
2062 * to everyone's atomic.h for this
2063 */
2064 int i;
2065 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2066 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302067 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002068 }
2069 }
2070
2071 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002072}
2073
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002074#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002075static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002076 void __user *buffer, size_t *lenp, loff_t *ppos)
2077{
2078 if (write && !capable(CAP_SYS_ADMIN))
2079 return -EPERM;
2080
2081 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2082}
2083#endif
2084
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085struct do_proc_dointvec_minmax_conv_param {
2086 int *min;
2087 int *max;
2088};
2089
Amerigo Wang00b7c332010-05-05 00:26:45 +00002090static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2091 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092 int write, void *data)
2093{
2094 struct do_proc_dointvec_minmax_conv_param *param = data;
2095 if (write) {
2096 int val = *negp ? -*lvalp : *lvalp;
2097 if ((param->min && *param->min > val) ||
2098 (param->max && *param->max < val))
2099 return -EINVAL;
2100 *valp = val;
2101 } else {
2102 int val = *valp;
2103 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002104 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 *lvalp = (unsigned long)-val;
2106 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002107 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 *lvalp = (unsigned long)val;
2109 }
2110 }
2111 return 0;
2112}
2113
2114/**
2115 * proc_dointvec_minmax - read a vector of integers with min/max values
2116 * @table: the sysctl table
2117 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118 * @buffer: the user buffer
2119 * @lenp: the size of the user buffer
2120 * @ppos: file position
2121 *
2122 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2123 * values from/to the user buffer, treated as an ASCII string.
2124 *
2125 * This routine will ensure the values are within the range specified by
2126 * table->extra1 (min) and table->extra2 (max).
2127 *
2128 * Returns 0 on success.
2129 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002130int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131 void __user *buffer, size_t *lenp, loff_t *ppos)
2132{
2133 struct do_proc_dointvec_minmax_conv_param param = {
2134 .min = (int *) table->extra1,
2135 .max = (int *) table->extra2,
2136 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002137 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002138 do_proc_dointvec_minmax_conv, &param);
2139}
2140
Kees Cook54b50192012-07-30 14:39:18 -07002141static void validate_coredump_safety(void)
2142{
Alex Kelly046d6622012-10-04 17:15:23 -07002143#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002144 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002145 core_pattern[0] != '/' && core_pattern[0] != '|') {
2146 printk(KERN_WARNING "Unsafe core_pattern used with "\
2147 "suid_dumpable=2. Pipe handler or fully qualified "\
2148 "core dump path required.\n");
2149 }
Alex Kelly046d6622012-10-04 17:15:23 -07002150#endif
Kees Cook54b50192012-07-30 14:39:18 -07002151}
2152
2153static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2154 void __user *buffer, size_t *lenp, loff_t *ppos)
2155{
2156 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2157 if (!error)
2158 validate_coredump_safety();
2159 return error;
2160}
2161
Alex Kelly046d6622012-10-04 17:15:23 -07002162#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002163static int proc_dostring_coredump(struct ctl_table *table, int write,
2164 void __user *buffer, size_t *lenp, loff_t *ppos)
2165{
2166 int error = proc_dostring(table, write, buffer, lenp, ppos);
2167 if (!error)
2168 validate_coredump_safety();
2169 return error;
2170}
Alex Kelly046d6622012-10-04 17:15:23 -07002171#endif
Kees Cook54b50192012-07-30 14:39:18 -07002172
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002173static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 void __user *buffer,
2175 size_t *lenp, loff_t *ppos,
2176 unsigned long convmul,
2177 unsigned long convdiv)
2178{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002179 unsigned long *i, *min, *max;
2180 int vleft, first = 1, err = 0;
2181 unsigned long page = 0;
2182 size_t left;
2183 char *kbuf;
2184
2185 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 *lenp = 0;
2187 return 0;
2188 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002189
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002190 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 min = (unsigned long *) table->extra1;
2192 max = (unsigned long *) table->extra2;
2193 vleft = table->maxlen / sizeof(unsigned long);
2194 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195
2196 if (write) {
2197 if (left > PAGE_SIZE - 1)
2198 left = PAGE_SIZE - 1;
2199 page = __get_free_page(GFP_TEMPORARY);
2200 kbuf = (char *) page;
2201 if (!kbuf)
2202 return -ENOMEM;
2203 if (copy_from_user(kbuf, buffer, left)) {
2204 err = -EFAULT;
2205 goto free;
2206 }
2207 kbuf[left] = 0;
2208 }
2209
Eric Dumazet27b3d802010-10-07 12:59:29 -07002210 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002211 unsigned long val;
2212
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002214 bool neg;
2215
2216 left -= proc_skip_spaces(&kbuf);
2217
2218 err = proc_get_long(&kbuf, &left, &val, &neg,
2219 proc_wspace_sep,
2220 sizeof(proc_wspace_sep), NULL);
2221 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 break;
2223 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224 continue;
2225 if ((min && val < *min) || (max && val > *max))
2226 continue;
2227 *i = val;
2228 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002229 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002230 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002231 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002232 if (err)
2233 break;
2234 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002235 err = proc_put_long(&buffer, &left, val, false);
2236 if (err)
2237 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 }
2239 }
2240
Amerigo Wang00b7c332010-05-05 00:26:45 +00002241 if (!write && !first && left && !err)
2242 err = proc_put_char(&buffer, &left, '\n');
2243 if (write && !err)
2244 left -= proc_skip_spaces(&kbuf);
2245free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002247 free_page(page);
2248 if (first)
2249 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 *lenp -= left;
2252 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002253 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254}
2255
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002256static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002257 void __user *buffer,
2258 size_t *lenp, loff_t *ppos,
2259 unsigned long convmul,
2260 unsigned long convdiv)
2261{
2262 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002263 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002264}
2265
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266/**
2267 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2268 * @table: the sysctl table
2269 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 * @buffer: the user buffer
2271 * @lenp: the size of the user buffer
2272 * @ppos: file position
2273 *
2274 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2275 * values from/to the user buffer, treated as an ASCII string.
2276 *
2277 * This routine will ensure the values are within the range specified by
2278 * table->extra1 (min) and table->extra2 (max).
2279 *
2280 * Returns 0 on success.
2281 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002282int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 void __user *buffer, size_t *lenp, loff_t *ppos)
2284{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002285 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286}
2287
2288/**
2289 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2290 * @table: the sysctl table
2291 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 * @buffer: the user buffer
2293 * @lenp: the size of the user buffer
2294 * @ppos: file position
2295 *
2296 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2297 * values from/to the user buffer, treated as an ASCII string. The values
2298 * are treated as milliseconds, and converted to jiffies when they are stored.
2299 *
2300 * This routine will ensure the values are within the range specified by
2301 * table->extra1 (min) and table->extra2 (max).
2302 *
2303 * Returns 0 on success.
2304 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002305int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 void __user *buffer,
2307 size_t *lenp, loff_t *ppos)
2308{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002309 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 lenp, ppos, HZ, 1000l);
2311}
2312
2313
Amerigo Wang00b7c332010-05-05 00:26:45 +00002314static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 int *valp,
2316 int write, void *data)
2317{
2318 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002319 if (*lvalp > LONG_MAX / HZ)
2320 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2322 } else {
2323 int val = *valp;
2324 unsigned long lval;
2325 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002326 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 lval = (unsigned long)-val;
2328 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002329 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330 lval = (unsigned long)val;
2331 }
2332 *lvalp = lval / HZ;
2333 }
2334 return 0;
2335}
2336
Amerigo Wang00b7c332010-05-05 00:26:45 +00002337static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 int *valp,
2339 int write, void *data)
2340{
2341 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002342 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2343 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2345 } else {
2346 int val = *valp;
2347 unsigned long lval;
2348 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002349 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 lval = (unsigned long)-val;
2351 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 lval = (unsigned long)val;
2354 }
2355 *lvalp = jiffies_to_clock_t(lval);
2356 }
2357 return 0;
2358}
2359
Amerigo Wang00b7c332010-05-05 00:26:45 +00002360static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361 int *valp,
2362 int write, void *data)
2363{
2364 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002365 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2366
2367 if (jif > INT_MAX)
2368 return 1;
2369 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 } else {
2371 int val = *valp;
2372 unsigned long lval;
2373 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002374 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375 lval = (unsigned long)-val;
2376 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002377 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 lval = (unsigned long)val;
2379 }
2380 *lvalp = jiffies_to_msecs(lval);
2381 }
2382 return 0;
2383}
2384
2385/**
2386 * proc_dointvec_jiffies - read a vector of integers as seconds
2387 * @table: the sysctl table
2388 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 * @buffer: the user buffer
2390 * @lenp: the size of the user buffer
2391 * @ppos: file position
2392 *
2393 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2394 * values from/to the user buffer, treated as an ASCII string.
2395 * The values read are assumed to be in seconds, and are converted into
2396 * jiffies.
2397 *
2398 * Returns 0 on success.
2399 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002400int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 void __user *buffer, size_t *lenp, loff_t *ppos)
2402{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 do_proc_dointvec_jiffies_conv,NULL);
2405}
2406
2407/**
2408 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2409 * @table: the sysctl table
2410 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 * @buffer: the user buffer
2412 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002413 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 *
2415 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2416 * values from/to the user buffer, treated as an ASCII string.
2417 * The values read are assumed to be in 1/USER_HZ seconds, and
2418 * are converted into jiffies.
2419 *
2420 * Returns 0 on success.
2421 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002422int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 void __user *buffer, size_t *lenp, loff_t *ppos)
2424{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002425 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426 do_proc_dointvec_userhz_jiffies_conv,NULL);
2427}
2428
2429/**
2430 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2431 * @table: the sysctl table
2432 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 * @buffer: the user buffer
2434 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002435 * @ppos: file position
2436 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 *
2438 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2439 * values from/to the user buffer, treated as an ASCII string.
2440 * The values read are assumed to be in 1/1000 seconds, and
2441 * are converted into jiffies.
2442 *
2443 * Returns 0 on success.
2444 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002445int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446 void __user *buffer, size_t *lenp, loff_t *ppos)
2447{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002448 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 do_proc_dointvec_ms_jiffies_conv, NULL);
2450}
2451
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002452static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002453 void __user *buffer, size_t *lenp, loff_t *ppos)
2454{
2455 struct pid *new_pid;
2456 pid_t tmp;
2457 int r;
2458
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002459 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002460
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002461 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002462 lenp, ppos, NULL, NULL);
2463 if (r || !write)
2464 return r;
2465
2466 new_pid = find_get_pid(tmp);
2467 if (!new_pid)
2468 return -ESRCH;
2469
2470 put_pid(xchg(&cad_pid, new_pid));
2471 return 0;
2472}
2473
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002474/**
2475 * proc_do_large_bitmap - read/write from/to a large bitmap
2476 * @table: the sysctl table
2477 * @write: %TRUE if this is a write to the sysctl file
2478 * @buffer: the user buffer
2479 * @lenp: the size of the user buffer
2480 * @ppos: file position
2481 *
2482 * The bitmap is stored at table->data and the bitmap length (in bits)
2483 * in table->maxlen.
2484 *
2485 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2486 * large bitmaps may be represented in a compact manner. Writing into
2487 * the file will clear the bitmap then update it with the given input.
2488 *
2489 * Returns 0 on success.
2490 */
2491int proc_do_large_bitmap(struct ctl_table *table, int write,
2492 void __user *buffer, size_t *lenp, loff_t *ppos)
2493{
2494 int err = 0;
2495 bool first = 1;
2496 size_t left = *lenp;
2497 unsigned long bitmap_len = table->maxlen;
2498 unsigned long *bitmap = (unsigned long *) table->data;
2499 unsigned long *tmp_bitmap = NULL;
2500 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2501
2502 if (!bitmap_len || !left || (*ppos && !write)) {
2503 *lenp = 0;
2504 return 0;
2505 }
2506
2507 if (write) {
2508 unsigned long page = 0;
2509 char *kbuf;
2510
2511 if (left > PAGE_SIZE - 1)
2512 left = PAGE_SIZE - 1;
2513
2514 page = __get_free_page(GFP_TEMPORARY);
2515 kbuf = (char *) page;
2516 if (!kbuf)
2517 return -ENOMEM;
2518 if (copy_from_user(kbuf, buffer, left)) {
2519 free_page(page);
2520 return -EFAULT;
2521 }
2522 kbuf[left] = 0;
2523
2524 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2525 GFP_KERNEL);
2526 if (!tmp_bitmap) {
2527 free_page(page);
2528 return -ENOMEM;
2529 }
2530 proc_skip_char(&kbuf, &left, '\n');
2531 while (!err && left) {
2532 unsigned long val_a, val_b;
2533 bool neg;
2534
2535 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2536 sizeof(tr_a), &c);
2537 if (err)
2538 break;
2539 if (val_a >= bitmap_len || neg) {
2540 err = -EINVAL;
2541 break;
2542 }
2543
2544 val_b = val_a;
2545 if (left) {
2546 kbuf++;
2547 left--;
2548 }
2549
2550 if (c == '-') {
2551 err = proc_get_long(&kbuf, &left, &val_b,
2552 &neg, tr_b, sizeof(tr_b),
2553 &c);
2554 if (err)
2555 break;
2556 if (val_b >= bitmap_len || neg ||
2557 val_a > val_b) {
2558 err = -EINVAL;
2559 break;
2560 }
2561 if (left) {
2562 kbuf++;
2563 left--;
2564 }
2565 }
2566
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002567 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002568 first = 0;
2569 proc_skip_char(&kbuf, &left, '\n');
2570 }
2571 free_page(page);
2572 } else {
2573 unsigned long bit_a, bit_b = 0;
2574
2575 while (left) {
2576 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2577 if (bit_a >= bitmap_len)
2578 break;
2579 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2580 bit_a + 1) - 1;
2581
2582 if (!first) {
2583 err = proc_put_char(&buffer, &left, ',');
2584 if (err)
2585 break;
2586 }
2587 err = proc_put_long(&buffer, &left, bit_a, false);
2588 if (err)
2589 break;
2590 if (bit_a != bit_b) {
2591 err = proc_put_char(&buffer, &left, '-');
2592 if (err)
2593 break;
2594 err = proc_put_long(&buffer, &left, bit_b, false);
2595 if (err)
2596 break;
2597 }
2598
2599 first = 0; bit_b++;
2600 }
2601 if (!err)
2602 err = proc_put_char(&buffer, &left, '\n');
2603 }
2604
2605 if (!err) {
2606 if (write) {
2607 if (*ppos)
2608 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2609 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002610 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002611 }
2612 kfree(tmp_bitmap);
2613 *lenp -= left;
2614 *ppos += *lenp;
2615 return 0;
2616 } else {
2617 kfree(tmp_bitmap);
2618 return err;
2619 }
2620}
2621
Jovi Zhang55610502011-01-12 17:00:45 -08002622#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002624int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 void __user *buffer, size_t *lenp, loff_t *ppos)
2626{
2627 return -ENOSYS;
2628}
2629
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002630int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 void __user *buffer, size_t *lenp, loff_t *ppos)
2632{
2633 return -ENOSYS;
2634}
2635
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002636int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002637 void __user *buffer, size_t *lenp, loff_t *ppos)
2638{
2639 return -ENOSYS;
2640}
2641
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002642int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 void __user *buffer, size_t *lenp, loff_t *ppos)
2644{
2645 return -ENOSYS;
2646}
2647
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002648int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 void __user *buffer, size_t *lenp, loff_t *ppos)
2650{
2651 return -ENOSYS;
2652}
2653
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002654int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 void __user *buffer, size_t *lenp, loff_t *ppos)
2656{
2657 return -ENOSYS;
2658}
2659
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002660int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 void __user *buffer, size_t *lenp, loff_t *ppos)
2662{
2663 return -ENOSYS;
2664}
2665
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002666int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 void __user *buffer,
2668 size_t *lenp, loff_t *ppos)
2669{
2670 return -ENOSYS;
2671}
2672
2673
Jovi Zhang55610502011-01-12 17:00:45 -08002674#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676/*
2677 * No sense putting this after each symbol definition, twice,
2678 * exception granted :-)
2679 */
2680EXPORT_SYMBOL(proc_dointvec);
2681EXPORT_SYMBOL(proc_dointvec_jiffies);
2682EXPORT_SYMBOL(proc_dointvec_minmax);
2683EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2684EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2685EXPORT_SYMBOL(proc_dostring);
2686EXPORT_SYMBOL(proc_doulongvec_minmax);
2687EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);