blob: dd5b4496637e284009a0e34280e98d88772f91f8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070026#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080027#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080028#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070030#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020032#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070033#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070034#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/init.h>
36#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010037#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030038#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/sysrq.h>
40#include <linux/highuid.h>
41#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020042#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070043#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070046#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/times.h>
48#include <linux/limits.h>
49#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020050#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070052#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080053#include <linux/nfs_fs.h>
54#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070055#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020056#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020057#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050058#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020059#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070060#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040061#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070062#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000063#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060064#include <linux/sched/sysctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#include <asm/uaccess.h>
67#include <asm/processor.h>
68
Andi Kleen29cbc782006-09-30 01:47:55 +020069#ifdef CONFIG_X86
70#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010071#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010072#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020073#endif
David Howellsd550bbd2012-03-28 18:30:03 +010074#ifdef CONFIG_SPARC
75#include <asm/setup.h>
76#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080077#ifdef CONFIG_BSD_PROCESS_ACCT
78#include <linux/acct.h>
79#endif
Dave Young4f0e0562010-03-10 15:24:09 -080080#ifdef CONFIG_RT_MUTEXES
81#include <linux/rtmutex.h>
82#endif
Dave Young2edf5e42010-03-10 15:24:10 -080083#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
84#include <linux/lockdep.h>
85#endif
Dave Young15485a42010-03-10 15:24:07 -080086#ifdef CONFIG_CHR_DEV_SG
87#include <scsi/sg.h>
88#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020089
Don Zickus58687ac2010-05-07 17:11:44 -040090#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050091#include <linux/nmi.h>
92#endif
93
Eric W. Biederman7058cb02007-10-18 03:05:58 -070094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#if defined(CONFIG_SYSCTL)
96
97/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern int sysctl_overcommit_memory;
99extern int sysctl_overcommit_ratio;
100extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200110extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100111extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400112extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000113#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages;
115#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200116#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200117extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200118#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400121#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700122static int sixty = 60;
123#endif
124
Aaron Tomlin270750db2014-01-20 17:34:13 +0000125static int __maybe_unused neg_one = -1;
126
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700127static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700128static int __maybe_unused one = 1;
129static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700130static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800131static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800143static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Dave Youngd14f1722010-02-25 20:28:57 -0500148#ifdef CONFIG_INOTIFY_USER
149#include <linux/inotify.h>
150#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700151#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif
153
David S. Miller08714202008-11-16 23:49:24 -0800154#ifdef CONFIG_SPARC64
155extern int sysctl_tsb_ratio;
156#endif
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#ifdef __hppa__
159extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530160#endif
161
162#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163extern int unaligned_enabled;
164#endif
165
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800167extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800168#endif
169
Vineet Guptab6fca722013-01-09 20:06:28 +0530170#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171extern int no_unaligned_warning;
172#endif
173
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700175static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700176 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700177static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800178 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700179#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700180
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700181#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700182static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700183 void __user *buffer, size_t *lenp, loff_t *ppos);
184#endif
185
Kees Cook54b50192012-07-30 14:39:18 -0700186static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
187 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700188#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700189static int proc_dostring_coredump(struct ctl_table *table, int write,
190 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700191#endif
Kees Cook54b50192012-07-30 14:39:18 -0700192
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700193#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800194/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100195static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700196
197static int sysrq_sysctl_handler(ctl_table *table, int write,
198 void __user *buffer, size_t *lenp,
199 loff_t *ppos)
200{
201 int error;
202
203 error = proc_dointvec(table, write, buffer, lenp, ppos);
204 if (error)
205 return error;
206
207 if (write)
208 sysrq_toggle_support(__sysrq_enabled);
209
210 return 0;
211}
212
213#endif
214
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700215static struct ctl_table kern_table[];
216static struct ctl_table vm_table[];
217static struct ctl_table fs_table[];
218static struct ctl_table debug_table[];
219static struct ctl_table dev_table[];
220extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800221#ifdef CONFIG_EPOLL
222extern struct ctl_table epoll_table[];
223#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
225#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
226int sysctl_legacy_va_layout;
227#endif
228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229/* The default sysctl tables: */
230
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800231static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 .procname = "kernel",
234 .mode = 0555,
235 .child = kern_table,
236 },
237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 .procname = "vm",
239 .mode = 0555,
240 .child = vm_table,
241 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "fs",
244 .mode = 0555,
245 .child = fs_table,
246 },
247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "debug",
249 .mode = 0555,
250 .child = debug_table,
251 },
252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 .procname = "dev",
254 .mode = 0555,
255 .child = dev_table,
256 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700257 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258};
259
Ingo Molnar77e54a12007-07-09 18:52:00 +0200260#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100261static int min_sched_granularity_ns = 100000; /* 100 usecs */
262static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
263static int min_wakeup_granularity_ns; /* 0 usecs */
264static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200265#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100266static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
267static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200268#endif /* CONFIG_SMP */
269#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200270
Mel Gorman5e771902010-05-24 14:32:31 -0700271#ifdef CONFIG_COMPACTION
272static int min_extfrag_threshold;
273static int max_extfrag_threshold = 1000;
274#endif
275
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700276static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200277 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200278 .procname = "sched_child_runs_first",
279 .data = &sysctl_sched_child_runs_first,
280 .maxlen = sizeof(unsigned int),
281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800282 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200283 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200284#ifdef CONFIG_SCHED_DEBUG
285 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100286 .procname = "sched_min_granularity_ns",
287 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200288 .maxlen = sizeof(unsigned int),
289 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800290 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100291 .extra1 = &min_sched_granularity_ns,
292 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200293 },
294 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200295 .procname = "sched_latency_ns",
296 .data = &sysctl_sched_latency,
297 .maxlen = sizeof(unsigned int),
298 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800299 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200300 .extra1 = &min_sched_granularity_ns,
301 .extra2 = &max_sched_granularity_ns,
302 },
303 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200304 .procname = "sched_wakeup_granularity_ns",
305 .data = &sysctl_sched_wakeup_granularity,
306 .maxlen = sizeof(unsigned int),
307 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800308 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200309 .extra1 = &min_wakeup_granularity_ns,
310 .extra2 = &max_wakeup_granularity_ns,
311 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200312#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200313 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100314 .procname = "sched_tunable_scaling",
315 .data = &sysctl_sched_tunable_scaling,
316 .maxlen = sizeof(enum sched_tunable_scaling),
317 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800318 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100319 .extra1 = &min_sched_tunable_scaling,
320 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200321 },
322 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900323 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200324 .data = &sysctl_sched_migration_cost,
325 .maxlen = sizeof(unsigned int),
326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800327 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200328 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100329 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100330 .procname = "sched_nr_migrate",
331 .data = &sysctl_sched_nr_migrate,
332 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100335 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530336 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900337 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200338 .data = &sysctl_sched_time_avg,
339 .maxlen = sizeof(unsigned int),
340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800341 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200342 },
343 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900344 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800345 .data = &sysctl_sched_shares_window,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
348 .proc_handler = proc_dointvec,
349 },
350 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530351 .procname = "timer_migration",
352 .data = &sysctl_timer_migration,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800355 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530356 .extra1 = &zero,
357 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530358 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200359#endif /* CONFIG_SMP */
360#ifdef CONFIG_NUMA_BALANCING
361 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200362 .procname = "numa_balancing_scan_delay_ms",
363 .data = &sysctl_numa_balancing_scan_delay,
364 .maxlen = sizeof(unsigned int),
365 .mode = 0644,
366 .proc_handler = proc_dointvec,
367 },
368 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200369 .procname = "numa_balancing_scan_period_min_ms",
370 .data = &sysctl_numa_balancing_scan_period_min,
371 .maxlen = sizeof(unsigned int),
372 .mode = 0644,
373 .proc_handler = proc_dointvec,
374 },
375 {
376 .procname = "numa_balancing_scan_period_max_ms",
377 .data = &sysctl_numa_balancing_scan_period_max,
378 .maxlen = sizeof(unsigned int),
379 .mode = 0644,
380 .proc_handler = proc_dointvec,
381 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200382 {
383 .procname = "numa_balancing_scan_size_mb",
384 .data = &sysctl_numa_balancing_scan_size,
385 .maxlen = sizeof(unsigned int),
386 .mode = 0644,
387 .proc_handler = proc_dointvec,
388 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100389 {
Rik van Rielde1c9ce2013-10-07 11:29:39 +0100390 .procname = "numa_balancing_migrate_deferred",
391 .data = &sysctl_numa_balancing_migrate_deferred,
392 .maxlen = sizeof(unsigned int),
393 .mode = 0644,
394 .proc_handler = proc_dointvec,
395 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200396#endif /* CONFIG_NUMA_BALANCING */
397#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200398 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100399 .procname = "sched_rt_period_us",
400 .data = &sysctl_sched_rt_period,
401 .maxlen = sizeof(unsigned int),
402 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800403 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100404 },
405 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100406 .procname = "sched_rt_runtime_us",
407 .data = &sysctl_sched_rt_runtime,
408 .maxlen = sizeof(int),
409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800410 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100411 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600412 {
413 .procname = "sched_rr_timeslice_ms",
414 .data = &sched_rr_timeslice,
415 .maxlen = sizeof(int),
416 .mode = 0644,
417 .proc_handler = sched_rr_handler,
418 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100419#ifdef CONFIG_SCHED_AUTOGROUP
420 {
421 .procname = "sched_autogroup_enabled",
422 .data = &sysctl_sched_autogroup_enabled,
423 .maxlen = sizeof(unsigned int),
424 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800425 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100426 .extra1 = &zero,
427 .extra2 = &one,
428 },
429#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700430#ifdef CONFIG_CFS_BANDWIDTH
431 {
432 .procname = "sched_cfs_bandwidth_slice_us",
433 .data = &sysctl_sched_cfs_bandwidth_slice,
434 .maxlen = sizeof(unsigned int),
435 .mode = 0644,
436 .proc_handler = proc_dointvec_minmax,
437 .extra1 = &one,
438 },
439#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700440#ifdef CONFIG_PROVE_LOCKING
441 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700442 .procname = "prove_locking",
443 .data = &prove_locking,
444 .maxlen = sizeof(int),
445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800446 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700447 },
448#endif
449#ifdef CONFIG_LOCK_STAT
450 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700451 .procname = "lock_stat",
452 .data = &lock_stat,
453 .maxlen = sizeof(int),
454 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800455 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700456 },
457#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 .procname = "panic",
460 .data = &panic_timeout,
461 .maxlen = sizeof(int),
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 },
Alex Kelly046d6622012-10-04 17:15:23 -0700465#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 .procname = "core_uses_pid",
468 .data = &core_uses_pid,
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 },
473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 .procname = "core_pattern",
475 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700476 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700478 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 },
Neil Hormana2939802009-09-23 15:56:56 -0700480 {
Neil Hormana2939802009-09-23 15:56:56 -0700481 .procname = "core_pipe_limit",
482 .data = &core_pipe_limit,
483 .maxlen = sizeof(unsigned int),
484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800485 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700486 },
Alex Kelly046d6622012-10-04 17:15:23 -0700487#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800488#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700491 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800493 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800495#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100496#ifdef CONFIG_LATENCYTOP
497 {
498 .procname = "latencytop",
499 .data = &latencytop_enabled,
500 .maxlen = sizeof(int),
501 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800502 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100503 },
504#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505#ifdef CONFIG_BLK_DEV_INITRD
506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 .procname = "real-root-dev",
508 .data = &real_root_dev,
509 .maxlen = sizeof(int),
510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800511 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 },
513#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700514 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700515 .procname = "print-fatal-signals",
516 .data = &print_fatal_signals,
517 .maxlen = sizeof(int),
518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800519 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700520 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700521#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 .procname = "reboot-cmd",
524 .data = reboot_command,
525 .maxlen = 256,
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 },
529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 .procname = "stop-a",
531 .data = &stop_a_enabled,
532 .maxlen = sizeof (int),
533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800534 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 },
536 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 .procname = "scons-poweroff",
538 .data = &scons_pwroff,
539 .maxlen = sizeof (int),
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 },
543#endif
David S. Miller08714202008-11-16 23:49:24 -0800544#ifdef CONFIG_SPARC64
545 {
David S. Miller08714202008-11-16 23:49:24 -0800546 .procname = "tsb-ratio",
547 .data = &sysctl_tsb_ratio,
548 .maxlen = sizeof (int),
549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800550 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800551 },
552#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553#ifdef __hppa__
554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 .procname = "soft-power",
556 .data = &pwrsw_enabled,
557 .maxlen = sizeof (int),
558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800559 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530561#endif
562#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 .procname = "unaligned-trap",
565 .data = &unaligned_enabled,
566 .maxlen = sizeof (int),
567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800568 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 },
570#endif
571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 .procname = "ctrl-alt-del",
573 .data = &C_A_D,
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 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400578#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200579 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200580 .procname = "ftrace_enabled",
581 .data = &ftrace_enabled,
582 .maxlen = sizeof(int),
583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800584 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200585 },
586#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500587#ifdef CONFIG_STACK_TRACER
588 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500589 .procname = "stack_tracer_enabled",
590 .data = &stack_tracer_enabled,
591 .maxlen = sizeof(int),
592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800593 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500594 },
595#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400596#ifdef CONFIG_TRACING
597 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100598 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400599 .data = &ftrace_dump_on_oops,
600 .maxlen = sizeof(int),
601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800602 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400603 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400604 {
605 .procname = "traceoff_on_warning",
606 .data = &__disable_trace_on_warning,
607 .maxlen = sizeof(__disable_trace_on_warning),
608 .mode = 0644,
609 .proc_handler = proc_dointvec,
610 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400611#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200612#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "modprobe",
615 .data = &modprobe_path,
616 .maxlen = KMOD_PATH_LEN,
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 },
Kees Cook3d433212009-04-02 15:49:29 -0700620 {
Kees Cook3d433212009-04-02 15:49:29 -0700621 .procname = "modules_disabled",
622 .data = &modules_disabled,
623 .maxlen = sizeof(int),
624 .mode = 0644,
625 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700627 .extra1 = &one,
628 .extra2 = &one,
629 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500631
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100634 .data = &uevent_helper,
635 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800637 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500639
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640#ifdef CONFIG_CHR_DEV_SG
641 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .procname = "sg-big-buff",
643 .data = &sg_big_buff,
644 .maxlen = sizeof (int),
645 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 },
648#endif
649#ifdef CONFIG_BSD_PROCESS_ACCT
650 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .procname = "acct",
652 .data = &acct_parm,
653 .maxlen = 3*sizeof(int),
654 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800655 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 },
657#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658#ifdef CONFIG_MAGIC_SYSRQ
659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800661 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .maxlen = sizeof (int),
663 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700664 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 },
666#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700667#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700670 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .maxlen = sizeof (int),
672 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700675#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .procname = "threads-max",
678 .data = &max_threads,
679 .maxlen = sizeof(int),
680 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800681 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 },
683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "random",
685 .mode = 0555,
686 .child = random_table,
687 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 {
Eric Paris17f60a72011-04-01 17:07:50 -0400689 .procname = "usermodehelper",
690 .mode = 0555,
691 .child = usermodehelper_table,
692 },
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "overflowuid",
695 .data = &overflowuid,
696 .maxlen = sizeof(int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .extra1 = &minolduid,
700 .extra2 = &maxolduid,
701 },
702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .procname = "overflowgid",
704 .data = &overflowgid,
705 .maxlen = sizeof(int),
706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800707 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 .extra1 = &minolduid,
709 .extra2 = &maxolduid,
710 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800711#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712#ifdef CONFIG_MATHEMU
713 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .procname = "ieee_emulation_warnings",
715 .data = &sysctl_ieee_emulation_warnings,
716 .maxlen = sizeof(int),
717 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800718 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 },
720#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200723 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 .maxlen = sizeof(int),
725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800726 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 },
728#endif
729 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 .procname = "pid_max",
731 .data = &pid_max,
732 .maxlen = sizeof (int),
733 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800734 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .extra1 = &pid_max_min,
736 .extra2 = &pid_max_max,
737 },
738 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .procname = "panic_on_oops",
740 .data = &panic_on_oops,
741 .maxlen = sizeof(int),
742 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800743 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800745#if defined CONFIG_PRINTK
746 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800747 .procname = "printk",
748 .data = &console_loglevel,
749 .maxlen = 4*sizeof(int),
750 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800751 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800752 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700755 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 },
760 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700762 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .maxlen = sizeof(int),
764 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800765 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 },
Dave Youngaf913222009-09-22 16:43:33 -0700767 {
Dave Youngaf913222009-09-22 16:43:33 -0700768 .procname = "printk_delay",
769 .data = &printk_delay_msec,
770 .maxlen = sizeof(int),
771 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800772 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700773 .extra1 = &zero,
774 .extra2 = &ten_thousand,
775 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800777 .procname = "dmesg_restrict",
778 .data = &dmesg_restrict,
779 .maxlen = sizeof(int),
780 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700781 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800782 .extra1 = &zero,
783 .extra2 = &one,
784 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800785 {
786 .procname = "kptr_restrict",
787 .data = &kptr_restrict,
788 .maxlen = sizeof(int),
789 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700790 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800791 .extra1 = &zero,
792 .extra2 = &two,
793 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800794#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800795 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .procname = "ngroups_max",
797 .data = &ngroups_max,
798 .maxlen = sizeof (int),
799 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800800 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 },
Dan Ballard73efc032011-10-31 17:11:20 -0700802 {
803 .procname = "cap_last_cap",
804 .data = (void *)&cap_last_cap,
805 .maxlen = sizeof(int),
806 .mode = 0444,
807 .proc_handler = proc_dointvec,
808 },
Don Zickus58687ac2010-05-07 17:11:44 -0400809#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500810 {
Don Zickus58687ac2010-05-07 17:11:44 -0400811 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200812 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500813 .maxlen = sizeof (int),
814 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700815 .proc_handler = proc_dowatchdog,
816 .extra1 = &zero,
817 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400818 },
819 {
820 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700821 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400822 .maxlen = sizeof(int),
823 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700824 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800825 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400826 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500827 },
Don Zickus2508ce12010-05-07 17:11:46 -0400828 {
829 .procname = "softlockup_panic",
830 .data = &softlockup_panic,
831 .maxlen = sizeof(int),
832 .mode = 0644,
833 .proc_handler = proc_dointvec_minmax,
834 .extra1 = &zero,
835 .extra2 = &one,
836 },
Don Zickus5dc30552010-11-29 17:07:17 -0500837 {
838 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200839 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500840 .maxlen = sizeof (int),
841 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700842 .proc_handler = proc_dowatchdog,
843 .extra1 = &zero,
844 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500845 },
846#endif
847#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
848 {
849 .procname = "unknown_nmi_panic",
850 .data = &unknown_nmi_panic,
851 .maxlen = sizeof (int),
852 .mode = 0644,
853 .proc_handler = proc_dointvec,
854 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500855#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856#if defined(CONFIG_X86)
857 {
Don Zickus8da5add2006-09-26 10:52:27 +0200858 .procname = "panic_on_unrecovered_nmi",
859 .data = &panic_on_unrecovered_nmi,
860 .maxlen = sizeof(int),
861 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800862 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200863 },
864 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700865 .procname = "panic_on_io_nmi",
866 .data = &panic_on_io_nmi,
867 .maxlen = sizeof(int),
868 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800869 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700870 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900871#ifdef CONFIG_DEBUG_STACKOVERFLOW
872 {
873 .procname = "panic_on_stackoverflow",
874 .data = &sysctl_panic_on_stackoverflow,
875 .maxlen = sizeof(int),
876 .mode = 0644,
877 .proc_handler = proc_dointvec,
878 },
879#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700880 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 .procname = "bootloader_type",
882 .data = &bootloader_type,
883 .maxlen = sizeof (int),
884 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800885 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100887 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700888 .procname = "bootloader_version",
889 .data = &bootloader_version,
890 .maxlen = sizeof (int),
891 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800892 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700893 },
894 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100895 .procname = "kstack_depth_to_print",
896 .data = &kstack_depth_to_print,
897 .maxlen = sizeof(int),
898 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800899 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100900 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100901 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100902 .procname = "io_delay_type",
903 .data = &io_delay_type,
904 .maxlen = sizeof(int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100907 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800909#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 .procname = "randomize_va_space",
912 .data = &randomize_va_space,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800917#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800918#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700919 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700920 .procname = "spin_retry",
921 .data = &spin_retry,
922 .maxlen = sizeof (int),
923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700925 },
926#endif
Len Brown673d5b42007-07-28 03:33:16 -0400927#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800928 {
Pavel Machekc255d842006-02-20 18:27:58 -0800929 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700930 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800931 .maxlen = sizeof (unsigned long),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800934 },
935#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530936#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800937 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800938 .procname = "ignore-unaligned-usertrap",
939 .data = &no_unaligned_warning,
940 .maxlen = sizeof (int),
941 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800942 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800943 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530944#endif
945#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800946 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800947 .procname = "unaligned-dump-stack",
948 .data = &unaligned_dump_stack,
949 .maxlen = sizeof (int),
950 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800951 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800952 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800953#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800954#ifdef CONFIG_DETECT_HUNG_TASK
955 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800956 .procname = "hung_task_panic",
957 .data = &sysctl_hung_task_panic,
958 .maxlen = sizeof(int),
959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800961 .extra1 = &zero,
962 .extra2 = &one,
963 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100964 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100965 .procname = "hung_task_check_count",
966 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800967 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100968 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800969 .proc_handler = proc_dointvec_minmax,
970 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100971 },
972 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100973 .procname = "hung_task_timeout_secs",
974 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100975 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100976 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100978 },
979 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100980 .procname = "hung_task_warnings",
981 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +0000982 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100983 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +0000984 .proc_handler = proc_dointvec_minmax,
985 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100986 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700987#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200988#ifdef CONFIG_COMPAT
989 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200990 .procname = "compat-log",
991 .data = &compat_log,
992 .maxlen = sizeof (int),
993 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800994 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200995 },
996#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700997#ifdef CONFIG_RT_MUTEXES
998 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700999 .procname = "max_lock_depth",
1000 .data = &max_lock_depth,
1001 .maxlen = sizeof(int),
1002 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001003 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001004 },
1005#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001006 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001007 .procname = "poweroff_cmd",
1008 .data = &poweroff_cmd,
1009 .maxlen = POWEROFF_CMD_PATH_LEN,
1010 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001011 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001012 },
David Howells0b77f5b2008-04-29 01:01:32 -07001013#ifdef CONFIG_KEYS
1014 {
David Howells0b77f5b2008-04-29 01:01:32 -07001015 .procname = "keys",
1016 .mode = 0555,
1017 .child = key_sysctls,
1018 },
1019#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001020#ifdef CONFIG_RCU_TORTURE_TEST
1021 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001022 .procname = "rcutorture_runnable",
1023 .data = &rcutorture_runnable,
1024 .maxlen = sizeof(int),
1025 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001026 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001027 },
1028#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001029#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001030 /*
1031 * User-space scripts rely on the existence of this file
1032 * as a feature check for perf_events being enabled.
1033 *
1034 * So it's an ABI, do not remove!
1035 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001036 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001037 .procname = "perf_event_paranoid",
1038 .data = &sysctl_perf_event_paranoid,
1039 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001040 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001041 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001042 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001043 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001044 .procname = "perf_event_mlock_kb",
1045 .data = &sysctl_perf_event_mlock,
1046 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001047 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001048 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001049 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001050 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001051 .procname = "perf_event_max_sample_rate",
1052 .data = &sysctl_perf_event_sample_rate,
1053 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001054 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001055 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001056 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001057 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001058 {
1059 .procname = "perf_cpu_time_max_percent",
1060 .data = &sysctl_perf_cpu_time_max_percent,
1061 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1062 .mode = 0644,
1063 .proc_handler = perf_cpu_time_max_percent_handler,
1064 .extra1 = &zero,
1065 .extra2 = &one_hundred,
1066 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001067#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001068#ifdef CONFIG_KMEMCHECK
1069 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001070 .procname = "kmemcheck",
1071 .data = &kmemcheck_enabled,
1072 .maxlen = sizeof(int),
1073 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001074 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001075 },
1076#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001077#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001078 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001079 .procname = "blk_iopoll",
1080 .data = &blk_iopoll_enabled,
1081 .maxlen = sizeof(int),
1082 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001083 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001084 },
Jens Axboecb684b52009-09-15 21:53:11 +02001085#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001086 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087};
1088
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001089static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 .procname = "overcommit_memory",
1092 .data = &sysctl_overcommit_memory,
1093 .maxlen = sizeof(sysctl_overcommit_memory),
1094 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001095 .proc_handler = proc_dointvec_minmax,
1096 .extra1 = &zero,
1097 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 },
1099 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001100 .procname = "panic_on_oom",
1101 .data = &sysctl_panic_on_oom,
1102 .maxlen = sizeof(sysctl_panic_on_oom),
1103 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001104 .proc_handler = proc_dointvec_minmax,
1105 .extra1 = &zero,
1106 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001107 },
1108 {
David Rientjesfe071d72007-10-16 23:25:56 -07001109 .procname = "oom_kill_allocating_task",
1110 .data = &sysctl_oom_kill_allocating_task,
1111 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1112 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001113 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001114 },
1115 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001116 .procname = "oom_dump_tasks",
1117 .data = &sysctl_oom_dump_tasks,
1118 .maxlen = sizeof(sysctl_oom_dump_tasks),
1119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001120 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001121 },
1122 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 .procname = "overcommit_ratio",
1124 .data = &sysctl_overcommit_ratio,
1125 .maxlen = sizeof(sysctl_overcommit_ratio),
1126 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001127 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 },
1129 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 .procname = "page-cluster",
1131 .data = &page_cluster,
1132 .maxlen = sizeof(int),
1133 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001134 .proc_handler = proc_dointvec_minmax,
1135 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 },
1137 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 .procname = "dirty_background_ratio",
1139 .data = &dirty_background_ratio,
1140 .maxlen = sizeof(dirty_background_ratio),
1141 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001142 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 .extra1 = &zero,
1144 .extra2 = &one_hundred,
1145 },
1146 {
David Rientjes2da02992009-01-06 14:39:31 -08001147 .procname = "dirty_background_bytes",
1148 .data = &dirty_background_bytes,
1149 .maxlen = sizeof(dirty_background_bytes),
1150 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001151 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001152 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001153 },
1154 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 .procname = "dirty_ratio",
1156 .data = &vm_dirty_ratio,
1157 .maxlen = sizeof(vm_dirty_ratio),
1158 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001159 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 .extra1 = &zero,
1161 .extra2 = &one_hundred,
1162 },
1163 {
David Rientjes2da02992009-01-06 14:39:31 -08001164 .procname = "dirty_bytes",
1165 .data = &vm_dirty_bytes,
1166 .maxlen = sizeof(vm_dirty_bytes),
1167 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001168 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001169 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001170 },
1171 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001173 .data = &dirty_writeback_interval,
1174 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 },
1178 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001180 .data = &dirty_expire_interval,
1181 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001183 .proc_handler = proc_dointvec_minmax,
1184 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 },
1186 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001187 .procname = "nr_pdflush_threads",
1188 .mode = 0444 /* read-only */,
1189 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 },
1191 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 .procname = "swappiness",
1193 .data = &vm_swappiness,
1194 .maxlen = sizeof(vm_swappiness),
1195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 .extra1 = &zero,
1198 .extra2 = &one_hundred,
1199 },
1200#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001201 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001203 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 .maxlen = sizeof(unsigned long),
1205 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001206 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 .extra1 = (void *)&hugetlb_zero,
1208 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001209 },
1210#ifdef CONFIG_NUMA
1211 {
1212 .procname = "nr_hugepages_mempolicy",
1213 .data = NULL,
1214 .maxlen = sizeof(unsigned long),
1215 .mode = 0644,
1216 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1217 .extra1 = (void *)&hugetlb_zero,
1218 .extra2 = (void *)&hugetlb_infinity,
1219 },
1220#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 .procname = "hugetlb_shm_group",
1223 .data = &sysctl_hugetlb_shm_group,
1224 .maxlen = sizeof(gid_t),
1225 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001226 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 },
Mel Gorman396faf02007-07-17 04:03:13 -07001228 {
Mel Gorman396faf02007-07-17 04:03:13 -07001229 .procname = "hugepages_treat_as_movable",
1230 .data = &hugepages_treat_as_movable,
1231 .maxlen = sizeof(int),
1232 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001233 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001234 },
Adam Litke54f9f802007-10-16 01:26:20 -07001235 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001236 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001237 .data = NULL,
1238 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001239 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001240 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001241 .extra1 = (void *)&hugetlb_zero,
1242 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001243 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244#endif
1245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 .procname = "lowmem_reserve_ratio",
1247 .data = &sysctl_lowmem_reserve_ratio,
1248 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1249 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001250 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 },
1252 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001253 .procname = "drop_caches",
1254 .data = &sysctl_drop_caches,
1255 .maxlen = sizeof(int),
1256 .mode = 0644,
1257 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001258 .extra1 = &one,
1259 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001260 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001261#ifdef CONFIG_COMPACTION
1262 {
1263 .procname = "compact_memory",
1264 .data = &sysctl_compact_memory,
1265 .maxlen = sizeof(int),
1266 .mode = 0200,
1267 .proc_handler = sysctl_compaction_handler,
1268 },
Mel Gorman5e771902010-05-24 14:32:31 -07001269 {
1270 .procname = "extfrag_threshold",
1271 .data = &sysctl_extfrag_threshold,
1272 .maxlen = sizeof(int),
1273 .mode = 0644,
1274 .proc_handler = sysctl_extfrag_handler,
1275 .extra1 = &min_extfrag_threshold,
1276 .extra2 = &max_extfrag_threshold,
1277 },
1278
Mel Gorman76ab0f52010-05-24 14:32:28 -07001279#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001280 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 .procname = "min_free_kbytes",
1282 .data = &min_free_kbytes,
1283 .maxlen = sizeof(min_free_kbytes),
1284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001285 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 .extra1 = &zero,
1287 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001288 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001289 .procname = "percpu_pagelist_fraction",
1290 .data = &percpu_pagelist_fraction,
1291 .maxlen = sizeof(percpu_pagelist_fraction),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001294 .extra1 = &min_percpu_pagelist_fract,
1295 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296#ifdef CONFIG_MMU
1297 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298 .procname = "max_map_count",
1299 .data = &sysctl_max_map_count,
1300 .maxlen = sizeof(sysctl_max_map_count),
1301 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001302 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001303 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001305#else
1306 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001307 .procname = "nr_trim_pages",
1308 .data = &sysctl_nr_trim_pages,
1309 .maxlen = sizeof(sysctl_nr_trim_pages),
1310 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001312 .extra1 = &zero,
1313 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314#endif
1315 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 .procname = "laptop_mode",
1317 .data = &laptop_mode,
1318 .maxlen = sizeof(laptop_mode),
1319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001320 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 },
1322 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 .procname = "block_dump",
1324 .data = &block_dump,
1325 .maxlen = sizeof(block_dump),
1326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001327 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 .extra1 = &zero,
1329 },
1330 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 .procname = "vfs_cache_pressure",
1332 .data = &sysctl_vfs_cache_pressure,
1333 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001335 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336 .extra1 = &zero,
1337 },
1338#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1339 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340 .procname = "legacy_va_layout",
1341 .data = &sysctl_legacy_va_layout,
1342 .maxlen = sizeof(sysctl_legacy_va_layout),
1343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001344 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 .extra1 = &zero,
1346 },
1347#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001348#ifdef CONFIG_NUMA
1349 {
Christoph Lameter17436602006-01-18 17:42:32 -08001350 .procname = "zone_reclaim_mode",
1351 .data = &zone_reclaim_mode,
1352 .maxlen = sizeof(zone_reclaim_mode),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001355 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001356 },
Christoph Lameter96146342006-07-03 00:24:13 -07001357 {
Christoph Lameter96146342006-07-03 00:24:13 -07001358 .procname = "min_unmapped_ratio",
1359 .data = &sysctl_min_unmapped_ratio,
1360 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001363 .extra1 = &zero,
1364 .extra2 = &one_hundred,
1365 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001366 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001367 .procname = "min_slab_ratio",
1368 .data = &sysctl_min_slab_ratio,
1369 .maxlen = sizeof(sysctl_min_slab_ratio),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001372 .extra1 = &zero,
1373 .extra2 = &one_hundred,
1374 },
Christoph Lameter17436602006-01-18 17:42:32 -08001375#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001376#ifdef CONFIG_SMP
1377 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001378 .procname = "stat_interval",
1379 .data = &sysctl_stat_interval,
1380 .maxlen = sizeof(sysctl_stat_interval),
1381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001382 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001383 },
1384#endif
David Howells6e141542009-12-15 19:27:45 +00001385#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001386 {
Eric Parised032182007-06-28 15:55:21 -04001387 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001388 .data = &dac_mmap_min_addr,
1389 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001390 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001391 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001392 },
David Howells6e141542009-12-15 19:27:45 +00001393#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001394#ifdef CONFIG_NUMA
1395 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001396 .procname = "numa_zonelist_order",
1397 .data = &numa_zonelist_order,
1398 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001400 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001401 },
1402#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001403#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001404 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001405 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001406 .procname = "vdso_enabled",
1407 .data = &vdso_enabled,
1408 .maxlen = sizeof(vdso_enabled),
1409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001410 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001411 .extra1 = &zero,
1412 },
1413#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001414#ifdef CONFIG_HIGHMEM
1415 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001416 .procname = "highmem_is_dirtyable",
1417 .data = &vm_highmem_is_dirtyable,
1418 .maxlen = sizeof(vm_highmem_is_dirtyable),
1419 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001420 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001421 .extra1 = &zero,
1422 .extra2 = &one,
1423 },
1424#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001425 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001426 .procname = "scan_unevictable_pages",
1427 .data = &scan_unevictable_pages,
1428 .maxlen = sizeof(scan_unevictable_pages),
1429 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001430 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001431 },
Andi Kleen6a460792009-09-16 11:50:15 +02001432#ifdef CONFIG_MEMORY_FAILURE
1433 {
Andi Kleen6a460792009-09-16 11:50:15 +02001434 .procname = "memory_failure_early_kill",
1435 .data = &sysctl_memory_failure_early_kill,
1436 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001439 .extra1 = &zero,
1440 .extra2 = &one,
1441 },
1442 {
Andi Kleen6a460792009-09-16 11:50:15 +02001443 .procname = "memory_failure_recovery",
1444 .data = &sysctl_memory_failure_recovery,
1445 .maxlen = sizeof(sysctl_memory_failure_recovery),
1446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001447 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001448 .extra1 = &zero,
1449 .extra2 = &one,
1450 },
1451#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001452 {
1453 .procname = "user_reserve_kbytes",
1454 .data = &sysctl_user_reserve_kbytes,
1455 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1456 .mode = 0644,
1457 .proc_handler = proc_doulongvec_minmax,
1458 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001459 {
1460 .procname = "admin_reserve_kbytes",
1461 .data = &sysctl_admin_reserve_kbytes,
1462 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1463 .mode = 0644,
1464 .proc_handler = proc_doulongvec_minmax,
1465 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001466 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467};
1468
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001469#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001470static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001471 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001472};
1473#endif
1474
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001475static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "inode-nr",
1478 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001479 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001481 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 },
1483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .procname = "inode-state",
1485 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001486 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001488 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 },
1490 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .procname = "file-nr",
1492 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001493 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001495 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 },
1497 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .procname = "file-max",
1499 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001500 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001502 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 },
1504 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001505 .procname = "nr_open",
1506 .data = &sysctl_nr_open,
1507 .maxlen = sizeof(int),
1508 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001509 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001510 .extra1 = &sysctl_nr_open_min,
1511 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001512 },
1513 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .procname = "dentry-state",
1515 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001516 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001518 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 },
1520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 .procname = "overflowuid",
1522 .data = &fs_overflowuid,
1523 .maxlen = sizeof(int),
1524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001525 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 .extra1 = &minolduid,
1527 .extra2 = &maxolduid,
1528 },
1529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .procname = "overflowgid",
1531 .data = &fs_overflowgid,
1532 .maxlen = sizeof(int),
1533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001534 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 .extra1 = &minolduid,
1536 .extra2 = &maxolduid,
1537 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001538#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 .procname = "leases-enable",
1541 .data = &leases_enable,
1542 .maxlen = sizeof(int),
1543 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001544 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001546#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547#ifdef CONFIG_DNOTIFY
1548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .procname = "dir-notify-enable",
1550 .data = &dir_notify_enable,
1551 .maxlen = sizeof(int),
1552 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001553 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 },
1555#endif
1556#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001557#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .procname = "lease-break-time",
1560 .data = &lease_break_time,
1561 .maxlen = sizeof(int),
1562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001563 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001565#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001566#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 .procname = "aio-nr",
1569 .data = &aio_nr,
1570 .maxlen = sizeof(aio_nr),
1571 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001572 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 },
1574 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 .procname = "aio-max-nr",
1576 .data = &aio_max_nr,
1577 .maxlen = sizeof(aio_max_nr),
1578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001579 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001581#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001582#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001583 {
Robert Love0399cb02005-07-13 12:38:18 -04001584 .procname = "inotify",
1585 .mode = 0555,
1586 .child = inotify_table,
1587 },
1588#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001589#ifdef CONFIG_EPOLL
1590 {
1591 .procname = "epoll",
1592 .mode = 0555,
1593 .child = epoll_table,
1594 },
1595#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001597 {
Kees Cook800179c2012-07-25 17:29:07 -07001598 .procname = "protected_symlinks",
1599 .data = &sysctl_protected_symlinks,
1600 .maxlen = sizeof(int),
1601 .mode = 0600,
1602 .proc_handler = proc_dointvec_minmax,
1603 .extra1 = &zero,
1604 .extra2 = &one,
1605 },
1606 {
1607 .procname = "protected_hardlinks",
1608 .data = &sysctl_protected_hardlinks,
1609 .maxlen = sizeof(int),
1610 .mode = 0600,
1611 .proc_handler = proc_dointvec_minmax,
1612 .extra1 = &zero,
1613 .extra2 = &one,
1614 },
1615 {
Alan Coxd6e71142005-06-23 00:09:43 -07001616 .procname = "suid_dumpable",
1617 .data = &suid_dumpable,
1618 .maxlen = sizeof(int),
1619 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001620 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001621 .extra1 = &zero,
1622 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001623 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001624#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1625 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001626 .procname = "binfmt_misc",
1627 .mode = 0555,
1628 .child = binfmt_misc_table,
1629 },
1630#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001631 {
Jens Axboeff9da692010-06-03 14:54:39 +02001632 .procname = "pipe-max-size",
1633 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001634 .maxlen = sizeof(int),
1635 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001636 .proc_handler = &pipe_proc_fn,
1637 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001638 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001639 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640};
1641
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001642static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001643#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001644 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001645 .procname = "exception-trace",
1646 .data = &show_unhandled_signals,
1647 .maxlen = sizeof(int),
1648 .mode = 0644,
1649 .proc_handler = proc_dointvec
1650 },
1651#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001652#if defined(CONFIG_OPTPROBES)
1653 {
1654 .procname = "kprobes-optimization",
1655 .data = &sysctl_kprobes_optimization,
1656 .maxlen = sizeof(int),
1657 .mode = 0644,
1658 .proc_handler = proc_kprobes_optimization_handler,
1659 .extra1 = &zero,
1660 .extra2 = &one,
1661 },
1662#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001663 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664};
1665
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001666static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001667 { }
Robert Love0eeca282005-07-12 17:06:03 -04001668};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001670int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001671{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001672 struct ctl_table_header *hdr;
1673
1674 hdr = register_sysctl_table(sysctl_base_table);
1675 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001676 return 0;
1677}
1678
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001679#endif /* CONFIG_SYSCTL */
1680
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681/*
1682 * /proc/sys support
1683 */
1684
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001685#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001686
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001687static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001688 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001689 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001690{
1691 size_t len;
1692 char __user *p;
1693 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001694
1695 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001696 *lenp = 0;
1697 return 0;
1698 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001699
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001700 if (write) {
1701 len = 0;
1702 p = buffer;
1703 while (len < *lenp) {
1704 if (get_user(c, p++))
1705 return -EFAULT;
1706 if (c == 0 || c == '\n')
1707 break;
1708 len++;
1709 }
1710 if (len >= maxlen)
1711 len = maxlen-1;
1712 if(copy_from_user(data, buffer, len))
1713 return -EFAULT;
1714 ((char *) data)[len] = 0;
1715 *ppos += *lenp;
1716 } else {
1717 len = strlen(data);
1718 if (len > maxlen)
1719 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001720
1721 if (*ppos > len) {
1722 *lenp = 0;
1723 return 0;
1724 }
1725
1726 data += *ppos;
1727 len -= *ppos;
1728
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001729 if (len > *lenp)
1730 len = *lenp;
1731 if (len)
1732 if(copy_to_user(buffer, data, len))
1733 return -EFAULT;
1734 if (len < *lenp) {
1735 if(put_user('\n', ((char __user *) buffer) + len))
1736 return -EFAULT;
1737 len++;
1738 }
1739 *lenp = len;
1740 *ppos += len;
1741 }
1742 return 0;
1743}
1744
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745/**
1746 * proc_dostring - read a string sysctl
1747 * @table: the sysctl table
1748 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 * @buffer: the user buffer
1750 * @lenp: the size of the user buffer
1751 * @ppos: file position
1752 *
1753 * Reads/writes a string from/to the user buffer. If the kernel
1754 * buffer provided is not large enough to hold the string, the
1755 * string is truncated. The copied string is %NULL-terminated.
1756 * If the string is being read by the user process, it is copied
1757 * and a newline '\n' is added. It is truncated if the buffer is
1758 * not large enough.
1759 *
1760 * Returns 0 on success.
1761 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001762int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763 void __user *buffer, size_t *lenp, loff_t *ppos)
1764{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001765 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001766 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767}
1768
Amerigo Wang00b7c332010-05-05 00:26:45 +00001769static size_t proc_skip_spaces(char **buf)
1770{
1771 size_t ret;
1772 char *tmp = skip_spaces(*buf);
1773 ret = tmp - *buf;
1774 *buf = tmp;
1775 return ret;
1776}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001777
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001778static void proc_skip_char(char **buf, size_t *size, const char v)
1779{
1780 while (*size) {
1781 if (**buf != v)
1782 break;
1783 (*size)--;
1784 (*buf)++;
1785 }
1786}
1787
Amerigo Wang00b7c332010-05-05 00:26:45 +00001788#define TMPBUFLEN 22
1789/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001790 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001791 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001792 * @buf: a kernel buffer
1793 * @size: size of the kernel buffer
1794 * @val: this is where the number will be stored
1795 * @neg: set to %TRUE if number is negative
1796 * @perm_tr: a vector which contains the allowed trailers
1797 * @perm_tr_len: size of the perm_tr vector
1798 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001799 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001800 * In case of success %0 is returned and @buf and @size are updated with
1801 * the amount of bytes read. If @tr is non-NULL and a trailing
1802 * character exists (size is non-zero after returning from this
1803 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001804 */
1805static int proc_get_long(char **buf, size_t *size,
1806 unsigned long *val, bool *neg,
1807 const char *perm_tr, unsigned perm_tr_len, char *tr)
1808{
1809 int len;
1810 char *p, tmp[TMPBUFLEN];
1811
1812 if (!*size)
1813 return -EINVAL;
1814
1815 len = *size;
1816 if (len > TMPBUFLEN - 1)
1817 len = TMPBUFLEN - 1;
1818
1819 memcpy(tmp, *buf, len);
1820
1821 tmp[len] = 0;
1822 p = tmp;
1823 if (*p == '-' && *size > 1) {
1824 *neg = true;
1825 p++;
1826 } else
1827 *neg = false;
1828 if (!isdigit(*p))
1829 return -EINVAL;
1830
1831 *val = simple_strtoul(p, &p, 0);
1832
1833 len = p - tmp;
1834
1835 /* We don't know if the next char is whitespace thus we may accept
1836 * invalid integers (e.g. 1234...a) or two integers instead of one
1837 * (e.g. 123...1). So lets not allow such large numbers. */
1838 if (len == TMPBUFLEN - 1)
1839 return -EINVAL;
1840
1841 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1842 return -EINVAL;
1843
1844 if (tr && (len < *size))
1845 *tr = *p;
1846
1847 *buf += len;
1848 *size -= len;
1849
1850 return 0;
1851}
1852
1853/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001854 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001855 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001856 * @buf: the user buffer
1857 * @size: the size of the user buffer
1858 * @val: the integer to be converted
1859 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001860 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001861 * In case of success %0 is returned and @buf and @size are updated with
1862 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001863 */
1864static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1865 bool neg)
1866{
1867 int len;
1868 char tmp[TMPBUFLEN], *p = tmp;
1869
1870 sprintf(p, "%s%lu", neg ? "-" : "", val);
1871 len = strlen(tmp);
1872 if (len > *size)
1873 len = *size;
1874 if (copy_to_user(*buf, tmp, len))
1875 return -EFAULT;
1876 *size -= len;
1877 *buf += len;
1878 return 0;
1879}
1880#undef TMPBUFLEN
1881
1882static int proc_put_char(void __user **buf, size_t *size, char c)
1883{
1884 if (*size) {
1885 char __user **buffer = (char __user **)buf;
1886 if (put_user(c, *buffer))
1887 return -EFAULT;
1888 (*size)--, (*buffer)++;
1889 *buf = *buffer;
1890 }
1891 return 0;
1892}
1893
1894static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 int *valp,
1896 int write, void *data)
1897{
1898 if (write) {
1899 *valp = *negp ? -*lvalp : *lvalp;
1900 } else {
1901 int val = *valp;
1902 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001903 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 *lvalp = (unsigned long)-val;
1905 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001906 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 *lvalp = (unsigned long)val;
1908 }
1909 }
1910 return 0;
1911}
1912
Amerigo Wang00b7c332010-05-05 00:26:45 +00001913static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1914
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001915static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001916 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001917 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001918 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 int write, void *data),
1920 void *data)
1921{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001922 int *i, vleft, first = 1, err = 0;
1923 unsigned long page = 0;
1924 size_t left;
1925 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926
Amerigo Wang00b7c332010-05-05 00:26:45 +00001927 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 *lenp = 0;
1929 return 0;
1930 }
1931
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001932 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 vleft = table->maxlen / sizeof(*i);
1934 left = *lenp;
1935
1936 if (!conv)
1937 conv = do_proc_dointvec_conv;
1938
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001940 if (left > PAGE_SIZE - 1)
1941 left = PAGE_SIZE - 1;
1942 page = __get_free_page(GFP_TEMPORARY);
1943 kbuf = (char *) page;
1944 if (!kbuf)
1945 return -ENOMEM;
1946 if (copy_from_user(kbuf, buffer, left)) {
1947 err = -EFAULT;
1948 goto free;
1949 }
1950 kbuf[left] = 0;
1951 }
1952
1953 for (; left && vleft--; i++, first=0) {
1954 unsigned long lval;
1955 bool neg;
1956
1957 if (write) {
1958 left -= proc_skip_spaces(&kbuf);
1959
J. R. Okajima563b0462010-05-25 16:10:14 -07001960 if (!left)
1961 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001962 err = proc_get_long(&kbuf, &left, &lval, &neg,
1963 proc_wspace_sep,
1964 sizeof(proc_wspace_sep), NULL);
1965 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001967 if (conv(&neg, &lval, i, 1, data)) {
1968 err = -EINVAL;
1969 break;
1970 }
1971 } else {
1972 if (conv(&neg, &lval, i, 0, data)) {
1973 err = -EINVAL;
1974 break;
1975 }
1976 if (!first)
1977 err = proc_put_char(&buffer, &left, '\t');
1978 if (err)
1979 break;
1980 err = proc_put_long(&buffer, &left, lval, neg);
1981 if (err)
1982 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001983 }
1984 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001985
1986 if (!write && !first && left && !err)
1987 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001988 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001989 left -= proc_skip_spaces(&kbuf);
1990free:
1991 if (write) {
1992 free_page(page);
1993 if (first)
1994 return err ? : -EINVAL;
1995 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996 *lenp -= left;
1997 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001998 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999}
2000
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002001static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002002 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002003 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002004 int write, void *data),
2005 void *data)
2006{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002007 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002008 buffer, lenp, ppos, conv, data);
2009}
2010
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011/**
2012 * proc_dointvec - read a vector of integers
2013 * @table: the sysctl table
2014 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015 * @buffer: the user buffer
2016 * @lenp: the size of the user buffer
2017 * @ppos: file position
2018 *
2019 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2020 * values from/to the user buffer, treated as an ASCII string.
2021 *
2022 * Returns 0 on success.
2023 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002024int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025 void __user *buffer, size_t *lenp, loff_t *ppos)
2026{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002027 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028 NULL,NULL);
2029}
2030
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002031/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002032 * Taint values can only be increased
2033 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002034 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002035static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002036 void __user *buffer, size_t *lenp, loff_t *ppos)
2037{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002038 struct ctl_table t;
2039 unsigned long tmptaint = get_taint();
2040 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002041
Bastian Blank91fcd412007-04-23 14:41:14 -07002042 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002043 return -EPERM;
2044
Andi Kleen25ddbb12008-10-15 22:01:41 -07002045 t = *table;
2046 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002047 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002048 if (err < 0)
2049 return err;
2050
2051 if (write) {
2052 /*
2053 * Poor man's atomic or. Not worth adding a primitive
2054 * to everyone's atomic.h for this
2055 */
2056 int i;
2057 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2058 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302059 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002060 }
2061 }
2062
2063 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002064}
2065
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002066#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002067static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002068 void __user *buffer, size_t *lenp, loff_t *ppos)
2069{
2070 if (write && !capable(CAP_SYS_ADMIN))
2071 return -EPERM;
2072
2073 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2074}
2075#endif
2076
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077struct do_proc_dointvec_minmax_conv_param {
2078 int *min;
2079 int *max;
2080};
2081
Amerigo Wang00b7c332010-05-05 00:26:45 +00002082static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2083 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 int write, void *data)
2085{
2086 struct do_proc_dointvec_minmax_conv_param *param = data;
2087 if (write) {
2088 int val = *negp ? -*lvalp : *lvalp;
2089 if ((param->min && *param->min > val) ||
2090 (param->max && *param->max < val))
2091 return -EINVAL;
2092 *valp = val;
2093 } else {
2094 int val = *valp;
2095 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002096 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 *lvalp = (unsigned long)-val;
2098 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002099 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002100 *lvalp = (unsigned long)val;
2101 }
2102 }
2103 return 0;
2104}
2105
2106/**
2107 * proc_dointvec_minmax - read a vector of integers with min/max values
2108 * @table: the sysctl table
2109 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110 * @buffer: the user buffer
2111 * @lenp: the size of the user buffer
2112 * @ppos: file position
2113 *
2114 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2115 * values from/to the user buffer, treated as an ASCII string.
2116 *
2117 * This routine will ensure the values are within the range specified by
2118 * table->extra1 (min) and table->extra2 (max).
2119 *
2120 * Returns 0 on success.
2121 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002122int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 void __user *buffer, size_t *lenp, loff_t *ppos)
2124{
2125 struct do_proc_dointvec_minmax_conv_param param = {
2126 .min = (int *) table->extra1,
2127 .max = (int *) table->extra2,
2128 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002129 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130 do_proc_dointvec_minmax_conv, &param);
2131}
2132
Kees Cook54b50192012-07-30 14:39:18 -07002133static void validate_coredump_safety(void)
2134{
Alex Kelly046d6622012-10-04 17:15:23 -07002135#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002136 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002137 core_pattern[0] != '/' && core_pattern[0] != '|') {
2138 printk(KERN_WARNING "Unsafe core_pattern used with "\
2139 "suid_dumpable=2. Pipe handler or fully qualified "\
2140 "core dump path required.\n");
2141 }
Alex Kelly046d6622012-10-04 17:15:23 -07002142#endif
Kees Cook54b50192012-07-30 14:39:18 -07002143}
2144
2145static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2146 void __user *buffer, size_t *lenp, loff_t *ppos)
2147{
2148 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2149 if (!error)
2150 validate_coredump_safety();
2151 return error;
2152}
2153
Alex Kelly046d6622012-10-04 17:15:23 -07002154#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002155static int proc_dostring_coredump(struct ctl_table *table, int write,
2156 void __user *buffer, size_t *lenp, loff_t *ppos)
2157{
2158 int error = proc_dostring(table, write, buffer, lenp, ppos);
2159 if (!error)
2160 validate_coredump_safety();
2161 return error;
2162}
Alex Kelly046d6622012-10-04 17:15:23 -07002163#endif
Kees Cook54b50192012-07-30 14:39:18 -07002164
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002165static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166 void __user *buffer,
2167 size_t *lenp, loff_t *ppos,
2168 unsigned long convmul,
2169 unsigned long convdiv)
2170{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002171 unsigned long *i, *min, *max;
2172 int vleft, first = 1, err = 0;
2173 unsigned long page = 0;
2174 size_t left;
2175 char *kbuf;
2176
2177 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 *lenp = 0;
2179 return 0;
2180 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002181
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002182 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183 min = (unsigned long *) table->extra1;
2184 max = (unsigned long *) table->extra2;
2185 vleft = table->maxlen / sizeof(unsigned long);
2186 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187
2188 if (write) {
2189 if (left > PAGE_SIZE - 1)
2190 left = PAGE_SIZE - 1;
2191 page = __get_free_page(GFP_TEMPORARY);
2192 kbuf = (char *) page;
2193 if (!kbuf)
2194 return -ENOMEM;
2195 if (copy_from_user(kbuf, buffer, left)) {
2196 err = -EFAULT;
2197 goto free;
2198 }
2199 kbuf[left] = 0;
2200 }
2201
Eric Dumazet27b3d802010-10-07 12:59:29 -07002202 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 unsigned long val;
2204
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002206 bool neg;
2207
2208 left -= proc_skip_spaces(&kbuf);
2209
2210 err = proc_get_long(&kbuf, &left, &val, &neg,
2211 proc_wspace_sep,
2212 sizeof(proc_wspace_sep), NULL);
2213 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214 break;
2215 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 continue;
2217 if ((min && val < *min) || (max && val > *max))
2218 continue;
2219 *i = val;
2220 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002221 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002222 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002223 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002224 if (err)
2225 break;
2226 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002227 err = proc_put_long(&buffer, &left, val, false);
2228 if (err)
2229 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002230 }
2231 }
2232
Amerigo Wang00b7c332010-05-05 00:26:45 +00002233 if (!write && !first && left && !err)
2234 err = proc_put_char(&buffer, &left, '\n');
2235 if (write && !err)
2236 left -= proc_skip_spaces(&kbuf);
2237free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002239 free_page(page);
2240 if (first)
2241 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002242 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 *lenp -= left;
2244 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002245 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246}
2247
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002248static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002249 void __user *buffer,
2250 size_t *lenp, loff_t *ppos,
2251 unsigned long convmul,
2252 unsigned long convdiv)
2253{
2254 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002255 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002256}
2257
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258/**
2259 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2260 * @table: the sysctl table
2261 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 * @buffer: the user buffer
2263 * @lenp: the size of the user buffer
2264 * @ppos: file position
2265 *
2266 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2267 * values from/to the user buffer, treated as an ASCII string.
2268 *
2269 * This routine will ensure the values are within the range specified by
2270 * table->extra1 (min) and table->extra2 (max).
2271 *
2272 * Returns 0 on success.
2273 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002274int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 void __user *buffer, size_t *lenp, loff_t *ppos)
2276{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002277 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278}
2279
2280/**
2281 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2282 * @table: the sysctl table
2283 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 * @buffer: the user buffer
2285 * @lenp: the size of the user buffer
2286 * @ppos: file position
2287 *
2288 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2289 * values from/to the user buffer, treated as an ASCII string. The values
2290 * are treated as milliseconds, and converted to jiffies when they are stored.
2291 *
2292 * This routine will ensure the values are within the range specified by
2293 * table->extra1 (min) and table->extra2 (max).
2294 *
2295 * Returns 0 on success.
2296 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002297int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 void __user *buffer,
2299 size_t *lenp, loff_t *ppos)
2300{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002301 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 lenp, ppos, HZ, 1000l);
2303}
2304
2305
Amerigo Wang00b7c332010-05-05 00:26:45 +00002306static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 int *valp,
2308 int write, void *data)
2309{
2310 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002311 if (*lvalp > LONG_MAX / HZ)
2312 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2314 } else {
2315 int val = *valp;
2316 unsigned long lval;
2317 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002318 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 lval = (unsigned long)-val;
2320 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002321 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 lval = (unsigned long)val;
2323 }
2324 *lvalp = lval / HZ;
2325 }
2326 return 0;
2327}
2328
Amerigo Wang00b7c332010-05-05 00:26:45 +00002329static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330 int *valp,
2331 int write, void *data)
2332{
2333 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002334 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2335 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2337 } else {
2338 int val = *valp;
2339 unsigned long lval;
2340 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002341 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 lval = (unsigned long)-val;
2343 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002344 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345 lval = (unsigned long)val;
2346 }
2347 *lvalp = jiffies_to_clock_t(lval);
2348 }
2349 return 0;
2350}
2351
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 int *valp,
2354 int write, void *data)
2355{
2356 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002357 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2358
2359 if (jif > INT_MAX)
2360 return 1;
2361 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 } else {
2363 int val = *valp;
2364 unsigned long lval;
2365 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002366 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 lval = (unsigned long)-val;
2368 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002369 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 lval = (unsigned long)val;
2371 }
2372 *lvalp = jiffies_to_msecs(lval);
2373 }
2374 return 0;
2375}
2376
2377/**
2378 * proc_dointvec_jiffies - read a vector of integers as seconds
2379 * @table: the sysctl table
2380 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 * @buffer: the user buffer
2382 * @lenp: the size of the user buffer
2383 * @ppos: file position
2384 *
2385 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2386 * values from/to the user buffer, treated as an ASCII string.
2387 * The values read are assumed to be in seconds, and are converted into
2388 * jiffies.
2389 *
2390 * Returns 0 on success.
2391 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002392int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 void __user *buffer, size_t *lenp, loff_t *ppos)
2394{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002395 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 do_proc_dointvec_jiffies_conv,NULL);
2397}
2398
2399/**
2400 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2401 * @table: the sysctl table
2402 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 * @buffer: the user buffer
2404 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002405 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 *
2407 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2408 * values from/to the user buffer, treated as an ASCII string.
2409 * The values read are assumed to be in 1/USER_HZ seconds, and
2410 * are converted into jiffies.
2411 *
2412 * Returns 0 on success.
2413 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002414int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415 void __user *buffer, size_t *lenp, loff_t *ppos)
2416{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002417 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418 do_proc_dointvec_userhz_jiffies_conv,NULL);
2419}
2420
2421/**
2422 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2423 * @table: the sysctl table
2424 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 * @buffer: the user buffer
2426 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002427 * @ppos: file position
2428 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 *
2430 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2431 * values from/to the user buffer, treated as an ASCII string.
2432 * The values read are assumed to be in 1/1000 seconds, and
2433 * are converted into jiffies.
2434 *
2435 * Returns 0 on success.
2436 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002437int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 void __user *buffer, size_t *lenp, loff_t *ppos)
2439{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002440 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 do_proc_dointvec_ms_jiffies_conv, NULL);
2442}
2443
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002444static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002445 void __user *buffer, size_t *lenp, loff_t *ppos)
2446{
2447 struct pid *new_pid;
2448 pid_t tmp;
2449 int r;
2450
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002451 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002452
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002453 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002454 lenp, ppos, NULL, NULL);
2455 if (r || !write)
2456 return r;
2457
2458 new_pid = find_get_pid(tmp);
2459 if (!new_pid)
2460 return -ESRCH;
2461
2462 put_pid(xchg(&cad_pid, new_pid));
2463 return 0;
2464}
2465
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002466/**
2467 * proc_do_large_bitmap - read/write from/to a large bitmap
2468 * @table: the sysctl table
2469 * @write: %TRUE if this is a write to the sysctl file
2470 * @buffer: the user buffer
2471 * @lenp: the size of the user buffer
2472 * @ppos: file position
2473 *
2474 * The bitmap is stored at table->data and the bitmap length (in bits)
2475 * in table->maxlen.
2476 *
2477 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2478 * large bitmaps may be represented in a compact manner. Writing into
2479 * the file will clear the bitmap then update it with the given input.
2480 *
2481 * Returns 0 on success.
2482 */
2483int proc_do_large_bitmap(struct ctl_table *table, int write,
2484 void __user *buffer, size_t *lenp, loff_t *ppos)
2485{
2486 int err = 0;
2487 bool first = 1;
2488 size_t left = *lenp;
2489 unsigned long bitmap_len = table->maxlen;
2490 unsigned long *bitmap = (unsigned long *) table->data;
2491 unsigned long *tmp_bitmap = NULL;
2492 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2493
2494 if (!bitmap_len || !left || (*ppos && !write)) {
2495 *lenp = 0;
2496 return 0;
2497 }
2498
2499 if (write) {
2500 unsigned long page = 0;
2501 char *kbuf;
2502
2503 if (left > PAGE_SIZE - 1)
2504 left = PAGE_SIZE - 1;
2505
2506 page = __get_free_page(GFP_TEMPORARY);
2507 kbuf = (char *) page;
2508 if (!kbuf)
2509 return -ENOMEM;
2510 if (copy_from_user(kbuf, buffer, left)) {
2511 free_page(page);
2512 return -EFAULT;
2513 }
2514 kbuf[left] = 0;
2515
2516 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2517 GFP_KERNEL);
2518 if (!tmp_bitmap) {
2519 free_page(page);
2520 return -ENOMEM;
2521 }
2522 proc_skip_char(&kbuf, &left, '\n');
2523 while (!err && left) {
2524 unsigned long val_a, val_b;
2525 bool neg;
2526
2527 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2528 sizeof(tr_a), &c);
2529 if (err)
2530 break;
2531 if (val_a >= bitmap_len || neg) {
2532 err = -EINVAL;
2533 break;
2534 }
2535
2536 val_b = val_a;
2537 if (left) {
2538 kbuf++;
2539 left--;
2540 }
2541
2542 if (c == '-') {
2543 err = proc_get_long(&kbuf, &left, &val_b,
2544 &neg, tr_b, sizeof(tr_b),
2545 &c);
2546 if (err)
2547 break;
2548 if (val_b >= bitmap_len || neg ||
2549 val_a > val_b) {
2550 err = -EINVAL;
2551 break;
2552 }
2553 if (left) {
2554 kbuf++;
2555 left--;
2556 }
2557 }
2558
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002559 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002560 first = 0;
2561 proc_skip_char(&kbuf, &left, '\n');
2562 }
2563 free_page(page);
2564 } else {
2565 unsigned long bit_a, bit_b = 0;
2566
2567 while (left) {
2568 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2569 if (bit_a >= bitmap_len)
2570 break;
2571 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2572 bit_a + 1) - 1;
2573
2574 if (!first) {
2575 err = proc_put_char(&buffer, &left, ',');
2576 if (err)
2577 break;
2578 }
2579 err = proc_put_long(&buffer, &left, bit_a, false);
2580 if (err)
2581 break;
2582 if (bit_a != bit_b) {
2583 err = proc_put_char(&buffer, &left, '-');
2584 if (err)
2585 break;
2586 err = proc_put_long(&buffer, &left, bit_b, false);
2587 if (err)
2588 break;
2589 }
2590
2591 first = 0; bit_b++;
2592 }
2593 if (!err)
2594 err = proc_put_char(&buffer, &left, '\n');
2595 }
2596
2597 if (!err) {
2598 if (write) {
2599 if (*ppos)
2600 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2601 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002602 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002603 }
2604 kfree(tmp_bitmap);
2605 *lenp -= left;
2606 *ppos += *lenp;
2607 return 0;
2608 } else {
2609 kfree(tmp_bitmap);
2610 return err;
2611 }
2612}
2613
Jovi Zhang55610502011-01-12 17:00:45 -08002614#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002616int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 void __user *buffer, size_t *lenp, loff_t *ppos)
2618{
2619 return -ENOSYS;
2620}
2621
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002622int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 void __user *buffer, size_t *lenp, loff_t *ppos)
2624{
2625 return -ENOSYS;
2626}
2627
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002628int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 void __user *buffer, size_t *lenp, loff_t *ppos)
2630{
2631 return -ENOSYS;
2632}
2633
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002634int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 void __user *buffer, size_t *lenp, loff_t *ppos)
2636{
2637 return -ENOSYS;
2638}
2639
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002640int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 void __user *buffer, size_t *lenp, loff_t *ppos)
2642{
2643 return -ENOSYS;
2644}
2645
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002646int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647 void __user *buffer, size_t *lenp, loff_t *ppos)
2648{
2649 return -ENOSYS;
2650}
2651
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002652int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653 void __user *buffer, size_t *lenp, loff_t *ppos)
2654{
2655 return -ENOSYS;
2656}
2657
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002658int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659 void __user *buffer,
2660 size_t *lenp, loff_t *ppos)
2661{
2662 return -ENOSYS;
2663}
2664
2665
Jovi Zhang55610502011-01-12 17:00:45 -08002666#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668/*
2669 * No sense putting this after each symbol definition, twice,
2670 * exception granted :-)
2671 */
2672EXPORT_SYMBOL(proc_dointvec);
2673EXPORT_SYMBOL(proc_dointvec_jiffies);
2674EXPORT_SYMBOL(proc_dointvec_minmax);
2675EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2676EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2677EXPORT_SYMBOL(proc_dostring);
2678EXPORT_SYMBOL(proc_doulongvec_minmax);
2679EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);