blob: 693eac39c2028d36a45a82d6160510b8fd105ed0 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#include <asm/uaccess.h>
67#include <asm/processor.h>
68
Andi Kleen29cbc782006-09-30 01:47:55 +020069#ifdef CONFIG_X86
70#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010071#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010072#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020073#endif
David Howellsd550bbd2012-03-28 18:30:03 +010074#ifdef CONFIG_SPARC
75#include <asm/setup.h>
76#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080077#ifdef CONFIG_BSD_PROCESS_ACCT
78#include <linux/acct.h>
79#endif
Dave Young4f0e0562010-03-10 15:24:09 -080080#ifdef CONFIG_RT_MUTEXES
81#include <linux/rtmutex.h>
82#endif
Dave Young2edf5e42010-03-10 15:24:10 -080083#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
84#include <linux/lockdep.h>
85#endif
Dave Young15485a42010-03-10 15:24:07 -080086#ifdef CONFIG_CHR_DEV_SG
87#include <scsi/sg.h>
88#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020089
Don Zickus58687ac2010-05-07 17:11:44 -040090#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050091#include <linux/nmi.h>
92#endif
93
Eric W. Biederman7058cb02007-10-18 03:05:58 -070094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#if defined(CONFIG_SYSCTL)
96
97/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -070099extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700100#ifdef CONFIG_COREDUMP
101extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700103extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700104#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800107extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200108extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100109extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400110extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000111#ifndef CONFIG_MMU
112extern int sysctl_nr_trim_pages;
113#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200114#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200115extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200116#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400119#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120static int sixty = 60;
121#endif
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;
Petr Holasekcb16e952011-03-23 16:43:09 -0700126static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700129#ifdef CONFIG_PRINTK
130static int ten_thousand = 10000;
131#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700133/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
134static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
137static int maxolduid = 65535;
138static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800139static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700142static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Dave Youngd14f1722010-02-25 20:28:57 -0500144#ifdef CONFIG_INOTIFY_USER
145#include <linux/inotify.h>
146#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700147#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148#endif
149
David S. Miller08714202008-11-16 23:49:24 -0800150#ifdef CONFIG_SPARC64
151extern int sysctl_tsb_ratio;
152#endif
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#ifdef __hppa__
155extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530156#endif
157
158#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159extern int unaligned_enabled;
160#endif
161
Jes Sorensend2b176e2006-02-28 09:42:23 -0800162#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800163extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800164#endif
165
Vineet Guptab6fca722013-01-09 20:06:28 +0530166#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
167extern int no_unaligned_warning;
168#endif
169
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700170#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700171static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700172 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700173static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800174 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700176
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700177#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700178static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700179 void __user *buffer, size_t *lenp, loff_t *ppos);
180#endif
181
Kees Cook54b50192012-07-30 14:39:18 -0700182static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
183 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700184#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700185static int proc_dostring_coredump(struct ctl_table *table, int write,
186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700187#endif
Kees Cook54b50192012-07-30 14:39:18 -0700188
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700189#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800190/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100191static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700192
193static int sysrq_sysctl_handler(ctl_table *table, int write,
194 void __user *buffer, size_t *lenp,
195 loff_t *ppos)
196{
197 int error;
198
199 error = proc_dointvec(table, write, buffer, lenp, ppos);
200 if (error)
201 return error;
202
203 if (write)
204 sysrq_toggle_support(__sysrq_enabled);
205
206 return 0;
207}
208
209#endif
210
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700211static struct ctl_table kern_table[];
212static struct ctl_table vm_table[];
213static struct ctl_table fs_table[];
214static struct ctl_table debug_table[];
215static struct ctl_table dev_table[];
216extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800217#ifdef CONFIG_EPOLL
218extern struct ctl_table epoll_table[];
219#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
222int sysctl_legacy_va_layout;
223#endif
224
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225/* The default sysctl tables: */
226
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800227static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 .procname = "kernel",
230 .mode = 0555,
231 .child = kern_table,
232 },
233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "vm",
235 .mode = 0555,
236 .child = vm_table,
237 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .procname = "fs",
240 .mode = 0555,
241 .child = fs_table,
242 },
243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .procname = "debug",
245 .mode = 0555,
246 .child = debug_table,
247 },
248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .procname = "dev",
250 .mode = 0555,
251 .child = dev_table,
252 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700253 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254};
255
Ingo Molnar77e54a12007-07-09 18:52:00 +0200256#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100257static int min_sched_granularity_ns = 100000; /* 100 usecs */
258static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
259static int min_wakeup_granularity_ns; /* 0 usecs */
260static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200261#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100262static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
263static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200264#endif /* CONFIG_SMP */
265#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200266
Mel Gorman5e771902010-05-24 14:32:31 -0700267#ifdef CONFIG_COMPACTION
268static int min_extfrag_threshold;
269static int max_extfrag_threshold = 1000;
270#endif
271
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700272static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200273 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200274 .procname = "sched_child_runs_first",
275 .data = &sysctl_sched_child_runs_first,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800278 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200279 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280#ifdef CONFIG_SCHED_DEBUG
281 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100282 .procname = "sched_min_granularity_ns",
283 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800286 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100287 .extra1 = &min_sched_granularity_ns,
288 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289 },
290 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200291 .procname = "sched_latency_ns",
292 .data = &sysctl_sched_latency,
293 .maxlen = sizeof(unsigned int),
294 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800295 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200296 .extra1 = &min_sched_granularity_ns,
297 .extra2 = &max_sched_granularity_ns,
298 },
299 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 .procname = "sched_wakeup_granularity_ns",
301 .data = &sysctl_sched_wakeup_granularity,
302 .maxlen = sizeof(unsigned int),
303 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800304 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200305 .extra1 = &min_wakeup_granularity_ns,
306 .extra2 = &max_wakeup_granularity_ns,
307 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200308#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200309 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100310 .procname = "sched_tunable_scaling",
311 .data = &sysctl_sched_tunable_scaling,
312 .maxlen = sizeof(enum sched_tunable_scaling),
313 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800314 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100315 .extra1 = &min_sched_tunable_scaling,
316 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200317 },
318 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900319 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200320 .data = &sysctl_sched_migration_cost,
321 .maxlen = sizeof(unsigned int),
322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800323 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200324 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100325 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100326 .procname = "sched_nr_migrate",
327 .data = &sysctl_sched_nr_migrate,
328 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100329 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800330 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100331 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530332 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900333 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200334 .data = &sysctl_sched_time_avg,
335 .maxlen = sizeof(unsigned int),
336 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800337 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200338 },
339 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900340 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800341 .data = &sysctl_sched_shares_window,
342 .maxlen = sizeof(unsigned int),
343 .mode = 0644,
344 .proc_handler = proc_dointvec,
345 },
346 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530347 .procname = "timer_migration",
348 .data = &sysctl_timer_migration,
349 .maxlen = sizeof(unsigned int),
350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800351 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530352 .extra1 = &zero,
353 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530354 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200355#endif /* CONFIG_SMP */
356#ifdef CONFIG_NUMA_BALANCING
357 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200358 .procname = "numa_balancing_scan_delay_ms",
359 .data = &sysctl_numa_balancing_scan_delay,
360 .maxlen = sizeof(unsigned int),
361 .mode = 0644,
362 .proc_handler = proc_dointvec,
363 },
364 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200365 .procname = "numa_balancing_scan_period_min_ms",
366 .data = &sysctl_numa_balancing_scan_period_min,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec,
370 },
371 {
372 .procname = "numa_balancing_scan_period_max_ms",
373 .data = &sysctl_numa_balancing_scan_period_max,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200378 {
379 .procname = "numa_balancing_scan_size_mb",
380 .data = &sysctl_numa_balancing_scan_size,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100385 {
Rik van Rielde1c9ce2013-10-07 11:29:39 +0100386 .procname = "numa_balancing_migrate_deferred",
387 .data = &sysctl_numa_balancing_migrate_deferred,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
390 .proc_handler = proc_dointvec,
391 },
Andi Kleen54a43d52014-01-23 15:53:13 -0800392 {
393 .procname = "numa_balancing",
394 .data = NULL, /* filled in by handler */
395 .maxlen = sizeof(unsigned int),
396 .mode = 0644,
397 .proc_handler = sysctl_numa_balancing,
398 .extra1 = &zero,
399 .extra2 = &one,
400 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200401#endif /* CONFIG_NUMA_BALANCING */
402#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200403 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100404 .procname = "sched_rt_period_us",
405 .data = &sysctl_sched_rt_period,
406 .maxlen = sizeof(unsigned int),
407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100409 },
410 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100411 .procname = "sched_rt_runtime_us",
412 .data = &sysctl_sched_rt_runtime,
413 .maxlen = sizeof(int),
414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800415 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100416 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600417 {
418 .procname = "sched_rr_timeslice_ms",
419 .data = &sched_rr_timeslice,
420 .maxlen = sizeof(int),
421 .mode = 0644,
422 .proc_handler = sched_rr_handler,
423 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100424#ifdef CONFIG_SCHED_AUTOGROUP
425 {
426 .procname = "sched_autogroup_enabled",
427 .data = &sysctl_sched_autogroup_enabled,
428 .maxlen = sizeof(unsigned int),
429 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800430 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100431 .extra1 = &zero,
432 .extra2 = &one,
433 },
434#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700435#ifdef CONFIG_CFS_BANDWIDTH
436 {
437 .procname = "sched_cfs_bandwidth_slice_us",
438 .data = &sysctl_sched_cfs_bandwidth_slice,
439 .maxlen = sizeof(unsigned int),
440 .mode = 0644,
441 .proc_handler = proc_dointvec_minmax,
442 .extra1 = &one,
443 },
444#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700445#ifdef CONFIG_PROVE_LOCKING
446 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700447 .procname = "prove_locking",
448 .data = &prove_locking,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700452 },
453#endif
454#ifdef CONFIG_LOCK_STAT
455 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700456 .procname = "lock_stat",
457 .data = &lock_stat,
458 .maxlen = sizeof(int),
459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700461 },
462#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "panic",
465 .data = &panic_timeout,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
Alex Kelly046d6622012-10-04 17:15:23 -0700470#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "core_uses_pid",
473 .data = &core_uses_pid,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800476 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 .procname = "core_pattern",
480 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700481 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700483 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 },
Neil Hormana2939802009-09-23 15:56:56 -0700485 {
Neil Hormana2939802009-09-23 15:56:56 -0700486 .procname = "core_pipe_limit",
487 .data = &core_pipe_limit,
488 .maxlen = sizeof(unsigned int),
489 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800490 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700491 },
Alex Kelly046d6622012-10-04 17:15:23 -0700492#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800493#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700496 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800500#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100501#ifdef CONFIG_LATENCYTOP
502 {
503 .procname = "latencytop",
504 .data = &latencytop_enabled,
505 .maxlen = sizeof(int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100508 },
509#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510#ifdef CONFIG_BLK_DEV_INITRD
511 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 .procname = "real-root-dev",
513 .data = &real_root_dev,
514 .maxlen = sizeof(int),
515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800516 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 },
518#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700519 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700520 .procname = "print-fatal-signals",
521 .data = &print_fatal_signals,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800524 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700525 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700526#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "reboot-cmd",
529 .data = reboot_command,
530 .maxlen = 256,
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "stop-a",
536 .data = &stop_a_enabled,
537 .maxlen = sizeof (int),
538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 },
541 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .procname = "scons-poweroff",
543 .data = &scons_pwroff,
544 .maxlen = sizeof (int),
545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 },
548#endif
David S. Miller08714202008-11-16 23:49:24 -0800549#ifdef CONFIG_SPARC64
550 {
David S. Miller08714202008-11-16 23:49:24 -0800551 .procname = "tsb-ratio",
552 .data = &sysctl_tsb_ratio,
553 .maxlen = sizeof (int),
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800556 },
557#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558#ifdef __hppa__
559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "soft-power",
561 .data = &pwrsw_enabled,
562 .maxlen = sizeof (int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530566#endif
567#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "unaligned-trap",
570 .data = &unaligned_enabled,
571 .maxlen = sizeof (int),
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
575#endif
576 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .procname = "ctrl-alt-del",
578 .data = &C_A_D,
579 .maxlen = sizeof(int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400583#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200584 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200585 .procname = "ftrace_enabled",
586 .data = &ftrace_enabled,
587 .maxlen = sizeof(int),
588 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200590 },
591#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500592#ifdef CONFIG_STACK_TRACER
593 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500594 .procname = "stack_tracer_enabled",
595 .data = &stack_tracer_enabled,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500599 },
600#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400601#ifdef CONFIG_TRACING
602 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100603 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400604 .data = &ftrace_dump_on_oops,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400608 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400609 {
610 .procname = "traceoff_on_warning",
611 .data = &__disable_trace_on_warning,
612 .maxlen = sizeof(__disable_trace_on_warning),
613 .mode = 0644,
614 .proc_handler = proc_dointvec,
615 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400616#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200617#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 .procname = "modprobe",
620 .data = &modprobe_path,
621 .maxlen = KMOD_PATH_LEN,
622 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800623 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 },
Kees Cook3d433212009-04-02 15:49:29 -0700625 {
Kees Cook3d433212009-04-02 15:49:29 -0700626 .procname = "modules_disabled",
627 .data = &modules_disabled,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800631 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700632 .extra1 = &one,
633 .extra2 = &one,
634 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500636
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100639 .data = &uevent_helper,
640 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800642 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500644
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645#ifdef CONFIG_CHR_DEV_SG
646 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .procname = "sg-big-buff",
648 .data = &sg_big_buff,
649 .maxlen = sizeof (int),
650 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 },
653#endif
654#ifdef CONFIG_BSD_PROCESS_ACCT
655 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .procname = "acct",
657 .data = &acct_parm,
658 .maxlen = 3*sizeof(int),
659 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800660 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 },
662#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663#ifdef CONFIG_MAGIC_SYSRQ
664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800666 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .maxlen = sizeof (int),
668 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700669 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700672#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700675 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .maxlen = sizeof (int),
677 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800678 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700680#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "threads-max",
683 .data = &max_threads,
684 .maxlen = sizeof(int),
685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 },
688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .procname = "random",
690 .mode = 0555,
691 .child = random_table,
692 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 {
Eric Paris17f60a72011-04-01 17:07:50 -0400694 .procname = "usermodehelper",
695 .mode = 0555,
696 .child = usermodehelper_table,
697 },
698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .procname = "overflowuid",
700 .data = &overflowuid,
701 .maxlen = sizeof(int),
702 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800703 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .extra1 = &minolduid,
705 .extra2 = &maxolduid,
706 },
707 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 .procname = "overflowgid",
709 .data = &overflowgid,
710 .maxlen = sizeof(int),
711 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800712 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .extra1 = &minolduid,
714 .extra2 = &maxolduid,
715 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800716#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717#ifdef CONFIG_MATHEMU
718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .procname = "ieee_emulation_warnings",
720 .data = &sysctl_ieee_emulation_warnings,
721 .maxlen = sizeof(int),
722 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800723 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 },
725#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200728 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 .maxlen = sizeof(int),
730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 },
733#endif
734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "pid_max",
736 .data = &pid_max,
737 .maxlen = sizeof (int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .extra1 = &pid_max_min,
741 .extra2 = &pid_max_max,
742 },
743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .procname = "panic_on_oops",
745 .data = &panic_on_oops,
746 .maxlen = sizeof(int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800750#if defined CONFIG_PRINTK
751 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800752 .procname = "printk",
753 .data = &console_loglevel,
754 .maxlen = 4*sizeof(int),
755 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800756 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800757 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700760 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 .maxlen = sizeof(int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 },
765 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700767 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 .maxlen = sizeof(int),
769 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800770 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 },
Dave Youngaf913222009-09-22 16:43:33 -0700772 {
Dave Youngaf913222009-09-22 16:43:33 -0700773 .procname = "printk_delay",
774 .data = &printk_delay_msec,
775 .maxlen = sizeof(int),
776 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800777 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700778 .extra1 = &zero,
779 .extra2 = &ten_thousand,
780 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800782 .procname = "dmesg_restrict",
783 .data = &dmesg_restrict,
784 .maxlen = sizeof(int),
785 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700786 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800787 .extra1 = &zero,
788 .extra2 = &one,
789 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800790 {
791 .procname = "kptr_restrict",
792 .data = &kptr_restrict,
793 .maxlen = sizeof(int),
794 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700795 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800796 .extra1 = &zero,
797 .extra2 = &two,
798 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800799#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800800 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 .procname = "ngroups_max",
802 .data = &ngroups_max,
803 .maxlen = sizeof (int),
804 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800805 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 },
Dan Ballard73efc032011-10-31 17:11:20 -0700807 {
808 .procname = "cap_last_cap",
809 .data = (void *)&cap_last_cap,
810 .maxlen = sizeof(int),
811 .mode = 0444,
812 .proc_handler = proc_dointvec,
813 },
Don Zickus58687ac2010-05-07 17:11:44 -0400814#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500815 {
Don Zickus58687ac2010-05-07 17:11:44 -0400816 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200817 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500818 .maxlen = sizeof (int),
819 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700820 .proc_handler = proc_dowatchdog,
821 .extra1 = &zero,
822 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400823 },
824 {
825 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700826 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400827 .maxlen = sizeof(int),
828 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700829 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800830 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400831 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500832 },
Don Zickus2508ce12010-05-07 17:11:46 -0400833 {
834 .procname = "softlockup_panic",
835 .data = &softlockup_panic,
836 .maxlen = sizeof(int),
837 .mode = 0644,
838 .proc_handler = proc_dointvec_minmax,
839 .extra1 = &zero,
840 .extra2 = &one,
841 },
Don Zickus5dc30552010-11-29 17:07:17 -0500842 {
843 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200844 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500845 .maxlen = sizeof (int),
846 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700847 .proc_handler = proc_dowatchdog,
848 .extra1 = &zero,
849 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500850 },
851#endif
852#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
853 {
854 .procname = "unknown_nmi_panic",
855 .data = &unknown_nmi_panic,
856 .maxlen = sizeof (int),
857 .mode = 0644,
858 .proc_handler = proc_dointvec,
859 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500860#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861#if defined(CONFIG_X86)
862 {
Don Zickus8da5add2006-09-26 10:52:27 +0200863 .procname = "panic_on_unrecovered_nmi",
864 .data = &panic_on_unrecovered_nmi,
865 .maxlen = sizeof(int),
866 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800867 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200868 },
869 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700870 .procname = "panic_on_io_nmi",
871 .data = &panic_on_io_nmi,
872 .maxlen = sizeof(int),
873 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800874 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700875 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900876#ifdef CONFIG_DEBUG_STACKOVERFLOW
877 {
878 .procname = "panic_on_stackoverflow",
879 .data = &sysctl_panic_on_stackoverflow,
880 .maxlen = sizeof(int),
881 .mode = 0644,
882 .proc_handler = proc_dointvec,
883 },
884#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700885 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 .procname = "bootloader_type",
887 .data = &bootloader_type,
888 .maxlen = sizeof (int),
889 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100892 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700893 .procname = "bootloader_version",
894 .data = &bootloader_version,
895 .maxlen = sizeof (int),
896 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700898 },
899 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100900 .procname = "kstack_depth_to_print",
901 .data = &kstack_depth_to_print,
902 .maxlen = sizeof(int),
903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100905 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100906 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100907 .procname = "io_delay_type",
908 .data = &io_delay_type,
909 .maxlen = sizeof(int),
910 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800911 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100912 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800914#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 .procname = "randomize_va_space",
917 .data = &randomize_va_space,
918 .maxlen = sizeof(int),
919 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800920 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800922#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800923#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700924 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700925 .procname = "spin_retry",
926 .data = &spin_retry,
927 .maxlen = sizeof (int),
928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700930 },
931#endif
Len Brown673d5b42007-07-28 03:33:16 -0400932#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800933 {
Pavel Machekc255d842006-02-20 18:27:58 -0800934 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700935 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800936 .maxlen = sizeof (unsigned long),
937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800939 },
940#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530941#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800942 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800943 .procname = "ignore-unaligned-usertrap",
944 .data = &no_unaligned_warning,
945 .maxlen = sizeof (int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800948 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530949#endif
950#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800951 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800952 .procname = "unaligned-dump-stack",
953 .data = &unaligned_dump_stack,
954 .maxlen = sizeof (int),
955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800956 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800957 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800958#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800959#ifdef CONFIG_DETECT_HUNG_TASK
960 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800961 .procname = "hung_task_panic",
962 .data = &sysctl_hung_task_panic,
963 .maxlen = sizeof(int),
964 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800965 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800966 .extra1 = &zero,
967 .extra2 = &one,
968 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100969 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100970 .procname = "hung_task_check_count",
971 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800972 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100973 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800974 .proc_handler = proc_dointvec_minmax,
975 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100976 },
977 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100978 .procname = "hung_task_timeout_secs",
979 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100980 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100981 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800982 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100983 },
984 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100985 .procname = "hung_task_warnings",
986 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100987 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100988 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800989 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100990 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700991#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200992#ifdef CONFIG_COMPAT
993 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200994 .procname = "compat-log",
995 .data = &compat_log,
996 .maxlen = sizeof (int),
997 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800998 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200999 },
1000#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001001#ifdef CONFIG_RT_MUTEXES
1002 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001003 .procname = "max_lock_depth",
1004 .data = &max_lock_depth,
1005 .maxlen = sizeof(int),
1006 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001007 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001008 },
1009#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001010 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001011 .procname = "poweroff_cmd",
1012 .data = &poweroff_cmd,
1013 .maxlen = POWEROFF_CMD_PATH_LEN,
1014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001016 },
David Howells0b77f5b2008-04-29 01:01:32 -07001017#ifdef CONFIG_KEYS
1018 {
David Howells0b77f5b2008-04-29 01:01:32 -07001019 .procname = "keys",
1020 .mode = 0555,
1021 .child = key_sysctls,
1022 },
1023#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001024#ifdef CONFIG_RCU_TORTURE_TEST
1025 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001026 .procname = "rcutorture_runnable",
1027 .data = &rcutorture_runnable,
1028 .maxlen = sizeof(int),
1029 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001030 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001031 },
1032#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001033#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001034 /*
1035 * User-space scripts rely on the existence of this file
1036 * as a feature check for perf_events being enabled.
1037 *
1038 * So it's an ABI, do not remove!
1039 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001040 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001041 .procname = "perf_event_paranoid",
1042 .data = &sysctl_perf_event_paranoid,
1043 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001044 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001045 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001046 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001047 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001048 .procname = "perf_event_mlock_kb",
1049 .data = &sysctl_perf_event_mlock,
1050 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001053 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001054 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001055 .procname = "perf_event_max_sample_rate",
1056 .data = &sysctl_perf_event_sample_rate,
1057 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001058 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001059 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001060 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001061 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001062 {
1063 .procname = "perf_cpu_time_max_percent",
1064 .data = &sysctl_perf_cpu_time_max_percent,
1065 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1066 .mode = 0644,
1067 .proc_handler = perf_cpu_time_max_percent_handler,
1068 .extra1 = &zero,
1069 .extra2 = &one_hundred,
1070 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001071#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001072#ifdef CONFIG_KMEMCHECK
1073 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001074 .procname = "kmemcheck",
1075 .data = &kmemcheck_enabled,
1076 .maxlen = sizeof(int),
1077 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001078 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001079 },
1080#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001081#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001082 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001083 .procname = "blk_iopoll",
1084 .data = &blk_iopoll_enabled,
1085 .maxlen = sizeof(int),
1086 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001087 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001088 },
Jens Axboecb684b52009-09-15 21:53:11 +02001089#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001090 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091};
1092
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001093static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "overcommit_memory",
1096 .data = &sysctl_overcommit_memory,
1097 .maxlen = sizeof(sysctl_overcommit_memory),
1098 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001099 .proc_handler = proc_dointvec_minmax,
1100 .extra1 = &zero,
1101 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 },
1103 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001104 .procname = "panic_on_oom",
1105 .data = &sysctl_panic_on_oom,
1106 .maxlen = sizeof(sysctl_panic_on_oom),
1107 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001108 .proc_handler = proc_dointvec_minmax,
1109 .extra1 = &zero,
1110 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001111 },
1112 {
David Rientjesfe071d72007-10-16 23:25:56 -07001113 .procname = "oom_kill_allocating_task",
1114 .data = &sysctl_oom_kill_allocating_task,
1115 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1116 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001117 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001118 },
1119 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001120 .procname = "oom_dump_tasks",
1121 .data = &sysctl_oom_dump_tasks,
1122 .maxlen = sizeof(sysctl_oom_dump_tasks),
1123 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001124 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001125 },
1126 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 .procname = "overcommit_ratio",
1128 .data = &sysctl_overcommit_ratio,
1129 .maxlen = sizeof(sysctl_overcommit_ratio),
1130 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001131 .proc_handler = overcommit_ratio_handler,
1132 },
1133 {
1134 .procname = "overcommit_kbytes",
1135 .data = &sysctl_overcommit_kbytes,
1136 .maxlen = sizeof(sysctl_overcommit_kbytes),
1137 .mode = 0644,
1138 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 },
1140 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 .procname = "page-cluster",
1142 .data = &page_cluster,
1143 .maxlen = sizeof(int),
1144 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001145 .proc_handler = proc_dointvec_minmax,
1146 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 },
1148 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 .procname = "dirty_background_ratio",
1150 .data = &dirty_background_ratio,
1151 .maxlen = sizeof(dirty_background_ratio),
1152 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001153 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .extra1 = &zero,
1155 .extra2 = &one_hundred,
1156 },
1157 {
David Rientjes2da02992009-01-06 14:39:31 -08001158 .procname = "dirty_background_bytes",
1159 .data = &dirty_background_bytes,
1160 .maxlen = sizeof(dirty_background_bytes),
1161 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001162 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001163 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001164 },
1165 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 .procname = "dirty_ratio",
1167 .data = &vm_dirty_ratio,
1168 .maxlen = sizeof(vm_dirty_ratio),
1169 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001170 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 .extra1 = &zero,
1172 .extra2 = &one_hundred,
1173 },
1174 {
David Rientjes2da02992009-01-06 14:39:31 -08001175 .procname = "dirty_bytes",
1176 .data = &vm_dirty_bytes,
1177 .maxlen = sizeof(vm_dirty_bytes),
1178 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001179 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001180 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001181 },
1182 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001184 .data = &dirty_writeback_interval,
1185 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001187 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 },
1189 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001191 .data = &dirty_expire_interval,
1192 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001194 .proc_handler = proc_dointvec_minmax,
1195 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 },
1197 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001198 .procname = "nr_pdflush_threads",
1199 .mode = 0444 /* read-only */,
1200 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 },
1202 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .procname = "swappiness",
1204 .data = &vm_swappiness,
1205 .maxlen = sizeof(vm_swappiness),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 .extra1 = &zero,
1209 .extra2 = &one_hundred,
1210 },
1211#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001212 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001214 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 .maxlen = sizeof(unsigned long),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 .extra1 = (void *)&hugetlb_zero,
1219 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001220 },
1221#ifdef CONFIG_NUMA
1222 {
1223 .procname = "nr_hugepages_mempolicy",
1224 .data = NULL,
1225 .maxlen = sizeof(unsigned long),
1226 .mode = 0644,
1227 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1228 .extra1 = (void *)&hugetlb_zero,
1229 .extra2 = (void *)&hugetlb_infinity,
1230 },
1231#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 .procname = "hugetlb_shm_group",
1234 .data = &sysctl_hugetlb_shm_group,
1235 .maxlen = sizeof(gid_t),
1236 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001237 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 },
Mel Gorman396faf02007-07-17 04:03:13 -07001239 {
Mel Gorman396faf02007-07-17 04:03:13 -07001240 .procname = "hugepages_treat_as_movable",
1241 .data = &hugepages_treat_as_movable,
1242 .maxlen = sizeof(int),
1243 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001244 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001245 },
Adam Litke54f9f802007-10-16 01:26:20 -07001246 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001247 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001248 .data = NULL,
1249 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001250 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001251 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001252 .extra1 = (void *)&hugetlb_zero,
1253 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001254 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255#endif
1256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "lowmem_reserve_ratio",
1258 .data = &sysctl_lowmem_reserve_ratio,
1259 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1260 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001261 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 },
1263 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001264 .procname = "drop_caches",
1265 .data = &sysctl_drop_caches,
1266 .maxlen = sizeof(int),
1267 .mode = 0644,
1268 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001269 .extra1 = &one,
1270 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001271 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001272#ifdef CONFIG_COMPACTION
1273 {
1274 .procname = "compact_memory",
1275 .data = &sysctl_compact_memory,
1276 .maxlen = sizeof(int),
1277 .mode = 0200,
1278 .proc_handler = sysctl_compaction_handler,
1279 },
Mel Gorman5e771902010-05-24 14:32:31 -07001280 {
1281 .procname = "extfrag_threshold",
1282 .data = &sysctl_extfrag_threshold,
1283 .maxlen = sizeof(int),
1284 .mode = 0644,
1285 .proc_handler = sysctl_extfrag_handler,
1286 .extra1 = &min_extfrag_threshold,
1287 .extra2 = &max_extfrag_threshold,
1288 },
1289
Mel Gorman76ab0f52010-05-24 14:32:28 -07001290#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001291 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001292 .procname = "min_free_kbytes",
1293 .data = &min_free_kbytes,
1294 .maxlen = sizeof(min_free_kbytes),
1295 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001296 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .extra1 = &zero,
1298 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001299 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001300 .procname = "percpu_pagelist_fraction",
1301 .data = &percpu_pagelist_fraction,
1302 .maxlen = sizeof(percpu_pagelist_fraction),
1303 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001304 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001305 .extra1 = &min_percpu_pagelist_fract,
1306 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307#ifdef CONFIG_MMU
1308 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 .procname = "max_map_count",
1310 .data = &sysctl_max_map_count,
1311 .maxlen = sizeof(sysctl_max_map_count),
1312 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001313 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001314 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001316#else
1317 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001318 .procname = "nr_trim_pages",
1319 .data = &sysctl_nr_trim_pages,
1320 .maxlen = sizeof(sysctl_nr_trim_pages),
1321 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001322 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001323 .extra1 = &zero,
1324 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325#endif
1326 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 .procname = "laptop_mode",
1328 .data = &laptop_mode,
1329 .maxlen = sizeof(laptop_mode),
1330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001331 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 },
1333 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 .procname = "block_dump",
1335 .data = &block_dump,
1336 .maxlen = sizeof(block_dump),
1337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001338 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 .extra1 = &zero,
1340 },
1341 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 .procname = "vfs_cache_pressure",
1343 .data = &sysctl_vfs_cache_pressure,
1344 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1345 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001346 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .extra1 = &zero,
1348 },
1349#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1350 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 .procname = "legacy_va_layout",
1352 .data = &sysctl_legacy_va_layout,
1353 .maxlen = sizeof(sysctl_legacy_va_layout),
1354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001355 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 .extra1 = &zero,
1357 },
1358#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001359#ifdef CONFIG_NUMA
1360 {
Christoph Lameter17436602006-01-18 17:42:32 -08001361 .procname = "zone_reclaim_mode",
1362 .data = &zone_reclaim_mode,
1363 .maxlen = sizeof(zone_reclaim_mode),
1364 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001365 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001366 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001367 },
Christoph Lameter96146342006-07-03 00:24:13 -07001368 {
Christoph Lameter96146342006-07-03 00:24:13 -07001369 .procname = "min_unmapped_ratio",
1370 .data = &sysctl_min_unmapped_ratio,
1371 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1372 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001373 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001374 .extra1 = &zero,
1375 .extra2 = &one_hundred,
1376 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001377 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001378 .procname = "min_slab_ratio",
1379 .data = &sysctl_min_slab_ratio,
1380 .maxlen = sizeof(sysctl_min_slab_ratio),
1381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001382 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001383 .extra1 = &zero,
1384 .extra2 = &one_hundred,
1385 },
Christoph Lameter17436602006-01-18 17:42:32 -08001386#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001387#ifdef CONFIG_SMP
1388 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001389 .procname = "stat_interval",
1390 .data = &sysctl_stat_interval,
1391 .maxlen = sizeof(sysctl_stat_interval),
1392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001393 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001394 },
1395#endif
David Howells6e141542009-12-15 19:27:45 +00001396#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001397 {
Eric Parised032182007-06-28 15:55:21 -04001398 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001399 .data = &dac_mmap_min_addr,
1400 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001402 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001403 },
David Howells6e141542009-12-15 19:27:45 +00001404#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001405#ifdef CONFIG_NUMA
1406 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001407 .procname = "numa_zonelist_order",
1408 .data = &numa_zonelist_order,
1409 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1410 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001411 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001412 },
1413#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001414#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001415 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001416 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001417 .procname = "vdso_enabled",
1418 .data = &vdso_enabled,
1419 .maxlen = sizeof(vdso_enabled),
1420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001421 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001422 .extra1 = &zero,
1423 },
1424#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001425#ifdef CONFIG_HIGHMEM
1426 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001427 .procname = "highmem_is_dirtyable",
1428 .data = &vm_highmem_is_dirtyable,
1429 .maxlen = sizeof(vm_highmem_is_dirtyable),
1430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001431 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001432 .extra1 = &zero,
1433 .extra2 = &one,
1434 },
1435#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001436 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001437 .procname = "scan_unevictable_pages",
1438 .data = &scan_unevictable_pages,
1439 .maxlen = sizeof(scan_unevictable_pages),
1440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001441 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001442 },
Andi Kleen6a460792009-09-16 11:50:15 +02001443#ifdef CONFIG_MEMORY_FAILURE
1444 {
Andi Kleen6a460792009-09-16 11:50:15 +02001445 .procname = "memory_failure_early_kill",
1446 .data = &sysctl_memory_failure_early_kill,
1447 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001449 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001450 .extra1 = &zero,
1451 .extra2 = &one,
1452 },
1453 {
Andi Kleen6a460792009-09-16 11:50:15 +02001454 .procname = "memory_failure_recovery",
1455 .data = &sysctl_memory_failure_recovery,
1456 .maxlen = sizeof(sysctl_memory_failure_recovery),
1457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001458 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001459 .extra1 = &zero,
1460 .extra2 = &one,
1461 },
1462#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001463 {
1464 .procname = "user_reserve_kbytes",
1465 .data = &sysctl_user_reserve_kbytes,
1466 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1467 .mode = 0644,
1468 .proc_handler = proc_doulongvec_minmax,
1469 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001470 {
1471 .procname = "admin_reserve_kbytes",
1472 .data = &sysctl_admin_reserve_kbytes,
1473 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1474 .mode = 0644,
1475 .proc_handler = proc_doulongvec_minmax,
1476 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001477 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478};
1479
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001480#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001481static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001482 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001483};
1484#endif
1485
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001486static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "inode-nr",
1489 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001490 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001492 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 },
1494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "inode-state",
1496 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001497 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001499 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 },
1501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 .procname = "file-nr",
1503 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001504 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001506 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 },
1508 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .procname = "file-max",
1510 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001511 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001513 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 },
1515 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001516 .procname = "nr_open",
1517 .data = &sysctl_nr_open,
1518 .maxlen = sizeof(int),
1519 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001520 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001521 .extra1 = &sysctl_nr_open_min,
1522 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001523 },
1524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 .procname = "dentry-state",
1526 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001527 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001529 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 },
1531 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 .procname = "overflowuid",
1533 .data = &fs_overflowuid,
1534 .maxlen = sizeof(int),
1535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001536 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 .extra1 = &minolduid,
1538 .extra2 = &maxolduid,
1539 },
1540 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 .procname = "overflowgid",
1542 .data = &fs_overflowgid,
1543 .maxlen = sizeof(int),
1544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001545 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 .extra1 = &minolduid,
1547 .extra2 = &maxolduid,
1548 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001549#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 .procname = "leases-enable",
1552 .data = &leases_enable,
1553 .maxlen = sizeof(int),
1554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001555 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001557#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558#ifdef CONFIG_DNOTIFY
1559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560 .procname = "dir-notify-enable",
1561 .data = &dir_notify_enable,
1562 .maxlen = sizeof(int),
1563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001564 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 },
1566#endif
1567#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001568#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001570 .procname = "lease-break-time",
1571 .data = &lease_break_time,
1572 .maxlen = sizeof(int),
1573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001574 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001576#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001577#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001579 .procname = "aio-nr",
1580 .data = &aio_nr,
1581 .maxlen = sizeof(aio_nr),
1582 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001583 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001584 },
1585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 .procname = "aio-max-nr",
1587 .data = &aio_max_nr,
1588 .maxlen = sizeof(aio_max_nr),
1589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001590 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001592#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001593#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001594 {
Robert Love0399cb02005-07-13 12:38:18 -04001595 .procname = "inotify",
1596 .mode = 0555,
1597 .child = inotify_table,
1598 },
1599#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001600#ifdef CONFIG_EPOLL
1601 {
1602 .procname = "epoll",
1603 .mode = 0555,
1604 .child = epoll_table,
1605 },
1606#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001608 {
Kees Cook800179c2012-07-25 17:29:07 -07001609 .procname = "protected_symlinks",
1610 .data = &sysctl_protected_symlinks,
1611 .maxlen = sizeof(int),
1612 .mode = 0600,
1613 .proc_handler = proc_dointvec_minmax,
1614 .extra1 = &zero,
1615 .extra2 = &one,
1616 },
1617 {
1618 .procname = "protected_hardlinks",
1619 .data = &sysctl_protected_hardlinks,
1620 .maxlen = sizeof(int),
1621 .mode = 0600,
1622 .proc_handler = proc_dointvec_minmax,
1623 .extra1 = &zero,
1624 .extra2 = &one,
1625 },
1626 {
Alan Coxd6e71142005-06-23 00:09:43 -07001627 .procname = "suid_dumpable",
1628 .data = &suid_dumpable,
1629 .maxlen = sizeof(int),
1630 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001631 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001632 .extra1 = &zero,
1633 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001634 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001635#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1636 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001637 .procname = "binfmt_misc",
1638 .mode = 0555,
1639 .child = binfmt_misc_table,
1640 },
1641#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001642 {
Jens Axboeff9da692010-06-03 14:54:39 +02001643 .procname = "pipe-max-size",
1644 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001645 .maxlen = sizeof(int),
1646 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001647 .proc_handler = &pipe_proc_fn,
1648 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001649 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001650 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001651};
1652
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001653static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001654#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001655 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001656 .procname = "exception-trace",
1657 .data = &show_unhandled_signals,
1658 .maxlen = sizeof(int),
1659 .mode = 0644,
1660 .proc_handler = proc_dointvec
1661 },
1662#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001663#if defined(CONFIG_OPTPROBES)
1664 {
1665 .procname = "kprobes-optimization",
1666 .data = &sysctl_kprobes_optimization,
1667 .maxlen = sizeof(int),
1668 .mode = 0644,
1669 .proc_handler = proc_kprobes_optimization_handler,
1670 .extra1 = &zero,
1671 .extra2 = &one,
1672 },
1673#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001674 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675};
1676
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001677static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001678 { }
Robert Love0eeca282005-07-12 17:06:03 -04001679};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001681int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001682{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001683 struct ctl_table_header *hdr;
1684
1685 hdr = register_sysctl_table(sysctl_base_table);
1686 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001687 return 0;
1688}
1689
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001690#endif /* CONFIG_SYSCTL */
1691
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692/*
1693 * /proc/sys support
1694 */
1695
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001696#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001698static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001699 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001700 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001701{
1702 size_t len;
1703 char __user *p;
1704 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001705
1706 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001707 *lenp = 0;
1708 return 0;
1709 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001710
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001711 if (write) {
1712 len = 0;
1713 p = buffer;
1714 while (len < *lenp) {
1715 if (get_user(c, p++))
1716 return -EFAULT;
1717 if (c == 0 || c == '\n')
1718 break;
1719 len++;
1720 }
1721 if (len >= maxlen)
1722 len = maxlen-1;
1723 if(copy_from_user(data, buffer, len))
1724 return -EFAULT;
1725 ((char *) data)[len] = 0;
1726 *ppos += *lenp;
1727 } else {
1728 len = strlen(data);
1729 if (len > maxlen)
1730 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001731
1732 if (*ppos > len) {
1733 *lenp = 0;
1734 return 0;
1735 }
1736
1737 data += *ppos;
1738 len -= *ppos;
1739
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001740 if (len > *lenp)
1741 len = *lenp;
1742 if (len)
1743 if(copy_to_user(buffer, data, len))
1744 return -EFAULT;
1745 if (len < *lenp) {
1746 if(put_user('\n', ((char __user *) buffer) + len))
1747 return -EFAULT;
1748 len++;
1749 }
1750 *lenp = len;
1751 *ppos += len;
1752 }
1753 return 0;
1754}
1755
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756/**
1757 * proc_dostring - read a string sysctl
1758 * @table: the sysctl table
1759 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 * @buffer: the user buffer
1761 * @lenp: the size of the user buffer
1762 * @ppos: file position
1763 *
1764 * Reads/writes a string from/to the user buffer. If the kernel
1765 * buffer provided is not large enough to hold the string, the
1766 * string is truncated. The copied string is %NULL-terminated.
1767 * If the string is being read by the user process, it is copied
1768 * and a newline '\n' is added. It is truncated if the buffer is
1769 * not large enough.
1770 *
1771 * Returns 0 on success.
1772 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001773int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774 void __user *buffer, size_t *lenp, loff_t *ppos)
1775{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001776 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001777 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778}
1779
Amerigo Wang00b7c332010-05-05 00:26:45 +00001780static size_t proc_skip_spaces(char **buf)
1781{
1782 size_t ret;
1783 char *tmp = skip_spaces(*buf);
1784 ret = tmp - *buf;
1785 *buf = tmp;
1786 return ret;
1787}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001789static void proc_skip_char(char **buf, size_t *size, const char v)
1790{
1791 while (*size) {
1792 if (**buf != v)
1793 break;
1794 (*size)--;
1795 (*buf)++;
1796 }
1797}
1798
Amerigo Wang00b7c332010-05-05 00:26:45 +00001799#define TMPBUFLEN 22
1800/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001801 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001802 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001803 * @buf: a kernel buffer
1804 * @size: size of the kernel buffer
1805 * @val: this is where the number will be stored
1806 * @neg: set to %TRUE if number is negative
1807 * @perm_tr: a vector which contains the allowed trailers
1808 * @perm_tr_len: size of the perm_tr vector
1809 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001810 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001811 * In case of success %0 is returned and @buf and @size are updated with
1812 * the amount of bytes read. If @tr is non-NULL and a trailing
1813 * character exists (size is non-zero after returning from this
1814 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001815 */
1816static int proc_get_long(char **buf, size_t *size,
1817 unsigned long *val, bool *neg,
1818 const char *perm_tr, unsigned perm_tr_len, char *tr)
1819{
1820 int len;
1821 char *p, tmp[TMPBUFLEN];
1822
1823 if (!*size)
1824 return -EINVAL;
1825
1826 len = *size;
1827 if (len > TMPBUFLEN - 1)
1828 len = TMPBUFLEN - 1;
1829
1830 memcpy(tmp, *buf, len);
1831
1832 tmp[len] = 0;
1833 p = tmp;
1834 if (*p == '-' && *size > 1) {
1835 *neg = true;
1836 p++;
1837 } else
1838 *neg = false;
1839 if (!isdigit(*p))
1840 return -EINVAL;
1841
1842 *val = simple_strtoul(p, &p, 0);
1843
1844 len = p - tmp;
1845
1846 /* We don't know if the next char is whitespace thus we may accept
1847 * invalid integers (e.g. 1234...a) or two integers instead of one
1848 * (e.g. 123...1). So lets not allow such large numbers. */
1849 if (len == TMPBUFLEN - 1)
1850 return -EINVAL;
1851
1852 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1853 return -EINVAL;
1854
1855 if (tr && (len < *size))
1856 *tr = *p;
1857
1858 *buf += len;
1859 *size -= len;
1860
1861 return 0;
1862}
1863
1864/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001865 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001866 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001867 * @buf: the user buffer
1868 * @size: the size of the user buffer
1869 * @val: the integer to be converted
1870 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001871 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001872 * In case of success %0 is returned and @buf and @size are updated with
1873 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001874 */
1875static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1876 bool neg)
1877{
1878 int len;
1879 char tmp[TMPBUFLEN], *p = tmp;
1880
1881 sprintf(p, "%s%lu", neg ? "-" : "", val);
1882 len = strlen(tmp);
1883 if (len > *size)
1884 len = *size;
1885 if (copy_to_user(*buf, tmp, len))
1886 return -EFAULT;
1887 *size -= len;
1888 *buf += len;
1889 return 0;
1890}
1891#undef TMPBUFLEN
1892
1893static int proc_put_char(void __user **buf, size_t *size, char c)
1894{
1895 if (*size) {
1896 char __user **buffer = (char __user **)buf;
1897 if (put_user(c, *buffer))
1898 return -EFAULT;
1899 (*size)--, (*buffer)++;
1900 *buf = *buffer;
1901 }
1902 return 0;
1903}
1904
1905static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 int *valp,
1907 int write, void *data)
1908{
1909 if (write) {
1910 *valp = *negp ? -*lvalp : *lvalp;
1911 } else {
1912 int val = *valp;
1913 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001914 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915 *lvalp = (unsigned long)-val;
1916 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001917 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 *lvalp = (unsigned long)val;
1919 }
1920 }
1921 return 0;
1922}
1923
Amerigo Wang00b7c332010-05-05 00:26:45 +00001924static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1925
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001926static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001927 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001928 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001929 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 int write, void *data),
1931 void *data)
1932{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001933 int *i, vleft, first = 1, err = 0;
1934 unsigned long page = 0;
1935 size_t left;
1936 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001937
Amerigo Wang00b7c332010-05-05 00:26:45 +00001938 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 *lenp = 0;
1940 return 0;
1941 }
1942
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001943 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 vleft = table->maxlen / sizeof(*i);
1945 left = *lenp;
1946
1947 if (!conv)
1948 conv = do_proc_dointvec_conv;
1949
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001951 if (left > PAGE_SIZE - 1)
1952 left = PAGE_SIZE - 1;
1953 page = __get_free_page(GFP_TEMPORARY);
1954 kbuf = (char *) page;
1955 if (!kbuf)
1956 return -ENOMEM;
1957 if (copy_from_user(kbuf, buffer, left)) {
1958 err = -EFAULT;
1959 goto free;
1960 }
1961 kbuf[left] = 0;
1962 }
1963
1964 for (; left && vleft--; i++, first=0) {
1965 unsigned long lval;
1966 bool neg;
1967
1968 if (write) {
1969 left -= proc_skip_spaces(&kbuf);
1970
J. R. Okajima563b0462010-05-25 16:10:14 -07001971 if (!left)
1972 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001973 err = proc_get_long(&kbuf, &left, &lval, &neg,
1974 proc_wspace_sep,
1975 sizeof(proc_wspace_sep), NULL);
1976 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001978 if (conv(&neg, &lval, i, 1, data)) {
1979 err = -EINVAL;
1980 break;
1981 }
1982 } else {
1983 if (conv(&neg, &lval, i, 0, data)) {
1984 err = -EINVAL;
1985 break;
1986 }
1987 if (!first)
1988 err = proc_put_char(&buffer, &left, '\t');
1989 if (err)
1990 break;
1991 err = proc_put_long(&buffer, &left, lval, neg);
1992 if (err)
1993 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994 }
1995 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001996
1997 if (!write && !first && left && !err)
1998 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001999 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002000 left -= proc_skip_spaces(&kbuf);
2001free:
2002 if (write) {
2003 free_page(page);
2004 if (first)
2005 return err ? : -EINVAL;
2006 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 *lenp -= left;
2008 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002009 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010}
2011
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002012static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002013 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002014 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002015 int write, void *data),
2016 void *data)
2017{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002018 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002019 buffer, lenp, ppos, conv, data);
2020}
2021
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022/**
2023 * proc_dointvec - read a vector of integers
2024 * @table: the sysctl table
2025 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026 * @buffer: the user buffer
2027 * @lenp: the size of the user buffer
2028 * @ppos: file position
2029 *
2030 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2031 * values from/to the user buffer, treated as an ASCII string.
2032 *
2033 * Returns 0 on success.
2034 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002035int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036 void __user *buffer, size_t *lenp, loff_t *ppos)
2037{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002038 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 NULL,NULL);
2040}
2041
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002042/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002043 * Taint values can only be increased
2044 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002045 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002046static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002047 void __user *buffer, size_t *lenp, loff_t *ppos)
2048{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002049 struct ctl_table t;
2050 unsigned long tmptaint = get_taint();
2051 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002052
Bastian Blank91fcd412007-04-23 14:41:14 -07002053 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002054 return -EPERM;
2055
Andi Kleen25ddbb12008-10-15 22:01:41 -07002056 t = *table;
2057 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002058 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002059 if (err < 0)
2060 return err;
2061
2062 if (write) {
2063 /*
2064 * Poor man's atomic or. Not worth adding a primitive
2065 * to everyone's atomic.h for this
2066 */
2067 int i;
2068 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2069 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302070 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002071 }
2072 }
2073
2074 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002075}
2076
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002077#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002078static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002079 void __user *buffer, size_t *lenp, loff_t *ppos)
2080{
2081 if (write && !capable(CAP_SYS_ADMIN))
2082 return -EPERM;
2083
2084 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2085}
2086#endif
2087
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088struct do_proc_dointvec_minmax_conv_param {
2089 int *min;
2090 int *max;
2091};
2092
Amerigo Wang00b7c332010-05-05 00:26:45 +00002093static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2094 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 int write, void *data)
2096{
2097 struct do_proc_dointvec_minmax_conv_param *param = data;
2098 if (write) {
2099 int val = *negp ? -*lvalp : *lvalp;
2100 if ((param->min && *param->min > val) ||
2101 (param->max && *param->max < val))
2102 return -EINVAL;
2103 *valp = val;
2104 } else {
2105 int val = *valp;
2106 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002107 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 *lvalp = (unsigned long)-val;
2109 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002110 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111 *lvalp = (unsigned long)val;
2112 }
2113 }
2114 return 0;
2115}
2116
2117/**
2118 * proc_dointvec_minmax - read a vector of integers with min/max values
2119 * @table: the sysctl table
2120 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 * @buffer: the user buffer
2122 * @lenp: the size of the user buffer
2123 * @ppos: file position
2124 *
2125 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2126 * values from/to the user buffer, treated as an ASCII string.
2127 *
2128 * This routine will ensure the values are within the range specified by
2129 * table->extra1 (min) and table->extra2 (max).
2130 *
2131 * Returns 0 on success.
2132 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002133int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 void __user *buffer, size_t *lenp, loff_t *ppos)
2135{
2136 struct do_proc_dointvec_minmax_conv_param param = {
2137 .min = (int *) table->extra1,
2138 .max = (int *) table->extra2,
2139 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002140 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141 do_proc_dointvec_minmax_conv, &param);
2142}
2143
Kees Cook54b50192012-07-30 14:39:18 -07002144static void validate_coredump_safety(void)
2145{
Alex Kelly046d6622012-10-04 17:15:23 -07002146#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002147 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002148 core_pattern[0] != '/' && core_pattern[0] != '|') {
2149 printk(KERN_WARNING "Unsafe core_pattern used with "\
2150 "suid_dumpable=2. Pipe handler or fully qualified "\
2151 "core dump path required.\n");
2152 }
Alex Kelly046d6622012-10-04 17:15:23 -07002153#endif
Kees Cook54b50192012-07-30 14:39:18 -07002154}
2155
2156static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2157 void __user *buffer, size_t *lenp, loff_t *ppos)
2158{
2159 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2160 if (!error)
2161 validate_coredump_safety();
2162 return error;
2163}
2164
Alex Kelly046d6622012-10-04 17:15:23 -07002165#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002166static int proc_dostring_coredump(struct ctl_table *table, int write,
2167 void __user *buffer, size_t *lenp, loff_t *ppos)
2168{
2169 int error = proc_dostring(table, write, buffer, lenp, ppos);
2170 if (!error)
2171 validate_coredump_safety();
2172 return error;
2173}
Alex Kelly046d6622012-10-04 17:15:23 -07002174#endif
Kees Cook54b50192012-07-30 14:39:18 -07002175
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002176static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 void __user *buffer,
2178 size_t *lenp, loff_t *ppos,
2179 unsigned long convmul,
2180 unsigned long convdiv)
2181{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002182 unsigned long *i, *min, *max;
2183 int vleft, first = 1, err = 0;
2184 unsigned long page = 0;
2185 size_t left;
2186 char *kbuf;
2187
2188 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189 *lenp = 0;
2190 return 0;
2191 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002192
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002193 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 min = (unsigned long *) table->extra1;
2195 max = (unsigned long *) table->extra2;
2196 vleft = table->maxlen / sizeof(unsigned long);
2197 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002198
2199 if (write) {
2200 if (left > PAGE_SIZE - 1)
2201 left = PAGE_SIZE - 1;
2202 page = __get_free_page(GFP_TEMPORARY);
2203 kbuf = (char *) page;
2204 if (!kbuf)
2205 return -ENOMEM;
2206 if (copy_from_user(kbuf, buffer, left)) {
2207 err = -EFAULT;
2208 goto free;
2209 }
2210 kbuf[left] = 0;
2211 }
2212
Eric Dumazet27b3d802010-10-07 12:59:29 -07002213 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002214 unsigned long val;
2215
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002217 bool neg;
2218
2219 left -= proc_skip_spaces(&kbuf);
2220
2221 err = proc_get_long(&kbuf, &left, &val, &neg,
2222 proc_wspace_sep,
2223 sizeof(proc_wspace_sep), NULL);
2224 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225 break;
2226 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 continue;
2228 if ((min && val < *min) || (max && val > *max))
2229 continue;
2230 *i = val;
2231 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002232 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002233 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002234 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002235 if (err)
2236 break;
2237 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002238 err = proc_put_long(&buffer, &left, val, false);
2239 if (err)
2240 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 }
2242 }
2243
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244 if (!write && !first && left && !err)
2245 err = proc_put_char(&buffer, &left, '\n');
2246 if (write && !err)
2247 left -= proc_skip_spaces(&kbuf);
2248free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002250 free_page(page);
2251 if (first)
2252 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254 *lenp -= left;
2255 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002256 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257}
2258
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002259static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002260 void __user *buffer,
2261 size_t *lenp, loff_t *ppos,
2262 unsigned long convmul,
2263 unsigned long convdiv)
2264{
2265 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002266 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002267}
2268
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269/**
2270 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2271 * @table: the sysctl table
2272 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 * @buffer: the user buffer
2274 * @lenp: the size of the user buffer
2275 * @ppos: file position
2276 *
2277 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2278 * values from/to the user buffer, treated as an ASCII string.
2279 *
2280 * This routine will ensure the values are within the range specified by
2281 * table->extra1 (min) and table->extra2 (max).
2282 *
2283 * Returns 0 on success.
2284 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002285int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286 void __user *buffer, size_t *lenp, loff_t *ppos)
2287{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002288 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289}
2290
2291/**
2292 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2293 * @table: the sysctl table
2294 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 * @buffer: the user buffer
2296 * @lenp: the size of the user buffer
2297 * @ppos: file position
2298 *
2299 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2300 * values from/to the user buffer, treated as an ASCII string. The values
2301 * are treated as milliseconds, and converted to jiffies when they are stored.
2302 *
2303 * This routine will ensure the values are within the range specified by
2304 * table->extra1 (min) and table->extra2 (max).
2305 *
2306 * Returns 0 on success.
2307 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002308int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309 void __user *buffer,
2310 size_t *lenp, loff_t *ppos)
2311{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002312 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 lenp, ppos, HZ, 1000l);
2314}
2315
2316
Amerigo Wang00b7c332010-05-05 00:26:45 +00002317static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 int *valp,
2319 int write, void *data)
2320{
2321 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002322 if (*lvalp > LONG_MAX / HZ)
2323 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2325 } else {
2326 int val = *valp;
2327 unsigned long lval;
2328 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002329 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330 lval = (unsigned long)-val;
2331 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002332 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 lval = (unsigned long)val;
2334 }
2335 *lvalp = lval / HZ;
2336 }
2337 return 0;
2338}
2339
Amerigo Wang00b7c332010-05-05 00:26:45 +00002340static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 int *valp,
2342 int write, void *data)
2343{
2344 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002345 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2346 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2348 } else {
2349 int val = *valp;
2350 unsigned long lval;
2351 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 lval = (unsigned long)-val;
2354 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002355 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 lval = (unsigned long)val;
2357 }
2358 *lvalp = jiffies_to_clock_t(lval);
2359 }
2360 return 0;
2361}
2362
Amerigo Wang00b7c332010-05-05 00:26:45 +00002363static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 int *valp,
2365 int write, void *data)
2366{
2367 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002368 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2369
2370 if (jif > INT_MAX)
2371 return 1;
2372 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373 } else {
2374 int val = *valp;
2375 unsigned long lval;
2376 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002377 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 lval = (unsigned long)-val;
2379 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002380 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 lval = (unsigned long)val;
2382 }
2383 *lvalp = jiffies_to_msecs(lval);
2384 }
2385 return 0;
2386}
2387
2388/**
2389 * proc_dointvec_jiffies - read a vector of integers as seconds
2390 * @table: the sysctl table
2391 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392 * @buffer: the user buffer
2393 * @lenp: the size of the user buffer
2394 * @ppos: file position
2395 *
2396 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2397 * values from/to the user buffer, treated as an ASCII string.
2398 * The values read are assumed to be in seconds, and are converted into
2399 * jiffies.
2400 *
2401 * Returns 0 on success.
2402 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 void __user *buffer, size_t *lenp, loff_t *ppos)
2405{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002406 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 do_proc_dointvec_jiffies_conv,NULL);
2408}
2409
2410/**
2411 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2412 * @table: the sysctl table
2413 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 * @buffer: the user buffer
2415 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002416 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 *
2418 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2419 * values from/to the user buffer, treated as an ASCII string.
2420 * The values read are assumed to be in 1/USER_HZ seconds, and
2421 * are converted into jiffies.
2422 *
2423 * Returns 0 on success.
2424 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002425int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426 void __user *buffer, size_t *lenp, loff_t *ppos)
2427{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002428 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 do_proc_dointvec_userhz_jiffies_conv,NULL);
2430}
2431
2432/**
2433 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2434 * @table: the sysctl table
2435 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 * @buffer: the user buffer
2437 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002438 * @ppos: file position
2439 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002440 *
2441 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2442 * values from/to the user buffer, treated as an ASCII string.
2443 * The values read are assumed to be in 1/1000 seconds, and
2444 * are converted into jiffies.
2445 *
2446 * Returns 0 on success.
2447 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002448int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 void __user *buffer, size_t *lenp, loff_t *ppos)
2450{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002451 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 do_proc_dointvec_ms_jiffies_conv, NULL);
2453}
2454
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002455static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002456 void __user *buffer, size_t *lenp, loff_t *ppos)
2457{
2458 struct pid *new_pid;
2459 pid_t tmp;
2460 int r;
2461
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002462 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002463
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002464 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002465 lenp, ppos, NULL, NULL);
2466 if (r || !write)
2467 return r;
2468
2469 new_pid = find_get_pid(tmp);
2470 if (!new_pid)
2471 return -ESRCH;
2472
2473 put_pid(xchg(&cad_pid, new_pid));
2474 return 0;
2475}
2476
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002477/**
2478 * proc_do_large_bitmap - read/write from/to a large bitmap
2479 * @table: the sysctl table
2480 * @write: %TRUE if this is a write to the sysctl file
2481 * @buffer: the user buffer
2482 * @lenp: the size of the user buffer
2483 * @ppos: file position
2484 *
2485 * The bitmap is stored at table->data and the bitmap length (in bits)
2486 * in table->maxlen.
2487 *
2488 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2489 * large bitmaps may be represented in a compact manner. Writing into
2490 * the file will clear the bitmap then update it with the given input.
2491 *
2492 * Returns 0 on success.
2493 */
2494int proc_do_large_bitmap(struct ctl_table *table, int write,
2495 void __user *buffer, size_t *lenp, loff_t *ppos)
2496{
2497 int err = 0;
2498 bool first = 1;
2499 size_t left = *lenp;
2500 unsigned long bitmap_len = table->maxlen;
2501 unsigned long *bitmap = (unsigned long *) table->data;
2502 unsigned long *tmp_bitmap = NULL;
2503 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2504
2505 if (!bitmap_len || !left || (*ppos && !write)) {
2506 *lenp = 0;
2507 return 0;
2508 }
2509
2510 if (write) {
2511 unsigned long page = 0;
2512 char *kbuf;
2513
2514 if (left > PAGE_SIZE - 1)
2515 left = PAGE_SIZE - 1;
2516
2517 page = __get_free_page(GFP_TEMPORARY);
2518 kbuf = (char *) page;
2519 if (!kbuf)
2520 return -ENOMEM;
2521 if (copy_from_user(kbuf, buffer, left)) {
2522 free_page(page);
2523 return -EFAULT;
2524 }
2525 kbuf[left] = 0;
2526
2527 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2528 GFP_KERNEL);
2529 if (!tmp_bitmap) {
2530 free_page(page);
2531 return -ENOMEM;
2532 }
2533 proc_skip_char(&kbuf, &left, '\n');
2534 while (!err && left) {
2535 unsigned long val_a, val_b;
2536 bool neg;
2537
2538 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2539 sizeof(tr_a), &c);
2540 if (err)
2541 break;
2542 if (val_a >= bitmap_len || neg) {
2543 err = -EINVAL;
2544 break;
2545 }
2546
2547 val_b = val_a;
2548 if (left) {
2549 kbuf++;
2550 left--;
2551 }
2552
2553 if (c == '-') {
2554 err = proc_get_long(&kbuf, &left, &val_b,
2555 &neg, tr_b, sizeof(tr_b),
2556 &c);
2557 if (err)
2558 break;
2559 if (val_b >= bitmap_len || neg ||
2560 val_a > val_b) {
2561 err = -EINVAL;
2562 break;
2563 }
2564 if (left) {
2565 kbuf++;
2566 left--;
2567 }
2568 }
2569
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002570 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002571 first = 0;
2572 proc_skip_char(&kbuf, &left, '\n');
2573 }
2574 free_page(page);
2575 } else {
2576 unsigned long bit_a, bit_b = 0;
2577
2578 while (left) {
2579 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2580 if (bit_a >= bitmap_len)
2581 break;
2582 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2583 bit_a + 1) - 1;
2584
2585 if (!first) {
2586 err = proc_put_char(&buffer, &left, ',');
2587 if (err)
2588 break;
2589 }
2590 err = proc_put_long(&buffer, &left, bit_a, false);
2591 if (err)
2592 break;
2593 if (bit_a != bit_b) {
2594 err = proc_put_char(&buffer, &left, '-');
2595 if (err)
2596 break;
2597 err = proc_put_long(&buffer, &left, bit_b, false);
2598 if (err)
2599 break;
2600 }
2601
2602 first = 0; bit_b++;
2603 }
2604 if (!err)
2605 err = proc_put_char(&buffer, &left, '\n');
2606 }
2607
2608 if (!err) {
2609 if (write) {
2610 if (*ppos)
2611 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2612 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002613 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002614 }
2615 kfree(tmp_bitmap);
2616 *lenp -= left;
2617 *ppos += *lenp;
2618 return 0;
2619 } else {
2620 kfree(tmp_bitmap);
2621 return err;
2622 }
2623}
2624
Jovi Zhang55610502011-01-12 17:00:45 -08002625#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002627int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 void __user *buffer, size_t *lenp, loff_t *ppos)
2629{
2630 return -ENOSYS;
2631}
2632
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002633int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 void __user *buffer, size_t *lenp, loff_t *ppos)
2635{
2636 return -ENOSYS;
2637}
2638
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002639int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 void __user *buffer, size_t *lenp, loff_t *ppos)
2641{
2642 return -ENOSYS;
2643}
2644
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002645int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 void __user *buffer, size_t *lenp, loff_t *ppos)
2647{
2648 return -ENOSYS;
2649}
2650
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002651int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 void __user *buffer, size_t *lenp, loff_t *ppos)
2653{
2654 return -ENOSYS;
2655}
2656
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002657int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 void __user *buffer, size_t *lenp, loff_t *ppos)
2659{
2660 return -ENOSYS;
2661}
2662
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002663int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664 void __user *buffer, size_t *lenp, loff_t *ppos)
2665{
2666 return -ENOSYS;
2667}
2668
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002669int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 void __user *buffer,
2671 size_t *lenp, loff_t *ppos)
2672{
2673 return -ENOSYS;
2674}
2675
2676
Jovi Zhang55610502011-01-12 17:00:45 -08002677#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679/*
2680 * No sense putting this after each symbol definition, twice,
2681 * exception granted :-)
2682 */
2683EXPORT_SYMBOL(proc_dointvec);
2684EXPORT_SYMBOL(proc_dointvec_jiffies);
2685EXPORT_SYMBOL(proc_dointvec_minmax);
2686EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2687EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2688EXPORT_SYMBOL(proc_dostring);
2689EXPORT_SYMBOL(proc_doulongvec_minmax);
2690EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);