blob: 49e13e1f8fe6a5e481edb3026ae20360918986c3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070026#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080027#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080028#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070030#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020032#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070033#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070034#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/init.h>
36#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010037#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030038#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/sysrq.h>
40#include <linux/highuid.h>
41#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020042#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070043#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070046#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/times.h>
48#include <linux/limits.h>
49#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020050#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070052#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080053#include <linux/nfs_fs.h>
54#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070055#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020056#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020057#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050058#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020059#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070060#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040061#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070062#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000063#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060064#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080065#include <linux/kexec.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67#include <asm/uaccess.h>
68#include <asm/processor.h>
69
Andi Kleen29cbc782006-09-30 01:47:55 +020070#ifdef CONFIG_X86
71#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010072#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010073#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020074#endif
David Howellsd550bbd2012-03-28 18:30:03 +010075#ifdef CONFIG_SPARC
76#include <asm/setup.h>
77#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080078#ifdef CONFIG_BSD_PROCESS_ACCT
79#include <linux/acct.h>
80#endif
Dave Young4f0e0562010-03-10 15:24:09 -080081#ifdef CONFIG_RT_MUTEXES
82#include <linux/rtmutex.h>
83#endif
Dave Young2edf5e42010-03-10 15:24:10 -080084#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
85#include <linux/lockdep.h>
86#endif
Dave Young15485a42010-03-10 15:24:07 -080087#ifdef CONFIG_CHR_DEV_SG
88#include <scsi/sg.h>
89#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020090
Don Zickus58687ac2010-05-07 17:11:44 -040091#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050092#include <linux/nmi.h>
93#endif
94
Eric W. Biederman7058cb02007-10-18 03:05:58 -070095
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#if defined(CONFIG_SYSCTL)
97
98/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700100extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700101#ifdef CONFIG_COREDUMP
102extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700104extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700105#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800108extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200109extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400111extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200115#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200116extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200117#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400120#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121static int sixty = 60;
122#endif
123
Aaron Tomlin270750db2014-01-20 17:34:13 +0000124static int __maybe_unused neg_one = -1;
125
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700127static int __maybe_unused one = 1;
128static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700129static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800130static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700132#ifdef CONFIG_PRINTK
133static int ten_thousand = 10000;
134#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700135
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700136/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
137static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
140static int maxolduid = 65535;
141static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800142static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Dave Youngd14f1722010-02-25 20:28:57 -0500147#ifdef CONFIG_INOTIFY_USER
148#include <linux/inotify.h>
149#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700150#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif
152
David S. Miller08714202008-11-16 23:49:24 -0800153#ifdef CONFIG_SPARC64
154extern int sysctl_tsb_ratio;
155#endif
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#ifdef __hppa__
158extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530159#endif
160
161#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162extern int unaligned_enabled;
163#endif
164
Jes Sorensend2b176e2006-02-28 09:42:23 -0800165#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800166extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#endif
168
Vineet Guptab6fca722013-01-09 20:06:28 +0530169#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
170extern int no_unaligned_warning;
171#endif
172
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700173#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700174static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700175 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700176static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800177 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700178#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700179
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700180#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700181static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700182 void __user *buffer, size_t *lenp, loff_t *ppos);
183#endif
184
Kees Cook54b50192012-07-30 14:39:18 -0700185static int proc_dointvec_minmax_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#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700188static int proc_dostring_coredump(struct ctl_table *table, int write,
189 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700190#endif
Kees Cook54b50192012-07-30 14:39:18 -0700191
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700192#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800193/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100194static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700195
196static int sysrq_sysctl_handler(ctl_table *table, int write,
197 void __user *buffer, size_t *lenp,
198 loff_t *ppos)
199{
200 int error;
201
202 error = proc_dointvec(table, write, buffer, lenp, ppos);
203 if (error)
204 return error;
205
206 if (write)
207 sysrq_toggle_support(__sysrq_enabled);
208
209 return 0;
210}
211
212#endif
213
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700214static struct ctl_table kern_table[];
215static struct ctl_table vm_table[];
216static struct ctl_table fs_table[];
217static struct ctl_table debug_table[];
218static struct ctl_table dev_table[];
219extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800220#ifdef CONFIG_EPOLL
221extern struct ctl_table epoll_table[];
222#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
225int sysctl_legacy_va_layout;
226#endif
227
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228/* The default sysctl tables: */
229
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800230static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 .procname = "kernel",
233 .mode = 0555,
234 .child = kern_table,
235 },
236 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 .procname = "vm",
238 .mode = 0555,
239 .child = vm_table,
240 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .procname = "fs",
243 .mode = 0555,
244 .child = fs_table,
245 },
246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .procname = "debug",
248 .mode = 0555,
249 .child = debug_table,
250 },
251 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 .procname = "dev",
253 .mode = 0555,
254 .child = dev_table,
255 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700256 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257};
258
Ingo Molnar77e54a12007-07-09 18:52:00 +0200259#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100260static int min_sched_granularity_ns = 100000; /* 100 usecs */
261static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
262static int min_wakeup_granularity_ns; /* 0 usecs */
263static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200264#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100265static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
266static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200267#endif /* CONFIG_SMP */
268#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200269
Mel Gorman5e771902010-05-24 14:32:31 -0700270#ifdef CONFIG_COMPACTION
271static int min_extfrag_threshold;
272static int max_extfrag_threshold = 1000;
273#endif
274
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700275static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200276 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200277 .procname = "sched_child_runs_first",
278 .data = &sysctl_sched_child_runs_first,
279 .maxlen = sizeof(unsigned int),
280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800281 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200282 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283#ifdef CONFIG_SCHED_DEBUG
284 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100285 .procname = "sched_min_granularity_ns",
286 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800289 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100290 .extra1 = &min_sched_granularity_ns,
291 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200292 },
293 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200294 .procname = "sched_latency_ns",
295 .data = &sysctl_sched_latency,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800298 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200299 .extra1 = &min_sched_granularity_ns,
300 .extra2 = &max_sched_granularity_ns,
301 },
302 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200303 .procname = "sched_wakeup_granularity_ns",
304 .data = &sysctl_sched_wakeup_granularity,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800307 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200308 .extra1 = &min_wakeup_granularity_ns,
309 .extra2 = &max_wakeup_granularity_ns,
310 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200311#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200312 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100313 .procname = "sched_tunable_scaling",
314 .data = &sysctl_sched_tunable_scaling,
315 .maxlen = sizeof(enum sched_tunable_scaling),
316 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800317 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100318 .extra1 = &min_sched_tunable_scaling,
319 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200320 },
321 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900322 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200323 .data = &sysctl_sched_migration_cost,
324 .maxlen = sizeof(unsigned int),
325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800326 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200327 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100328 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100329 .procname = "sched_nr_migrate",
330 .data = &sysctl_sched_nr_migrate,
331 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800333 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100334 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530335 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900336 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200337 .data = &sysctl_sched_time_avg,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800340 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200341 },
342 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900343 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800344 .data = &sysctl_sched_shares_window,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
347 .proc_handler = proc_dointvec,
348 },
349 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530350 .procname = "timer_migration",
351 .data = &sysctl_timer_migration,
352 .maxlen = sizeof(unsigned int),
353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800354 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530355 .extra1 = &zero,
356 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530357 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200358#endif /* CONFIG_SMP */
359#ifdef CONFIG_NUMA_BALANCING
360 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200361 .procname = "numa_balancing_scan_delay_ms",
362 .data = &sysctl_numa_balancing_scan_delay,
363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
365 .proc_handler = proc_dointvec,
366 },
367 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200368 .procname = "numa_balancing_scan_period_min_ms",
369 .data = &sysctl_numa_balancing_scan_period_min,
370 .maxlen = sizeof(unsigned int),
371 .mode = 0644,
372 .proc_handler = proc_dointvec,
373 },
374 {
375 .procname = "numa_balancing_scan_period_max_ms",
376 .data = &sysctl_numa_balancing_scan_period_max,
377 .maxlen = sizeof(unsigned int),
378 .mode = 0644,
379 .proc_handler = proc_dointvec,
380 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200381 {
382 .procname = "numa_balancing_scan_size_mb",
383 .data = &sysctl_numa_balancing_scan_size,
384 .maxlen = sizeof(unsigned int),
385 .mode = 0644,
386 .proc_handler = proc_dointvec,
387 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100388 {
Rik van Rielde1c9ce2013-10-07 11:29:39 +0100389 .procname = "numa_balancing_migrate_deferred",
390 .data = &sysctl_numa_balancing_migrate_deferred,
391 .maxlen = sizeof(unsigned int),
392 .mode = 0644,
393 .proc_handler = proc_dointvec,
394 },
Andi Kleen54a43d52014-01-23 15:53:13 -0800395 {
396 .procname = "numa_balancing",
397 .data = NULL, /* filled in by handler */
398 .maxlen = sizeof(unsigned int),
399 .mode = 0644,
400 .proc_handler = sysctl_numa_balancing,
401 .extra1 = &zero,
402 .extra2 = &one,
403 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200404#endif /* CONFIG_NUMA_BALANCING */
405#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200406 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100407 .procname = "sched_rt_period_us",
408 .data = &sysctl_sched_rt_period,
409 .maxlen = sizeof(unsigned int),
410 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800411 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100412 },
413 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100414 .procname = "sched_rt_runtime_us",
415 .data = &sysctl_sched_rt_runtime,
416 .maxlen = sizeof(int),
417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800418 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100419 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600420 {
421 .procname = "sched_rr_timeslice_ms",
422 .data = &sched_rr_timeslice,
423 .maxlen = sizeof(int),
424 .mode = 0644,
425 .proc_handler = sched_rr_handler,
426 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100427#ifdef CONFIG_SCHED_AUTOGROUP
428 {
429 .procname = "sched_autogroup_enabled",
430 .data = &sysctl_sched_autogroup_enabled,
431 .maxlen = sizeof(unsigned int),
432 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800433 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100434 .extra1 = &zero,
435 .extra2 = &one,
436 },
437#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700438#ifdef CONFIG_CFS_BANDWIDTH
439 {
440 .procname = "sched_cfs_bandwidth_slice_us",
441 .data = &sysctl_sched_cfs_bandwidth_slice,
442 .maxlen = sizeof(unsigned int),
443 .mode = 0644,
444 .proc_handler = proc_dointvec_minmax,
445 .extra1 = &one,
446 },
447#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700448#ifdef CONFIG_PROVE_LOCKING
449 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700450 .procname = "prove_locking",
451 .data = &prove_locking,
452 .maxlen = sizeof(int),
453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800454 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 },
456#endif
457#ifdef CONFIG_LOCK_STAT
458 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700459 .procname = "lock_stat",
460 .data = &lock_stat,
461 .maxlen = sizeof(int),
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700464 },
465#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200466 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 .procname = "panic",
468 .data = &panic_timeout,
469 .maxlen = sizeof(int),
470 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800471 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 },
Alex Kelly046d6622012-10-04 17:15:23 -0700473#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 .procname = "core_uses_pid",
476 .data = &core_uses_pid,
477 .maxlen = sizeof(int),
478 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800479 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 },
481 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .procname = "core_pattern",
483 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700484 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700486 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 },
Neil Hormana2939802009-09-23 15:56:56 -0700488 {
Neil Hormana2939802009-09-23 15:56:56 -0700489 .procname = "core_pipe_limit",
490 .data = &core_pipe_limit,
491 .maxlen = sizeof(unsigned int),
492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800493 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700494 },
Alex Kelly046d6622012-10-04 17:15:23 -0700495#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800496#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700499 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800500 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800501 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800503#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100504#ifdef CONFIG_LATENCYTOP
505 {
506 .procname = "latencytop",
507 .data = &latencytop_enabled,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100511 },
512#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513#ifdef CONFIG_BLK_DEV_INITRD
514 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 .procname = "real-root-dev",
516 .data = &real_root_dev,
517 .maxlen = sizeof(int),
518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800519 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 },
521#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700522 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700523 .procname = "print-fatal-signals",
524 .data = &print_fatal_signals,
525 .maxlen = sizeof(int),
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700528 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700529#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 .procname = "reboot-cmd",
532 .data = reboot_command,
533 .maxlen = 256,
534 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800535 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 },
537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .procname = "stop-a",
539 .data = &stop_a_enabled,
540 .maxlen = sizeof (int),
541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 },
544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "scons-poweroff",
546 .data = &scons_pwroff,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551#endif
David S. Miller08714202008-11-16 23:49:24 -0800552#ifdef CONFIG_SPARC64
553 {
David S. Miller08714202008-11-16 23:49:24 -0800554 .procname = "tsb-ratio",
555 .data = &sysctl_tsb_ratio,
556 .maxlen = sizeof (int),
557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800558 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800559 },
560#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561#ifdef __hppa__
562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 .procname = "soft-power",
564 .data = &pwrsw_enabled,
565 .maxlen = sizeof (int),
566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530569#endif
570#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 .procname = "unaligned-trap",
573 .data = &unaligned_enabled,
574 .maxlen = sizeof (int),
575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800576 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 },
578#endif
579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "ctrl-alt-del",
581 .data = &C_A_D,
582 .maxlen = sizeof(int),
583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800584 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400586#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200587 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200588 .procname = "ftrace_enabled",
589 .data = &ftrace_enabled,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200593 },
594#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500595#ifdef CONFIG_STACK_TRACER
596 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500597 .procname = "stack_tracer_enabled",
598 .data = &stack_tracer_enabled,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500602 },
603#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400604#ifdef CONFIG_TRACING
605 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100606 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400607 .data = &ftrace_dump_on_oops,
608 .maxlen = sizeof(int),
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400611 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400612 {
613 .procname = "traceoff_on_warning",
614 .data = &__disable_trace_on_warning,
615 .maxlen = sizeof(__disable_trace_on_warning),
616 .mode = 0644,
617 .proc_handler = proc_dointvec,
618 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400619#endif
Kees Cook79847542014-01-23 15:55:59 -0800620#ifdef CONFIG_KEXEC
621 {
622 .procname = "kexec_load_disabled",
623 .data = &kexec_load_disabled,
624 .maxlen = sizeof(int),
625 .mode = 0644,
626 /* only handle a transition from default "0" to "1" */
627 .proc_handler = proc_dointvec_minmax,
628 .extra1 = &one,
629 .extra2 = &one,
630 },
631#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200632#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "modprobe",
635 .data = &modprobe_path,
636 .maxlen = KMOD_PATH_LEN,
637 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800638 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 },
Kees Cook3d433212009-04-02 15:49:29 -0700640 {
Kees Cook3d433212009-04-02 15:49:29 -0700641 .procname = "modules_disabled",
642 .data = &modules_disabled,
643 .maxlen = sizeof(int),
644 .mode = 0644,
645 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700647 .extra1 = &one,
648 .extra2 = &one,
649 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500651
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100654 .data = &uevent_helper,
655 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800657 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500659
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660#ifdef CONFIG_CHR_DEV_SG
661 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .procname = "sg-big-buff",
663 .data = &sg_big_buff,
664 .maxlen = sizeof (int),
665 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 },
668#endif
669#ifdef CONFIG_BSD_PROCESS_ACCT
670 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .procname = "acct",
672 .data = &acct_parm,
673 .maxlen = 3*sizeof(int),
674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800675 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 },
677#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678#ifdef CONFIG_MAGIC_SYSRQ
679 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800681 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .maxlen = sizeof (int),
683 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700684 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 },
686#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700687#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700690 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 .maxlen = sizeof (int),
692 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800693 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700695#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .procname = "threads-max",
698 .data = &max_threads,
699 .maxlen = sizeof(int),
700 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800701 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 },
703 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .procname = "random",
705 .mode = 0555,
706 .child = random_table,
707 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Eric Paris17f60a72011-04-01 17:07:50 -0400709 .procname = "usermodehelper",
710 .mode = 0555,
711 .child = usermodehelper_table,
712 },
713 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .procname = "overflowuid",
715 .data = &overflowuid,
716 .maxlen = sizeof(int),
717 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800718 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .extra1 = &minolduid,
720 .extra2 = &maxolduid,
721 },
722 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 .procname = "overflowgid",
724 .data = &overflowgid,
725 .maxlen = sizeof(int),
726 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800727 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .extra1 = &minolduid,
729 .extra2 = &maxolduid,
730 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800731#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732#ifdef CONFIG_MATHEMU
733 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .procname = "ieee_emulation_warnings",
735 .data = &sysctl_ieee_emulation_warnings,
736 .maxlen = sizeof(int),
737 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800738 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 },
740#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200743 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .maxlen = sizeof(int),
745 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800746 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 },
748#endif
749 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 .procname = "pid_max",
751 .data = &pid_max,
752 .maxlen = sizeof (int),
753 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800754 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .extra1 = &pid_max_min,
756 .extra2 = &pid_max_max,
757 },
758 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .procname = "panic_on_oops",
760 .data = &panic_on_oops,
761 .maxlen = sizeof(int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800765#if defined CONFIG_PRINTK
766 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800767 .procname = "printk",
768 .data = &console_loglevel,
769 .maxlen = 4*sizeof(int),
770 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800771 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800772 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700775 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 .maxlen = sizeof(int),
777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800778 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 },
780 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700782 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 .maxlen = sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 },
Dave Youngaf913222009-09-22 16:43:33 -0700787 {
Dave Youngaf913222009-09-22 16:43:33 -0700788 .procname = "printk_delay",
789 .data = &printk_delay_msec,
790 .maxlen = sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700793 .extra1 = &zero,
794 .extra2 = &ten_thousand,
795 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800797 .procname = "dmesg_restrict",
798 .data = &dmesg_restrict,
799 .maxlen = sizeof(int),
800 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700801 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800802 .extra1 = &zero,
803 .extra2 = &one,
804 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800805 {
806 .procname = "kptr_restrict",
807 .data = &kptr_restrict,
808 .maxlen = sizeof(int),
809 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700810 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800811 .extra1 = &zero,
812 .extra2 = &two,
813 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800814#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800815 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 .procname = "ngroups_max",
817 .data = &ngroups_max,
818 .maxlen = sizeof (int),
819 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800820 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 },
Dan Ballard73efc032011-10-31 17:11:20 -0700822 {
823 .procname = "cap_last_cap",
824 .data = (void *)&cap_last_cap,
825 .maxlen = sizeof(int),
826 .mode = 0444,
827 .proc_handler = proc_dointvec,
828 },
Don Zickus58687ac2010-05-07 17:11:44 -0400829#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500830 {
Don Zickus58687ac2010-05-07 17:11:44 -0400831 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200832 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500833 .maxlen = sizeof (int),
834 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700835 .proc_handler = proc_dowatchdog,
836 .extra1 = &zero,
837 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400838 },
839 {
840 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700841 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400842 .maxlen = sizeof(int),
843 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700844 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800845 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400846 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500847 },
Don Zickus2508ce12010-05-07 17:11:46 -0400848 {
849 .procname = "softlockup_panic",
850 .data = &softlockup_panic,
851 .maxlen = sizeof(int),
852 .mode = 0644,
853 .proc_handler = proc_dointvec_minmax,
854 .extra1 = &zero,
855 .extra2 = &one,
856 },
Don Zickus5dc30552010-11-29 17:07:17 -0500857 {
858 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200859 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500860 .maxlen = sizeof (int),
861 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700862 .proc_handler = proc_dowatchdog,
863 .extra1 = &zero,
864 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500865 },
866#endif
867#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
868 {
869 .procname = "unknown_nmi_panic",
870 .data = &unknown_nmi_panic,
871 .maxlen = sizeof (int),
872 .mode = 0644,
873 .proc_handler = proc_dointvec,
874 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500875#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876#if defined(CONFIG_X86)
877 {
Don Zickus8da5add2006-09-26 10:52:27 +0200878 .procname = "panic_on_unrecovered_nmi",
879 .data = &panic_on_unrecovered_nmi,
880 .maxlen = sizeof(int),
881 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800882 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200883 },
884 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700885 .procname = "panic_on_io_nmi",
886 .data = &panic_on_io_nmi,
887 .maxlen = sizeof(int),
888 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800889 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700890 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900891#ifdef CONFIG_DEBUG_STACKOVERFLOW
892 {
893 .procname = "panic_on_stackoverflow",
894 .data = &sysctl_panic_on_stackoverflow,
895 .maxlen = sizeof(int),
896 .mode = 0644,
897 .proc_handler = proc_dointvec,
898 },
899#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700900 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 .procname = "bootloader_type",
902 .data = &bootloader_type,
903 .maxlen = sizeof (int),
904 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800905 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100907 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700908 .procname = "bootloader_version",
909 .data = &bootloader_version,
910 .maxlen = sizeof (int),
911 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800912 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700913 },
914 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100915 .procname = "kstack_depth_to_print",
916 .data = &kstack_depth_to_print,
917 .maxlen = sizeof(int),
918 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800919 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100920 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100921 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100922 .procname = "io_delay_type",
923 .data = &io_delay_type,
924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100927 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800929#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 .procname = "randomize_va_space",
932 .data = &randomize_va_space,
933 .maxlen = sizeof(int),
934 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800935 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800937#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800938#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700939 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700940 .procname = "spin_retry",
941 .data = &spin_retry,
942 .maxlen = sizeof (int),
943 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800944 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700945 },
946#endif
Len Brown673d5b42007-07-28 03:33:16 -0400947#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800948 {
Pavel Machekc255d842006-02-20 18:27:58 -0800949 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700950 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800951 .maxlen = sizeof (unsigned long),
952 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800953 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800954 },
955#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530956#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800957 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800958 .procname = "ignore-unaligned-usertrap",
959 .data = &no_unaligned_warning,
960 .maxlen = sizeof (int),
961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800962 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800963 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530964#endif
965#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800966 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800967 .procname = "unaligned-dump-stack",
968 .data = &unaligned_dump_stack,
969 .maxlen = sizeof (int),
970 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800971 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800972 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800973#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800974#ifdef CONFIG_DETECT_HUNG_TASK
975 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800976 .procname = "hung_task_panic",
977 .data = &sysctl_hung_task_panic,
978 .maxlen = sizeof(int),
979 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800980 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800981 .extra1 = &zero,
982 .extra2 = &one,
983 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100984 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100985 .procname = "hung_task_check_count",
986 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800987 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100988 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800989 .proc_handler = proc_dointvec_minmax,
990 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100991 },
992 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100993 .procname = "hung_task_timeout_secs",
994 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100995 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100998 },
999 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001000 .procname = "hung_task_warnings",
1001 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001002 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001003 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001004 .proc_handler = proc_dointvec_minmax,
1005 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001006 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001007#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001008#ifdef CONFIG_COMPAT
1009 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001010 .procname = "compat-log",
1011 .data = &compat_log,
1012 .maxlen = sizeof (int),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001015 },
1016#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001017#ifdef CONFIG_RT_MUTEXES
1018 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001019 .procname = "max_lock_depth",
1020 .data = &max_lock_depth,
1021 .maxlen = sizeof(int),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001024 },
1025#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001026 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001027 .procname = "poweroff_cmd",
1028 .data = &poweroff_cmd,
1029 .maxlen = POWEROFF_CMD_PATH_LEN,
1030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001032 },
David Howells0b77f5b2008-04-29 01:01:32 -07001033#ifdef CONFIG_KEYS
1034 {
David Howells0b77f5b2008-04-29 01:01:32 -07001035 .procname = "keys",
1036 .mode = 0555,
1037 .child = key_sysctls,
1038 },
1039#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001040#ifdef CONFIG_RCU_TORTURE_TEST
1041 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001042 .procname = "rcutorture_runnable",
1043 .data = &rcutorture_runnable,
1044 .maxlen = sizeof(int),
1045 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001046 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001047 },
1048#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001049#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001050 /*
1051 * User-space scripts rely on the existence of this file
1052 * as a feature check for perf_events being enabled.
1053 *
1054 * So it's an ABI, do not remove!
1055 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001056 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001057 .procname = "perf_event_paranoid",
1058 .data = &sysctl_perf_event_paranoid,
1059 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001060 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001061 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001062 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001063 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001064 .procname = "perf_event_mlock_kb",
1065 .data = &sysctl_perf_event_mlock,
1066 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001067 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001068 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001069 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001070 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001071 .procname = "perf_event_max_sample_rate",
1072 .data = &sysctl_perf_event_sample_rate,
1073 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001074 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001075 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001076 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001077 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001078 {
1079 .procname = "perf_cpu_time_max_percent",
1080 .data = &sysctl_perf_cpu_time_max_percent,
1081 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1082 .mode = 0644,
1083 .proc_handler = perf_cpu_time_max_percent_handler,
1084 .extra1 = &zero,
1085 .extra2 = &one_hundred,
1086 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001087#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001088#ifdef CONFIG_KMEMCHECK
1089 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001090 .procname = "kmemcheck",
1091 .data = &kmemcheck_enabled,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001095 },
1096#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001097#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001098 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001099 .procname = "blk_iopoll",
1100 .data = &blk_iopoll_enabled,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001104 },
Jens Axboecb684b52009-09-15 21:53:11 +02001105#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001106 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107};
1108
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001109static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111 .procname = "overcommit_memory",
1112 .data = &sysctl_overcommit_memory,
1113 .maxlen = sizeof(sysctl_overcommit_memory),
1114 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001115 .proc_handler = proc_dointvec_minmax,
1116 .extra1 = &zero,
1117 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 },
1119 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001120 .procname = "panic_on_oom",
1121 .data = &sysctl_panic_on_oom,
1122 .maxlen = sizeof(sysctl_panic_on_oom),
1123 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001124 .proc_handler = proc_dointvec_minmax,
1125 .extra1 = &zero,
1126 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001127 },
1128 {
David Rientjesfe071d72007-10-16 23:25:56 -07001129 .procname = "oom_kill_allocating_task",
1130 .data = &sysctl_oom_kill_allocating_task,
1131 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1132 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001133 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001134 },
1135 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001136 .procname = "oom_dump_tasks",
1137 .data = &sysctl_oom_dump_tasks,
1138 .maxlen = sizeof(sysctl_oom_dump_tasks),
1139 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001140 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001141 },
1142 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 .procname = "overcommit_ratio",
1144 .data = &sysctl_overcommit_ratio,
1145 .maxlen = sizeof(sysctl_overcommit_ratio),
1146 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001147 .proc_handler = overcommit_ratio_handler,
1148 },
1149 {
1150 .procname = "overcommit_kbytes",
1151 .data = &sysctl_overcommit_kbytes,
1152 .maxlen = sizeof(sysctl_overcommit_kbytes),
1153 .mode = 0644,
1154 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 },
1156 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .procname = "page-cluster",
1158 .data = &page_cluster,
1159 .maxlen = sizeof(int),
1160 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001161 .proc_handler = proc_dointvec_minmax,
1162 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 },
1164 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 .procname = "dirty_background_ratio",
1166 .data = &dirty_background_ratio,
1167 .maxlen = sizeof(dirty_background_ratio),
1168 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001169 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 .extra1 = &zero,
1171 .extra2 = &one_hundred,
1172 },
1173 {
David Rientjes2da02992009-01-06 14:39:31 -08001174 .procname = "dirty_background_bytes",
1175 .data = &dirty_background_bytes,
1176 .maxlen = sizeof(dirty_background_bytes),
1177 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001178 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001179 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001180 },
1181 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 .procname = "dirty_ratio",
1183 .data = &vm_dirty_ratio,
1184 .maxlen = sizeof(vm_dirty_ratio),
1185 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001186 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 .extra1 = &zero,
1188 .extra2 = &one_hundred,
1189 },
1190 {
David Rientjes2da02992009-01-06 14:39:31 -08001191 .procname = "dirty_bytes",
1192 .data = &vm_dirty_bytes,
1193 .maxlen = sizeof(vm_dirty_bytes),
1194 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001195 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001196 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001197 },
1198 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001200 .data = &dirty_writeback_interval,
1201 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001203 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 },
1205 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001207 .data = &dirty_expire_interval,
1208 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001210 .proc_handler = proc_dointvec_minmax,
1211 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212 },
1213 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001214 .procname = "nr_pdflush_threads",
1215 .mode = 0444 /* read-only */,
1216 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 },
1218 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 .procname = "swappiness",
1220 .data = &vm_swappiness,
1221 .maxlen = sizeof(vm_swappiness),
1222 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001223 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 .extra1 = &zero,
1225 .extra2 = &one_hundred,
1226 },
1227#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001228 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001230 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 .maxlen = sizeof(unsigned long),
1232 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001233 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 .extra1 = (void *)&hugetlb_zero,
1235 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001236 },
1237#ifdef CONFIG_NUMA
1238 {
1239 .procname = "nr_hugepages_mempolicy",
1240 .data = NULL,
1241 .maxlen = sizeof(unsigned long),
1242 .mode = 0644,
1243 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1244 .extra1 = (void *)&hugetlb_zero,
1245 .extra2 = (void *)&hugetlb_infinity,
1246 },
1247#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249 .procname = "hugetlb_shm_group",
1250 .data = &sysctl_hugetlb_shm_group,
1251 .maxlen = sizeof(gid_t),
1252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001253 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 },
Mel Gorman396faf02007-07-17 04:03:13 -07001255 {
Mel Gorman396faf02007-07-17 04:03:13 -07001256 .procname = "hugepages_treat_as_movable",
1257 .data = &hugepages_treat_as_movable,
1258 .maxlen = sizeof(int),
1259 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001260 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001261 },
Adam Litke54f9f802007-10-16 01:26:20 -07001262 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001263 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001264 .data = NULL,
1265 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001268 .extra1 = (void *)&hugetlb_zero,
1269 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001270 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271#endif
1272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 .procname = "lowmem_reserve_ratio",
1274 .data = &sysctl_lowmem_reserve_ratio,
1275 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001277 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 },
1279 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001280 .procname = "drop_caches",
1281 .data = &sysctl_drop_caches,
1282 .maxlen = sizeof(int),
1283 .mode = 0644,
1284 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001285 .extra1 = &one,
1286 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001287 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001288#ifdef CONFIG_COMPACTION
1289 {
1290 .procname = "compact_memory",
1291 .data = &sysctl_compact_memory,
1292 .maxlen = sizeof(int),
1293 .mode = 0200,
1294 .proc_handler = sysctl_compaction_handler,
1295 },
Mel Gorman5e771902010-05-24 14:32:31 -07001296 {
1297 .procname = "extfrag_threshold",
1298 .data = &sysctl_extfrag_threshold,
1299 .maxlen = sizeof(int),
1300 .mode = 0644,
1301 .proc_handler = sysctl_extfrag_handler,
1302 .extra1 = &min_extfrag_threshold,
1303 .extra2 = &max_extfrag_threshold,
1304 },
1305
Mel Gorman76ab0f52010-05-24 14:32:28 -07001306#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001307 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 .procname = "min_free_kbytes",
1309 .data = &min_free_kbytes,
1310 .maxlen = sizeof(min_free_kbytes),
1311 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001312 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .extra1 = &zero,
1314 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001315 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001316 .procname = "percpu_pagelist_fraction",
1317 .data = &percpu_pagelist_fraction,
1318 .maxlen = sizeof(percpu_pagelist_fraction),
1319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001320 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001321 .extra1 = &min_percpu_pagelist_fract,
1322 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323#ifdef CONFIG_MMU
1324 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .procname = "max_map_count",
1326 .data = &sysctl_max_map_count,
1327 .maxlen = sizeof(sysctl_max_map_count),
1328 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001329 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001330 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001332#else
1333 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001334 .procname = "nr_trim_pages",
1335 .data = &sysctl_nr_trim_pages,
1336 .maxlen = sizeof(sysctl_nr_trim_pages),
1337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001338 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001339 .extra1 = &zero,
1340 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341#endif
1342 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 .procname = "laptop_mode",
1344 .data = &laptop_mode,
1345 .maxlen = sizeof(laptop_mode),
1346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001347 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 },
1349 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .procname = "block_dump",
1351 .data = &block_dump,
1352 .maxlen = sizeof(block_dump),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .extra1 = &zero,
1356 },
1357 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 .procname = "vfs_cache_pressure",
1359 .data = &sysctl_vfs_cache_pressure,
1360 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 .extra1 = &zero,
1364 },
1365#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1366 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .procname = "legacy_va_layout",
1368 .data = &sysctl_legacy_va_layout,
1369 .maxlen = sizeof(sysctl_legacy_va_layout),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 .extra1 = &zero,
1373 },
1374#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001375#ifdef CONFIG_NUMA
1376 {
Christoph Lameter17436602006-01-18 17:42:32 -08001377 .procname = "zone_reclaim_mode",
1378 .data = &zone_reclaim_mode,
1379 .maxlen = sizeof(zone_reclaim_mode),
1380 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001381 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001382 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001383 },
Christoph Lameter96146342006-07-03 00:24:13 -07001384 {
Christoph Lameter96146342006-07-03 00:24:13 -07001385 .procname = "min_unmapped_ratio",
1386 .data = &sysctl_min_unmapped_ratio,
1387 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001389 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001390 .extra1 = &zero,
1391 .extra2 = &one_hundred,
1392 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001393 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001394 .procname = "min_slab_ratio",
1395 .data = &sysctl_min_slab_ratio,
1396 .maxlen = sizeof(sysctl_min_slab_ratio),
1397 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001398 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001399 .extra1 = &zero,
1400 .extra2 = &one_hundred,
1401 },
Christoph Lameter17436602006-01-18 17:42:32 -08001402#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001403#ifdef CONFIG_SMP
1404 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001405 .procname = "stat_interval",
1406 .data = &sysctl_stat_interval,
1407 .maxlen = sizeof(sysctl_stat_interval),
1408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001409 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001410 },
1411#endif
David Howells6e141542009-12-15 19:27:45 +00001412#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001413 {
Eric Parised032182007-06-28 15:55:21 -04001414 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001415 .data = &dac_mmap_min_addr,
1416 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001419 },
David Howells6e141542009-12-15 19:27:45 +00001420#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001421#ifdef CONFIG_NUMA
1422 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001423 .procname = "numa_zonelist_order",
1424 .data = &numa_zonelist_order,
1425 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1426 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001427 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001428 },
1429#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001430#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001431 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001432 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001433 .procname = "vdso_enabled",
1434 .data = &vdso_enabled,
1435 .maxlen = sizeof(vdso_enabled),
1436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001437 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001438 .extra1 = &zero,
1439 },
1440#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001441#ifdef CONFIG_HIGHMEM
1442 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001443 .procname = "highmem_is_dirtyable",
1444 .data = &vm_highmem_is_dirtyable,
1445 .maxlen = sizeof(vm_highmem_is_dirtyable),
1446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001447 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001448 .extra1 = &zero,
1449 .extra2 = &one,
1450 },
1451#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001452 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001453 .procname = "scan_unevictable_pages",
1454 .data = &scan_unevictable_pages,
1455 .maxlen = sizeof(scan_unevictable_pages),
1456 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001457 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001458 },
Andi Kleen6a460792009-09-16 11:50:15 +02001459#ifdef CONFIG_MEMORY_FAILURE
1460 {
Andi Kleen6a460792009-09-16 11:50:15 +02001461 .procname = "memory_failure_early_kill",
1462 .data = &sysctl_memory_failure_early_kill,
1463 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001465 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001466 .extra1 = &zero,
1467 .extra2 = &one,
1468 },
1469 {
Andi Kleen6a460792009-09-16 11:50:15 +02001470 .procname = "memory_failure_recovery",
1471 .data = &sysctl_memory_failure_recovery,
1472 .maxlen = sizeof(sysctl_memory_failure_recovery),
1473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001475 .extra1 = &zero,
1476 .extra2 = &one,
1477 },
1478#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001479 {
1480 .procname = "user_reserve_kbytes",
1481 .data = &sysctl_user_reserve_kbytes,
1482 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1483 .mode = 0644,
1484 .proc_handler = proc_doulongvec_minmax,
1485 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001486 {
1487 .procname = "admin_reserve_kbytes",
1488 .data = &sysctl_admin_reserve_kbytes,
1489 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1490 .mode = 0644,
1491 .proc_handler = proc_doulongvec_minmax,
1492 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001493 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494};
1495
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001496#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001497static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001498 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001499};
1500#endif
1501
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001502static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 .procname = "inode-nr",
1505 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001506 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001508 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 },
1510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .procname = "inode-state",
1512 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001513 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001515 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 },
1517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 .procname = "file-nr",
1519 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001520 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001522 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 },
1524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 .procname = "file-max",
1526 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001527 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001529 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 },
1531 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001532 .procname = "nr_open",
1533 .data = &sysctl_nr_open,
1534 .maxlen = sizeof(int),
1535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001536 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001537 .extra1 = &sysctl_nr_open_min,
1538 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001539 },
1540 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 .procname = "dentry-state",
1542 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001543 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001545 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 },
1547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 .procname = "overflowuid",
1549 .data = &fs_overflowuid,
1550 .maxlen = sizeof(int),
1551 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 .extra1 = &minolduid,
1554 .extra2 = &maxolduid,
1555 },
1556 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 .procname = "overflowgid",
1558 .data = &fs_overflowgid,
1559 .maxlen = sizeof(int),
1560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001561 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 .extra1 = &minolduid,
1563 .extra2 = &maxolduid,
1564 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001565#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 .procname = "leases-enable",
1568 .data = &leases_enable,
1569 .maxlen = sizeof(int),
1570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001573#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574#ifdef CONFIG_DNOTIFY
1575 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576 .procname = "dir-notify-enable",
1577 .data = &dir_notify_enable,
1578 .maxlen = sizeof(int),
1579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001580 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 },
1582#endif
1583#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001584#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 .procname = "lease-break-time",
1587 .data = &lease_break_time,
1588 .maxlen = sizeof(int),
1589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001592#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001593#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595 .procname = "aio-nr",
1596 .data = &aio_nr,
1597 .maxlen = sizeof(aio_nr),
1598 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001599 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600 },
1601 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 .procname = "aio-max-nr",
1603 .data = &aio_max_nr,
1604 .maxlen = sizeof(aio_max_nr),
1605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001606 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001608#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001609#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001610 {
Robert Love0399cb02005-07-13 12:38:18 -04001611 .procname = "inotify",
1612 .mode = 0555,
1613 .child = inotify_table,
1614 },
1615#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001616#ifdef CONFIG_EPOLL
1617 {
1618 .procname = "epoll",
1619 .mode = 0555,
1620 .child = epoll_table,
1621 },
1622#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001624 {
Kees Cook800179c2012-07-25 17:29:07 -07001625 .procname = "protected_symlinks",
1626 .data = &sysctl_protected_symlinks,
1627 .maxlen = sizeof(int),
1628 .mode = 0600,
1629 .proc_handler = proc_dointvec_minmax,
1630 .extra1 = &zero,
1631 .extra2 = &one,
1632 },
1633 {
1634 .procname = "protected_hardlinks",
1635 .data = &sysctl_protected_hardlinks,
1636 .maxlen = sizeof(int),
1637 .mode = 0600,
1638 .proc_handler = proc_dointvec_minmax,
1639 .extra1 = &zero,
1640 .extra2 = &one,
1641 },
1642 {
Alan Coxd6e71142005-06-23 00:09:43 -07001643 .procname = "suid_dumpable",
1644 .data = &suid_dumpable,
1645 .maxlen = sizeof(int),
1646 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001647 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001648 .extra1 = &zero,
1649 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001650 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001651#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1652 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001653 .procname = "binfmt_misc",
1654 .mode = 0555,
1655 .child = binfmt_misc_table,
1656 },
1657#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001658 {
Jens Axboeff9da692010-06-03 14:54:39 +02001659 .procname = "pipe-max-size",
1660 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001661 .maxlen = sizeof(int),
1662 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001663 .proc_handler = &pipe_proc_fn,
1664 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001665 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001666 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667};
1668
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001669static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001670#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001671 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001672 .procname = "exception-trace",
1673 .data = &show_unhandled_signals,
1674 .maxlen = sizeof(int),
1675 .mode = 0644,
1676 .proc_handler = proc_dointvec
1677 },
1678#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001679#if defined(CONFIG_OPTPROBES)
1680 {
1681 .procname = "kprobes-optimization",
1682 .data = &sysctl_kprobes_optimization,
1683 .maxlen = sizeof(int),
1684 .mode = 0644,
1685 .proc_handler = proc_kprobes_optimization_handler,
1686 .extra1 = &zero,
1687 .extra2 = &one,
1688 },
1689#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001690 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691};
1692
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001693static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001694 { }
Robert Love0eeca282005-07-12 17:06:03 -04001695};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001697int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001698{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001699 struct ctl_table_header *hdr;
1700
1701 hdr = register_sysctl_table(sysctl_base_table);
1702 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001703 return 0;
1704}
1705
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001706#endif /* CONFIG_SYSCTL */
1707
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708/*
1709 * /proc/sys support
1710 */
1711
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001712#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001714static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001715 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001716 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001717{
1718 size_t len;
1719 char __user *p;
1720 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001721
1722 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001723 *lenp = 0;
1724 return 0;
1725 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001726
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001727 if (write) {
1728 len = 0;
1729 p = buffer;
1730 while (len < *lenp) {
1731 if (get_user(c, p++))
1732 return -EFAULT;
1733 if (c == 0 || c == '\n')
1734 break;
1735 len++;
1736 }
1737 if (len >= maxlen)
1738 len = maxlen-1;
1739 if(copy_from_user(data, buffer, len))
1740 return -EFAULT;
1741 ((char *) data)[len] = 0;
1742 *ppos += *lenp;
1743 } else {
1744 len = strlen(data);
1745 if (len > maxlen)
1746 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001747
1748 if (*ppos > len) {
1749 *lenp = 0;
1750 return 0;
1751 }
1752
1753 data += *ppos;
1754 len -= *ppos;
1755
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001756 if (len > *lenp)
1757 len = *lenp;
1758 if (len)
1759 if(copy_to_user(buffer, data, len))
1760 return -EFAULT;
1761 if (len < *lenp) {
1762 if(put_user('\n', ((char __user *) buffer) + len))
1763 return -EFAULT;
1764 len++;
1765 }
1766 *lenp = len;
1767 *ppos += len;
1768 }
1769 return 0;
1770}
1771
Linus Torvalds1da177e2005-04-16 15:20:36 -07001772/**
1773 * proc_dostring - read a string sysctl
1774 * @table: the sysctl table
1775 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001776 * @buffer: the user buffer
1777 * @lenp: the size of the user buffer
1778 * @ppos: file position
1779 *
1780 * Reads/writes a string from/to the user buffer. If the kernel
1781 * buffer provided is not large enough to hold the string, the
1782 * string is truncated. The copied string is %NULL-terminated.
1783 * If the string is being read by the user process, it is copied
1784 * and a newline '\n' is added. It is truncated if the buffer is
1785 * not large enough.
1786 *
1787 * Returns 0 on success.
1788 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001789int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001790 void __user *buffer, size_t *lenp, loff_t *ppos)
1791{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001792 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001793 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794}
1795
Amerigo Wang00b7c332010-05-05 00:26:45 +00001796static size_t proc_skip_spaces(char **buf)
1797{
1798 size_t ret;
1799 char *tmp = skip_spaces(*buf);
1800 ret = tmp - *buf;
1801 *buf = tmp;
1802 return ret;
1803}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001805static void proc_skip_char(char **buf, size_t *size, const char v)
1806{
1807 while (*size) {
1808 if (**buf != v)
1809 break;
1810 (*size)--;
1811 (*buf)++;
1812 }
1813}
1814
Amerigo Wang00b7c332010-05-05 00:26:45 +00001815#define TMPBUFLEN 22
1816/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001817 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001818 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001819 * @buf: a kernel buffer
1820 * @size: size of the kernel buffer
1821 * @val: this is where the number will be stored
1822 * @neg: set to %TRUE if number is negative
1823 * @perm_tr: a vector which contains the allowed trailers
1824 * @perm_tr_len: size of the perm_tr vector
1825 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001826 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001827 * In case of success %0 is returned and @buf and @size are updated with
1828 * the amount of bytes read. If @tr is non-NULL and a trailing
1829 * character exists (size is non-zero after returning from this
1830 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001831 */
1832static int proc_get_long(char **buf, size_t *size,
1833 unsigned long *val, bool *neg,
1834 const char *perm_tr, unsigned perm_tr_len, char *tr)
1835{
1836 int len;
1837 char *p, tmp[TMPBUFLEN];
1838
1839 if (!*size)
1840 return -EINVAL;
1841
1842 len = *size;
1843 if (len > TMPBUFLEN - 1)
1844 len = TMPBUFLEN - 1;
1845
1846 memcpy(tmp, *buf, len);
1847
1848 tmp[len] = 0;
1849 p = tmp;
1850 if (*p == '-' && *size > 1) {
1851 *neg = true;
1852 p++;
1853 } else
1854 *neg = false;
1855 if (!isdigit(*p))
1856 return -EINVAL;
1857
1858 *val = simple_strtoul(p, &p, 0);
1859
1860 len = p - tmp;
1861
1862 /* We don't know if the next char is whitespace thus we may accept
1863 * invalid integers (e.g. 1234...a) or two integers instead of one
1864 * (e.g. 123...1). So lets not allow such large numbers. */
1865 if (len == TMPBUFLEN - 1)
1866 return -EINVAL;
1867
1868 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1869 return -EINVAL;
1870
1871 if (tr && (len < *size))
1872 *tr = *p;
1873
1874 *buf += len;
1875 *size -= len;
1876
1877 return 0;
1878}
1879
1880/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001881 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001882 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001883 * @buf: the user buffer
1884 * @size: the size of the user buffer
1885 * @val: the integer to be converted
1886 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001887 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001888 * In case of success %0 is returned and @buf and @size are updated with
1889 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001890 */
1891static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1892 bool neg)
1893{
1894 int len;
1895 char tmp[TMPBUFLEN], *p = tmp;
1896
1897 sprintf(p, "%s%lu", neg ? "-" : "", val);
1898 len = strlen(tmp);
1899 if (len > *size)
1900 len = *size;
1901 if (copy_to_user(*buf, tmp, len))
1902 return -EFAULT;
1903 *size -= len;
1904 *buf += len;
1905 return 0;
1906}
1907#undef TMPBUFLEN
1908
1909static int proc_put_char(void __user **buf, size_t *size, char c)
1910{
1911 if (*size) {
1912 char __user **buffer = (char __user **)buf;
1913 if (put_user(c, *buffer))
1914 return -EFAULT;
1915 (*size)--, (*buffer)++;
1916 *buf = *buffer;
1917 }
1918 return 0;
1919}
1920
1921static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922 int *valp,
1923 int write, void *data)
1924{
1925 if (write) {
1926 *valp = *negp ? -*lvalp : *lvalp;
1927 } else {
1928 int val = *valp;
1929 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001930 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931 *lvalp = (unsigned long)-val;
1932 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001933 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934 *lvalp = (unsigned long)val;
1935 }
1936 }
1937 return 0;
1938}
1939
Amerigo Wang00b7c332010-05-05 00:26:45 +00001940static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1941
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001942static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001943 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001944 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001945 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001946 int write, void *data),
1947 void *data)
1948{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001949 int *i, vleft, first = 1, err = 0;
1950 unsigned long page = 0;
1951 size_t left;
1952 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001953
Amerigo Wang00b7c332010-05-05 00:26:45 +00001954 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001955 *lenp = 0;
1956 return 0;
1957 }
1958
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001959 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960 vleft = table->maxlen / sizeof(*i);
1961 left = *lenp;
1962
1963 if (!conv)
1964 conv = do_proc_dointvec_conv;
1965
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001967 if (left > PAGE_SIZE - 1)
1968 left = PAGE_SIZE - 1;
1969 page = __get_free_page(GFP_TEMPORARY);
1970 kbuf = (char *) page;
1971 if (!kbuf)
1972 return -ENOMEM;
1973 if (copy_from_user(kbuf, buffer, left)) {
1974 err = -EFAULT;
1975 goto free;
1976 }
1977 kbuf[left] = 0;
1978 }
1979
1980 for (; left && vleft--; i++, first=0) {
1981 unsigned long lval;
1982 bool neg;
1983
1984 if (write) {
1985 left -= proc_skip_spaces(&kbuf);
1986
J. R. Okajima563b0462010-05-25 16:10:14 -07001987 if (!left)
1988 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001989 err = proc_get_long(&kbuf, &left, &lval, &neg,
1990 proc_wspace_sep,
1991 sizeof(proc_wspace_sep), NULL);
1992 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001994 if (conv(&neg, &lval, i, 1, data)) {
1995 err = -EINVAL;
1996 break;
1997 }
1998 } else {
1999 if (conv(&neg, &lval, i, 0, data)) {
2000 err = -EINVAL;
2001 break;
2002 }
2003 if (!first)
2004 err = proc_put_char(&buffer, &left, '\t');
2005 if (err)
2006 break;
2007 err = proc_put_long(&buffer, &left, lval, neg);
2008 if (err)
2009 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010 }
2011 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002012
2013 if (!write && !first && left && !err)
2014 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002015 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002016 left -= proc_skip_spaces(&kbuf);
2017free:
2018 if (write) {
2019 free_page(page);
2020 if (first)
2021 return err ? : -EINVAL;
2022 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 *lenp -= left;
2024 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002025 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026}
2027
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002028static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002029 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002030 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002031 int write, void *data),
2032 void *data)
2033{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002034 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002035 buffer, lenp, ppos, conv, data);
2036}
2037
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038/**
2039 * proc_dointvec - read a vector of integers
2040 * @table: the sysctl table
2041 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042 * @buffer: the user buffer
2043 * @lenp: the size of the user buffer
2044 * @ppos: file position
2045 *
2046 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2047 * values from/to the user buffer, treated as an ASCII string.
2048 *
2049 * Returns 0 on success.
2050 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002051int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 void __user *buffer, size_t *lenp, loff_t *ppos)
2053{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002054 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055 NULL,NULL);
2056}
2057
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002058/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002059 * Taint values can only be increased
2060 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002061 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002062static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002063 void __user *buffer, size_t *lenp, loff_t *ppos)
2064{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002065 struct ctl_table t;
2066 unsigned long tmptaint = get_taint();
2067 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002068
Bastian Blank91fcd412007-04-23 14:41:14 -07002069 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002070 return -EPERM;
2071
Andi Kleen25ddbb12008-10-15 22:01:41 -07002072 t = *table;
2073 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002074 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002075 if (err < 0)
2076 return err;
2077
2078 if (write) {
2079 /*
2080 * Poor man's atomic or. Not worth adding a primitive
2081 * to everyone's atomic.h for this
2082 */
2083 int i;
2084 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2085 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302086 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002087 }
2088 }
2089
2090 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002091}
2092
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002093#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002094static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002095 void __user *buffer, size_t *lenp, loff_t *ppos)
2096{
2097 if (write && !capable(CAP_SYS_ADMIN))
2098 return -EPERM;
2099
2100 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2101}
2102#endif
2103
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104struct do_proc_dointvec_minmax_conv_param {
2105 int *min;
2106 int *max;
2107};
2108
Amerigo Wang00b7c332010-05-05 00:26:45 +00002109static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2110 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111 int write, void *data)
2112{
2113 struct do_proc_dointvec_minmax_conv_param *param = data;
2114 if (write) {
2115 int val = *negp ? -*lvalp : *lvalp;
2116 if ((param->min && *param->min > val) ||
2117 (param->max && *param->max < val))
2118 return -EINVAL;
2119 *valp = val;
2120 } else {
2121 int val = *valp;
2122 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002123 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124 *lvalp = (unsigned long)-val;
2125 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002126 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127 *lvalp = (unsigned long)val;
2128 }
2129 }
2130 return 0;
2131}
2132
2133/**
2134 * proc_dointvec_minmax - read a vector of integers with min/max values
2135 * @table: the sysctl table
2136 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 * @buffer: the user buffer
2138 * @lenp: the size of the user buffer
2139 * @ppos: file position
2140 *
2141 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2142 * values from/to the user buffer, treated as an ASCII string.
2143 *
2144 * This routine will ensure the values are within the range specified by
2145 * table->extra1 (min) and table->extra2 (max).
2146 *
2147 * Returns 0 on success.
2148 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002149int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 void __user *buffer, size_t *lenp, loff_t *ppos)
2151{
2152 struct do_proc_dointvec_minmax_conv_param param = {
2153 .min = (int *) table->extra1,
2154 .max = (int *) table->extra2,
2155 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002156 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 do_proc_dointvec_minmax_conv, &param);
2158}
2159
Kees Cook54b50192012-07-30 14:39:18 -07002160static void validate_coredump_safety(void)
2161{
Alex Kelly046d6622012-10-04 17:15:23 -07002162#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002163 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002164 core_pattern[0] != '/' && core_pattern[0] != '|') {
2165 printk(KERN_WARNING "Unsafe core_pattern used with "\
2166 "suid_dumpable=2. Pipe handler or fully qualified "\
2167 "core dump path required.\n");
2168 }
Alex Kelly046d6622012-10-04 17:15:23 -07002169#endif
Kees Cook54b50192012-07-30 14:39:18 -07002170}
2171
2172static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2173 void __user *buffer, size_t *lenp, loff_t *ppos)
2174{
2175 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2176 if (!error)
2177 validate_coredump_safety();
2178 return error;
2179}
2180
Alex Kelly046d6622012-10-04 17:15:23 -07002181#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002182static int proc_dostring_coredump(struct ctl_table *table, int write,
2183 void __user *buffer, size_t *lenp, loff_t *ppos)
2184{
2185 int error = proc_dostring(table, write, buffer, lenp, ppos);
2186 if (!error)
2187 validate_coredump_safety();
2188 return error;
2189}
Alex Kelly046d6622012-10-04 17:15:23 -07002190#endif
Kees Cook54b50192012-07-30 14:39:18 -07002191
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002192static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193 void __user *buffer,
2194 size_t *lenp, loff_t *ppos,
2195 unsigned long convmul,
2196 unsigned long convdiv)
2197{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002198 unsigned long *i, *min, *max;
2199 int vleft, first = 1, err = 0;
2200 unsigned long page = 0;
2201 size_t left;
2202 char *kbuf;
2203
2204 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 *lenp = 0;
2206 return 0;
2207 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002208
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002209 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 min = (unsigned long *) table->extra1;
2211 max = (unsigned long *) table->extra2;
2212 vleft = table->maxlen / sizeof(unsigned long);
2213 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002214
2215 if (write) {
2216 if (left > PAGE_SIZE - 1)
2217 left = PAGE_SIZE - 1;
2218 page = __get_free_page(GFP_TEMPORARY);
2219 kbuf = (char *) page;
2220 if (!kbuf)
2221 return -ENOMEM;
2222 if (copy_from_user(kbuf, buffer, left)) {
2223 err = -EFAULT;
2224 goto free;
2225 }
2226 kbuf[left] = 0;
2227 }
2228
Eric Dumazet27b3d802010-10-07 12:59:29 -07002229 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002230 unsigned long val;
2231
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002233 bool neg;
2234
2235 left -= proc_skip_spaces(&kbuf);
2236
2237 err = proc_get_long(&kbuf, &left, &val, &neg,
2238 proc_wspace_sep,
2239 sizeof(proc_wspace_sep), NULL);
2240 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 break;
2242 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 continue;
2244 if ((min && val < *min) || (max && val > *max))
2245 continue;
2246 *i = val;
2247 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002248 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002249 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002250 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002251 if (err)
2252 break;
2253 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002254 err = proc_put_long(&buffer, &left, val, false);
2255 if (err)
2256 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 }
2258 }
2259
Amerigo Wang00b7c332010-05-05 00:26:45 +00002260 if (!write && !first && left && !err)
2261 err = proc_put_char(&buffer, &left, '\n');
2262 if (write && !err)
2263 left -= proc_skip_spaces(&kbuf);
2264free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002266 free_page(page);
2267 if (first)
2268 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 *lenp -= left;
2271 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002272 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273}
2274
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002275static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002276 void __user *buffer,
2277 size_t *lenp, loff_t *ppos,
2278 unsigned long convmul,
2279 unsigned long convdiv)
2280{
2281 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002282 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002283}
2284
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285/**
2286 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2287 * @table: the sysctl table
2288 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 * @buffer: the user buffer
2290 * @lenp: the size of the user buffer
2291 * @ppos: file position
2292 *
2293 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2294 * values from/to the user buffer, treated as an ASCII string.
2295 *
2296 * This routine will ensure the values are within the range specified by
2297 * table->extra1 (min) and table->extra2 (max).
2298 *
2299 * Returns 0 on success.
2300 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002301int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 void __user *buffer, size_t *lenp, loff_t *ppos)
2303{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002304 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305}
2306
2307/**
2308 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2309 * @table: the sysctl table
2310 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311 * @buffer: the user buffer
2312 * @lenp: the size of the user buffer
2313 * @ppos: file position
2314 *
2315 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2316 * values from/to the user buffer, treated as an ASCII string. The values
2317 * are treated as milliseconds, and converted to jiffies when they are stored.
2318 *
2319 * This routine will ensure the values are within the range specified by
2320 * table->extra1 (min) and table->extra2 (max).
2321 *
2322 * Returns 0 on success.
2323 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002324int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 void __user *buffer,
2326 size_t *lenp, loff_t *ppos)
2327{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002328 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 lenp, ppos, HZ, 1000l);
2330}
2331
2332
Amerigo Wang00b7c332010-05-05 00:26:45 +00002333static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 int *valp,
2335 int write, void *data)
2336{
2337 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002338 if (*lvalp > LONG_MAX / HZ)
2339 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2341 } else {
2342 int val = *valp;
2343 unsigned long lval;
2344 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002345 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346 lval = (unsigned long)-val;
2347 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 lval = (unsigned long)val;
2350 }
2351 *lvalp = lval / HZ;
2352 }
2353 return 0;
2354}
2355
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 int *valp,
2358 int write, void *data)
2359{
2360 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002361 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2362 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002363 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2364 } else {
2365 int val = *valp;
2366 unsigned long lval;
2367 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002368 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 lval = (unsigned long)-val;
2370 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002371 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 lval = (unsigned long)val;
2373 }
2374 *lvalp = jiffies_to_clock_t(lval);
2375 }
2376 return 0;
2377}
2378
Amerigo Wang00b7c332010-05-05 00:26:45 +00002379static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 int *valp,
2381 int write, void *data)
2382{
2383 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002384 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2385
2386 if (jif > INT_MAX)
2387 return 1;
2388 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 } else {
2390 int val = *valp;
2391 unsigned long lval;
2392 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002393 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 lval = (unsigned long)-val;
2395 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002396 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 lval = (unsigned long)val;
2398 }
2399 *lvalp = jiffies_to_msecs(lval);
2400 }
2401 return 0;
2402}
2403
2404/**
2405 * proc_dointvec_jiffies - read a vector of integers as seconds
2406 * @table: the sysctl table
2407 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 * @buffer: the user buffer
2409 * @lenp: the size of the user buffer
2410 * @ppos: file position
2411 *
2412 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2413 * values from/to the user buffer, treated as an ASCII string.
2414 * The values read are assumed to be in seconds, and are converted into
2415 * jiffies.
2416 *
2417 * Returns 0 on success.
2418 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002419int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 void __user *buffer, size_t *lenp, loff_t *ppos)
2421{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002422 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 do_proc_dointvec_jiffies_conv,NULL);
2424}
2425
2426/**
2427 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2428 * @table: the sysctl table
2429 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 * @buffer: the user buffer
2431 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002432 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 *
2434 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2435 * values from/to the user buffer, treated as an ASCII string.
2436 * The values read are assumed to be in 1/USER_HZ seconds, and
2437 * are converted into jiffies.
2438 *
2439 * Returns 0 on success.
2440 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002441int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 void __user *buffer, size_t *lenp, loff_t *ppos)
2443{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002444 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 do_proc_dointvec_userhz_jiffies_conv,NULL);
2446}
2447
2448/**
2449 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2450 * @table: the sysctl table
2451 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 * @buffer: the user buffer
2453 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002454 * @ppos: file position
2455 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 *
2457 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2458 * values from/to the user buffer, treated as an ASCII string.
2459 * The values read are assumed to be in 1/1000 seconds, and
2460 * are converted into jiffies.
2461 *
2462 * Returns 0 on success.
2463 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002464int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 void __user *buffer, size_t *lenp, loff_t *ppos)
2466{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002467 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 do_proc_dointvec_ms_jiffies_conv, NULL);
2469}
2470
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002471static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002472 void __user *buffer, size_t *lenp, loff_t *ppos)
2473{
2474 struct pid *new_pid;
2475 pid_t tmp;
2476 int r;
2477
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002478 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002479
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002480 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002481 lenp, ppos, NULL, NULL);
2482 if (r || !write)
2483 return r;
2484
2485 new_pid = find_get_pid(tmp);
2486 if (!new_pid)
2487 return -ESRCH;
2488
2489 put_pid(xchg(&cad_pid, new_pid));
2490 return 0;
2491}
2492
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002493/**
2494 * proc_do_large_bitmap - read/write from/to a large bitmap
2495 * @table: the sysctl table
2496 * @write: %TRUE if this is a write to the sysctl file
2497 * @buffer: the user buffer
2498 * @lenp: the size of the user buffer
2499 * @ppos: file position
2500 *
2501 * The bitmap is stored at table->data and the bitmap length (in bits)
2502 * in table->maxlen.
2503 *
2504 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2505 * large bitmaps may be represented in a compact manner. Writing into
2506 * the file will clear the bitmap then update it with the given input.
2507 *
2508 * Returns 0 on success.
2509 */
2510int proc_do_large_bitmap(struct ctl_table *table, int write,
2511 void __user *buffer, size_t *lenp, loff_t *ppos)
2512{
2513 int err = 0;
2514 bool first = 1;
2515 size_t left = *lenp;
2516 unsigned long bitmap_len = table->maxlen;
2517 unsigned long *bitmap = (unsigned long *) table->data;
2518 unsigned long *tmp_bitmap = NULL;
2519 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2520
2521 if (!bitmap_len || !left || (*ppos && !write)) {
2522 *lenp = 0;
2523 return 0;
2524 }
2525
2526 if (write) {
2527 unsigned long page = 0;
2528 char *kbuf;
2529
2530 if (left > PAGE_SIZE - 1)
2531 left = PAGE_SIZE - 1;
2532
2533 page = __get_free_page(GFP_TEMPORARY);
2534 kbuf = (char *) page;
2535 if (!kbuf)
2536 return -ENOMEM;
2537 if (copy_from_user(kbuf, buffer, left)) {
2538 free_page(page);
2539 return -EFAULT;
2540 }
2541 kbuf[left] = 0;
2542
2543 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2544 GFP_KERNEL);
2545 if (!tmp_bitmap) {
2546 free_page(page);
2547 return -ENOMEM;
2548 }
2549 proc_skip_char(&kbuf, &left, '\n');
2550 while (!err && left) {
2551 unsigned long val_a, val_b;
2552 bool neg;
2553
2554 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2555 sizeof(tr_a), &c);
2556 if (err)
2557 break;
2558 if (val_a >= bitmap_len || neg) {
2559 err = -EINVAL;
2560 break;
2561 }
2562
2563 val_b = val_a;
2564 if (left) {
2565 kbuf++;
2566 left--;
2567 }
2568
2569 if (c == '-') {
2570 err = proc_get_long(&kbuf, &left, &val_b,
2571 &neg, tr_b, sizeof(tr_b),
2572 &c);
2573 if (err)
2574 break;
2575 if (val_b >= bitmap_len || neg ||
2576 val_a > val_b) {
2577 err = -EINVAL;
2578 break;
2579 }
2580 if (left) {
2581 kbuf++;
2582 left--;
2583 }
2584 }
2585
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002586 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002587 first = 0;
2588 proc_skip_char(&kbuf, &left, '\n');
2589 }
2590 free_page(page);
2591 } else {
2592 unsigned long bit_a, bit_b = 0;
2593
2594 while (left) {
2595 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2596 if (bit_a >= bitmap_len)
2597 break;
2598 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2599 bit_a + 1) - 1;
2600
2601 if (!first) {
2602 err = proc_put_char(&buffer, &left, ',');
2603 if (err)
2604 break;
2605 }
2606 err = proc_put_long(&buffer, &left, bit_a, false);
2607 if (err)
2608 break;
2609 if (bit_a != bit_b) {
2610 err = proc_put_char(&buffer, &left, '-');
2611 if (err)
2612 break;
2613 err = proc_put_long(&buffer, &left, bit_b, false);
2614 if (err)
2615 break;
2616 }
2617
2618 first = 0; bit_b++;
2619 }
2620 if (!err)
2621 err = proc_put_char(&buffer, &left, '\n');
2622 }
2623
2624 if (!err) {
2625 if (write) {
2626 if (*ppos)
2627 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2628 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002629 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002630 }
2631 kfree(tmp_bitmap);
2632 *lenp -= left;
2633 *ppos += *lenp;
2634 return 0;
2635 } else {
2636 kfree(tmp_bitmap);
2637 return err;
2638 }
2639}
2640
Jovi Zhang55610502011-01-12 17:00:45 -08002641#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002643int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 void __user *buffer, size_t *lenp, loff_t *ppos)
2645{
2646 return -ENOSYS;
2647}
2648
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002649int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 void __user *buffer, size_t *lenp, loff_t *ppos)
2651{
2652 return -ENOSYS;
2653}
2654
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002655int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 void __user *buffer, size_t *lenp, loff_t *ppos)
2657{
2658 return -ENOSYS;
2659}
2660
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002661int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 void __user *buffer, size_t *lenp, loff_t *ppos)
2663{
2664 return -ENOSYS;
2665}
2666
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002667int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 void __user *buffer, size_t *lenp, loff_t *ppos)
2669{
2670 return -ENOSYS;
2671}
2672
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002673int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 void __user *buffer, size_t *lenp, loff_t *ppos)
2675{
2676 return -ENOSYS;
2677}
2678
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002679int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 void __user *buffer, size_t *lenp, loff_t *ppos)
2681{
2682 return -ENOSYS;
2683}
2684
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002685int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 void __user *buffer,
2687 size_t *lenp, loff_t *ppos)
2688{
2689 return -ENOSYS;
2690}
2691
2692
Jovi Zhang55610502011-01-12 17:00:45 -08002693#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694
Linus Torvalds1da177e2005-04-16 15:20:36 -07002695/*
2696 * No sense putting this after each symbol definition, twice,
2697 * exception granted :-)
2698 */
2699EXPORT_SYMBOL(proc_dointvec);
2700EXPORT_SYMBOL(proc_dointvec_jiffies);
2701EXPORT_SYMBOL(proc_dointvec_minmax);
2702EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2703EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2704EXPORT_SYMBOL(proc_dostring);
2705EXPORT_SYMBOL(proc_doulongvec_minmax);
2706EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);