blob: 74f5b580fe34904fa4d9bcb2790545a323367773 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070026#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080027#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080028#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070030#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020032#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070033#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070034#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/init.h>
36#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010037#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030038#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/sysrq.h>
40#include <linux/highuid.h>
41#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020042#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070043#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070046#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/times.h>
48#include <linux/limits.h>
49#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020050#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070052#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080053#include <linux/nfs_fs.h>
54#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070055#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020056#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020057#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050058#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020059#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070060#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040061#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070062#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000063#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060064#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080065#include <linux/kexec.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67#include <asm/uaccess.h>
68#include <asm/processor.h>
69
Andi Kleen29cbc782006-09-30 01:47:55 +020070#ifdef CONFIG_X86
71#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010072#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010073#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020074#endif
David Howellsd550bbd2012-03-28 18:30:03 +010075#ifdef CONFIG_SPARC
76#include <asm/setup.h>
77#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080078#ifdef CONFIG_BSD_PROCESS_ACCT
79#include <linux/acct.h>
80#endif
Dave Young4f0e0562010-03-10 15:24:09 -080081#ifdef CONFIG_RT_MUTEXES
82#include <linux/rtmutex.h>
83#endif
Dave Young2edf5e42010-03-10 15:24:10 -080084#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
85#include <linux/lockdep.h>
86#endif
Dave Young15485a42010-03-10 15:24:07 -080087#ifdef CONFIG_CHR_DEV_SG
88#include <scsi/sg.h>
89#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020090
Don Zickus58687ac2010-05-07 17:11:44 -040091#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050092#include <linux/nmi.h>
93#endif
94
Eric W. Biederman7058cb02007-10-18 03:05:58 -070095
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#if defined(CONFIG_SYSCTL)
97
98/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700100extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700101#ifdef CONFIG_COREDUMP
102extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700104extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700105#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800108extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200109extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400111extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700129#ifdef CONFIG_PRINTK
130static int ten_thousand = 10000;
131#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700133/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
134static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
137static int maxolduid = 65535;
138static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800139static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700142static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Liu Hua80df2842014-04-07 15:38:57 -0700144/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
145#ifdef CONFIG_DETECT_HUNG_TASK
146static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
147#endif
148
Dave Youngd14f1722010-02-25 20:28:57 -0500149#ifdef CONFIG_INOTIFY_USER
150#include <linux/inotify.h>
151#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700152#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153#endif
154
David S. Miller08714202008-11-16 23:49:24 -0800155#ifdef CONFIG_SPARC64
156extern int sysctl_tsb_ratio;
157#endif
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#ifdef __hppa__
160extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530161#endif
162
163#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164extern int unaligned_enabled;
165#endif
166
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800168extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#endif
170
Vineet Guptab6fca722013-01-09 20:06:28 +0530171#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172extern int no_unaligned_warning;
173#endif
174
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700176static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700177 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700178static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800179 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700180#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700181
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700182#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700183static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700184 void __user *buffer, size_t *lenp, loff_t *ppos);
185#endif
186
Kees Cook54b50192012-07-30 14:39:18 -0700187static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
188 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700189#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700190static int proc_dostring_coredump(struct ctl_table *table, int write,
191 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700192#endif
Kees Cook54b50192012-07-30 14:39:18 -0700193
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700194#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800195/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100196static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700197
198static int sysrq_sysctl_handler(ctl_table *table, int write,
199 void __user *buffer, size_t *lenp,
200 loff_t *ppos)
201{
202 int error;
203
204 error = proc_dointvec(table, write, buffer, lenp, ppos);
205 if (error)
206 return error;
207
208 if (write)
209 sysrq_toggle_support(__sysrq_enabled);
210
211 return 0;
212}
213
214#endif
215
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700216static struct ctl_table kern_table[];
217static struct ctl_table vm_table[];
218static struct ctl_table fs_table[];
219static struct ctl_table debug_table[];
220static struct ctl_table dev_table[];
221extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800222#ifdef CONFIG_EPOLL
223extern struct ctl_table epoll_table[];
224#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
227int sysctl_legacy_va_layout;
228#endif
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230/* The default sysctl tables: */
231
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800232static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "kernel",
235 .mode = 0555,
236 .child = kern_table,
237 },
238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .procname = "vm",
240 .mode = 0555,
241 .child = vm_table,
242 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .procname = "fs",
245 .mode = 0555,
246 .child = fs_table,
247 },
248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .procname = "debug",
250 .mode = 0555,
251 .child = debug_table,
252 },
253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 .procname = "dev",
255 .mode = 0555,
256 .child = dev_table,
257 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700258 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259};
260
Ingo Molnar77e54a12007-07-09 18:52:00 +0200261#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100262static int min_sched_granularity_ns = 100000; /* 100 usecs */
263static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
264static int min_wakeup_granularity_ns; /* 0 usecs */
265static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200266#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100267static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
268static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200269#endif /* CONFIG_SMP */
270#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200271
Mel Gorman5e771902010-05-24 14:32:31 -0700272#ifdef CONFIG_COMPACTION
273static int min_extfrag_threshold;
274static int max_extfrag_threshold = 1000;
275#endif
276
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700277static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200278 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200279 .procname = "sched_child_runs_first",
280 .data = &sysctl_sched_child_runs_first,
281 .maxlen = sizeof(unsigned int),
282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800283 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200284 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285#ifdef CONFIG_SCHED_DEBUG
286 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100287 .procname = "sched_min_granularity_ns",
288 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289 .maxlen = sizeof(unsigned int),
290 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800291 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100292 .extra1 = &min_sched_granularity_ns,
293 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200294 },
295 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200296 .procname = "sched_latency_ns",
297 .data = &sysctl_sched_latency,
298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800300 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200301 .extra1 = &min_sched_granularity_ns,
302 .extra2 = &max_sched_granularity_ns,
303 },
304 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200305 .procname = "sched_wakeup_granularity_ns",
306 .data = &sysctl_sched_wakeup_granularity,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800309 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200310 .extra1 = &min_wakeup_granularity_ns,
311 .extra2 = &max_wakeup_granularity_ns,
312 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200313#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200314 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100315 .procname = "sched_tunable_scaling",
316 .data = &sysctl_sched_tunable_scaling,
317 .maxlen = sizeof(enum sched_tunable_scaling),
318 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800319 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100320 .extra1 = &min_sched_tunable_scaling,
321 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200322 },
323 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900324 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200325 .data = &sysctl_sched_migration_cost,
326 .maxlen = sizeof(unsigned int),
327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800328 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200329 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100330 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100331 .procname = "sched_nr_migrate",
332 .data = &sysctl_sched_nr_migrate,
333 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800335 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100336 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530337 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900338 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200339 .data = &sysctl_sched_time_avg,
340 .maxlen = sizeof(unsigned int),
341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800342 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200343 },
344 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900345 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800346 .data = &sysctl_sched_shares_window,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
349 .proc_handler = proc_dointvec,
350 },
351 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530352 .procname = "timer_migration",
353 .data = &sysctl_timer_migration,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800356 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530357 .extra1 = &zero,
358 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530359 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200360#endif /* CONFIG_SMP */
361#ifdef CONFIG_NUMA_BALANCING
362 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200363 .procname = "numa_balancing_scan_delay_ms",
364 .data = &sysctl_numa_balancing_scan_delay,
365 .maxlen = sizeof(unsigned int),
366 .mode = 0644,
367 .proc_handler = proc_dointvec,
368 },
369 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200370 .procname = "numa_balancing_scan_period_min_ms",
371 .data = &sysctl_numa_balancing_scan_period_min,
372 .maxlen = sizeof(unsigned int),
373 .mode = 0644,
374 .proc_handler = proc_dointvec,
375 },
376 {
377 .procname = "numa_balancing_scan_period_max_ms",
378 .data = &sysctl_numa_balancing_scan_period_max,
379 .maxlen = sizeof(unsigned int),
380 .mode = 0644,
381 .proc_handler = proc_dointvec,
382 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200383 {
384 .procname = "numa_balancing_scan_size_mb",
385 .data = &sysctl_numa_balancing_scan_size,
386 .maxlen = sizeof(unsigned int),
387 .mode = 0644,
388 .proc_handler = proc_dointvec,
389 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100390 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800391 .procname = "numa_balancing",
392 .data = NULL, /* filled in by handler */
393 .maxlen = sizeof(unsigned int),
394 .mode = 0644,
395 .proc_handler = sysctl_numa_balancing,
396 .extra1 = &zero,
397 .extra2 = &one,
398 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200399#endif /* CONFIG_NUMA_BALANCING */
400#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200401 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100402 .procname = "sched_rt_period_us",
403 .data = &sysctl_sched_rt_period,
404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800406 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100407 },
408 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100409 .procname = "sched_rt_runtime_us",
410 .data = &sysctl_sched_rt_runtime,
411 .maxlen = sizeof(int),
412 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800413 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100414 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600415 {
416 .procname = "sched_rr_timeslice_ms",
417 .data = &sched_rr_timeslice,
418 .maxlen = sizeof(int),
419 .mode = 0644,
420 .proc_handler = sched_rr_handler,
421 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100422#ifdef CONFIG_SCHED_AUTOGROUP
423 {
424 .procname = "sched_autogroup_enabled",
425 .data = &sysctl_sched_autogroup_enabled,
426 .maxlen = sizeof(unsigned int),
427 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800428 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100429 .extra1 = &zero,
430 .extra2 = &one,
431 },
432#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700433#ifdef CONFIG_CFS_BANDWIDTH
434 {
435 .procname = "sched_cfs_bandwidth_slice_us",
436 .data = &sysctl_sched_cfs_bandwidth_slice,
437 .maxlen = sizeof(unsigned int),
438 .mode = 0644,
439 .proc_handler = proc_dointvec_minmax,
440 .extra1 = &one,
441 },
442#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700443#ifdef CONFIG_PROVE_LOCKING
444 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700445 .procname = "prove_locking",
446 .data = &prove_locking,
447 .maxlen = sizeof(int),
448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800449 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700450 },
451#endif
452#ifdef CONFIG_LOCK_STAT
453 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454 .procname = "lock_stat",
455 .data = &lock_stat,
456 .maxlen = sizeof(int),
457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800458 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700459 },
460#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "panic",
463 .data = &panic_timeout,
464 .maxlen = sizeof(int),
465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
Alex Kelly046d6622012-10-04 17:15:23 -0700468#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 .procname = "core_uses_pid",
471 .data = &core_uses_pid,
472 .maxlen = sizeof(int),
473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800474 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 },
476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 .procname = "core_pattern",
478 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700479 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700481 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 },
Neil Hormana2939802009-09-23 15:56:56 -0700483 {
Neil Hormana2939802009-09-23 15:56:56 -0700484 .procname = "core_pipe_limit",
485 .data = &core_pipe_limit,
486 .maxlen = sizeof(unsigned int),
487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800488 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700489 },
Alex Kelly046d6622012-10-04 17:15:23 -0700490#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800491#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700494 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800496 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800498#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100499#ifdef CONFIG_LATENCYTOP
500 {
501 .procname = "latencytop",
502 .data = &latencytop_enabled,
503 .maxlen = sizeof(int),
504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100506 },
507#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508#ifdef CONFIG_BLK_DEV_INITRD
509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "real-root-dev",
511 .data = &real_root_dev,
512 .maxlen = sizeof(int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 },
516#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700517 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700518 .procname = "print-fatal-signals",
519 .data = &print_fatal_signals,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700523 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700524#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 .procname = "reboot-cmd",
527 .data = reboot_command,
528 .maxlen = 256,
529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800530 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 },
532 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 .procname = "stop-a",
534 .data = &stop_a_enabled,
535 .maxlen = sizeof (int),
536 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800537 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 },
539 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 .procname = "scons-poweroff",
541 .data = &scons_pwroff,
542 .maxlen = sizeof (int),
543 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800544 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 },
546#endif
David S. Miller08714202008-11-16 23:49:24 -0800547#ifdef CONFIG_SPARC64
548 {
David S. Miller08714202008-11-16 23:49:24 -0800549 .procname = "tsb-ratio",
550 .data = &sysctl_tsb_ratio,
551 .maxlen = sizeof (int),
552 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800553 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800554 },
555#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556#ifdef __hppa__
557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .procname = "soft-power",
559 .data = &pwrsw_enabled,
560 .maxlen = sizeof (int),
561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530564#endif
565#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .procname = "unaligned-trap",
568 .data = &unaligned_enabled,
569 .maxlen = sizeof (int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
573#endif
574 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .procname = "ctrl-alt-del",
576 .data = &C_A_D,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400581#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200582 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200583 .procname = "ftrace_enabled",
584 .data = &ftrace_enabled,
585 .maxlen = sizeof(int),
586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800587 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200588 },
589#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500590#ifdef CONFIG_STACK_TRACER
591 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500592 .procname = "stack_tracer_enabled",
593 .data = &stack_tracer_enabled,
594 .maxlen = sizeof(int),
595 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800596 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500597 },
598#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400599#ifdef CONFIG_TRACING
600 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100601 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400602 .data = &ftrace_dump_on_oops,
603 .maxlen = sizeof(int),
604 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800605 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400606 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400607 {
608 .procname = "traceoff_on_warning",
609 .data = &__disable_trace_on_warning,
610 .maxlen = sizeof(__disable_trace_on_warning),
611 .mode = 0644,
612 .proc_handler = proc_dointvec,
613 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400614#endif
Kees Cook79847542014-01-23 15:55:59 -0800615#ifdef CONFIG_KEXEC
616 {
617 .procname = "kexec_load_disabled",
618 .data = &kexec_load_disabled,
619 .maxlen = sizeof(int),
620 .mode = 0644,
621 /* only handle a transition from default "0" to "1" */
622 .proc_handler = proc_dointvec_minmax,
623 .extra1 = &one,
624 .extra2 = &one,
625 },
626#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200627#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 .procname = "modprobe",
630 .data = &modprobe_path,
631 .maxlen = KMOD_PATH_LEN,
632 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800633 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 },
Kees Cook3d433212009-04-02 15:49:29 -0700635 {
Kees Cook3d433212009-04-02 15:49:29 -0700636 .procname = "modules_disabled",
637 .data = &modules_disabled,
638 .maxlen = sizeof(int),
639 .mode = 0644,
640 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700642 .extra1 = &one,
643 .extra2 = &one,
644 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500646
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 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500654
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",
1421 .data = &vdso_enabled,
1422 .maxlen = sizeof(vdso_enabled),
1423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001424 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001425 .extra1 = &zero,
1426 },
1427#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001428#ifdef CONFIG_HIGHMEM
1429 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001430 .procname = "highmem_is_dirtyable",
1431 .data = &vm_highmem_is_dirtyable,
1432 .maxlen = sizeof(vm_highmem_is_dirtyable),
1433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001434 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001435 .extra1 = &zero,
1436 .extra2 = &one,
1437 },
1438#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001439 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001440 .procname = "scan_unevictable_pages",
1441 .data = &scan_unevictable_pages,
1442 .maxlen = sizeof(scan_unevictable_pages),
1443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001444 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001445 },
Andi Kleen6a460792009-09-16 11:50:15 +02001446#ifdef CONFIG_MEMORY_FAILURE
1447 {
Andi Kleen6a460792009-09-16 11:50:15 +02001448 .procname = "memory_failure_early_kill",
1449 .data = &sysctl_memory_failure_early_kill,
1450 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001452 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001453 .extra1 = &zero,
1454 .extra2 = &one,
1455 },
1456 {
Andi Kleen6a460792009-09-16 11:50:15 +02001457 .procname = "memory_failure_recovery",
1458 .data = &sysctl_memory_failure_recovery,
1459 .maxlen = sizeof(sysctl_memory_failure_recovery),
1460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001461 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001462 .extra1 = &zero,
1463 .extra2 = &one,
1464 },
1465#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001466 {
1467 .procname = "user_reserve_kbytes",
1468 .data = &sysctl_user_reserve_kbytes,
1469 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1470 .mode = 0644,
1471 .proc_handler = proc_doulongvec_minmax,
1472 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001473 {
1474 .procname = "admin_reserve_kbytes",
1475 .data = &sysctl_admin_reserve_kbytes,
1476 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1477 .mode = 0644,
1478 .proc_handler = proc_doulongvec_minmax,
1479 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001480 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481};
1482
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001483#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001484static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001485 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001486};
1487#endif
1488
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001489static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .procname = "inode-nr",
1492 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001493 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001495 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 },
1497 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .procname = "inode-state",
1499 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001500 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001502 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 },
1504 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 .procname = "file-nr",
1506 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001507 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001509 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 },
1511 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 .procname = "file-max",
1513 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001514 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001516 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 },
1518 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001519 .procname = "nr_open",
1520 .data = &sysctl_nr_open,
1521 .maxlen = sizeof(int),
1522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001524 .extra1 = &sysctl_nr_open_min,
1525 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001526 },
1527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .procname = "dentry-state",
1529 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001530 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001532 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 },
1534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 .procname = "overflowuid",
1536 .data = &fs_overflowuid,
1537 .maxlen = sizeof(int),
1538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001539 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 .extra1 = &minolduid,
1541 .extra2 = &maxolduid,
1542 },
1543 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 .procname = "overflowgid",
1545 .data = &fs_overflowgid,
1546 .maxlen = sizeof(int),
1547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001548 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .extra1 = &minolduid,
1550 .extra2 = &maxolduid,
1551 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001552#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 .procname = "leases-enable",
1555 .data = &leases_enable,
1556 .maxlen = sizeof(int),
1557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001558 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001560#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561#ifdef CONFIG_DNOTIFY
1562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 .procname = "dir-notify-enable",
1564 .data = &dir_notify_enable,
1565 .maxlen = sizeof(int),
1566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 },
1569#endif
1570#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001571#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 .procname = "lease-break-time",
1574 .data = &lease_break_time,
1575 .maxlen = sizeof(int),
1576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001577 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001579#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001580#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 .procname = "aio-nr",
1583 .data = &aio_nr,
1584 .maxlen = sizeof(aio_nr),
1585 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001586 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 },
1588 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 .procname = "aio-max-nr",
1590 .data = &aio_max_nr,
1591 .maxlen = sizeof(aio_max_nr),
1592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001593 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001595#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001596#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001597 {
Robert Love0399cb02005-07-13 12:38:18 -04001598 .procname = "inotify",
1599 .mode = 0555,
1600 .child = inotify_table,
1601 },
1602#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001603#ifdef CONFIG_EPOLL
1604 {
1605 .procname = "epoll",
1606 .mode = 0555,
1607 .child = epoll_table,
1608 },
1609#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001611 {
Kees Cook800179c2012-07-25 17:29:07 -07001612 .procname = "protected_symlinks",
1613 .data = &sysctl_protected_symlinks,
1614 .maxlen = sizeof(int),
1615 .mode = 0600,
1616 .proc_handler = proc_dointvec_minmax,
1617 .extra1 = &zero,
1618 .extra2 = &one,
1619 },
1620 {
1621 .procname = "protected_hardlinks",
1622 .data = &sysctl_protected_hardlinks,
1623 .maxlen = sizeof(int),
1624 .mode = 0600,
1625 .proc_handler = proc_dointvec_minmax,
1626 .extra1 = &zero,
1627 .extra2 = &one,
1628 },
1629 {
Alan Coxd6e71142005-06-23 00:09:43 -07001630 .procname = "suid_dumpable",
1631 .data = &suid_dumpable,
1632 .maxlen = sizeof(int),
1633 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001634 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001635 .extra1 = &zero,
1636 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001637 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001638#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1639 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001640 .procname = "binfmt_misc",
1641 .mode = 0555,
1642 .child = binfmt_misc_table,
1643 },
1644#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001645 {
Jens Axboeff9da692010-06-03 14:54:39 +02001646 .procname = "pipe-max-size",
1647 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001648 .maxlen = sizeof(int),
1649 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001650 .proc_handler = &pipe_proc_fn,
1651 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001652 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001653 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654};
1655
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001656static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001657#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001658 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001659 .procname = "exception-trace",
1660 .data = &show_unhandled_signals,
1661 .maxlen = sizeof(int),
1662 .mode = 0644,
1663 .proc_handler = proc_dointvec
1664 },
1665#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001666#if defined(CONFIG_OPTPROBES)
1667 {
1668 .procname = "kprobes-optimization",
1669 .data = &sysctl_kprobes_optimization,
1670 .maxlen = sizeof(int),
1671 .mode = 0644,
1672 .proc_handler = proc_kprobes_optimization_handler,
1673 .extra1 = &zero,
1674 .extra2 = &one,
1675 },
1676#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001677 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678};
1679
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001680static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001681 { }
Robert Love0eeca282005-07-12 17:06:03 -04001682};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001684int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001685{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001686 struct ctl_table_header *hdr;
1687
1688 hdr = register_sysctl_table(sysctl_base_table);
1689 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001690 return 0;
1691}
1692
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001693#endif /* CONFIG_SYSCTL */
1694
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695/*
1696 * /proc/sys support
1697 */
1698
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001699#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001701static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001702 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001703 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001704{
1705 size_t len;
1706 char __user *p;
1707 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001708
1709 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001710 *lenp = 0;
1711 return 0;
1712 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001713
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001714 if (write) {
1715 len = 0;
1716 p = buffer;
1717 while (len < *lenp) {
1718 if (get_user(c, p++))
1719 return -EFAULT;
1720 if (c == 0 || c == '\n')
1721 break;
1722 len++;
1723 }
1724 if (len >= maxlen)
1725 len = maxlen-1;
1726 if(copy_from_user(data, buffer, len))
1727 return -EFAULT;
1728 ((char *) data)[len] = 0;
1729 *ppos += *lenp;
1730 } else {
1731 len = strlen(data);
1732 if (len > maxlen)
1733 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001734
1735 if (*ppos > len) {
1736 *lenp = 0;
1737 return 0;
1738 }
1739
1740 data += *ppos;
1741 len -= *ppos;
1742
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001743 if (len > *lenp)
1744 len = *lenp;
1745 if (len)
1746 if(copy_to_user(buffer, data, len))
1747 return -EFAULT;
1748 if (len < *lenp) {
1749 if(put_user('\n', ((char __user *) buffer) + len))
1750 return -EFAULT;
1751 len++;
1752 }
1753 *lenp = len;
1754 *ppos += len;
1755 }
1756 return 0;
1757}
1758
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759/**
1760 * proc_dostring - read a string sysctl
1761 * @table: the sysctl table
1762 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763 * @buffer: the user buffer
1764 * @lenp: the size of the user buffer
1765 * @ppos: file position
1766 *
1767 * Reads/writes a string from/to the user buffer. If the kernel
1768 * buffer provided is not large enough to hold the string, the
1769 * string is truncated. The copied string is %NULL-terminated.
1770 * If the string is being read by the user process, it is copied
1771 * and a newline '\n' is added. It is truncated if the buffer is
1772 * not large enough.
1773 *
1774 * Returns 0 on success.
1775 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001776int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001777 void __user *buffer, size_t *lenp, loff_t *ppos)
1778{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001779 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001780 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781}
1782
Amerigo Wang00b7c332010-05-05 00:26:45 +00001783static size_t proc_skip_spaces(char **buf)
1784{
1785 size_t ret;
1786 char *tmp = skip_spaces(*buf);
1787 ret = tmp - *buf;
1788 *buf = tmp;
1789 return ret;
1790}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001791
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001792static void proc_skip_char(char **buf, size_t *size, const char v)
1793{
1794 while (*size) {
1795 if (**buf != v)
1796 break;
1797 (*size)--;
1798 (*buf)++;
1799 }
1800}
1801
Amerigo Wang00b7c332010-05-05 00:26:45 +00001802#define TMPBUFLEN 22
1803/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001804 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001805 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001806 * @buf: a kernel buffer
1807 * @size: size of the kernel buffer
1808 * @val: this is where the number will be stored
1809 * @neg: set to %TRUE if number is negative
1810 * @perm_tr: a vector which contains the allowed trailers
1811 * @perm_tr_len: size of the perm_tr vector
1812 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001813 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001814 * In case of success %0 is returned and @buf and @size are updated with
1815 * the amount of bytes read. If @tr is non-NULL and a trailing
1816 * character exists (size is non-zero after returning from this
1817 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001818 */
1819static int proc_get_long(char **buf, size_t *size,
1820 unsigned long *val, bool *neg,
1821 const char *perm_tr, unsigned perm_tr_len, char *tr)
1822{
1823 int len;
1824 char *p, tmp[TMPBUFLEN];
1825
1826 if (!*size)
1827 return -EINVAL;
1828
1829 len = *size;
1830 if (len > TMPBUFLEN - 1)
1831 len = TMPBUFLEN - 1;
1832
1833 memcpy(tmp, *buf, len);
1834
1835 tmp[len] = 0;
1836 p = tmp;
1837 if (*p == '-' && *size > 1) {
1838 *neg = true;
1839 p++;
1840 } else
1841 *neg = false;
1842 if (!isdigit(*p))
1843 return -EINVAL;
1844
1845 *val = simple_strtoul(p, &p, 0);
1846
1847 len = p - tmp;
1848
1849 /* We don't know if the next char is whitespace thus we may accept
1850 * invalid integers (e.g. 1234...a) or two integers instead of one
1851 * (e.g. 123...1). So lets not allow such large numbers. */
1852 if (len == TMPBUFLEN - 1)
1853 return -EINVAL;
1854
1855 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1856 return -EINVAL;
1857
1858 if (tr && (len < *size))
1859 *tr = *p;
1860
1861 *buf += len;
1862 *size -= len;
1863
1864 return 0;
1865}
1866
1867/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001868 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001869 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001870 * @buf: the user buffer
1871 * @size: the size of the user buffer
1872 * @val: the integer to be converted
1873 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001874 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001875 * In case of success %0 is returned and @buf and @size are updated with
1876 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001877 */
1878static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1879 bool neg)
1880{
1881 int len;
1882 char tmp[TMPBUFLEN], *p = tmp;
1883
1884 sprintf(p, "%s%lu", neg ? "-" : "", val);
1885 len = strlen(tmp);
1886 if (len > *size)
1887 len = *size;
1888 if (copy_to_user(*buf, tmp, len))
1889 return -EFAULT;
1890 *size -= len;
1891 *buf += len;
1892 return 0;
1893}
1894#undef TMPBUFLEN
1895
1896static int proc_put_char(void __user **buf, size_t *size, char c)
1897{
1898 if (*size) {
1899 char __user **buffer = (char __user **)buf;
1900 if (put_user(c, *buffer))
1901 return -EFAULT;
1902 (*size)--, (*buffer)++;
1903 *buf = *buffer;
1904 }
1905 return 0;
1906}
1907
1908static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001909 int *valp,
1910 int write, void *data)
1911{
1912 if (write) {
1913 *valp = *negp ? -*lvalp : *lvalp;
1914 } else {
1915 int val = *valp;
1916 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001917 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 *lvalp = (unsigned long)-val;
1919 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001920 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921 *lvalp = (unsigned long)val;
1922 }
1923 }
1924 return 0;
1925}
1926
Amerigo Wang00b7c332010-05-05 00:26:45 +00001927static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1928
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001929static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001930 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001931 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001932 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 int write, void *data),
1934 void *data)
1935{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001936 int *i, vleft, first = 1, err = 0;
1937 unsigned long page = 0;
1938 size_t left;
1939 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940
Amerigo Wang00b7c332010-05-05 00:26:45 +00001941 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942 *lenp = 0;
1943 return 0;
1944 }
1945
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001946 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947 vleft = table->maxlen / sizeof(*i);
1948 left = *lenp;
1949
1950 if (!conv)
1951 conv = do_proc_dointvec_conv;
1952
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001954 if (left > PAGE_SIZE - 1)
1955 left = PAGE_SIZE - 1;
1956 page = __get_free_page(GFP_TEMPORARY);
1957 kbuf = (char *) page;
1958 if (!kbuf)
1959 return -ENOMEM;
1960 if (copy_from_user(kbuf, buffer, left)) {
1961 err = -EFAULT;
1962 goto free;
1963 }
1964 kbuf[left] = 0;
1965 }
1966
1967 for (; left && vleft--; i++, first=0) {
1968 unsigned long lval;
1969 bool neg;
1970
1971 if (write) {
1972 left -= proc_skip_spaces(&kbuf);
1973
J. R. Okajima563b0462010-05-25 16:10:14 -07001974 if (!left)
1975 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001976 err = proc_get_long(&kbuf, &left, &lval, &neg,
1977 proc_wspace_sep,
1978 sizeof(proc_wspace_sep), NULL);
1979 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001980 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001981 if (conv(&neg, &lval, i, 1, data)) {
1982 err = -EINVAL;
1983 break;
1984 }
1985 } else {
1986 if (conv(&neg, &lval, i, 0, data)) {
1987 err = -EINVAL;
1988 break;
1989 }
1990 if (!first)
1991 err = proc_put_char(&buffer, &left, '\t');
1992 if (err)
1993 break;
1994 err = proc_put_long(&buffer, &left, lval, neg);
1995 if (err)
1996 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997 }
1998 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001999
2000 if (!write && !first && left && !err)
2001 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002002 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002003 left -= proc_skip_spaces(&kbuf);
2004free:
2005 if (write) {
2006 free_page(page);
2007 if (first)
2008 return err ? : -EINVAL;
2009 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010 *lenp -= left;
2011 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002012 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013}
2014
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002015static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002016 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002017 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002018 int write, void *data),
2019 void *data)
2020{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002021 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002022 buffer, lenp, ppos, conv, data);
2023}
2024
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025/**
2026 * proc_dointvec - read a vector of integers
2027 * @table: the sysctl table
2028 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029 * @buffer: the user buffer
2030 * @lenp: the size of the user buffer
2031 * @ppos: file position
2032 *
2033 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2034 * values from/to the user buffer, treated as an ASCII string.
2035 *
2036 * Returns 0 on success.
2037 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002038int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 void __user *buffer, size_t *lenp, loff_t *ppos)
2040{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002041 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042 NULL,NULL);
2043}
2044
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002045/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002046 * Taint values can only be increased
2047 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002048 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002049static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002050 void __user *buffer, size_t *lenp, loff_t *ppos)
2051{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002052 struct ctl_table t;
2053 unsigned long tmptaint = get_taint();
2054 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002055
Bastian Blank91fcd412007-04-23 14:41:14 -07002056 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002057 return -EPERM;
2058
Andi Kleen25ddbb12008-10-15 22:01:41 -07002059 t = *table;
2060 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002061 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002062 if (err < 0)
2063 return err;
2064
2065 if (write) {
2066 /*
2067 * Poor man's atomic or. Not worth adding a primitive
2068 * to everyone's atomic.h for this
2069 */
2070 int i;
2071 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2072 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302073 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002074 }
2075 }
2076
2077 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002078}
2079
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002080#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002081static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002082 void __user *buffer, size_t *lenp, loff_t *ppos)
2083{
2084 if (write && !capable(CAP_SYS_ADMIN))
2085 return -EPERM;
2086
2087 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2088}
2089#endif
2090
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091struct do_proc_dointvec_minmax_conv_param {
2092 int *min;
2093 int *max;
2094};
2095
Amerigo Wang00b7c332010-05-05 00:26:45 +00002096static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2097 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 int write, void *data)
2099{
2100 struct do_proc_dointvec_minmax_conv_param *param = data;
2101 if (write) {
2102 int val = *negp ? -*lvalp : *lvalp;
2103 if ((param->min && *param->min > val) ||
2104 (param->max && *param->max < val))
2105 return -EINVAL;
2106 *valp = val;
2107 } else {
2108 int val = *valp;
2109 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002110 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111 *lvalp = (unsigned long)-val;
2112 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002113 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114 *lvalp = (unsigned long)val;
2115 }
2116 }
2117 return 0;
2118}
2119
2120/**
2121 * proc_dointvec_minmax - read a vector of integers with min/max values
2122 * @table: the sysctl table
2123 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124 * @buffer: the user buffer
2125 * @lenp: the size of the user buffer
2126 * @ppos: file position
2127 *
2128 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2129 * values from/to the user buffer, treated as an ASCII string.
2130 *
2131 * This routine will ensure the values are within the range specified by
2132 * table->extra1 (min) and table->extra2 (max).
2133 *
2134 * Returns 0 on success.
2135 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002136int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 void __user *buffer, size_t *lenp, loff_t *ppos)
2138{
2139 struct do_proc_dointvec_minmax_conv_param param = {
2140 .min = (int *) table->extra1,
2141 .max = (int *) table->extra2,
2142 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002143 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 do_proc_dointvec_minmax_conv, &param);
2145}
2146
Kees Cook54b50192012-07-30 14:39:18 -07002147static void validate_coredump_safety(void)
2148{
Alex Kelly046d6622012-10-04 17:15:23 -07002149#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002150 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002151 core_pattern[0] != '/' && core_pattern[0] != '|') {
2152 printk(KERN_WARNING "Unsafe core_pattern used with "\
2153 "suid_dumpable=2. Pipe handler or fully qualified "\
2154 "core dump path required.\n");
2155 }
Alex Kelly046d6622012-10-04 17:15:23 -07002156#endif
Kees Cook54b50192012-07-30 14:39:18 -07002157}
2158
2159static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2160 void __user *buffer, size_t *lenp, loff_t *ppos)
2161{
2162 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2163 if (!error)
2164 validate_coredump_safety();
2165 return error;
2166}
2167
Alex Kelly046d6622012-10-04 17:15:23 -07002168#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002169static int proc_dostring_coredump(struct ctl_table *table, int write,
2170 void __user *buffer, size_t *lenp, loff_t *ppos)
2171{
2172 int error = proc_dostring(table, write, buffer, lenp, ppos);
2173 if (!error)
2174 validate_coredump_safety();
2175 return error;
2176}
Alex Kelly046d6622012-10-04 17:15:23 -07002177#endif
Kees Cook54b50192012-07-30 14:39:18 -07002178
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002179static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 void __user *buffer,
2181 size_t *lenp, loff_t *ppos,
2182 unsigned long convmul,
2183 unsigned long convdiv)
2184{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 unsigned long *i, *min, *max;
2186 int vleft, first = 1, err = 0;
2187 unsigned long page = 0;
2188 size_t left;
2189 char *kbuf;
2190
2191 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192 *lenp = 0;
2193 return 0;
2194 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002196 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 min = (unsigned long *) table->extra1;
2198 max = (unsigned long *) table->extra2;
2199 vleft = table->maxlen / sizeof(unsigned long);
2200 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002201
2202 if (write) {
2203 if (left > PAGE_SIZE - 1)
2204 left = PAGE_SIZE - 1;
2205 page = __get_free_page(GFP_TEMPORARY);
2206 kbuf = (char *) page;
2207 if (!kbuf)
2208 return -ENOMEM;
2209 if (copy_from_user(kbuf, buffer, left)) {
2210 err = -EFAULT;
2211 goto free;
2212 }
2213 kbuf[left] = 0;
2214 }
2215
Eric Dumazet27b3d802010-10-07 12:59:29 -07002216 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002217 unsigned long val;
2218
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002220 bool neg;
2221
2222 left -= proc_skip_spaces(&kbuf);
2223
2224 err = proc_get_long(&kbuf, &left, &val, &neg,
2225 proc_wspace_sep,
2226 sizeof(proc_wspace_sep), NULL);
2227 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 break;
2229 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 continue;
2231 if ((min && val < *min) || (max && val > *max))
2232 continue;
2233 *i = val;
2234 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002235 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002236 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002237 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002238 if (err)
2239 break;
2240 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002241 err = proc_put_long(&buffer, &left, val, false);
2242 if (err)
2243 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 }
2245 }
2246
Amerigo Wang00b7c332010-05-05 00:26:45 +00002247 if (!write && !first && left && !err)
2248 err = proc_put_char(&buffer, &left, '\n');
2249 if (write && !err)
2250 left -= proc_skip_spaces(&kbuf);
2251free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002253 free_page(page);
2254 if (first)
2255 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 *lenp -= left;
2258 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002259 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260}
2261
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002262static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002263 void __user *buffer,
2264 size_t *lenp, loff_t *ppos,
2265 unsigned long convmul,
2266 unsigned long convdiv)
2267{
2268 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002269 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002270}
2271
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272/**
2273 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2274 * @table: the sysctl table
2275 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276 * @buffer: the user buffer
2277 * @lenp: the size of the user buffer
2278 * @ppos: file position
2279 *
2280 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2281 * values from/to the user buffer, treated as an ASCII string.
2282 *
2283 * This routine will ensure the values are within the range specified by
2284 * table->extra1 (min) and table->extra2 (max).
2285 *
2286 * Returns 0 on success.
2287 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002288int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 void __user *buffer, size_t *lenp, loff_t *ppos)
2290{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002291 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292}
2293
2294/**
2295 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2296 * @table: the sysctl table
2297 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 * @buffer: the user buffer
2299 * @lenp: the size of the user buffer
2300 * @ppos: file position
2301 *
2302 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2303 * values from/to the user buffer, treated as an ASCII string. The values
2304 * are treated as milliseconds, and converted to jiffies when they are stored.
2305 *
2306 * This routine will ensure the values are within the range specified by
2307 * table->extra1 (min) and table->extra2 (max).
2308 *
2309 * Returns 0 on success.
2310 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002311int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 void __user *buffer,
2313 size_t *lenp, loff_t *ppos)
2314{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002315 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 lenp, ppos, HZ, 1000l);
2317}
2318
2319
Amerigo Wang00b7c332010-05-05 00:26:45 +00002320static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 int *valp,
2322 int write, void *data)
2323{
2324 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002325 if (*lvalp > LONG_MAX / HZ)
2326 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2328 } else {
2329 int val = *valp;
2330 unsigned long lval;
2331 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002332 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 lval = (unsigned long)-val;
2334 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 lval = (unsigned long)val;
2337 }
2338 *lvalp = lval / HZ;
2339 }
2340 return 0;
2341}
2342
Amerigo Wang00b7c332010-05-05 00:26:45 +00002343static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 int *valp,
2345 int write, void *data)
2346{
2347 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002348 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2349 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2351 } else {
2352 int val = *valp;
2353 unsigned long lval;
2354 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002355 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 lval = (unsigned long)-val;
2357 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002358 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359 lval = (unsigned long)val;
2360 }
2361 *lvalp = jiffies_to_clock_t(lval);
2362 }
2363 return 0;
2364}
2365
Amerigo Wang00b7c332010-05-05 00:26:45 +00002366static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 int *valp,
2368 int write, void *data)
2369{
2370 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002371 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2372
2373 if (jif > INT_MAX)
2374 return 1;
2375 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 } else {
2377 int val = *valp;
2378 unsigned long lval;
2379 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002380 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 lval = (unsigned long)-val;
2382 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002383 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 lval = (unsigned long)val;
2385 }
2386 *lvalp = jiffies_to_msecs(lval);
2387 }
2388 return 0;
2389}
2390
2391/**
2392 * proc_dointvec_jiffies - read a vector of integers as seconds
2393 * @table: the sysctl table
2394 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 * @buffer: the user buffer
2396 * @lenp: the size of the user buffer
2397 * @ppos: file position
2398 *
2399 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2400 * values from/to the user buffer, treated as an ASCII string.
2401 * The values read are assumed to be in seconds, and are converted into
2402 * jiffies.
2403 *
2404 * Returns 0 on success.
2405 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002406int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 void __user *buffer, size_t *lenp, loff_t *ppos)
2408{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002409 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410 do_proc_dointvec_jiffies_conv,NULL);
2411}
2412
2413/**
2414 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2415 * @table: the sysctl table
2416 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 * @buffer: the user buffer
2418 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002419 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 *
2421 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2422 * values from/to the user buffer, treated as an ASCII string.
2423 * The values read are assumed to be in 1/USER_HZ seconds, and
2424 * are converted into jiffies.
2425 *
2426 * Returns 0 on success.
2427 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002428int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 void __user *buffer, size_t *lenp, loff_t *ppos)
2430{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002431 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 do_proc_dointvec_userhz_jiffies_conv,NULL);
2433}
2434
2435/**
2436 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2437 * @table: the sysctl table
2438 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 * @buffer: the user buffer
2440 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002441 * @ppos: file position
2442 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002443 *
2444 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2445 * values from/to the user buffer, treated as an ASCII string.
2446 * The values read are assumed to be in 1/1000 seconds, and
2447 * are converted into jiffies.
2448 *
2449 * Returns 0 on success.
2450 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002451int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 void __user *buffer, size_t *lenp, loff_t *ppos)
2453{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002454 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455 do_proc_dointvec_ms_jiffies_conv, NULL);
2456}
2457
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002458static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002459 void __user *buffer, size_t *lenp, loff_t *ppos)
2460{
2461 struct pid *new_pid;
2462 pid_t tmp;
2463 int r;
2464
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002465 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002466
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002467 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002468 lenp, ppos, NULL, NULL);
2469 if (r || !write)
2470 return r;
2471
2472 new_pid = find_get_pid(tmp);
2473 if (!new_pid)
2474 return -ESRCH;
2475
2476 put_pid(xchg(&cad_pid, new_pid));
2477 return 0;
2478}
2479
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002480/**
2481 * proc_do_large_bitmap - read/write from/to a large bitmap
2482 * @table: the sysctl table
2483 * @write: %TRUE if this is a write to the sysctl file
2484 * @buffer: the user buffer
2485 * @lenp: the size of the user buffer
2486 * @ppos: file position
2487 *
2488 * The bitmap is stored at table->data and the bitmap length (in bits)
2489 * in table->maxlen.
2490 *
2491 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2492 * large bitmaps may be represented in a compact manner. Writing into
2493 * the file will clear the bitmap then update it with the given input.
2494 *
2495 * Returns 0 on success.
2496 */
2497int proc_do_large_bitmap(struct ctl_table *table, int write,
2498 void __user *buffer, size_t *lenp, loff_t *ppos)
2499{
2500 int err = 0;
2501 bool first = 1;
2502 size_t left = *lenp;
2503 unsigned long bitmap_len = table->maxlen;
2504 unsigned long *bitmap = (unsigned long *) table->data;
2505 unsigned long *tmp_bitmap = NULL;
2506 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2507
2508 if (!bitmap_len || !left || (*ppos && !write)) {
2509 *lenp = 0;
2510 return 0;
2511 }
2512
2513 if (write) {
2514 unsigned long page = 0;
2515 char *kbuf;
2516
2517 if (left > PAGE_SIZE - 1)
2518 left = PAGE_SIZE - 1;
2519
2520 page = __get_free_page(GFP_TEMPORARY);
2521 kbuf = (char *) page;
2522 if (!kbuf)
2523 return -ENOMEM;
2524 if (copy_from_user(kbuf, buffer, left)) {
2525 free_page(page);
2526 return -EFAULT;
2527 }
2528 kbuf[left] = 0;
2529
2530 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2531 GFP_KERNEL);
2532 if (!tmp_bitmap) {
2533 free_page(page);
2534 return -ENOMEM;
2535 }
2536 proc_skip_char(&kbuf, &left, '\n');
2537 while (!err && left) {
2538 unsigned long val_a, val_b;
2539 bool neg;
2540
2541 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2542 sizeof(tr_a), &c);
2543 if (err)
2544 break;
2545 if (val_a >= bitmap_len || neg) {
2546 err = -EINVAL;
2547 break;
2548 }
2549
2550 val_b = val_a;
2551 if (left) {
2552 kbuf++;
2553 left--;
2554 }
2555
2556 if (c == '-') {
2557 err = proc_get_long(&kbuf, &left, &val_b,
2558 &neg, tr_b, sizeof(tr_b),
2559 &c);
2560 if (err)
2561 break;
2562 if (val_b >= bitmap_len || neg ||
2563 val_a > val_b) {
2564 err = -EINVAL;
2565 break;
2566 }
2567 if (left) {
2568 kbuf++;
2569 left--;
2570 }
2571 }
2572
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002573 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002574 first = 0;
2575 proc_skip_char(&kbuf, &left, '\n');
2576 }
2577 free_page(page);
2578 } else {
2579 unsigned long bit_a, bit_b = 0;
2580
2581 while (left) {
2582 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2583 if (bit_a >= bitmap_len)
2584 break;
2585 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2586 bit_a + 1) - 1;
2587
2588 if (!first) {
2589 err = proc_put_char(&buffer, &left, ',');
2590 if (err)
2591 break;
2592 }
2593 err = proc_put_long(&buffer, &left, bit_a, false);
2594 if (err)
2595 break;
2596 if (bit_a != bit_b) {
2597 err = proc_put_char(&buffer, &left, '-');
2598 if (err)
2599 break;
2600 err = proc_put_long(&buffer, &left, bit_b, false);
2601 if (err)
2602 break;
2603 }
2604
2605 first = 0; bit_b++;
2606 }
2607 if (!err)
2608 err = proc_put_char(&buffer, &left, '\n');
2609 }
2610
2611 if (!err) {
2612 if (write) {
2613 if (*ppos)
2614 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2615 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002616 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002617 }
2618 kfree(tmp_bitmap);
2619 *lenp -= left;
2620 *ppos += *lenp;
2621 return 0;
2622 } else {
2623 kfree(tmp_bitmap);
2624 return err;
2625 }
2626}
2627
Jovi Zhang55610502011-01-12 17:00:45 -08002628#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002630int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 void __user *buffer, size_t *lenp, loff_t *ppos)
2632{
2633 return -ENOSYS;
2634}
2635
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002636int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002637 void __user *buffer, size_t *lenp, loff_t *ppos)
2638{
2639 return -ENOSYS;
2640}
2641
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002642int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 void __user *buffer, size_t *lenp, loff_t *ppos)
2644{
2645 return -ENOSYS;
2646}
2647
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002648int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 void __user *buffer, size_t *lenp, loff_t *ppos)
2650{
2651 return -ENOSYS;
2652}
2653
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002654int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 void __user *buffer, size_t *lenp, loff_t *ppos)
2656{
2657 return -ENOSYS;
2658}
2659
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002660int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 void __user *buffer, size_t *lenp, loff_t *ppos)
2662{
2663 return -ENOSYS;
2664}
2665
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002666int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 void __user *buffer, size_t *lenp, loff_t *ppos)
2668{
2669 return -ENOSYS;
2670}
2671
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002672int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 void __user *buffer,
2674 size_t *lenp, loff_t *ppos)
2675{
2676 return -ENOSYS;
2677}
2678
2679
Jovi Zhang55610502011-01-12 17:00:45 -08002680#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682/*
2683 * No sense putting this after each symbol definition, twice,
2684 * exception granted :-)
2685 */
2686EXPORT_SYMBOL(proc_dointvec);
2687EXPORT_SYMBOL(proc_dointvec_jiffies);
2688EXPORT_SYMBOL(proc_dointvec_minmax);
2689EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2690EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2691EXPORT_SYMBOL(proc_dostring);
2692EXPORT_SYMBOL(proc_doulongvec_minmax);
2693EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);