blob: 3e214beabbe9aed686ac2e226837b6e7d94f0279 [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
Liu Hua80df2842014-04-07 15:38:57 -0700144/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
145#ifdef CONFIG_DETECT_HUNG_TASK
146static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
147#endif
148
Dave Youngd14f1722010-02-25 20:28:57 -0500149#ifdef CONFIG_INOTIFY_USER
150#include <linux/inotify.h>
151#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700152#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153#endif
154
David S. Miller08714202008-11-16 23:49:24 -0800155#ifdef CONFIG_SPARC64
156extern int sysctl_tsb_ratio;
157#endif
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#ifdef __hppa__
160extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530161#endif
162
163#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164extern int unaligned_enabled;
165#endif
166
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800168extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#endif
170
Vineet Guptab6fca722013-01-09 20:06:28 +0530171#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172extern int no_unaligned_warning;
173#endif
174
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700176static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700177 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700178static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800179 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700180#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700181
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700182#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700183static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700184 void __user *buffer, size_t *lenp, loff_t *ppos);
185#endif
186
Kees Cook54b50192012-07-30 14:39:18 -0700187static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
188 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700189#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700190static int proc_dostring_coredump(struct ctl_table *table, int write,
191 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700192#endif
Kees Cook54b50192012-07-30 14:39:18 -0700193
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700194#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800195/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100196static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700197
198static int sysrq_sysctl_handler(ctl_table *table, int write,
199 void __user *buffer, size_t *lenp,
200 loff_t *ppos)
201{
202 int error;
203
204 error = proc_dointvec(table, write, buffer, lenp, ppos);
205 if (error)
206 return error;
207
208 if (write)
209 sysrq_toggle_support(__sysrq_enabled);
210
211 return 0;
212}
213
214#endif
215
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700216static struct ctl_table kern_table[];
217static struct ctl_table vm_table[];
218static struct ctl_table fs_table[];
219static struct ctl_table debug_table[];
220static struct ctl_table dev_table[];
221extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800222#ifdef CONFIG_EPOLL
223extern struct ctl_table epoll_table[];
224#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
227int sysctl_legacy_va_layout;
228#endif
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230/* The default sysctl tables: */
231
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800232static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "kernel",
235 .mode = 0555,
236 .child = kern_table,
237 },
238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .procname = "vm",
240 .mode = 0555,
241 .child = vm_table,
242 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .procname = "fs",
245 .mode = 0555,
246 .child = fs_table,
247 },
248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .procname = "debug",
250 .mode = 0555,
251 .child = debug_table,
252 },
253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 .procname = "dev",
255 .mode = 0555,
256 .child = dev_table,
257 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700258 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259};
260
Ingo Molnar77e54a12007-07-09 18:52:00 +0200261#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100262static int min_sched_granularity_ns = 100000; /* 100 usecs */
263static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
264static int min_wakeup_granularity_ns; /* 0 usecs */
265static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200266#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100267static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
268static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200269#endif /* CONFIG_SMP */
270#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200271
Mel Gorman5e771902010-05-24 14:32:31 -0700272#ifdef CONFIG_COMPACTION
273static int min_extfrag_threshold;
274static int max_extfrag_threshold = 1000;
275#endif
276
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700277static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200278 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200279 .procname = "sched_child_runs_first",
280 .data = &sysctl_sched_child_runs_first,
281 .maxlen = sizeof(unsigned int),
282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800283 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200284 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285#ifdef CONFIG_SCHED_DEBUG
286 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100287 .procname = "sched_min_granularity_ns",
288 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289 .maxlen = sizeof(unsigned int),
290 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800291 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100292 .extra1 = &min_sched_granularity_ns,
293 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200294 },
295 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200296 .procname = "sched_latency_ns",
297 .data = &sysctl_sched_latency,
298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800300 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200301 .extra1 = &min_sched_granularity_ns,
302 .extra2 = &max_sched_granularity_ns,
303 },
304 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200305 .procname = "sched_wakeup_granularity_ns",
306 .data = &sysctl_sched_wakeup_granularity,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800309 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200310 .extra1 = &min_wakeup_granularity_ns,
311 .extra2 = &max_wakeup_granularity_ns,
312 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200313#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200314 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100315 .procname = "sched_tunable_scaling",
316 .data = &sysctl_sched_tunable_scaling,
317 .maxlen = sizeof(enum sched_tunable_scaling),
318 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800319 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100320 .extra1 = &min_sched_tunable_scaling,
321 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200322 },
323 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900324 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200325 .data = &sysctl_sched_migration_cost,
326 .maxlen = sizeof(unsigned int),
327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800328 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200329 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100330 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100331 .procname = "sched_nr_migrate",
332 .data = &sysctl_sched_nr_migrate,
333 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800335 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100336 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530337 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900338 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200339 .data = &sysctl_sched_time_avg,
340 .maxlen = sizeof(unsigned int),
341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800342 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200343 },
344 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900345 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800346 .data = &sysctl_sched_shares_window,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
349 .proc_handler = proc_dointvec,
350 },
351 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530352 .procname = "timer_migration",
353 .data = &sysctl_timer_migration,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800356 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530357 .extra1 = &zero,
358 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530359 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200360#endif /* CONFIG_SMP */
361#ifdef CONFIG_NUMA_BALANCING
362 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200363 .procname = "numa_balancing_scan_delay_ms",
364 .data = &sysctl_numa_balancing_scan_delay,
365 .maxlen = sizeof(unsigned int),
366 .mode = 0644,
367 .proc_handler = proc_dointvec,
368 },
369 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200370 .procname = "numa_balancing_scan_period_min_ms",
371 .data = &sysctl_numa_balancing_scan_period_min,
372 .maxlen = sizeof(unsigned int),
373 .mode = 0644,
374 .proc_handler = proc_dointvec,
375 },
376 {
377 .procname = "numa_balancing_scan_period_max_ms",
378 .data = &sysctl_numa_balancing_scan_period_max,
379 .maxlen = sizeof(unsigned int),
380 .mode = 0644,
381 .proc_handler = proc_dointvec,
382 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200383 {
384 .procname = "numa_balancing_scan_size_mb",
385 .data = &sysctl_numa_balancing_scan_size,
386 .maxlen = sizeof(unsigned int),
387 .mode = 0644,
388 .proc_handler = proc_dointvec,
389 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100390 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800391 .procname = "numa_balancing",
392 .data = NULL, /* filled in by handler */
393 .maxlen = sizeof(unsigned int),
394 .mode = 0644,
395 .proc_handler = sysctl_numa_balancing,
396 .extra1 = &zero,
397 .extra2 = &one,
398 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200399#endif /* CONFIG_NUMA_BALANCING */
400#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200401 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100402 .procname = "sched_rt_period_us",
403 .data = &sysctl_sched_rt_period,
404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800406 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100407 },
408 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100409 .procname = "sched_rt_runtime_us",
410 .data = &sysctl_sched_rt_runtime,
411 .maxlen = sizeof(int),
412 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800413 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100414 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600415 {
416 .procname = "sched_rr_timeslice_ms",
417 .data = &sched_rr_timeslice,
418 .maxlen = sizeof(int),
419 .mode = 0644,
420 .proc_handler = sched_rr_handler,
421 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100422#ifdef CONFIG_SCHED_AUTOGROUP
423 {
424 .procname = "sched_autogroup_enabled",
425 .data = &sysctl_sched_autogroup_enabled,
426 .maxlen = sizeof(unsigned int),
427 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800428 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100429 .extra1 = &zero,
430 .extra2 = &one,
431 },
432#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700433#ifdef CONFIG_CFS_BANDWIDTH
434 {
435 .procname = "sched_cfs_bandwidth_slice_us",
436 .data = &sysctl_sched_cfs_bandwidth_slice,
437 .maxlen = sizeof(unsigned int),
438 .mode = 0644,
439 .proc_handler = proc_dointvec_minmax,
440 .extra1 = &one,
441 },
442#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700443#ifdef CONFIG_PROVE_LOCKING
444 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700445 .procname = "prove_locking",
446 .data = &prove_locking,
447 .maxlen = sizeof(int),
448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800449 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700450 },
451#endif
452#ifdef CONFIG_LOCK_STAT
453 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454 .procname = "lock_stat",
455 .data = &lock_stat,
456 .maxlen = sizeof(int),
457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800458 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700459 },
460#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "panic",
463 .data = &panic_timeout,
464 .maxlen = sizeof(int),
465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
Alex Kelly046d6622012-10-04 17:15:23 -0700468#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 .procname = "core_uses_pid",
471 .data = &core_uses_pid,
472 .maxlen = sizeof(int),
473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800474 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 },
476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 .procname = "core_pattern",
478 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700479 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700481 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 },
Neil Hormana2939802009-09-23 15:56:56 -0700483 {
Neil Hormana2939802009-09-23 15:56:56 -0700484 .procname = "core_pipe_limit",
485 .data = &core_pipe_limit,
486 .maxlen = sizeof(unsigned int),
487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800488 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700489 },
Alex Kelly046d6622012-10-04 17:15:23 -0700490#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800491#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700494 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800496 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800498#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100499#ifdef CONFIG_LATENCYTOP
500 {
501 .procname = "latencytop",
502 .data = &latencytop_enabled,
503 .maxlen = sizeof(int),
504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100506 },
507#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508#ifdef CONFIG_BLK_DEV_INITRD
509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "real-root-dev",
511 .data = &real_root_dev,
512 .maxlen = sizeof(int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 },
516#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700517 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700518 .procname = "print-fatal-signals",
519 .data = &print_fatal_signals,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700523 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700524#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 .procname = "reboot-cmd",
527 .data = reboot_command,
528 .maxlen = 256,
529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800530 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 },
532 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 .procname = "stop-a",
534 .data = &stop_a_enabled,
535 .maxlen = sizeof (int),
536 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800537 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 },
539 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 .procname = "scons-poweroff",
541 .data = &scons_pwroff,
542 .maxlen = sizeof (int),
543 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800544 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 },
546#endif
David S. Miller08714202008-11-16 23:49:24 -0800547#ifdef CONFIG_SPARC64
548 {
David S. Miller08714202008-11-16 23:49:24 -0800549 .procname = "tsb-ratio",
550 .data = &sysctl_tsb_ratio,
551 .maxlen = sizeof (int),
552 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800553 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800554 },
555#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556#ifdef __hppa__
557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .procname = "soft-power",
559 .data = &pwrsw_enabled,
560 .maxlen = sizeof (int),
561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530564#endif
565#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .procname = "unaligned-trap",
568 .data = &unaligned_enabled,
569 .maxlen = sizeof (int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
573#endif
574 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .procname = "ctrl-alt-del",
576 .data = &C_A_D,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400581#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200582 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200583 .procname = "ftrace_enabled",
584 .data = &ftrace_enabled,
585 .maxlen = sizeof(int),
586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800587 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200588 },
589#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500590#ifdef CONFIG_STACK_TRACER
591 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500592 .procname = "stack_tracer_enabled",
593 .data = &stack_tracer_enabled,
594 .maxlen = sizeof(int),
595 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800596 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500597 },
598#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400599#ifdef CONFIG_TRACING
600 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100601 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400602 .data = &ftrace_dump_on_oops,
603 .maxlen = sizeof(int),
604 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800605 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400606 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400607 {
608 .procname = "traceoff_on_warning",
609 .data = &__disable_trace_on_warning,
610 .maxlen = sizeof(__disable_trace_on_warning),
611 .mode = 0644,
612 .proc_handler = proc_dointvec,
613 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400614#endif
Kees Cook79847542014-01-23 15:55:59 -0800615#ifdef CONFIG_KEXEC
616 {
617 .procname = "kexec_load_disabled",
618 .data = &kexec_load_disabled,
619 .maxlen = sizeof(int),
620 .mode = 0644,
621 /* only handle a transition from default "0" to "1" */
622 .proc_handler = proc_dointvec_minmax,
623 .extra1 = &one,
624 .extra2 = &one,
625 },
626#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200627#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 .procname = "modprobe",
630 .data = &modprobe_path,
631 .maxlen = KMOD_PATH_LEN,
632 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800633 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 },
Kees Cook3d433212009-04-02 15:49:29 -0700635 {
Kees Cook3d433212009-04-02 15:49:29 -0700636 .procname = "modules_disabled",
637 .data = &modules_disabled,
638 .maxlen = sizeof(int),
639 .mode = 0644,
640 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700642 .extra1 = &one,
643 .extra2 = &one,
644 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700646#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100649 .data = &uevent_helper,
650 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800652 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 },
Michael Marineau86d56132014-04-10 14:09:31 -0700654#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655#ifdef CONFIG_CHR_DEV_SG
656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .procname = "sg-big-buff",
658 .data = &sg_big_buff,
659 .maxlen = sizeof (int),
660 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 },
663#endif
664#ifdef CONFIG_BSD_PROCESS_ACCT
665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 .procname = "acct",
667 .data = &acct_parm,
668 .maxlen = 3*sizeof(int),
669 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800670 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 },
672#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673#ifdef CONFIG_MAGIC_SYSRQ
674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800676 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .maxlen = sizeof (int),
678 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700679 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 },
681#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700682#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700685 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .maxlen = sizeof (int),
687 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800688 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700690#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .procname = "threads-max",
693 .data = &max_threads,
694 .maxlen = sizeof(int),
695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800696 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 },
698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .procname = "random",
700 .mode = 0555,
701 .child = random_table,
702 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 {
Eric Paris17f60a72011-04-01 17:07:50 -0400704 .procname = "usermodehelper",
705 .mode = 0555,
706 .child = usermodehelper_table,
707 },
708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "overflowuid",
710 .data = &overflowuid,
711 .maxlen = sizeof(int),
712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .extra1 = &minolduid,
715 .extra2 = &maxolduid,
716 },
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "overflowgid",
719 .data = &overflowgid,
720 .maxlen = sizeof(int),
721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 .extra1 = &minolduid,
724 .extra2 = &maxolduid,
725 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800726#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727#ifdef CONFIG_MATHEMU
728 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 .procname = "ieee_emulation_warnings",
730 .data = &sysctl_ieee_emulation_warnings,
731 .maxlen = sizeof(int),
732 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800733 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 },
735#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200738 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .maxlen = sizeof(int),
740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800741 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 },
743#endif
744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .procname = "pid_max",
746 .data = &pid_max,
747 .maxlen = sizeof (int),
748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 .extra1 = &pid_max_min,
751 .extra2 = &pid_max_max,
752 },
753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .procname = "panic_on_oops",
755 .data = &panic_on_oops,
756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800760#if defined CONFIG_PRINTK
761 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800762 .procname = "printk",
763 .data = &console_loglevel,
764 .maxlen = 4*sizeof(int),
765 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800766 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800767 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700770 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 .maxlen = sizeof(int),
772 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800773 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 },
775 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700777 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 .maxlen = sizeof(int),
779 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800780 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 },
Dave Youngaf913222009-09-22 16:43:33 -0700782 {
Dave Youngaf913222009-09-22 16:43:33 -0700783 .procname = "printk_delay",
784 .data = &printk_delay_msec,
785 .maxlen = sizeof(int),
786 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800787 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700788 .extra1 = &zero,
789 .extra2 = &ten_thousand,
790 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800792 .procname = "dmesg_restrict",
793 .data = &dmesg_restrict,
794 .maxlen = sizeof(int),
795 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700796 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800797 .extra1 = &zero,
798 .extra2 = &one,
799 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800800 {
801 .procname = "kptr_restrict",
802 .data = &kptr_restrict,
803 .maxlen = sizeof(int),
804 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700805 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800806 .extra1 = &zero,
807 .extra2 = &two,
808 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800809#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800810 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 .procname = "ngroups_max",
812 .data = &ngroups_max,
813 .maxlen = sizeof (int),
814 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800815 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 },
Dan Ballard73efc032011-10-31 17:11:20 -0700817 {
818 .procname = "cap_last_cap",
819 .data = (void *)&cap_last_cap,
820 .maxlen = sizeof(int),
821 .mode = 0444,
822 .proc_handler = proc_dointvec,
823 },
Don Zickus58687ac2010-05-07 17:11:44 -0400824#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500825 {
Don Zickus58687ac2010-05-07 17:11:44 -0400826 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200827 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500828 .maxlen = sizeof (int),
829 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700830 .proc_handler = proc_dowatchdog,
831 .extra1 = &zero,
832 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400833 },
834 {
835 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700836 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400837 .maxlen = sizeof(int),
838 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700839 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800840 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400841 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500842 },
Don Zickus2508ce12010-05-07 17:11:46 -0400843 {
844 .procname = "softlockup_panic",
845 .data = &softlockup_panic,
846 .maxlen = sizeof(int),
847 .mode = 0644,
848 .proc_handler = proc_dointvec_minmax,
849 .extra1 = &zero,
850 .extra2 = &one,
851 },
Don Zickus5dc30552010-11-29 17:07:17 -0500852 {
853 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200854 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500855 .maxlen = sizeof (int),
856 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700857 .proc_handler = proc_dowatchdog,
858 .extra1 = &zero,
859 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500860 },
861#endif
862#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
863 {
864 .procname = "unknown_nmi_panic",
865 .data = &unknown_nmi_panic,
866 .maxlen = sizeof (int),
867 .mode = 0644,
868 .proc_handler = proc_dointvec,
869 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500870#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871#if defined(CONFIG_X86)
872 {
Don Zickus8da5add2006-09-26 10:52:27 +0200873 .procname = "panic_on_unrecovered_nmi",
874 .data = &panic_on_unrecovered_nmi,
875 .maxlen = sizeof(int),
876 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800877 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200878 },
879 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700880 .procname = "panic_on_io_nmi",
881 .data = &panic_on_io_nmi,
882 .maxlen = sizeof(int),
883 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800884 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700885 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900886#ifdef CONFIG_DEBUG_STACKOVERFLOW
887 {
888 .procname = "panic_on_stackoverflow",
889 .data = &sysctl_panic_on_stackoverflow,
890 .maxlen = sizeof(int),
891 .mode = 0644,
892 .proc_handler = proc_dointvec,
893 },
894#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700895 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 .procname = "bootloader_type",
897 .data = &bootloader_type,
898 .maxlen = sizeof (int),
899 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800900 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100902 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700903 .procname = "bootloader_version",
904 .data = &bootloader_version,
905 .maxlen = sizeof (int),
906 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800907 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700908 },
909 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100910 .procname = "kstack_depth_to_print",
911 .data = &kstack_depth_to_print,
912 .maxlen = sizeof(int),
913 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800914 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100915 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100916 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100917 .procname = "io_delay_type",
918 .data = &io_delay_type,
919 .maxlen = sizeof(int),
920 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800921 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100922 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800924#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 .procname = "randomize_va_space",
927 .data = &randomize_va_space,
928 .maxlen = sizeof(int),
929 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800930 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800932#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800933#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700934 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700935 .procname = "spin_retry",
936 .data = &spin_retry,
937 .maxlen = sizeof (int),
938 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800939 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700940 },
941#endif
Len Brown673d5b42007-07-28 03:33:16 -0400942#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800943 {
Pavel Machekc255d842006-02-20 18:27:58 -0800944 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700945 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800946 .maxlen = sizeof (unsigned long),
947 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800948 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800949 },
950#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530951#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800952 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800953 .procname = "ignore-unaligned-usertrap",
954 .data = &no_unaligned_warning,
955 .maxlen = sizeof (int),
956 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800957 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800958 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530959#endif
960#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800961 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800962 .procname = "unaligned-dump-stack",
963 .data = &unaligned_dump_stack,
964 .maxlen = sizeof (int),
965 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800966 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800967 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800968#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800969#ifdef CONFIG_DETECT_HUNG_TASK
970 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800971 .procname = "hung_task_panic",
972 .data = &sysctl_hung_task_panic,
973 .maxlen = sizeof(int),
974 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800975 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800976 .extra1 = &zero,
977 .extra2 = &one,
978 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100979 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100980 .procname = "hung_task_check_count",
981 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800982 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100983 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800984 .proc_handler = proc_dointvec_minmax,
985 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100986 },
987 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100988 .procname = "hung_task_timeout_secs",
989 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100990 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100991 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800992 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -0700993 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100994 },
995 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100996 .procname = "hung_task_warnings",
997 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +0000998 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100999 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001000 .proc_handler = proc_dointvec_minmax,
1001 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001002 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001003#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001004#ifdef CONFIG_COMPAT
1005 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001006 .procname = "compat-log",
1007 .data = &compat_log,
1008 .maxlen = sizeof (int),
1009 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001010 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001011 },
1012#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001013#ifdef CONFIG_RT_MUTEXES
1014 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001015 .procname = "max_lock_depth",
1016 .data = &max_lock_depth,
1017 .maxlen = sizeof(int),
1018 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001019 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001020 },
1021#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001022 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001023 .procname = "poweroff_cmd",
1024 .data = &poweroff_cmd,
1025 .maxlen = POWEROFF_CMD_PATH_LEN,
1026 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001027 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001028 },
David Howells0b77f5b2008-04-29 01:01:32 -07001029#ifdef CONFIG_KEYS
1030 {
David Howells0b77f5b2008-04-29 01:01:32 -07001031 .procname = "keys",
1032 .mode = 0555,
1033 .child = key_sysctls,
1034 },
1035#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001036#ifdef CONFIG_RCU_TORTURE_TEST
1037 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001038 .procname = "rcutorture_runnable",
1039 .data = &rcutorture_runnable,
1040 .maxlen = sizeof(int),
1041 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001043 },
1044#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001045#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001046 /*
1047 * User-space scripts rely on the existence of this file
1048 * as a feature check for perf_events being enabled.
1049 *
1050 * So it's an ABI, do not remove!
1051 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001052 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001053 .procname = "perf_event_paranoid",
1054 .data = &sysctl_perf_event_paranoid,
1055 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001056 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001057 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001058 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001059 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001060 .procname = "perf_event_mlock_kb",
1061 .data = &sysctl_perf_event_mlock,
1062 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001063 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001064 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001065 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001066 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001067 .procname = "perf_event_max_sample_rate",
1068 .data = &sysctl_perf_event_sample_rate,
1069 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001070 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001071 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001072 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001073 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001074 {
1075 .procname = "perf_cpu_time_max_percent",
1076 .data = &sysctl_perf_cpu_time_max_percent,
1077 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1078 .mode = 0644,
1079 .proc_handler = perf_cpu_time_max_percent_handler,
1080 .extra1 = &zero,
1081 .extra2 = &one_hundred,
1082 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001083#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001084#ifdef CONFIG_KMEMCHECK
1085 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001086 .procname = "kmemcheck",
1087 .data = &kmemcheck_enabled,
1088 .maxlen = sizeof(int),
1089 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001090 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001091 },
1092#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001093 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094};
1095
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001096static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 .procname = "overcommit_memory",
1099 .data = &sysctl_overcommit_memory,
1100 .maxlen = sizeof(sysctl_overcommit_memory),
1101 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001102 .proc_handler = proc_dointvec_minmax,
1103 .extra1 = &zero,
1104 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 },
1106 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001107 .procname = "panic_on_oom",
1108 .data = &sysctl_panic_on_oom,
1109 .maxlen = sizeof(sysctl_panic_on_oom),
1110 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001111 .proc_handler = proc_dointvec_minmax,
1112 .extra1 = &zero,
1113 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001114 },
1115 {
David Rientjesfe071d72007-10-16 23:25:56 -07001116 .procname = "oom_kill_allocating_task",
1117 .data = &sysctl_oom_kill_allocating_task,
1118 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001120 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001121 },
1122 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001123 .procname = "oom_dump_tasks",
1124 .data = &sysctl_oom_dump_tasks,
1125 .maxlen = sizeof(sysctl_oom_dump_tasks),
1126 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001127 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001128 },
1129 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 .procname = "overcommit_ratio",
1131 .data = &sysctl_overcommit_ratio,
1132 .maxlen = sizeof(sysctl_overcommit_ratio),
1133 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001134 .proc_handler = overcommit_ratio_handler,
1135 },
1136 {
1137 .procname = "overcommit_kbytes",
1138 .data = &sysctl_overcommit_kbytes,
1139 .maxlen = sizeof(sysctl_overcommit_kbytes),
1140 .mode = 0644,
1141 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 },
1143 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .procname = "page-cluster",
1145 .data = &page_cluster,
1146 .maxlen = sizeof(int),
1147 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001148 .proc_handler = proc_dointvec_minmax,
1149 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 },
1151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "dirty_background_ratio",
1153 .data = &dirty_background_ratio,
1154 .maxlen = sizeof(dirty_background_ratio),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .extra1 = &zero,
1158 .extra2 = &one_hundred,
1159 },
1160 {
David Rientjes2da02992009-01-06 14:39:31 -08001161 .procname = "dirty_background_bytes",
1162 .data = &dirty_background_bytes,
1163 .maxlen = sizeof(dirty_background_bytes),
1164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001165 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001166 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001167 },
1168 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .procname = "dirty_ratio",
1170 .data = &vm_dirty_ratio,
1171 .maxlen = sizeof(vm_dirty_ratio),
1172 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001173 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 .extra1 = &zero,
1175 .extra2 = &one_hundred,
1176 },
1177 {
David Rientjes2da02992009-01-06 14:39:31 -08001178 .procname = "dirty_bytes",
1179 .data = &vm_dirty_bytes,
1180 .maxlen = sizeof(vm_dirty_bytes),
1181 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001182 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001183 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001184 },
1185 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001187 .data = &dirty_writeback_interval,
1188 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001190 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 },
1192 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001194 .data = &dirty_expire_interval,
1195 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001197 .proc_handler = proc_dointvec_minmax,
1198 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 },
1200 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001201 .procname = "nr_pdflush_threads",
1202 .mode = 0444 /* read-only */,
1203 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 },
1205 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 .procname = "swappiness",
1207 .data = &vm_swappiness,
1208 .maxlen = sizeof(vm_swappiness),
1209 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001210 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 .extra1 = &zero,
1212 .extra2 = &one_hundred,
1213 },
1214#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001215 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001217 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 .maxlen = sizeof(unsigned long),
1219 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001220 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 .extra1 = (void *)&hugetlb_zero,
1222 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001223 },
1224#ifdef CONFIG_NUMA
1225 {
1226 .procname = "nr_hugepages_mempolicy",
1227 .data = NULL,
1228 .maxlen = sizeof(unsigned long),
1229 .mode = 0644,
1230 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1231 .extra1 = (void *)&hugetlb_zero,
1232 .extra2 = (void *)&hugetlb_infinity,
1233 },
1234#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236 .procname = "hugetlb_shm_group",
1237 .data = &sysctl_hugetlb_shm_group,
1238 .maxlen = sizeof(gid_t),
1239 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001240 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 },
Mel Gorman396faf02007-07-17 04:03:13 -07001242 {
Mel Gorman396faf02007-07-17 04:03:13 -07001243 .procname = "hugepages_treat_as_movable",
1244 .data = &hugepages_treat_as_movable,
1245 .maxlen = sizeof(int),
1246 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001247 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001248 },
Adam Litke54f9f802007-10-16 01:26:20 -07001249 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001250 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001251 .data = NULL,
1252 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001255 .extra1 = (void *)&hugetlb_zero,
1256 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001257 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258#endif
1259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 .procname = "lowmem_reserve_ratio",
1261 .data = &sysctl_lowmem_reserve_ratio,
1262 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1263 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001264 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 },
1266 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001267 .procname = "drop_caches",
1268 .data = &sysctl_drop_caches,
1269 .maxlen = sizeof(int),
1270 .mode = 0644,
1271 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001272 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001273 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001274 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001275#ifdef CONFIG_COMPACTION
1276 {
1277 .procname = "compact_memory",
1278 .data = &sysctl_compact_memory,
1279 .maxlen = sizeof(int),
1280 .mode = 0200,
1281 .proc_handler = sysctl_compaction_handler,
1282 },
Mel Gorman5e771902010-05-24 14:32:31 -07001283 {
1284 .procname = "extfrag_threshold",
1285 .data = &sysctl_extfrag_threshold,
1286 .maxlen = sizeof(int),
1287 .mode = 0644,
1288 .proc_handler = sysctl_extfrag_handler,
1289 .extra1 = &min_extfrag_threshold,
1290 .extra2 = &max_extfrag_threshold,
1291 },
1292
Mel Gorman76ab0f52010-05-24 14:32:28 -07001293#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .procname = "min_free_kbytes",
1296 .data = &min_free_kbytes,
1297 .maxlen = sizeof(min_free_kbytes),
1298 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001299 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .extra1 = &zero,
1301 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001302 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001303 .procname = "percpu_pagelist_fraction",
1304 .data = &percpu_pagelist_fraction,
1305 .maxlen = sizeof(percpu_pagelist_fraction),
1306 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001308 .extra1 = &min_percpu_pagelist_fract,
1309 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310#ifdef CONFIG_MMU
1311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .procname = "max_map_count",
1313 .data = &sysctl_max_map_count,
1314 .maxlen = sizeof(sysctl_max_map_count),
1315 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001316 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001317 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001319#else
1320 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001321 .procname = "nr_trim_pages",
1322 .data = &sysctl_nr_trim_pages,
1323 .maxlen = sizeof(sysctl_nr_trim_pages),
1324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001325 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001326 .extra1 = &zero,
1327 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328#endif
1329 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330 .procname = "laptop_mode",
1331 .data = &laptop_mode,
1332 .maxlen = sizeof(laptop_mode),
1333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 },
1336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "block_dump",
1338 .data = &block_dump,
1339 .maxlen = sizeof(block_dump),
1340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 .extra1 = &zero,
1343 },
1344 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 .procname = "vfs_cache_pressure",
1346 .data = &sysctl_vfs_cache_pressure,
1347 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1348 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001349 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .extra1 = &zero,
1351 },
1352#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1353 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001354 .procname = "legacy_va_layout",
1355 .data = &sysctl_legacy_va_layout,
1356 .maxlen = sizeof(sysctl_legacy_va_layout),
1357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001358 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 .extra1 = &zero,
1360 },
1361#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001362#ifdef CONFIG_NUMA
1363 {
Christoph Lameter17436602006-01-18 17:42:32 -08001364 .procname = "zone_reclaim_mode",
1365 .data = &zone_reclaim_mode,
1366 .maxlen = sizeof(zone_reclaim_mode),
1367 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001368 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001369 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001370 },
Christoph Lameter96146342006-07-03 00:24:13 -07001371 {
Christoph Lameter96146342006-07-03 00:24:13 -07001372 .procname = "min_unmapped_ratio",
1373 .data = &sysctl_min_unmapped_ratio,
1374 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001376 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001377 .extra1 = &zero,
1378 .extra2 = &one_hundred,
1379 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001380 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001381 .procname = "min_slab_ratio",
1382 .data = &sysctl_min_slab_ratio,
1383 .maxlen = sizeof(sysctl_min_slab_ratio),
1384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001386 .extra1 = &zero,
1387 .extra2 = &one_hundred,
1388 },
Christoph Lameter17436602006-01-18 17:42:32 -08001389#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001390#ifdef CONFIG_SMP
1391 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001392 .procname = "stat_interval",
1393 .data = &sysctl_stat_interval,
1394 .maxlen = sizeof(sysctl_stat_interval),
1395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001396 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001397 },
1398#endif
David Howells6e141542009-12-15 19:27:45 +00001399#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001400 {
Eric Parised032182007-06-28 15:55:21 -04001401 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001402 .data = &dac_mmap_min_addr,
1403 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001406 },
David Howells6e141542009-12-15 19:27:45 +00001407#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001408#ifdef CONFIG_NUMA
1409 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001410 .procname = "numa_zonelist_order",
1411 .data = &numa_zonelist_order,
1412 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1413 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001414 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001415 },
1416#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001417#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001418 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001419 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001420 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001421#ifdef CONFIG_X86_32
1422 .data = &vdso32_enabled,
1423 .maxlen = sizeof(vdso32_enabled),
1424#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001425 .data = &vdso_enabled,
1426 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001427#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001429 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001430 .extra1 = &zero,
1431 },
1432#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001433#ifdef CONFIG_HIGHMEM
1434 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001435 .procname = "highmem_is_dirtyable",
1436 .data = &vm_highmem_is_dirtyable,
1437 .maxlen = sizeof(vm_highmem_is_dirtyable),
1438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001439 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001440 .extra1 = &zero,
1441 .extra2 = &one,
1442 },
1443#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001444 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001445 .procname = "scan_unevictable_pages",
1446 .data = &scan_unevictable_pages,
1447 .maxlen = sizeof(scan_unevictable_pages),
1448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001449 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001450 },
Andi Kleen6a460792009-09-16 11:50:15 +02001451#ifdef CONFIG_MEMORY_FAILURE
1452 {
Andi Kleen6a460792009-09-16 11:50:15 +02001453 .procname = "memory_failure_early_kill",
1454 .data = &sysctl_memory_failure_early_kill,
1455 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1456 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001457 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001458 .extra1 = &zero,
1459 .extra2 = &one,
1460 },
1461 {
Andi Kleen6a460792009-09-16 11:50:15 +02001462 .procname = "memory_failure_recovery",
1463 .data = &sysctl_memory_failure_recovery,
1464 .maxlen = sizeof(sysctl_memory_failure_recovery),
1465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001466 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001467 .extra1 = &zero,
1468 .extra2 = &one,
1469 },
1470#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001471 {
1472 .procname = "user_reserve_kbytes",
1473 .data = &sysctl_user_reserve_kbytes,
1474 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1475 .mode = 0644,
1476 .proc_handler = proc_doulongvec_minmax,
1477 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001478 {
1479 .procname = "admin_reserve_kbytes",
1480 .data = &sysctl_admin_reserve_kbytes,
1481 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1482 .mode = 0644,
1483 .proc_handler = proc_doulongvec_minmax,
1484 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001485 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486};
1487
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001488#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001489static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001490 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001491};
1492#endif
1493
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001494static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 .procname = "inode-nr",
1497 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001498 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001500 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 },
1502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 .procname = "inode-state",
1504 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001505 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001507 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 },
1509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 .procname = "file-nr",
1511 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001512 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001514 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 },
1516 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .procname = "file-max",
1518 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001519 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001521 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 },
1523 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001524 .procname = "nr_open",
1525 .data = &sysctl_nr_open,
1526 .maxlen = sizeof(int),
1527 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001528 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001529 .extra1 = &sysctl_nr_open_min,
1530 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001531 },
1532 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 .procname = "dentry-state",
1534 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001535 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001536 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001537 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 },
1539 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 .procname = "overflowuid",
1541 .data = &fs_overflowuid,
1542 .maxlen = sizeof(int),
1543 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001544 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545 .extra1 = &minolduid,
1546 .extra2 = &maxolduid,
1547 },
1548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .procname = "overflowgid",
1550 .data = &fs_overflowgid,
1551 .maxlen = sizeof(int),
1552 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001553 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 .extra1 = &minolduid,
1555 .extra2 = &maxolduid,
1556 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001557#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .procname = "leases-enable",
1560 .data = &leases_enable,
1561 .maxlen = sizeof(int),
1562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001563 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001565#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566#ifdef CONFIG_DNOTIFY
1567 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 .procname = "dir-notify-enable",
1569 .data = &dir_notify_enable,
1570 .maxlen = sizeof(int),
1571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001572 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 },
1574#endif
1575#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001576#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 .procname = "lease-break-time",
1579 .data = &lease_break_time,
1580 .maxlen = sizeof(int),
1581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001584#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001585#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 .procname = "aio-nr",
1588 .data = &aio_nr,
1589 .maxlen = sizeof(aio_nr),
1590 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001591 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001592 },
1593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 .procname = "aio-max-nr",
1595 .data = &aio_max_nr,
1596 .maxlen = sizeof(aio_max_nr),
1597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001598 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001600#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001601#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001602 {
Robert Love0399cb02005-07-13 12:38:18 -04001603 .procname = "inotify",
1604 .mode = 0555,
1605 .child = inotify_table,
1606 },
1607#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001608#ifdef CONFIG_EPOLL
1609 {
1610 .procname = "epoll",
1611 .mode = 0555,
1612 .child = epoll_table,
1613 },
1614#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001616 {
Kees Cook800179c2012-07-25 17:29:07 -07001617 .procname = "protected_symlinks",
1618 .data = &sysctl_protected_symlinks,
1619 .maxlen = sizeof(int),
1620 .mode = 0600,
1621 .proc_handler = proc_dointvec_minmax,
1622 .extra1 = &zero,
1623 .extra2 = &one,
1624 },
1625 {
1626 .procname = "protected_hardlinks",
1627 .data = &sysctl_protected_hardlinks,
1628 .maxlen = sizeof(int),
1629 .mode = 0600,
1630 .proc_handler = proc_dointvec_minmax,
1631 .extra1 = &zero,
1632 .extra2 = &one,
1633 },
1634 {
Alan Coxd6e71142005-06-23 00:09:43 -07001635 .procname = "suid_dumpable",
1636 .data = &suid_dumpable,
1637 .maxlen = sizeof(int),
1638 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001639 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001640 .extra1 = &zero,
1641 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001642 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001643#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1644 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001645 .procname = "binfmt_misc",
1646 .mode = 0555,
1647 .child = binfmt_misc_table,
1648 },
1649#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001650 {
Jens Axboeff9da692010-06-03 14:54:39 +02001651 .procname = "pipe-max-size",
1652 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001653 .maxlen = sizeof(int),
1654 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001655 .proc_handler = &pipe_proc_fn,
1656 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001657 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001658 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659};
1660
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001661static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001662#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001663 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001664 .procname = "exception-trace",
1665 .data = &show_unhandled_signals,
1666 .maxlen = sizeof(int),
1667 .mode = 0644,
1668 .proc_handler = proc_dointvec
1669 },
1670#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001671#if defined(CONFIG_OPTPROBES)
1672 {
1673 .procname = "kprobes-optimization",
1674 .data = &sysctl_kprobes_optimization,
1675 .maxlen = sizeof(int),
1676 .mode = 0644,
1677 .proc_handler = proc_kprobes_optimization_handler,
1678 .extra1 = &zero,
1679 .extra2 = &one,
1680 },
1681#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001682 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683};
1684
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001685static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001686 { }
Robert Love0eeca282005-07-12 17:06:03 -04001687};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001689int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001690{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001691 struct ctl_table_header *hdr;
1692
1693 hdr = register_sysctl_table(sysctl_base_table);
1694 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001695 return 0;
1696}
1697
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001698#endif /* CONFIG_SYSCTL */
1699
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700/*
1701 * /proc/sys support
1702 */
1703
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001704#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705
Kees Cookf8808302014-06-06 14:37:17 -07001706static int _proc_do_string(char *data, int maxlen, int write,
1707 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001708 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001709{
1710 size_t len;
1711 char __user *p;
1712 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001713
1714 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001715 *lenp = 0;
1716 return 0;
1717 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001718
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001719 if (write) {
1720 len = 0;
1721 p = buffer;
1722 while (len < *lenp) {
1723 if (get_user(c, p++))
1724 return -EFAULT;
1725 if (c == 0 || c == '\n')
1726 break;
1727 len++;
1728 }
1729 if (len >= maxlen)
1730 len = maxlen-1;
1731 if(copy_from_user(data, buffer, len))
1732 return -EFAULT;
Kees Cookf8808302014-06-06 14:37:17 -07001733 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001734 *ppos += *lenp;
1735 } else {
1736 len = strlen(data);
1737 if (len > maxlen)
1738 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001739
1740 if (*ppos > len) {
1741 *lenp = 0;
1742 return 0;
1743 }
1744
1745 data += *ppos;
1746 len -= *ppos;
1747
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001748 if (len > *lenp)
1749 len = *lenp;
1750 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001751 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001752 return -EFAULT;
1753 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001754 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001755 return -EFAULT;
1756 len++;
1757 }
1758 *lenp = len;
1759 *ppos += len;
1760 }
1761 return 0;
1762}
1763
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764/**
1765 * proc_dostring - read a string sysctl
1766 * @table: the sysctl table
1767 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 * @buffer: the user buffer
1769 * @lenp: the size of the user buffer
1770 * @ppos: file position
1771 *
1772 * Reads/writes a string from/to the user buffer. If the kernel
1773 * buffer provided is not large enough to hold the string, the
1774 * string is truncated. The copied string is %NULL-terminated.
1775 * If the string is being read by the user process, it is copied
1776 * and a newline '\n' is added. It is truncated if the buffer is
1777 * not large enough.
1778 *
1779 * Returns 0 on success.
1780 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001781int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782 void __user *buffer, size_t *lenp, loff_t *ppos)
1783{
Kees Cookf8808302014-06-06 14:37:17 -07001784 return _proc_do_string((char *)(table->data), table->maxlen, write,
1785 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786}
1787
Amerigo Wang00b7c332010-05-05 00:26:45 +00001788static size_t proc_skip_spaces(char **buf)
1789{
1790 size_t ret;
1791 char *tmp = skip_spaces(*buf);
1792 ret = tmp - *buf;
1793 *buf = tmp;
1794 return ret;
1795}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001797static void proc_skip_char(char **buf, size_t *size, const char v)
1798{
1799 while (*size) {
1800 if (**buf != v)
1801 break;
1802 (*size)--;
1803 (*buf)++;
1804 }
1805}
1806
Amerigo Wang00b7c332010-05-05 00:26:45 +00001807#define TMPBUFLEN 22
1808/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001809 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001810 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001811 * @buf: a kernel buffer
1812 * @size: size of the kernel buffer
1813 * @val: this is where the number will be stored
1814 * @neg: set to %TRUE if number is negative
1815 * @perm_tr: a vector which contains the allowed trailers
1816 * @perm_tr_len: size of the perm_tr vector
1817 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001818 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001819 * In case of success %0 is returned and @buf and @size are updated with
1820 * the amount of bytes read. If @tr is non-NULL and a trailing
1821 * character exists (size is non-zero after returning from this
1822 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001823 */
1824static int proc_get_long(char **buf, size_t *size,
1825 unsigned long *val, bool *neg,
1826 const char *perm_tr, unsigned perm_tr_len, char *tr)
1827{
1828 int len;
1829 char *p, tmp[TMPBUFLEN];
1830
1831 if (!*size)
1832 return -EINVAL;
1833
1834 len = *size;
1835 if (len > TMPBUFLEN - 1)
1836 len = TMPBUFLEN - 1;
1837
1838 memcpy(tmp, *buf, len);
1839
1840 tmp[len] = 0;
1841 p = tmp;
1842 if (*p == '-' && *size > 1) {
1843 *neg = true;
1844 p++;
1845 } else
1846 *neg = false;
1847 if (!isdigit(*p))
1848 return -EINVAL;
1849
1850 *val = simple_strtoul(p, &p, 0);
1851
1852 len = p - tmp;
1853
1854 /* We don't know if the next char is whitespace thus we may accept
1855 * invalid integers (e.g. 1234...a) or two integers instead of one
1856 * (e.g. 123...1). So lets not allow such large numbers. */
1857 if (len == TMPBUFLEN - 1)
1858 return -EINVAL;
1859
1860 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1861 return -EINVAL;
1862
1863 if (tr && (len < *size))
1864 *tr = *p;
1865
1866 *buf += len;
1867 *size -= len;
1868
1869 return 0;
1870}
1871
1872/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001873 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001874 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001875 * @buf: the user buffer
1876 * @size: the size of the user buffer
1877 * @val: the integer to be converted
1878 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001879 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001880 * In case of success %0 is returned and @buf and @size are updated with
1881 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001882 */
1883static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1884 bool neg)
1885{
1886 int len;
1887 char tmp[TMPBUFLEN], *p = tmp;
1888
1889 sprintf(p, "%s%lu", neg ? "-" : "", val);
1890 len = strlen(tmp);
1891 if (len > *size)
1892 len = *size;
1893 if (copy_to_user(*buf, tmp, len))
1894 return -EFAULT;
1895 *size -= len;
1896 *buf += len;
1897 return 0;
1898}
1899#undef TMPBUFLEN
1900
1901static int proc_put_char(void __user **buf, size_t *size, char c)
1902{
1903 if (*size) {
1904 char __user **buffer = (char __user **)buf;
1905 if (put_user(c, *buffer))
1906 return -EFAULT;
1907 (*size)--, (*buffer)++;
1908 *buf = *buffer;
1909 }
1910 return 0;
1911}
1912
1913static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 int *valp,
1915 int write, void *data)
1916{
1917 if (write) {
1918 *valp = *negp ? -*lvalp : *lvalp;
1919 } else {
1920 int val = *valp;
1921 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001922 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 *lvalp = (unsigned long)-val;
1924 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001925 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926 *lvalp = (unsigned long)val;
1927 }
1928 }
1929 return 0;
1930}
1931
Amerigo Wang00b7c332010-05-05 00:26:45 +00001932static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1933
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001934static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001935 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001936 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001937 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 int write, void *data),
1939 void *data)
1940{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001941 int *i, vleft, first = 1, err = 0;
1942 unsigned long page = 0;
1943 size_t left;
1944 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001945
Amerigo Wang00b7c332010-05-05 00:26:45 +00001946 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 *lenp = 0;
1948 return 0;
1949 }
1950
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001951 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 vleft = table->maxlen / sizeof(*i);
1953 left = *lenp;
1954
1955 if (!conv)
1956 conv = do_proc_dointvec_conv;
1957
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001959 if (left > PAGE_SIZE - 1)
1960 left = PAGE_SIZE - 1;
1961 page = __get_free_page(GFP_TEMPORARY);
1962 kbuf = (char *) page;
1963 if (!kbuf)
1964 return -ENOMEM;
1965 if (copy_from_user(kbuf, buffer, left)) {
1966 err = -EFAULT;
1967 goto free;
1968 }
1969 kbuf[left] = 0;
1970 }
1971
1972 for (; left && vleft--; i++, first=0) {
1973 unsigned long lval;
1974 bool neg;
1975
1976 if (write) {
1977 left -= proc_skip_spaces(&kbuf);
1978
J. R. Okajima563b0462010-05-25 16:10:14 -07001979 if (!left)
1980 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001981 err = proc_get_long(&kbuf, &left, &lval, &neg,
1982 proc_wspace_sep,
1983 sizeof(proc_wspace_sep), NULL);
1984 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001986 if (conv(&neg, &lval, i, 1, data)) {
1987 err = -EINVAL;
1988 break;
1989 }
1990 } else {
1991 if (conv(&neg, &lval, i, 0, data)) {
1992 err = -EINVAL;
1993 break;
1994 }
1995 if (!first)
1996 err = proc_put_char(&buffer, &left, '\t');
1997 if (err)
1998 break;
1999 err = proc_put_long(&buffer, &left, lval, neg);
2000 if (err)
2001 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 }
2003 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002004
2005 if (!write && !first && left && !err)
2006 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002007 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002008 left -= proc_skip_spaces(&kbuf);
2009free:
2010 if (write) {
2011 free_page(page);
2012 if (first)
2013 return err ? : -EINVAL;
2014 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015 *lenp -= left;
2016 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002017 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018}
2019
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002020static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002021 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002022 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002023 int write, void *data),
2024 void *data)
2025{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002026 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002027 buffer, lenp, ppos, conv, data);
2028}
2029
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030/**
2031 * proc_dointvec - read a vector of integers
2032 * @table: the sysctl table
2033 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034 * @buffer: the user buffer
2035 * @lenp: the size of the user buffer
2036 * @ppos: file position
2037 *
2038 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2039 * values from/to the user buffer, treated as an ASCII string.
2040 *
2041 * Returns 0 on success.
2042 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002043int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044 void __user *buffer, size_t *lenp, loff_t *ppos)
2045{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002046 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047 NULL,NULL);
2048}
2049
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002050/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002051 * Taint values can only be increased
2052 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002053 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002054static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002055 void __user *buffer, size_t *lenp, loff_t *ppos)
2056{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002057 struct ctl_table t;
2058 unsigned long tmptaint = get_taint();
2059 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002060
Bastian Blank91fcd412007-04-23 14:41:14 -07002061 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002062 return -EPERM;
2063
Andi Kleen25ddbb12008-10-15 22:01:41 -07002064 t = *table;
2065 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002066 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002067 if (err < 0)
2068 return err;
2069
2070 if (write) {
2071 /*
2072 * Poor man's atomic or. Not worth adding a primitive
2073 * to everyone's atomic.h for this
2074 */
2075 int i;
2076 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2077 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302078 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002079 }
2080 }
2081
2082 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002083}
2084
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002085#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002086static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002087 void __user *buffer, size_t *lenp, loff_t *ppos)
2088{
2089 if (write && !capable(CAP_SYS_ADMIN))
2090 return -EPERM;
2091
2092 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2093}
2094#endif
2095
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096struct do_proc_dointvec_minmax_conv_param {
2097 int *min;
2098 int *max;
2099};
2100
Amerigo Wang00b7c332010-05-05 00:26:45 +00002101static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2102 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 int write, void *data)
2104{
2105 struct do_proc_dointvec_minmax_conv_param *param = data;
2106 if (write) {
2107 int val = *negp ? -*lvalp : *lvalp;
2108 if ((param->min && *param->min > val) ||
2109 (param->max && *param->max < val))
2110 return -EINVAL;
2111 *valp = val;
2112 } else {
2113 int val = *valp;
2114 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002115 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 *lvalp = (unsigned long)-val;
2117 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002118 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 *lvalp = (unsigned long)val;
2120 }
2121 }
2122 return 0;
2123}
2124
2125/**
2126 * proc_dointvec_minmax - read a vector of integers with min/max values
2127 * @table: the sysctl table
2128 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 * @buffer: the user buffer
2130 * @lenp: the size of the user buffer
2131 * @ppos: file position
2132 *
2133 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2134 * values from/to the user buffer, treated as an ASCII string.
2135 *
2136 * This routine will ensure the values are within the range specified by
2137 * table->extra1 (min) and table->extra2 (max).
2138 *
2139 * Returns 0 on success.
2140 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002141int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142 void __user *buffer, size_t *lenp, loff_t *ppos)
2143{
2144 struct do_proc_dointvec_minmax_conv_param param = {
2145 .min = (int *) table->extra1,
2146 .max = (int *) table->extra2,
2147 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002148 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 do_proc_dointvec_minmax_conv, &param);
2150}
2151
Kees Cook54b50192012-07-30 14:39:18 -07002152static void validate_coredump_safety(void)
2153{
Alex Kelly046d6622012-10-04 17:15:23 -07002154#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002155 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002156 core_pattern[0] != '/' && core_pattern[0] != '|') {
2157 printk(KERN_WARNING "Unsafe core_pattern used with "\
2158 "suid_dumpable=2. Pipe handler or fully qualified "\
2159 "core dump path required.\n");
2160 }
Alex Kelly046d6622012-10-04 17:15:23 -07002161#endif
Kees Cook54b50192012-07-30 14:39:18 -07002162}
2163
2164static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2165 void __user *buffer, size_t *lenp, loff_t *ppos)
2166{
2167 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2168 if (!error)
2169 validate_coredump_safety();
2170 return error;
2171}
2172
Alex Kelly046d6622012-10-04 17:15:23 -07002173#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002174static int proc_dostring_coredump(struct ctl_table *table, int write,
2175 void __user *buffer, size_t *lenp, loff_t *ppos)
2176{
2177 int error = proc_dostring(table, write, buffer, lenp, ppos);
2178 if (!error)
2179 validate_coredump_safety();
2180 return error;
2181}
Alex Kelly046d6622012-10-04 17:15:23 -07002182#endif
Kees Cook54b50192012-07-30 14:39:18 -07002183
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002184static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 void __user *buffer,
2186 size_t *lenp, loff_t *ppos,
2187 unsigned long convmul,
2188 unsigned long convdiv)
2189{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002190 unsigned long *i, *min, *max;
2191 int vleft, first = 1, err = 0;
2192 unsigned long page = 0;
2193 size_t left;
2194 char *kbuf;
2195
2196 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 *lenp = 0;
2198 return 0;
2199 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002200
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002201 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 min = (unsigned long *) table->extra1;
2203 max = (unsigned long *) table->extra2;
2204 vleft = table->maxlen / sizeof(unsigned long);
2205 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002206
2207 if (write) {
2208 if (left > PAGE_SIZE - 1)
2209 left = PAGE_SIZE - 1;
2210 page = __get_free_page(GFP_TEMPORARY);
2211 kbuf = (char *) page;
2212 if (!kbuf)
2213 return -ENOMEM;
2214 if (copy_from_user(kbuf, buffer, left)) {
2215 err = -EFAULT;
2216 goto free;
2217 }
2218 kbuf[left] = 0;
2219 }
2220
Eric Dumazet27b3d802010-10-07 12:59:29 -07002221 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002222 unsigned long val;
2223
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002225 bool neg;
2226
2227 left -= proc_skip_spaces(&kbuf);
2228
2229 err = proc_get_long(&kbuf, &left, &val, &neg,
2230 proc_wspace_sep,
2231 sizeof(proc_wspace_sep), NULL);
2232 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 break;
2234 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 continue;
2236 if ((min && val < *min) || (max && val > *max))
2237 continue;
2238 *i = val;
2239 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002240 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002241 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002242 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002243 if (err)
2244 break;
2245 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002246 err = proc_put_long(&buffer, &left, val, false);
2247 if (err)
2248 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249 }
2250 }
2251
Amerigo Wang00b7c332010-05-05 00:26:45 +00002252 if (!write && !first && left && !err)
2253 err = proc_put_char(&buffer, &left, '\n');
2254 if (write && !err)
2255 left -= proc_skip_spaces(&kbuf);
2256free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258 free_page(page);
2259 if (first)
2260 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 *lenp -= left;
2263 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002264 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265}
2266
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002267static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002268 void __user *buffer,
2269 size_t *lenp, loff_t *ppos,
2270 unsigned long convmul,
2271 unsigned long convdiv)
2272{
2273 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002274 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002275}
2276
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277/**
2278 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2279 * @table: the sysctl table
2280 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 * @buffer: the user buffer
2282 * @lenp: the size of the user buffer
2283 * @ppos: file position
2284 *
2285 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2286 * values from/to the user buffer, treated as an ASCII string.
2287 *
2288 * This routine will ensure the values are within the range specified by
2289 * table->extra1 (min) and table->extra2 (max).
2290 *
2291 * Returns 0 on success.
2292 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002293int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 void __user *buffer, size_t *lenp, loff_t *ppos)
2295{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002296 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297}
2298
2299/**
2300 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2301 * @table: the sysctl table
2302 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 * @buffer: the user buffer
2304 * @lenp: the size of the user buffer
2305 * @ppos: file position
2306 *
2307 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2308 * values from/to the user buffer, treated as an ASCII string. The values
2309 * are treated as milliseconds, and converted to jiffies when they are stored.
2310 *
2311 * This routine will ensure the values are within the range specified by
2312 * table->extra1 (min) and table->extra2 (max).
2313 *
2314 * Returns 0 on success.
2315 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002316int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 void __user *buffer,
2318 size_t *lenp, loff_t *ppos)
2319{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002320 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 lenp, ppos, HZ, 1000l);
2322}
2323
2324
Amerigo Wang00b7c332010-05-05 00:26:45 +00002325static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326 int *valp,
2327 int write, void *data)
2328{
2329 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002330 if (*lvalp > LONG_MAX / HZ)
2331 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2333 } else {
2334 int val = *valp;
2335 unsigned long lval;
2336 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002337 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 lval = (unsigned long)-val;
2339 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002340 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 lval = (unsigned long)val;
2342 }
2343 *lvalp = lval / HZ;
2344 }
2345 return 0;
2346}
2347
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 int *valp,
2350 int write, void *data)
2351{
2352 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002353 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2354 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2356 } else {
2357 int val = *valp;
2358 unsigned long lval;
2359 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002360 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361 lval = (unsigned long)-val;
2362 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002363 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 lval = (unsigned long)val;
2365 }
2366 *lvalp = jiffies_to_clock_t(lval);
2367 }
2368 return 0;
2369}
2370
Amerigo Wang00b7c332010-05-05 00:26:45 +00002371static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 int *valp,
2373 int write, void *data)
2374{
2375 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002376 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2377
2378 if (jif > INT_MAX)
2379 return 1;
2380 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 } else {
2382 int val = *valp;
2383 unsigned long lval;
2384 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002385 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 lval = (unsigned long)-val;
2387 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002388 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 lval = (unsigned long)val;
2390 }
2391 *lvalp = jiffies_to_msecs(lval);
2392 }
2393 return 0;
2394}
2395
2396/**
2397 * proc_dointvec_jiffies - read a vector of integers as seconds
2398 * @table: the sysctl table
2399 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 * @buffer: the user buffer
2401 * @lenp: the size of the user buffer
2402 * @ppos: file position
2403 *
2404 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2405 * values from/to the user buffer, treated as an ASCII string.
2406 * The values read are assumed to be in seconds, and are converted into
2407 * jiffies.
2408 *
2409 * Returns 0 on success.
2410 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002411int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412 void __user *buffer, size_t *lenp, loff_t *ppos)
2413{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002414 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415 do_proc_dointvec_jiffies_conv,NULL);
2416}
2417
2418/**
2419 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2420 * @table: the sysctl table
2421 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 * @buffer: the user buffer
2423 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002424 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 *
2426 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2427 * values from/to the user buffer, treated as an ASCII string.
2428 * The values read are assumed to be in 1/USER_HZ seconds, and
2429 * are converted into jiffies.
2430 *
2431 * Returns 0 on success.
2432 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002433int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 void __user *buffer, size_t *lenp, loff_t *ppos)
2435{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002436 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 do_proc_dointvec_userhz_jiffies_conv,NULL);
2438}
2439
2440/**
2441 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2442 * @table: the sysctl table
2443 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 * @buffer: the user buffer
2445 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002446 * @ppos: file position
2447 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 *
2449 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2450 * values from/to the user buffer, treated as an ASCII string.
2451 * The values read are assumed to be in 1/1000 seconds, and
2452 * are converted into jiffies.
2453 *
2454 * Returns 0 on success.
2455 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002456int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 void __user *buffer, size_t *lenp, loff_t *ppos)
2458{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002459 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002460 do_proc_dointvec_ms_jiffies_conv, NULL);
2461}
2462
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002463static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002464 void __user *buffer, size_t *lenp, loff_t *ppos)
2465{
2466 struct pid *new_pid;
2467 pid_t tmp;
2468 int r;
2469
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002470 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002471
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002472 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002473 lenp, ppos, NULL, NULL);
2474 if (r || !write)
2475 return r;
2476
2477 new_pid = find_get_pid(tmp);
2478 if (!new_pid)
2479 return -ESRCH;
2480
2481 put_pid(xchg(&cad_pid, new_pid));
2482 return 0;
2483}
2484
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002485/**
2486 * proc_do_large_bitmap - read/write from/to a large bitmap
2487 * @table: the sysctl table
2488 * @write: %TRUE if this is a write to the sysctl file
2489 * @buffer: the user buffer
2490 * @lenp: the size of the user buffer
2491 * @ppos: file position
2492 *
2493 * The bitmap is stored at table->data and the bitmap length (in bits)
2494 * in table->maxlen.
2495 *
2496 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2497 * large bitmaps may be represented in a compact manner. Writing into
2498 * the file will clear the bitmap then update it with the given input.
2499 *
2500 * Returns 0 on success.
2501 */
2502int proc_do_large_bitmap(struct ctl_table *table, int write,
2503 void __user *buffer, size_t *lenp, loff_t *ppos)
2504{
2505 int err = 0;
2506 bool first = 1;
2507 size_t left = *lenp;
2508 unsigned long bitmap_len = table->maxlen;
2509 unsigned long *bitmap = (unsigned long *) table->data;
2510 unsigned long *tmp_bitmap = NULL;
2511 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2512
2513 if (!bitmap_len || !left || (*ppos && !write)) {
2514 *lenp = 0;
2515 return 0;
2516 }
2517
2518 if (write) {
2519 unsigned long page = 0;
2520 char *kbuf;
2521
2522 if (left > PAGE_SIZE - 1)
2523 left = PAGE_SIZE - 1;
2524
2525 page = __get_free_page(GFP_TEMPORARY);
2526 kbuf = (char *) page;
2527 if (!kbuf)
2528 return -ENOMEM;
2529 if (copy_from_user(kbuf, buffer, left)) {
2530 free_page(page);
2531 return -EFAULT;
2532 }
2533 kbuf[left] = 0;
2534
2535 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2536 GFP_KERNEL);
2537 if (!tmp_bitmap) {
2538 free_page(page);
2539 return -ENOMEM;
2540 }
2541 proc_skip_char(&kbuf, &left, '\n');
2542 while (!err && left) {
2543 unsigned long val_a, val_b;
2544 bool neg;
2545
2546 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2547 sizeof(tr_a), &c);
2548 if (err)
2549 break;
2550 if (val_a >= bitmap_len || neg) {
2551 err = -EINVAL;
2552 break;
2553 }
2554
2555 val_b = val_a;
2556 if (left) {
2557 kbuf++;
2558 left--;
2559 }
2560
2561 if (c == '-') {
2562 err = proc_get_long(&kbuf, &left, &val_b,
2563 &neg, tr_b, sizeof(tr_b),
2564 &c);
2565 if (err)
2566 break;
2567 if (val_b >= bitmap_len || neg ||
2568 val_a > val_b) {
2569 err = -EINVAL;
2570 break;
2571 }
2572 if (left) {
2573 kbuf++;
2574 left--;
2575 }
2576 }
2577
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002578 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002579 first = 0;
2580 proc_skip_char(&kbuf, &left, '\n');
2581 }
2582 free_page(page);
2583 } else {
2584 unsigned long bit_a, bit_b = 0;
2585
2586 while (left) {
2587 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2588 if (bit_a >= bitmap_len)
2589 break;
2590 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2591 bit_a + 1) - 1;
2592
2593 if (!first) {
2594 err = proc_put_char(&buffer, &left, ',');
2595 if (err)
2596 break;
2597 }
2598 err = proc_put_long(&buffer, &left, bit_a, false);
2599 if (err)
2600 break;
2601 if (bit_a != bit_b) {
2602 err = proc_put_char(&buffer, &left, '-');
2603 if (err)
2604 break;
2605 err = proc_put_long(&buffer, &left, bit_b, false);
2606 if (err)
2607 break;
2608 }
2609
2610 first = 0; bit_b++;
2611 }
2612 if (!err)
2613 err = proc_put_char(&buffer, &left, '\n');
2614 }
2615
2616 if (!err) {
2617 if (write) {
2618 if (*ppos)
2619 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2620 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002621 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002622 }
2623 kfree(tmp_bitmap);
2624 *lenp -= left;
2625 *ppos += *lenp;
2626 return 0;
2627 } else {
2628 kfree(tmp_bitmap);
2629 return err;
2630 }
2631}
2632
Jovi Zhang55610502011-01-12 17:00:45 -08002633#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002635int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 void __user *buffer, size_t *lenp, loff_t *ppos)
2637{
2638 return -ENOSYS;
2639}
2640
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002641int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642 void __user *buffer, size_t *lenp, loff_t *ppos)
2643{
2644 return -ENOSYS;
2645}
2646
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002647int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 void __user *buffer, size_t *lenp, loff_t *ppos)
2649{
2650 return -ENOSYS;
2651}
2652
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002653int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 void __user *buffer, size_t *lenp, loff_t *ppos)
2655{
2656 return -ENOSYS;
2657}
2658
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002659int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 void __user *buffer, size_t *lenp, loff_t *ppos)
2661{
2662 return -ENOSYS;
2663}
2664
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002665int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666 void __user *buffer, size_t *lenp, loff_t *ppos)
2667{
2668 return -ENOSYS;
2669}
2670
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002671int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672 void __user *buffer, size_t *lenp, loff_t *ppos)
2673{
2674 return -ENOSYS;
2675}
2676
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002677int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 void __user *buffer,
2679 size_t *lenp, loff_t *ppos)
2680{
2681 return -ENOSYS;
2682}
2683
2684
Jovi Zhang55610502011-01-12 17:00:45 -08002685#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686
Linus Torvalds1da177e2005-04-16 15:20:36 -07002687/*
2688 * No sense putting this after each symbol definition, twice,
2689 * exception granted :-)
2690 */
2691EXPORT_SYMBOL(proc_dointvec);
2692EXPORT_SYMBOL(proc_dointvec_jiffies);
2693EXPORT_SYMBOL(proc_dointvec_minmax);
2694EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2695EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2696EXPORT_SYMBOL(proc_dostring);
2697EXPORT_SYMBOL(proc_doulongvec_minmax);
2698EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);