blob: ac6847feaa83bb6bcb7d86366590a7dd26d6c591 [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 Rostedtf38f1d2a2008-12-16 23:06:40 -0500590#ifdef CONFIG_STACK_TRACER
591 {
Steven Rostedtf38f1d2a2008-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 Rostedtf38f1d2a2008-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) {
Kees Cook2ca9bb42014-06-06 14:37:18 -07001720 /* Start writing from beginning of buffer. */
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001721 len = 0;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001722 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001723 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001724 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001725 if (get_user(c, p++))
1726 return -EFAULT;
1727 if (c == 0 || c == '\n')
1728 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001729 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001730 }
Kees Cookf8808302014-06-06 14:37:17 -07001731 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001732 } else {
1733 len = strlen(data);
1734 if (len > maxlen)
1735 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001736
1737 if (*ppos > len) {
1738 *lenp = 0;
1739 return 0;
1740 }
1741
1742 data += *ppos;
1743 len -= *ppos;
1744
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001745 if (len > *lenp)
1746 len = *lenp;
1747 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001748 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001749 return -EFAULT;
1750 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001751 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001752 return -EFAULT;
1753 len++;
1754 }
1755 *lenp = len;
1756 *ppos += len;
1757 }
1758 return 0;
1759}
1760
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761/**
1762 * proc_dostring - read a string sysctl
1763 * @table: the sysctl table
1764 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765 * @buffer: the user buffer
1766 * @lenp: the size of the user buffer
1767 * @ppos: file position
1768 *
1769 * Reads/writes a string from/to the user buffer. If the kernel
1770 * buffer provided is not large enough to hold the string, the
1771 * string is truncated. The copied string is %NULL-terminated.
1772 * If the string is being read by the user process, it is copied
1773 * and a newline '\n' is added. It is truncated if the buffer is
1774 * not large enough.
1775 *
1776 * Returns 0 on success.
1777 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001778int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779 void __user *buffer, size_t *lenp, loff_t *ppos)
1780{
Kees Cookf8808302014-06-06 14:37:17 -07001781 return _proc_do_string((char *)(table->data), table->maxlen, write,
1782 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783}
1784
Amerigo Wang00b7c332010-05-05 00:26:45 +00001785static size_t proc_skip_spaces(char **buf)
1786{
1787 size_t ret;
1788 char *tmp = skip_spaces(*buf);
1789 ret = tmp - *buf;
1790 *buf = tmp;
1791 return ret;
1792}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001794static void proc_skip_char(char **buf, size_t *size, const char v)
1795{
1796 while (*size) {
1797 if (**buf != v)
1798 break;
1799 (*size)--;
1800 (*buf)++;
1801 }
1802}
1803
Amerigo Wang00b7c332010-05-05 00:26:45 +00001804#define TMPBUFLEN 22
1805/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001806 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001807 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001808 * @buf: a kernel buffer
1809 * @size: size of the kernel buffer
1810 * @val: this is where the number will be stored
1811 * @neg: set to %TRUE if number is negative
1812 * @perm_tr: a vector which contains the allowed trailers
1813 * @perm_tr_len: size of the perm_tr vector
1814 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001815 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001816 * In case of success %0 is returned and @buf and @size are updated with
1817 * the amount of bytes read. If @tr is non-NULL and a trailing
1818 * character exists (size is non-zero after returning from this
1819 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001820 */
1821static int proc_get_long(char **buf, size_t *size,
1822 unsigned long *val, bool *neg,
1823 const char *perm_tr, unsigned perm_tr_len, char *tr)
1824{
1825 int len;
1826 char *p, tmp[TMPBUFLEN];
1827
1828 if (!*size)
1829 return -EINVAL;
1830
1831 len = *size;
1832 if (len > TMPBUFLEN - 1)
1833 len = TMPBUFLEN - 1;
1834
1835 memcpy(tmp, *buf, len);
1836
1837 tmp[len] = 0;
1838 p = tmp;
1839 if (*p == '-' && *size > 1) {
1840 *neg = true;
1841 p++;
1842 } else
1843 *neg = false;
1844 if (!isdigit(*p))
1845 return -EINVAL;
1846
1847 *val = simple_strtoul(p, &p, 0);
1848
1849 len = p - tmp;
1850
1851 /* We don't know if the next char is whitespace thus we may accept
1852 * invalid integers (e.g. 1234...a) or two integers instead of one
1853 * (e.g. 123...1). So lets not allow such large numbers. */
1854 if (len == TMPBUFLEN - 1)
1855 return -EINVAL;
1856
1857 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1858 return -EINVAL;
1859
1860 if (tr && (len < *size))
1861 *tr = *p;
1862
1863 *buf += len;
1864 *size -= len;
1865
1866 return 0;
1867}
1868
1869/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001870 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001871 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001872 * @buf: the user buffer
1873 * @size: the size of the user buffer
1874 * @val: the integer to be converted
1875 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001876 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001877 * In case of success %0 is returned and @buf and @size are updated with
1878 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001879 */
1880static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1881 bool neg)
1882{
1883 int len;
1884 char tmp[TMPBUFLEN], *p = tmp;
1885
1886 sprintf(p, "%s%lu", neg ? "-" : "", val);
1887 len = strlen(tmp);
1888 if (len > *size)
1889 len = *size;
1890 if (copy_to_user(*buf, tmp, len))
1891 return -EFAULT;
1892 *size -= len;
1893 *buf += len;
1894 return 0;
1895}
1896#undef TMPBUFLEN
1897
1898static int proc_put_char(void __user **buf, size_t *size, char c)
1899{
1900 if (*size) {
1901 char __user **buffer = (char __user **)buf;
1902 if (put_user(c, *buffer))
1903 return -EFAULT;
1904 (*size)--, (*buffer)++;
1905 *buf = *buffer;
1906 }
1907 return 0;
1908}
1909
1910static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911 int *valp,
1912 int write, void *data)
1913{
1914 if (write) {
1915 *valp = *negp ? -*lvalp : *lvalp;
1916 } else {
1917 int val = *valp;
1918 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001919 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 *lvalp = (unsigned long)-val;
1921 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001922 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 *lvalp = (unsigned long)val;
1924 }
1925 }
1926 return 0;
1927}
1928
Amerigo Wang00b7c332010-05-05 00:26:45 +00001929static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1930
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001931static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001932 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001933 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001934 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001935 int write, void *data),
1936 void *data)
1937{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001938 int *i, vleft, first = 1, err = 0;
1939 unsigned long page = 0;
1940 size_t left;
1941 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942
Amerigo Wang00b7c332010-05-05 00:26:45 +00001943 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 *lenp = 0;
1945 return 0;
1946 }
1947
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001948 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949 vleft = table->maxlen / sizeof(*i);
1950 left = *lenp;
1951
1952 if (!conv)
1953 conv = do_proc_dointvec_conv;
1954
Linus Torvalds1da177e2005-04-16 15:20:36 -07001955 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001956 if (left > PAGE_SIZE - 1)
1957 left = PAGE_SIZE - 1;
1958 page = __get_free_page(GFP_TEMPORARY);
1959 kbuf = (char *) page;
1960 if (!kbuf)
1961 return -ENOMEM;
1962 if (copy_from_user(kbuf, buffer, left)) {
1963 err = -EFAULT;
1964 goto free;
1965 }
1966 kbuf[left] = 0;
1967 }
1968
1969 for (; left && vleft--; i++, first=0) {
1970 unsigned long lval;
1971 bool neg;
1972
1973 if (write) {
1974 left -= proc_skip_spaces(&kbuf);
1975
J. R. Okajima563b0462010-05-25 16:10:14 -07001976 if (!left)
1977 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001978 err = proc_get_long(&kbuf, &left, &lval, &neg,
1979 proc_wspace_sep,
1980 sizeof(proc_wspace_sep), NULL);
1981 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001983 if (conv(&neg, &lval, i, 1, data)) {
1984 err = -EINVAL;
1985 break;
1986 }
1987 } else {
1988 if (conv(&neg, &lval, i, 0, data)) {
1989 err = -EINVAL;
1990 break;
1991 }
1992 if (!first)
1993 err = proc_put_char(&buffer, &left, '\t');
1994 if (err)
1995 break;
1996 err = proc_put_long(&buffer, &left, lval, neg);
1997 if (err)
1998 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 }
2000 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002001
2002 if (!write && !first && left && !err)
2003 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002004 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002005 left -= proc_skip_spaces(&kbuf);
2006free:
2007 if (write) {
2008 free_page(page);
2009 if (first)
2010 return err ? : -EINVAL;
2011 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012 *lenp -= left;
2013 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002014 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015}
2016
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002017static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002018 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002019 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002020 int write, void *data),
2021 void *data)
2022{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002023 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002024 buffer, lenp, ppos, conv, data);
2025}
2026
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027/**
2028 * proc_dointvec - read a vector of integers
2029 * @table: the sysctl table
2030 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031 * @buffer: the user buffer
2032 * @lenp: the size of the user buffer
2033 * @ppos: file position
2034 *
2035 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2036 * values from/to the user buffer, treated as an ASCII string.
2037 *
2038 * Returns 0 on success.
2039 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002040int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002041 void __user *buffer, size_t *lenp, loff_t *ppos)
2042{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002043 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044 NULL,NULL);
2045}
2046
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002047/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002048 * Taint values can only be increased
2049 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002050 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002051static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002052 void __user *buffer, size_t *lenp, loff_t *ppos)
2053{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002054 struct ctl_table t;
2055 unsigned long tmptaint = get_taint();
2056 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002057
Bastian Blank91fcd412007-04-23 14:41:14 -07002058 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002059 return -EPERM;
2060
Andi Kleen25ddbb12008-10-15 22:01:41 -07002061 t = *table;
2062 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002063 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002064 if (err < 0)
2065 return err;
2066
2067 if (write) {
2068 /*
2069 * Poor man's atomic or. Not worth adding a primitive
2070 * to everyone's atomic.h for this
2071 */
2072 int i;
2073 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2074 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302075 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002076 }
2077 }
2078
2079 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002080}
2081
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002082#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002083static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002084 void __user *buffer, size_t *lenp, loff_t *ppos)
2085{
2086 if (write && !capable(CAP_SYS_ADMIN))
2087 return -EPERM;
2088
2089 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2090}
2091#endif
2092
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093struct do_proc_dointvec_minmax_conv_param {
2094 int *min;
2095 int *max;
2096};
2097
Amerigo Wang00b7c332010-05-05 00:26:45 +00002098static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2099 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002100 int write, void *data)
2101{
2102 struct do_proc_dointvec_minmax_conv_param *param = data;
2103 if (write) {
2104 int val = *negp ? -*lvalp : *lvalp;
2105 if ((param->min && *param->min > val) ||
2106 (param->max && *param->max < val))
2107 return -EINVAL;
2108 *valp = val;
2109 } else {
2110 int val = *valp;
2111 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002112 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113 *lvalp = (unsigned long)-val;
2114 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002115 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 *lvalp = (unsigned long)val;
2117 }
2118 }
2119 return 0;
2120}
2121
2122/**
2123 * proc_dointvec_minmax - read a vector of integers with min/max values
2124 * @table: the sysctl table
2125 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126 * @buffer: the user buffer
2127 * @lenp: the size of the user buffer
2128 * @ppos: file position
2129 *
2130 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2131 * values from/to the user buffer, treated as an ASCII string.
2132 *
2133 * This routine will ensure the values are within the range specified by
2134 * table->extra1 (min) and table->extra2 (max).
2135 *
2136 * Returns 0 on success.
2137 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002138int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139 void __user *buffer, size_t *lenp, loff_t *ppos)
2140{
2141 struct do_proc_dointvec_minmax_conv_param param = {
2142 .min = (int *) table->extra1,
2143 .max = (int *) table->extra2,
2144 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002145 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146 do_proc_dointvec_minmax_conv, &param);
2147}
2148
Kees Cook54b50192012-07-30 14:39:18 -07002149static void validate_coredump_safety(void)
2150{
Alex Kelly046d6622012-10-04 17:15:23 -07002151#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002152 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002153 core_pattern[0] != '/' && core_pattern[0] != '|') {
2154 printk(KERN_WARNING "Unsafe core_pattern used with "\
2155 "suid_dumpable=2. Pipe handler or fully qualified "\
2156 "core dump path required.\n");
2157 }
Alex Kelly046d6622012-10-04 17:15:23 -07002158#endif
Kees Cook54b50192012-07-30 14:39:18 -07002159}
2160
2161static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2162 void __user *buffer, size_t *lenp, loff_t *ppos)
2163{
2164 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2165 if (!error)
2166 validate_coredump_safety();
2167 return error;
2168}
2169
Alex Kelly046d6622012-10-04 17:15:23 -07002170#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002171static int proc_dostring_coredump(struct ctl_table *table, int write,
2172 void __user *buffer, size_t *lenp, loff_t *ppos)
2173{
2174 int error = proc_dostring(table, write, buffer, lenp, ppos);
2175 if (!error)
2176 validate_coredump_safety();
2177 return error;
2178}
Alex Kelly046d6622012-10-04 17:15:23 -07002179#endif
Kees Cook54b50192012-07-30 14:39:18 -07002180
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002181static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 void __user *buffer,
2183 size_t *lenp, loff_t *ppos,
2184 unsigned long convmul,
2185 unsigned long convdiv)
2186{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187 unsigned long *i, *min, *max;
2188 int vleft, first = 1, err = 0;
2189 unsigned long page = 0;
2190 size_t left;
2191 char *kbuf;
2192
2193 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 *lenp = 0;
2195 return 0;
2196 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002197
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002198 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 min = (unsigned long *) table->extra1;
2200 max = (unsigned long *) table->extra2;
2201 vleft = table->maxlen / sizeof(unsigned long);
2202 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203
2204 if (write) {
2205 if (left > PAGE_SIZE - 1)
2206 left = PAGE_SIZE - 1;
2207 page = __get_free_page(GFP_TEMPORARY);
2208 kbuf = (char *) page;
2209 if (!kbuf)
2210 return -ENOMEM;
2211 if (copy_from_user(kbuf, buffer, left)) {
2212 err = -EFAULT;
2213 goto free;
2214 }
2215 kbuf[left] = 0;
2216 }
2217
Eric Dumazet27b3d802010-10-07 12:59:29 -07002218 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002219 unsigned long val;
2220
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002222 bool neg;
2223
2224 left -= proc_skip_spaces(&kbuf);
2225
2226 err = proc_get_long(&kbuf, &left, &val, &neg,
2227 proc_wspace_sep,
2228 sizeof(proc_wspace_sep), NULL);
2229 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 break;
2231 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 continue;
2233 if ((min && val < *min) || (max && val > *max))
2234 continue;
2235 *i = val;
2236 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002237 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002238 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002239 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002240 if (err)
2241 break;
2242 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002243 err = proc_put_long(&buffer, &left, val, false);
2244 if (err)
2245 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 }
2247 }
2248
Amerigo Wang00b7c332010-05-05 00:26:45 +00002249 if (!write && !first && left && !err)
2250 err = proc_put_char(&buffer, &left, '\n');
2251 if (write && !err)
2252 left -= proc_skip_spaces(&kbuf);
2253free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002255 free_page(page);
2256 if (first)
2257 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 *lenp -= left;
2260 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002261 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262}
2263
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002264static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002265 void __user *buffer,
2266 size_t *lenp, loff_t *ppos,
2267 unsigned long convmul,
2268 unsigned long convdiv)
2269{
2270 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002271 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002272}
2273
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274/**
2275 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2276 * @table: the sysctl table
2277 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 * @buffer: the user buffer
2279 * @lenp: the size of the user buffer
2280 * @ppos: file position
2281 *
2282 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2283 * values from/to the user buffer, treated as an ASCII string.
2284 *
2285 * This routine will ensure the values are within the range specified by
2286 * table->extra1 (min) and table->extra2 (max).
2287 *
2288 * Returns 0 on success.
2289 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002290int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 void __user *buffer, size_t *lenp, loff_t *ppos)
2292{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002293 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294}
2295
2296/**
2297 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2298 * @table: the sysctl table
2299 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 * @buffer: the user buffer
2301 * @lenp: the size of the user buffer
2302 * @ppos: file position
2303 *
2304 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2305 * values from/to the user buffer, treated as an ASCII string. The values
2306 * are treated as milliseconds, and converted to jiffies when they are stored.
2307 *
2308 * This routine will ensure the values are within the range specified by
2309 * table->extra1 (min) and table->extra2 (max).
2310 *
2311 * Returns 0 on success.
2312 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002313int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 void __user *buffer,
2315 size_t *lenp, loff_t *ppos)
2316{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002317 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 lenp, ppos, HZ, 1000l);
2319}
2320
2321
Amerigo Wang00b7c332010-05-05 00:26:45 +00002322static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002323 int *valp,
2324 int write, void *data)
2325{
2326 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002327 if (*lvalp > LONG_MAX / HZ)
2328 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2330 } else {
2331 int val = *valp;
2332 unsigned long lval;
2333 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002334 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335 lval = (unsigned long)-val;
2336 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002337 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 lval = (unsigned long)val;
2339 }
2340 *lvalp = lval / HZ;
2341 }
2342 return 0;
2343}
2344
Amerigo Wang00b7c332010-05-05 00:26:45 +00002345static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346 int *valp,
2347 int write, void *data)
2348{
2349 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002350 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2351 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002352 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2353 } else {
2354 int val = *valp;
2355 unsigned long lval;
2356 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002357 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 lval = (unsigned long)-val;
2359 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002360 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361 lval = (unsigned long)val;
2362 }
2363 *lvalp = jiffies_to_clock_t(lval);
2364 }
2365 return 0;
2366}
2367
Amerigo Wang00b7c332010-05-05 00:26:45 +00002368static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 int *valp,
2370 int write, void *data)
2371{
2372 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002373 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2374
2375 if (jif > INT_MAX)
2376 return 1;
2377 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 } else {
2379 int val = *valp;
2380 unsigned long lval;
2381 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002382 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 lval = (unsigned long)-val;
2384 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002385 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 lval = (unsigned long)val;
2387 }
2388 *lvalp = jiffies_to_msecs(lval);
2389 }
2390 return 0;
2391}
2392
2393/**
2394 * proc_dointvec_jiffies - read a vector of integers as seconds
2395 * @table: the sysctl table
2396 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 * @buffer: the user buffer
2398 * @lenp: the size of the user buffer
2399 * @ppos: file position
2400 *
2401 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2402 * values from/to the user buffer, treated as an ASCII string.
2403 * The values read are assumed to be in seconds, and are converted into
2404 * jiffies.
2405 *
2406 * Returns 0 on success.
2407 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002408int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 void __user *buffer, size_t *lenp, loff_t *ppos)
2410{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002411 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412 do_proc_dointvec_jiffies_conv,NULL);
2413}
2414
2415/**
2416 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2417 * @table: the sysctl table
2418 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419 * @buffer: the user buffer
2420 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002421 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 *
2423 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2424 * values from/to the user buffer, treated as an ASCII string.
2425 * The values read are assumed to be in 1/USER_HZ seconds, and
2426 * are converted into jiffies.
2427 *
2428 * Returns 0 on success.
2429 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002430int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 void __user *buffer, size_t *lenp, loff_t *ppos)
2432{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002433 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 do_proc_dointvec_userhz_jiffies_conv,NULL);
2435}
2436
2437/**
2438 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2439 * @table: the sysctl table
2440 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 * @buffer: the user buffer
2442 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002443 * @ppos: file position
2444 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 *
2446 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2447 * values from/to the user buffer, treated as an ASCII string.
2448 * The values read are assumed to be in 1/1000 seconds, and
2449 * are converted into jiffies.
2450 *
2451 * Returns 0 on success.
2452 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002453int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 void __user *buffer, size_t *lenp, loff_t *ppos)
2455{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002456 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 do_proc_dointvec_ms_jiffies_conv, NULL);
2458}
2459
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002460static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002461 void __user *buffer, size_t *lenp, loff_t *ppos)
2462{
2463 struct pid *new_pid;
2464 pid_t tmp;
2465 int r;
2466
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002467 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002468
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002469 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002470 lenp, ppos, NULL, NULL);
2471 if (r || !write)
2472 return r;
2473
2474 new_pid = find_get_pid(tmp);
2475 if (!new_pid)
2476 return -ESRCH;
2477
2478 put_pid(xchg(&cad_pid, new_pid));
2479 return 0;
2480}
2481
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002482/**
2483 * proc_do_large_bitmap - read/write from/to a large bitmap
2484 * @table: the sysctl table
2485 * @write: %TRUE if this is a write to the sysctl file
2486 * @buffer: the user buffer
2487 * @lenp: the size of the user buffer
2488 * @ppos: file position
2489 *
2490 * The bitmap is stored at table->data and the bitmap length (in bits)
2491 * in table->maxlen.
2492 *
2493 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2494 * large bitmaps may be represented in a compact manner. Writing into
2495 * the file will clear the bitmap then update it with the given input.
2496 *
2497 * Returns 0 on success.
2498 */
2499int proc_do_large_bitmap(struct ctl_table *table, int write,
2500 void __user *buffer, size_t *lenp, loff_t *ppos)
2501{
2502 int err = 0;
2503 bool first = 1;
2504 size_t left = *lenp;
2505 unsigned long bitmap_len = table->maxlen;
2506 unsigned long *bitmap = (unsigned long *) table->data;
2507 unsigned long *tmp_bitmap = NULL;
2508 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2509
2510 if (!bitmap_len || !left || (*ppos && !write)) {
2511 *lenp = 0;
2512 return 0;
2513 }
2514
2515 if (write) {
2516 unsigned long page = 0;
2517 char *kbuf;
2518
2519 if (left > PAGE_SIZE - 1)
2520 left = PAGE_SIZE - 1;
2521
2522 page = __get_free_page(GFP_TEMPORARY);
2523 kbuf = (char *) page;
2524 if (!kbuf)
2525 return -ENOMEM;
2526 if (copy_from_user(kbuf, buffer, left)) {
2527 free_page(page);
2528 return -EFAULT;
2529 }
2530 kbuf[left] = 0;
2531
2532 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2533 GFP_KERNEL);
2534 if (!tmp_bitmap) {
2535 free_page(page);
2536 return -ENOMEM;
2537 }
2538 proc_skip_char(&kbuf, &left, '\n');
2539 while (!err && left) {
2540 unsigned long val_a, val_b;
2541 bool neg;
2542
2543 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2544 sizeof(tr_a), &c);
2545 if (err)
2546 break;
2547 if (val_a >= bitmap_len || neg) {
2548 err = -EINVAL;
2549 break;
2550 }
2551
2552 val_b = val_a;
2553 if (left) {
2554 kbuf++;
2555 left--;
2556 }
2557
2558 if (c == '-') {
2559 err = proc_get_long(&kbuf, &left, &val_b,
2560 &neg, tr_b, sizeof(tr_b),
2561 &c);
2562 if (err)
2563 break;
2564 if (val_b >= bitmap_len || neg ||
2565 val_a > val_b) {
2566 err = -EINVAL;
2567 break;
2568 }
2569 if (left) {
2570 kbuf++;
2571 left--;
2572 }
2573 }
2574
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002575 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002576 first = 0;
2577 proc_skip_char(&kbuf, &left, '\n');
2578 }
2579 free_page(page);
2580 } else {
2581 unsigned long bit_a, bit_b = 0;
2582
2583 while (left) {
2584 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2585 if (bit_a >= bitmap_len)
2586 break;
2587 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2588 bit_a + 1) - 1;
2589
2590 if (!first) {
2591 err = proc_put_char(&buffer, &left, ',');
2592 if (err)
2593 break;
2594 }
2595 err = proc_put_long(&buffer, &left, bit_a, false);
2596 if (err)
2597 break;
2598 if (bit_a != bit_b) {
2599 err = proc_put_char(&buffer, &left, '-');
2600 if (err)
2601 break;
2602 err = proc_put_long(&buffer, &left, bit_b, false);
2603 if (err)
2604 break;
2605 }
2606
2607 first = 0; bit_b++;
2608 }
2609 if (!err)
2610 err = proc_put_char(&buffer, &left, '\n');
2611 }
2612
2613 if (!err) {
2614 if (write) {
2615 if (*ppos)
2616 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2617 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002618 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002619 }
2620 kfree(tmp_bitmap);
2621 *lenp -= left;
2622 *ppos += *lenp;
2623 return 0;
2624 } else {
2625 kfree(tmp_bitmap);
2626 return err;
2627 }
2628}
2629
Jovi Zhang55610502011-01-12 17:00:45 -08002630#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002632int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 void __user *buffer, size_t *lenp, loff_t *ppos)
2634{
2635 return -ENOSYS;
2636}
2637
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002638int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 void __user *buffer, size_t *lenp, loff_t *ppos)
2640{
2641 return -ENOSYS;
2642}
2643
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002644int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 void __user *buffer, size_t *lenp, loff_t *ppos)
2646{
2647 return -ENOSYS;
2648}
2649
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002650int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 void __user *buffer, size_t *lenp, loff_t *ppos)
2652{
2653 return -ENOSYS;
2654}
2655
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002656int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 void __user *buffer, size_t *lenp, loff_t *ppos)
2658{
2659 return -ENOSYS;
2660}
2661
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002662int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663 void __user *buffer, size_t *lenp, loff_t *ppos)
2664{
2665 return -ENOSYS;
2666}
2667
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002668int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669 void __user *buffer, size_t *lenp, loff_t *ppos)
2670{
2671 return -ENOSYS;
2672}
2673
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002674int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 void __user *buffer,
2676 size_t *lenp, loff_t *ppos)
2677{
2678 return -ENOSYS;
2679}
2680
2681
Jovi Zhang55610502011-01-12 17:00:45 -08002682#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684/*
2685 * No sense putting this after each symbol definition, twice,
2686 * exception granted :-)
2687 */
2688EXPORT_SYMBOL(proc_dointvec);
2689EXPORT_SYMBOL(proc_dointvec_jiffies);
2690EXPORT_SYMBOL(proc_dointvec_minmax);
2691EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2692EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2693EXPORT_SYMBOL(proc_dostring);
2694EXPORT_SYMBOL(proc_doulongvec_minmax);
2695EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);