blob: c398a58673a75594ad5951dc4607f07dce451f62 [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 Tomlin2397efb2014-01-20 17:34:12 +0000125static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700127static int __maybe_unused one = 1;
128static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700129static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800130static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700132#ifdef CONFIG_PRINTK
133static int ten_thousand = 10000;
134#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700135
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700136/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
137static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
140static int maxolduid = 65535;
141static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800142static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Dave Youngd14f1722010-02-25 20:28:57 -0500147#ifdef CONFIG_INOTIFY_USER
148#include <linux/inotify.h>
149#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700150#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif
152
David S. Miller08714202008-11-16 23:49:24 -0800153#ifdef CONFIG_SPARC64
154extern int sysctl_tsb_ratio;
155#endif
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#ifdef __hppa__
158extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530159#endif
160
161#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162extern int unaligned_enabled;
163#endif
164
Jes Sorensend2b176e2006-02-28 09:42:23 -0800165#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800166extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#endif
168
Vineet Guptab6fca722013-01-09 20:06:28 +0530169#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
170extern int no_unaligned_warning;
171#endif
172
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700173#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700174static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700175 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700176static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800177 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700178#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700179
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700180#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700181static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700182 void __user *buffer, size_t *lenp, loff_t *ppos);
183#endif
184
Kees Cook54b50192012-07-30 14:39:18 -0700185static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700187#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700188static int proc_dostring_coredump(struct ctl_table *table, int write,
189 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700190#endif
Kees Cook54b50192012-07-30 14:39:18 -0700191
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700192#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800193/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100194static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700195
196static int sysrq_sysctl_handler(ctl_table *table, int write,
197 void __user *buffer, size_t *lenp,
198 loff_t *ppos)
199{
200 int error;
201
202 error = proc_dointvec(table, write, buffer, lenp, ppos);
203 if (error)
204 return error;
205
206 if (write)
207 sysrq_toggle_support(__sysrq_enabled);
208
209 return 0;
210}
211
212#endif
213
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700214static struct ctl_table kern_table[];
215static struct ctl_table vm_table[];
216static struct ctl_table fs_table[];
217static struct ctl_table debug_table[];
218static struct ctl_table dev_table[];
219extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800220#ifdef CONFIG_EPOLL
221extern struct ctl_table epoll_table[];
222#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
225int sysctl_legacy_va_layout;
226#endif
227
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228/* The default sysctl tables: */
229
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800230static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 .procname = "kernel",
233 .mode = 0555,
234 .child = kern_table,
235 },
236 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 .procname = "vm",
238 .mode = 0555,
239 .child = vm_table,
240 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .procname = "fs",
243 .mode = 0555,
244 .child = fs_table,
245 },
246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .procname = "debug",
248 .mode = 0555,
249 .child = debug_table,
250 },
251 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 .procname = "dev",
253 .mode = 0555,
254 .child = dev_table,
255 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700256 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257};
258
Ingo Molnar77e54a12007-07-09 18:52:00 +0200259#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100260static int min_sched_granularity_ns = 100000; /* 100 usecs */
261static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
262static int min_wakeup_granularity_ns; /* 0 usecs */
263static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200264#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100265static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
266static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200267#endif /* CONFIG_SMP */
268#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200269
Mel Gorman5e771902010-05-24 14:32:31 -0700270#ifdef CONFIG_COMPACTION
271static int min_extfrag_threshold;
272static int max_extfrag_threshold = 1000;
273#endif
274
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700275static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200276 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200277 .procname = "sched_child_runs_first",
278 .data = &sysctl_sched_child_runs_first,
279 .maxlen = sizeof(unsigned int),
280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800281 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200282 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283#ifdef CONFIG_SCHED_DEBUG
284 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100285 .procname = "sched_min_granularity_ns",
286 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800289 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100290 .extra1 = &min_sched_granularity_ns,
291 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200292 },
293 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200294 .procname = "sched_latency_ns",
295 .data = &sysctl_sched_latency,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800298 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200299 .extra1 = &min_sched_granularity_ns,
300 .extra2 = &max_sched_granularity_ns,
301 },
302 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200303 .procname = "sched_wakeup_granularity_ns",
304 .data = &sysctl_sched_wakeup_granularity,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800307 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200308 .extra1 = &min_wakeup_granularity_ns,
309 .extra2 = &max_wakeup_granularity_ns,
310 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200311#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200312 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100313 .procname = "sched_tunable_scaling",
314 .data = &sysctl_sched_tunable_scaling,
315 .maxlen = sizeof(enum sched_tunable_scaling),
316 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800317 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100318 .extra1 = &min_sched_tunable_scaling,
319 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200320 },
321 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900322 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200323 .data = &sysctl_sched_migration_cost,
324 .maxlen = sizeof(unsigned int),
325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800326 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200327 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100328 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100329 .procname = "sched_nr_migrate",
330 .data = &sysctl_sched_nr_migrate,
331 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800333 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100334 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530335 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900336 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200337 .data = &sysctl_sched_time_avg,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800340 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200341 },
342 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900343 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800344 .data = &sysctl_sched_shares_window,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
347 .proc_handler = proc_dointvec,
348 },
349 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530350 .procname = "timer_migration",
351 .data = &sysctl_timer_migration,
352 .maxlen = sizeof(unsigned int),
353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800354 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530355 .extra1 = &zero,
356 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530357 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200358#endif /* CONFIG_SMP */
359#ifdef CONFIG_NUMA_BALANCING
360 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200361 .procname = "numa_balancing_scan_delay_ms",
362 .data = &sysctl_numa_balancing_scan_delay,
363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
365 .proc_handler = proc_dointvec,
366 },
367 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200368 .procname = "numa_balancing_scan_period_min_ms",
369 .data = &sysctl_numa_balancing_scan_period_min,
370 .maxlen = sizeof(unsigned int),
371 .mode = 0644,
372 .proc_handler = proc_dointvec,
373 },
374 {
375 .procname = "numa_balancing_scan_period_max_ms",
376 .data = &sysctl_numa_balancing_scan_period_max,
377 .maxlen = sizeof(unsigned int),
378 .mode = 0644,
379 .proc_handler = proc_dointvec,
380 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200381 {
382 .procname = "numa_balancing_scan_size_mb",
383 .data = &sysctl_numa_balancing_scan_size,
384 .maxlen = sizeof(unsigned int),
385 .mode = 0644,
386 .proc_handler = proc_dointvec,
387 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100388 {
Rik van Rielde1c9ce62013-10-07 11:29:39 +0100389 .procname = "numa_balancing_migrate_deferred",
390 .data = &sysctl_numa_balancing_migrate_deferred,
391 .maxlen = sizeof(unsigned int),
392 .mode = 0644,
393 .proc_handler = proc_dointvec,
394 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200395#endif /* CONFIG_NUMA_BALANCING */
396#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200397 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100398 .procname = "sched_rt_period_us",
399 .data = &sysctl_sched_rt_period,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800402 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100403 },
404 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100405 .procname = "sched_rt_runtime_us",
406 .data = &sysctl_sched_rt_runtime,
407 .maxlen = sizeof(int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100410 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600411 {
412 .procname = "sched_rr_timeslice_ms",
413 .data = &sched_rr_timeslice,
414 .maxlen = sizeof(int),
415 .mode = 0644,
416 .proc_handler = sched_rr_handler,
417 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100418#ifdef CONFIG_SCHED_AUTOGROUP
419 {
420 .procname = "sched_autogroup_enabled",
421 .data = &sysctl_sched_autogroup_enabled,
422 .maxlen = sizeof(unsigned int),
423 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800424 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100425 .extra1 = &zero,
426 .extra2 = &one,
427 },
428#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700429#ifdef CONFIG_CFS_BANDWIDTH
430 {
431 .procname = "sched_cfs_bandwidth_slice_us",
432 .data = &sysctl_sched_cfs_bandwidth_slice,
433 .maxlen = sizeof(unsigned int),
434 .mode = 0644,
435 .proc_handler = proc_dointvec_minmax,
436 .extra1 = &one,
437 },
438#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700439#ifdef CONFIG_PROVE_LOCKING
440 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700441 .procname = "prove_locking",
442 .data = &prove_locking,
443 .maxlen = sizeof(int),
444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800445 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446 },
447#endif
448#ifdef CONFIG_LOCK_STAT
449 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700450 .procname = "lock_stat",
451 .data = &lock_stat,
452 .maxlen = sizeof(int),
453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800454 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 },
456#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200457 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 .procname = "panic",
459 .data = &panic_timeout,
460 .maxlen = sizeof(int),
461 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800462 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 },
Alex Kelly046d6622012-10-04 17:15:23 -0700464#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 .procname = "core_uses_pid",
467 .data = &core_uses_pid,
468 .maxlen = sizeof(int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 },
472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "core_pattern",
474 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700475 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700477 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
Neil Hormana2939802009-09-23 15:56:56 -0700479 {
Neil Hormana2939802009-09-23 15:56:56 -0700480 .procname = "core_pipe_limit",
481 .data = &core_pipe_limit,
482 .maxlen = sizeof(unsigned int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700485 },
Alex Kelly046d6622012-10-04 17:15:23 -0700486#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800487#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700490 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800494#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100495#ifdef CONFIG_LATENCYTOP
496 {
497 .procname = "latencytop",
498 .data = &latencytop_enabled,
499 .maxlen = sizeof(int),
500 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800501 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100502 },
503#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504#ifdef CONFIG_BLK_DEV_INITRD
505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 .procname = "real-root-dev",
507 .data = &real_root_dev,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 },
512#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700513 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700514 .procname = "print-fatal-signals",
515 .data = &print_fatal_signals,
516 .maxlen = sizeof(int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700519 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700520#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 .procname = "reboot-cmd",
523 .data = reboot_command,
524 .maxlen = 256,
525 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800526 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 },
528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .procname = "stop-a",
530 .data = &stop_a_enabled,
531 .maxlen = sizeof (int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 .procname = "scons-poweroff",
537 .data = &scons_pwroff,
538 .maxlen = sizeof (int),
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 },
542#endif
David S. Miller08714202008-11-16 23:49:24 -0800543#ifdef CONFIG_SPARC64
544 {
David S. Miller08714202008-11-16 23:49:24 -0800545 .procname = "tsb-ratio",
546 .data = &sysctl_tsb_ratio,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800550 },
551#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552#ifdef __hppa__
553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 .procname = "soft-power",
555 .data = &pwrsw_enabled,
556 .maxlen = sizeof (int),
557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800558 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530560#endif
561#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 .procname = "unaligned-trap",
564 .data = &unaligned_enabled,
565 .maxlen = sizeof (int),
566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 },
569#endif
570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .procname = "ctrl-alt-del",
572 .data = &C_A_D,
573 .maxlen = sizeof(int),
574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800575 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400577#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200578 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200579 .procname = "ftrace_enabled",
580 .data = &ftrace_enabled,
581 .maxlen = sizeof(int),
582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200584 },
585#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500586#ifdef CONFIG_STACK_TRACER
587 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500588 .procname = "stack_tracer_enabled",
589 .data = &stack_tracer_enabled,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500593 },
594#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400595#ifdef CONFIG_TRACING
596 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100597 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400598 .data = &ftrace_dump_on_oops,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400602 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400603 {
604 .procname = "traceoff_on_warning",
605 .data = &__disable_trace_on_warning,
606 .maxlen = sizeof(__disable_trace_on_warning),
607 .mode = 0644,
608 .proc_handler = proc_dointvec,
609 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400610#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200611#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 .procname = "modprobe",
614 .data = &modprobe_path,
615 .maxlen = KMOD_PATH_LEN,
616 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 },
Kees Cook3d433212009-04-02 15:49:29 -0700619 {
Kees Cook3d433212009-04-02 15:49:29 -0700620 .procname = "modules_disabled",
621 .data = &modules_disabled,
622 .maxlen = sizeof(int),
623 .mode = 0644,
624 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800625 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700626 .extra1 = &one,
627 .extra2 = &one,
628 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500630
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100633 .data = &uevent_helper,
634 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800636 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500638
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639#ifdef CONFIG_CHR_DEV_SG
640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "sg-big-buff",
642 .data = &sg_big_buff,
643 .maxlen = sizeof (int),
644 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800645 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 },
647#endif
648#ifdef CONFIG_BSD_PROCESS_ACCT
649 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .procname = "acct",
651 .data = &acct_parm,
652 .maxlen = 3*sizeof(int),
653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 },
656#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657#ifdef CONFIG_MAGIC_SYSRQ
658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800660 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .maxlen = sizeof (int),
662 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700663 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 },
665#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700666#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700669 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .maxlen = sizeof (int),
671 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800672 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700674#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "threads-max",
677 .data = &max_threads,
678 .maxlen = sizeof(int),
679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "random",
684 .mode = 0555,
685 .child = random_table,
686 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 {
Eric Paris17f60a72011-04-01 17:07:50 -0400688 .procname = "usermodehelper",
689 .mode = 0555,
690 .child = usermodehelper_table,
691 },
692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "overflowuid",
694 .data = &overflowuid,
695 .maxlen = sizeof(int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 .extra1 = &minolduid,
699 .extra2 = &maxolduid,
700 },
701 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .procname = "overflowgid",
703 .data = &overflowgid,
704 .maxlen = sizeof(int),
705 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 .extra1 = &minolduid,
708 .extra2 = &maxolduid,
709 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800710#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711#ifdef CONFIG_MATHEMU
712 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .procname = "ieee_emulation_warnings",
714 .data = &sysctl_ieee_emulation_warnings,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 },
719#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200722 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 .maxlen = sizeof(int),
724 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800725 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 },
727#endif
728 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 .procname = "pid_max",
730 .data = &pid_max,
731 .maxlen = sizeof (int),
732 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800733 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .extra1 = &pid_max_min,
735 .extra2 = &pid_max_max,
736 },
737 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 .procname = "panic_on_oops",
739 .data = &panic_on_oops,
740 .maxlen = sizeof(int),
741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800744#if defined CONFIG_PRINTK
745 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800746 .procname = "printk",
747 .data = &console_loglevel,
748 .maxlen = 4*sizeof(int),
749 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800751 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700754 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .maxlen = sizeof(int),
756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800757 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
759 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700761 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 .maxlen = sizeof(int),
763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 },
Dave Youngaf913222009-09-22 16:43:33 -0700766 {
Dave Youngaf913222009-09-22 16:43:33 -0700767 .procname = "printk_delay",
768 .data = &printk_delay_msec,
769 .maxlen = sizeof(int),
770 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800771 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700772 .extra1 = &zero,
773 .extra2 = &ten_thousand,
774 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800776 .procname = "dmesg_restrict",
777 .data = &dmesg_restrict,
778 .maxlen = sizeof(int),
779 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700780 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800781 .extra1 = &zero,
782 .extra2 = &one,
783 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800784 {
785 .procname = "kptr_restrict",
786 .data = &kptr_restrict,
787 .maxlen = sizeof(int),
788 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700789 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800790 .extra1 = &zero,
791 .extra2 = &two,
792 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800793#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800794 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 .procname = "ngroups_max",
796 .data = &ngroups_max,
797 .maxlen = sizeof (int),
798 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 },
Dan Ballard73efc032011-10-31 17:11:20 -0700801 {
802 .procname = "cap_last_cap",
803 .data = (void *)&cap_last_cap,
804 .maxlen = sizeof(int),
805 .mode = 0444,
806 .proc_handler = proc_dointvec,
807 },
Don Zickus58687ac2010-05-07 17:11:44 -0400808#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500809 {
Don Zickus58687ac2010-05-07 17:11:44 -0400810 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200811 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500812 .maxlen = sizeof (int),
813 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700814 .proc_handler = proc_dowatchdog,
815 .extra1 = &zero,
816 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400817 },
818 {
819 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700820 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400821 .maxlen = sizeof(int),
822 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700823 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800824 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400825 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500826 },
Don Zickus2508ce12010-05-07 17:11:46 -0400827 {
828 .procname = "softlockup_panic",
829 .data = &softlockup_panic,
830 .maxlen = sizeof(int),
831 .mode = 0644,
832 .proc_handler = proc_dointvec_minmax,
833 .extra1 = &zero,
834 .extra2 = &one,
835 },
Don Zickus5dc30552010-11-29 17:07:17 -0500836 {
837 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200838 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500839 .maxlen = sizeof (int),
840 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700841 .proc_handler = proc_dowatchdog,
842 .extra1 = &zero,
843 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500844 },
845#endif
846#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
847 {
848 .procname = "unknown_nmi_panic",
849 .data = &unknown_nmi_panic,
850 .maxlen = sizeof (int),
851 .mode = 0644,
852 .proc_handler = proc_dointvec,
853 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500854#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855#if defined(CONFIG_X86)
856 {
Don Zickus8da5add2006-09-26 10:52:27 +0200857 .procname = "panic_on_unrecovered_nmi",
858 .data = &panic_on_unrecovered_nmi,
859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200862 },
863 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700864 .procname = "panic_on_io_nmi",
865 .data = &panic_on_io_nmi,
866 .maxlen = sizeof(int),
867 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800868 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700869 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900870#ifdef CONFIG_DEBUG_STACKOVERFLOW
871 {
872 .procname = "panic_on_stackoverflow",
873 .data = &sysctl_panic_on_stackoverflow,
874 .maxlen = sizeof(int),
875 .mode = 0644,
876 .proc_handler = proc_dointvec,
877 },
878#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700879 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 .procname = "bootloader_type",
881 .data = &bootloader_type,
882 .maxlen = sizeof (int),
883 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800884 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100886 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700887 .procname = "bootloader_version",
888 .data = &bootloader_version,
889 .maxlen = sizeof (int),
890 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800891 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700892 },
893 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100894 .procname = "kstack_depth_to_print",
895 .data = &kstack_depth_to_print,
896 .maxlen = sizeof(int),
897 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800898 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100899 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100900 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100901 .procname = "io_delay_type",
902 .data = &io_delay_type,
903 .maxlen = sizeof(int),
904 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800905 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100906 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800908#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 .procname = "randomize_va_space",
911 .data = &randomize_va_space,
912 .maxlen = sizeof(int),
913 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800914 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800916#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800917#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700918 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700919 .procname = "spin_retry",
920 .data = &spin_retry,
921 .maxlen = sizeof (int),
922 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800923 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700924 },
925#endif
Len Brown673d5b42007-07-28 03:33:16 -0400926#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800927 {
Pavel Machekc255d842006-02-20 18:27:58 -0800928 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700929 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800930 .maxlen = sizeof (unsigned long),
931 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800932 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800933 },
934#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530935#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800936 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800937 .procname = "ignore-unaligned-usertrap",
938 .data = &no_unaligned_warning,
939 .maxlen = sizeof (int),
940 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800941 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800942 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530943#endif
944#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800945 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800946 .procname = "unaligned-dump-stack",
947 .data = &unaligned_dump_stack,
948 .maxlen = sizeof (int),
949 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800950 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800951 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800952#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800953#ifdef CONFIG_DETECT_HUNG_TASK
954 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800955 .procname = "hung_task_panic",
956 .data = &sysctl_hung_task_panic,
957 .maxlen = sizeof(int),
958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800960 .extra1 = &zero,
961 .extra2 = &one,
962 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100963 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100964 .procname = "hung_task_check_count",
965 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800966 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100967 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800968 .proc_handler = proc_dointvec_minmax,
969 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100970 },
971 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100972 .procname = "hung_task_timeout_secs",
973 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100974 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100975 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800976 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100977 },
978 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100979 .procname = "hung_task_warnings",
980 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100981 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100982 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100984 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700985#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200986#ifdef CONFIG_COMPAT
987 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200988 .procname = "compat-log",
989 .data = &compat_log,
990 .maxlen = sizeof (int),
991 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800992 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200993 },
994#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700995#ifdef CONFIG_RT_MUTEXES
996 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700997 .procname = "max_lock_depth",
998 .data = &max_lock_depth,
999 .maxlen = sizeof(int),
1000 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001001 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001002 },
1003#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001004 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001005 .procname = "poweroff_cmd",
1006 .data = &poweroff_cmd,
1007 .maxlen = POWEROFF_CMD_PATH_LEN,
1008 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001009 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001010 },
David Howells0b77f5b2008-04-29 01:01:32 -07001011#ifdef CONFIG_KEYS
1012 {
David Howells0b77f5b2008-04-29 01:01:32 -07001013 .procname = "keys",
1014 .mode = 0555,
1015 .child = key_sysctls,
1016 },
1017#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001018#ifdef CONFIG_RCU_TORTURE_TEST
1019 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001020 .procname = "rcutorture_runnable",
1021 .data = &rcutorture_runnable,
1022 .maxlen = sizeof(int),
1023 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001024 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001025 },
1026#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001027#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001028 /*
1029 * User-space scripts rely on the existence of this file
1030 * as a feature check for perf_events being enabled.
1031 *
1032 * So it's an ABI, do not remove!
1033 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001034 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001035 .procname = "perf_event_paranoid",
1036 .data = &sysctl_perf_event_paranoid,
1037 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001038 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001039 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001040 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001041 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001042 .procname = "perf_event_mlock_kb",
1043 .data = &sysctl_perf_event_mlock,
1044 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001045 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001046 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001047 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001048 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001049 .procname = "perf_event_max_sample_rate",
1050 .data = &sysctl_perf_event_sample_rate,
1051 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001052 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001053 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001054 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001055 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001056 {
1057 .procname = "perf_cpu_time_max_percent",
1058 .data = &sysctl_perf_cpu_time_max_percent,
1059 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1060 .mode = 0644,
1061 .proc_handler = perf_cpu_time_max_percent_handler,
1062 .extra1 = &zero,
1063 .extra2 = &one_hundred,
1064 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001065#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001066#ifdef CONFIG_KMEMCHECK
1067 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001068 .procname = "kmemcheck",
1069 .data = &kmemcheck_enabled,
1070 .maxlen = sizeof(int),
1071 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001072 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001073 },
1074#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001075#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001076 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001077 .procname = "blk_iopoll",
1078 .data = &blk_iopoll_enabled,
1079 .maxlen = sizeof(int),
1080 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001081 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001082 },
Jens Axboecb684b52009-09-15 21:53:11 +02001083#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001084 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085};
1086
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001087static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 .procname = "overcommit_memory",
1090 .data = &sysctl_overcommit_memory,
1091 .maxlen = sizeof(sysctl_overcommit_memory),
1092 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001093 .proc_handler = proc_dointvec_minmax,
1094 .extra1 = &zero,
1095 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 },
1097 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001098 .procname = "panic_on_oom",
1099 .data = &sysctl_panic_on_oom,
1100 .maxlen = sizeof(sysctl_panic_on_oom),
1101 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001102 .proc_handler = proc_dointvec_minmax,
1103 .extra1 = &zero,
1104 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001105 },
1106 {
David Rientjesfe071d72007-10-16 23:25:56 -07001107 .procname = "oom_kill_allocating_task",
1108 .data = &sysctl_oom_kill_allocating_task,
1109 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001112 },
1113 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001114 .procname = "oom_dump_tasks",
1115 .data = &sysctl_oom_dump_tasks,
1116 .maxlen = sizeof(sysctl_oom_dump_tasks),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001119 },
1120 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 .procname = "overcommit_ratio",
1122 .data = &sysctl_overcommit_ratio,
1123 .maxlen = sizeof(sysctl_overcommit_ratio),
1124 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 },
1127 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 .procname = "page-cluster",
1129 .data = &page_cluster,
1130 .maxlen = sizeof(int),
1131 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001132 .proc_handler = proc_dointvec_minmax,
1133 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 },
1135 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 .procname = "dirty_background_ratio",
1137 .data = &dirty_background_ratio,
1138 .maxlen = sizeof(dirty_background_ratio),
1139 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001140 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 .extra1 = &zero,
1142 .extra2 = &one_hundred,
1143 },
1144 {
David Rientjes2da02992009-01-06 14:39:31 -08001145 .procname = "dirty_background_bytes",
1146 .data = &dirty_background_bytes,
1147 .maxlen = sizeof(dirty_background_bytes),
1148 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001149 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001150 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001151 },
1152 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 .procname = "dirty_ratio",
1154 .data = &vm_dirty_ratio,
1155 .maxlen = sizeof(vm_dirty_ratio),
1156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001157 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .extra1 = &zero,
1159 .extra2 = &one_hundred,
1160 },
1161 {
David Rientjes2da02992009-01-06 14:39:31 -08001162 .procname = "dirty_bytes",
1163 .data = &vm_dirty_bytes,
1164 .maxlen = sizeof(vm_dirty_bytes),
1165 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001166 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001167 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001168 },
1169 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001171 .data = &dirty_writeback_interval,
1172 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 },
1176 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001178 .data = &dirty_expire_interval,
1179 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001181 .proc_handler = proc_dointvec_minmax,
1182 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 },
1184 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001185 .procname = "nr_pdflush_threads",
1186 .mode = 0444 /* read-only */,
1187 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 },
1189 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 .procname = "swappiness",
1191 .data = &vm_swappiness,
1192 .maxlen = sizeof(vm_swappiness),
1193 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001194 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 .extra1 = &zero,
1196 .extra2 = &one_hundred,
1197 },
1198#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001199 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001201 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 .maxlen = sizeof(unsigned long),
1203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001204 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 .extra1 = (void *)&hugetlb_zero,
1206 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001207 },
1208#ifdef CONFIG_NUMA
1209 {
1210 .procname = "nr_hugepages_mempolicy",
1211 .data = NULL,
1212 .maxlen = sizeof(unsigned long),
1213 .mode = 0644,
1214 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1215 .extra1 = (void *)&hugetlb_zero,
1216 .extra2 = (void *)&hugetlb_infinity,
1217 },
1218#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 .procname = "hugetlb_shm_group",
1221 .data = &sysctl_hugetlb_shm_group,
1222 .maxlen = sizeof(gid_t),
1223 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001224 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 },
Mel Gorman396faf02007-07-17 04:03:13 -07001226 {
Mel Gorman396faf02007-07-17 04:03:13 -07001227 .procname = "hugepages_treat_as_movable",
1228 .data = &hugepages_treat_as_movable,
1229 .maxlen = sizeof(int),
1230 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001231 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001232 },
Adam Litke54f9f802007-10-16 01:26:20 -07001233 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001234 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001235 .data = NULL,
1236 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001237 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001238 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001239 .extra1 = (void *)&hugetlb_zero,
1240 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001241 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242#endif
1243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244 .procname = "lowmem_reserve_ratio",
1245 .data = &sysctl_lowmem_reserve_ratio,
1246 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1247 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001248 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249 },
1250 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001251 .procname = "drop_caches",
1252 .data = &sysctl_drop_caches,
1253 .maxlen = sizeof(int),
1254 .mode = 0644,
1255 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001256 .extra1 = &one,
1257 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001258 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001259#ifdef CONFIG_COMPACTION
1260 {
1261 .procname = "compact_memory",
1262 .data = &sysctl_compact_memory,
1263 .maxlen = sizeof(int),
1264 .mode = 0200,
1265 .proc_handler = sysctl_compaction_handler,
1266 },
Mel Gorman5e771902010-05-24 14:32:31 -07001267 {
1268 .procname = "extfrag_threshold",
1269 .data = &sysctl_extfrag_threshold,
1270 .maxlen = sizeof(int),
1271 .mode = 0644,
1272 .proc_handler = sysctl_extfrag_handler,
1273 .extra1 = &min_extfrag_threshold,
1274 .extra2 = &max_extfrag_threshold,
1275 },
1276
Mel Gorman76ab0f52010-05-24 14:32:28 -07001277#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001278 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 .procname = "min_free_kbytes",
1280 .data = &min_free_kbytes,
1281 .maxlen = sizeof(min_free_kbytes),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 .extra1 = &zero,
1285 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001286 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001287 .procname = "percpu_pagelist_fraction",
1288 .data = &percpu_pagelist_fraction,
1289 .maxlen = sizeof(percpu_pagelist_fraction),
1290 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001291 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001292 .extra1 = &min_percpu_pagelist_fract,
1293 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294#ifdef CONFIG_MMU
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "max_map_count",
1297 .data = &sysctl_max_map_count,
1298 .maxlen = sizeof(sysctl_max_map_count),
1299 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001300 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001301 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001303#else
1304 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001305 .procname = "nr_trim_pages",
1306 .data = &sysctl_nr_trim_pages,
1307 .maxlen = sizeof(sysctl_nr_trim_pages),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001310 .extra1 = &zero,
1311 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312#endif
1313 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 .procname = "laptop_mode",
1315 .data = &laptop_mode,
1316 .maxlen = sizeof(laptop_mode),
1317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 },
1320 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 .procname = "block_dump",
1322 .data = &block_dump,
1323 .maxlen = sizeof(block_dump),
1324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001325 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326 .extra1 = &zero,
1327 },
1328 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 .procname = "vfs_cache_pressure",
1330 .data = &sysctl_vfs_cache_pressure,
1331 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001333 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 .extra1 = &zero,
1335 },
1336#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1337 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 .procname = "legacy_va_layout",
1339 .data = &sysctl_legacy_va_layout,
1340 .maxlen = sizeof(sysctl_legacy_va_layout),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 .extra1 = &zero,
1344 },
1345#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001346#ifdef CONFIG_NUMA
1347 {
Christoph Lameter17436602006-01-18 17:42:32 -08001348 .procname = "zone_reclaim_mode",
1349 .data = &zone_reclaim_mode,
1350 .maxlen = sizeof(zone_reclaim_mode),
1351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001352 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001353 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001354 },
Christoph Lameter96146342006-07-03 00:24:13 -07001355 {
Christoph Lameter96146342006-07-03 00:24:13 -07001356 .procname = "min_unmapped_ratio",
1357 .data = &sysctl_min_unmapped_ratio,
1358 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001361 .extra1 = &zero,
1362 .extra2 = &one_hundred,
1363 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001364 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001365 .procname = "min_slab_ratio",
1366 .data = &sysctl_min_slab_ratio,
1367 .maxlen = sizeof(sysctl_min_slab_ratio),
1368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001369 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001370 .extra1 = &zero,
1371 .extra2 = &one_hundred,
1372 },
Christoph Lameter17436602006-01-18 17:42:32 -08001373#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001374#ifdef CONFIG_SMP
1375 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001376 .procname = "stat_interval",
1377 .data = &sysctl_stat_interval,
1378 .maxlen = sizeof(sysctl_stat_interval),
1379 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001380 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001381 },
1382#endif
David Howells6e141542009-12-15 19:27:45 +00001383#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001384 {
Eric Parised032182007-06-28 15:55:21 -04001385 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001386 .data = &dac_mmap_min_addr,
1387 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001389 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001390 },
David Howells6e141542009-12-15 19:27:45 +00001391#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001392#ifdef CONFIG_NUMA
1393 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001394 .procname = "numa_zonelist_order",
1395 .data = &numa_zonelist_order,
1396 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1397 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001398 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001399 },
1400#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001401#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001402 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001403 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001404 .procname = "vdso_enabled",
1405 .data = &vdso_enabled,
1406 .maxlen = sizeof(vdso_enabled),
1407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001408 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001409 .extra1 = &zero,
1410 },
1411#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001412#ifdef CONFIG_HIGHMEM
1413 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001414 .procname = "highmem_is_dirtyable",
1415 .data = &vm_highmem_is_dirtyable,
1416 .maxlen = sizeof(vm_highmem_is_dirtyable),
1417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001419 .extra1 = &zero,
1420 .extra2 = &one,
1421 },
1422#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001423 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001424 .procname = "scan_unevictable_pages",
1425 .data = &scan_unevictable_pages,
1426 .maxlen = sizeof(scan_unevictable_pages),
1427 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001428 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001429 },
Andi Kleen6a460792009-09-16 11:50:15 +02001430#ifdef CONFIG_MEMORY_FAILURE
1431 {
Andi Kleen6a460792009-09-16 11:50:15 +02001432 .procname = "memory_failure_early_kill",
1433 .data = &sysctl_memory_failure_early_kill,
1434 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001436 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001437 .extra1 = &zero,
1438 .extra2 = &one,
1439 },
1440 {
Andi Kleen6a460792009-09-16 11:50:15 +02001441 .procname = "memory_failure_recovery",
1442 .data = &sysctl_memory_failure_recovery,
1443 .maxlen = sizeof(sysctl_memory_failure_recovery),
1444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001445 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001446 .extra1 = &zero,
1447 .extra2 = &one,
1448 },
1449#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001450 {
1451 .procname = "user_reserve_kbytes",
1452 .data = &sysctl_user_reserve_kbytes,
1453 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1454 .mode = 0644,
1455 .proc_handler = proc_doulongvec_minmax,
1456 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001457 {
1458 .procname = "admin_reserve_kbytes",
1459 .data = &sysctl_admin_reserve_kbytes,
1460 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1461 .mode = 0644,
1462 .proc_handler = proc_doulongvec_minmax,
1463 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001464 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465};
1466
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001467#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001468static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001469 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001470};
1471#endif
1472
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001473static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 .procname = "inode-nr",
1476 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001477 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001479 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 },
1481 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 .procname = "inode-state",
1483 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001484 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001486 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 },
1488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 .procname = "file-nr",
1490 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001491 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001493 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 },
1495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 .procname = "file-max",
1497 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001498 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001500 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 },
1502 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001503 .procname = "nr_open",
1504 .data = &sysctl_nr_open,
1505 .maxlen = sizeof(int),
1506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001507 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001508 .extra1 = &sysctl_nr_open_min,
1509 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001510 },
1511 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 .procname = "dentry-state",
1513 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001514 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001516 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 },
1518 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 .procname = "overflowuid",
1520 .data = &fs_overflowuid,
1521 .maxlen = sizeof(int),
1522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 .extra1 = &minolduid,
1525 .extra2 = &maxolduid,
1526 },
1527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .procname = "overflowgid",
1529 .data = &fs_overflowgid,
1530 .maxlen = sizeof(int),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 .extra1 = &minolduid,
1534 .extra2 = &maxolduid,
1535 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001536#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 .procname = "leases-enable",
1539 .data = &leases_enable,
1540 .maxlen = sizeof(int),
1541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001542 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001544#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545#ifdef CONFIG_DNOTIFY
1546 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 .procname = "dir-notify-enable",
1548 .data = &dir_notify_enable,
1549 .maxlen = sizeof(int),
1550 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001551 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 },
1553#endif
1554#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001555#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557 .procname = "lease-break-time",
1558 .data = &lease_break_time,
1559 .maxlen = sizeof(int),
1560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001561 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001563#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001564#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566 .procname = "aio-nr",
1567 .data = &aio_nr,
1568 .maxlen = sizeof(aio_nr),
1569 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001570 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571 },
1572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 .procname = "aio-max-nr",
1574 .data = &aio_max_nr,
1575 .maxlen = sizeof(aio_max_nr),
1576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001577 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001579#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001580#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001581 {
Robert Love0399cb02005-07-13 12:38:18 -04001582 .procname = "inotify",
1583 .mode = 0555,
1584 .child = inotify_table,
1585 },
1586#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001587#ifdef CONFIG_EPOLL
1588 {
1589 .procname = "epoll",
1590 .mode = 0555,
1591 .child = epoll_table,
1592 },
1593#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001595 {
Kees Cook800179c2012-07-25 17:29:07 -07001596 .procname = "protected_symlinks",
1597 .data = &sysctl_protected_symlinks,
1598 .maxlen = sizeof(int),
1599 .mode = 0600,
1600 .proc_handler = proc_dointvec_minmax,
1601 .extra1 = &zero,
1602 .extra2 = &one,
1603 },
1604 {
1605 .procname = "protected_hardlinks",
1606 .data = &sysctl_protected_hardlinks,
1607 .maxlen = sizeof(int),
1608 .mode = 0600,
1609 .proc_handler = proc_dointvec_minmax,
1610 .extra1 = &zero,
1611 .extra2 = &one,
1612 },
1613 {
Alan Coxd6e71142005-06-23 00:09:43 -07001614 .procname = "suid_dumpable",
1615 .data = &suid_dumpable,
1616 .maxlen = sizeof(int),
1617 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001618 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001619 .extra1 = &zero,
1620 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001621 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001622#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1623 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001624 .procname = "binfmt_misc",
1625 .mode = 0555,
1626 .child = binfmt_misc_table,
1627 },
1628#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001629 {
Jens Axboeff9da692010-06-03 14:54:39 +02001630 .procname = "pipe-max-size",
1631 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001632 .maxlen = sizeof(int),
1633 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001634 .proc_handler = &pipe_proc_fn,
1635 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001636 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001637 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001638};
1639
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001640static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001641#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001642 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001643 .procname = "exception-trace",
1644 .data = &show_unhandled_signals,
1645 .maxlen = sizeof(int),
1646 .mode = 0644,
1647 .proc_handler = proc_dointvec
1648 },
1649#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001650#if defined(CONFIG_OPTPROBES)
1651 {
1652 .procname = "kprobes-optimization",
1653 .data = &sysctl_kprobes_optimization,
1654 .maxlen = sizeof(int),
1655 .mode = 0644,
1656 .proc_handler = proc_kprobes_optimization_handler,
1657 .extra1 = &zero,
1658 .extra2 = &one,
1659 },
1660#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001661 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662};
1663
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001664static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001665 { }
Robert Love0eeca282005-07-12 17:06:03 -04001666};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001668int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001669{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001670 struct ctl_table_header *hdr;
1671
1672 hdr = register_sysctl_table(sysctl_base_table);
1673 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001674 return 0;
1675}
1676
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001677#endif /* CONFIG_SYSCTL */
1678
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679/*
1680 * /proc/sys support
1681 */
1682
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001683#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001685static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001686 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001687 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001688{
1689 size_t len;
1690 char __user *p;
1691 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001692
1693 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001694 *lenp = 0;
1695 return 0;
1696 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001697
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001698 if (write) {
1699 len = 0;
1700 p = buffer;
1701 while (len < *lenp) {
1702 if (get_user(c, p++))
1703 return -EFAULT;
1704 if (c == 0 || c == '\n')
1705 break;
1706 len++;
1707 }
1708 if (len >= maxlen)
1709 len = maxlen-1;
1710 if(copy_from_user(data, buffer, len))
1711 return -EFAULT;
1712 ((char *) data)[len] = 0;
1713 *ppos += *lenp;
1714 } else {
1715 len = strlen(data);
1716 if (len > maxlen)
1717 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001718
1719 if (*ppos > len) {
1720 *lenp = 0;
1721 return 0;
1722 }
1723
1724 data += *ppos;
1725 len -= *ppos;
1726
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001727 if (len > *lenp)
1728 len = *lenp;
1729 if (len)
1730 if(copy_to_user(buffer, data, len))
1731 return -EFAULT;
1732 if (len < *lenp) {
1733 if(put_user('\n', ((char __user *) buffer) + len))
1734 return -EFAULT;
1735 len++;
1736 }
1737 *lenp = len;
1738 *ppos += len;
1739 }
1740 return 0;
1741}
1742
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743/**
1744 * proc_dostring - read a string sysctl
1745 * @table: the sysctl table
1746 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747 * @buffer: the user buffer
1748 * @lenp: the size of the user buffer
1749 * @ppos: file position
1750 *
1751 * Reads/writes a string from/to the user buffer. If the kernel
1752 * buffer provided is not large enough to hold the string, the
1753 * string is truncated. The copied string is %NULL-terminated.
1754 * If the string is being read by the user process, it is copied
1755 * and a newline '\n' is added. It is truncated if the buffer is
1756 * not large enough.
1757 *
1758 * Returns 0 on success.
1759 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001760int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761 void __user *buffer, size_t *lenp, loff_t *ppos)
1762{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001763 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001764 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765}
1766
Amerigo Wang00b7c332010-05-05 00:26:45 +00001767static size_t proc_skip_spaces(char **buf)
1768{
1769 size_t ret;
1770 char *tmp = skip_spaces(*buf);
1771 ret = tmp - *buf;
1772 *buf = tmp;
1773 return ret;
1774}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001776static void proc_skip_char(char **buf, size_t *size, const char v)
1777{
1778 while (*size) {
1779 if (**buf != v)
1780 break;
1781 (*size)--;
1782 (*buf)++;
1783 }
1784}
1785
Amerigo Wang00b7c332010-05-05 00:26:45 +00001786#define TMPBUFLEN 22
1787/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001788 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001789 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001790 * @buf: a kernel buffer
1791 * @size: size of the kernel buffer
1792 * @val: this is where the number will be stored
1793 * @neg: set to %TRUE if number is negative
1794 * @perm_tr: a vector which contains the allowed trailers
1795 * @perm_tr_len: size of the perm_tr vector
1796 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001797 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001798 * In case of success %0 is returned and @buf and @size are updated with
1799 * the amount of bytes read. If @tr is non-NULL and a trailing
1800 * character exists (size is non-zero after returning from this
1801 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001802 */
1803static int proc_get_long(char **buf, size_t *size,
1804 unsigned long *val, bool *neg,
1805 const char *perm_tr, unsigned perm_tr_len, char *tr)
1806{
1807 int len;
1808 char *p, tmp[TMPBUFLEN];
1809
1810 if (!*size)
1811 return -EINVAL;
1812
1813 len = *size;
1814 if (len > TMPBUFLEN - 1)
1815 len = TMPBUFLEN - 1;
1816
1817 memcpy(tmp, *buf, len);
1818
1819 tmp[len] = 0;
1820 p = tmp;
1821 if (*p == '-' && *size > 1) {
1822 *neg = true;
1823 p++;
1824 } else
1825 *neg = false;
1826 if (!isdigit(*p))
1827 return -EINVAL;
1828
1829 *val = simple_strtoul(p, &p, 0);
1830
1831 len = p - tmp;
1832
1833 /* We don't know if the next char is whitespace thus we may accept
1834 * invalid integers (e.g. 1234...a) or two integers instead of one
1835 * (e.g. 123...1). So lets not allow such large numbers. */
1836 if (len == TMPBUFLEN - 1)
1837 return -EINVAL;
1838
1839 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1840 return -EINVAL;
1841
1842 if (tr && (len < *size))
1843 *tr = *p;
1844
1845 *buf += len;
1846 *size -= len;
1847
1848 return 0;
1849}
1850
1851/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001852 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001853 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001854 * @buf: the user buffer
1855 * @size: the size of the user buffer
1856 * @val: the integer to be converted
1857 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001858 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001859 * In case of success %0 is returned and @buf and @size are updated with
1860 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861 */
1862static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1863 bool neg)
1864{
1865 int len;
1866 char tmp[TMPBUFLEN], *p = tmp;
1867
1868 sprintf(p, "%s%lu", neg ? "-" : "", val);
1869 len = strlen(tmp);
1870 if (len > *size)
1871 len = *size;
1872 if (copy_to_user(*buf, tmp, len))
1873 return -EFAULT;
1874 *size -= len;
1875 *buf += len;
1876 return 0;
1877}
1878#undef TMPBUFLEN
1879
1880static int proc_put_char(void __user **buf, size_t *size, char c)
1881{
1882 if (*size) {
1883 char __user **buffer = (char __user **)buf;
1884 if (put_user(c, *buffer))
1885 return -EFAULT;
1886 (*size)--, (*buffer)++;
1887 *buf = *buffer;
1888 }
1889 return 0;
1890}
1891
1892static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 int *valp,
1894 int write, void *data)
1895{
1896 if (write) {
1897 *valp = *negp ? -*lvalp : *lvalp;
1898 } else {
1899 int val = *valp;
1900 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001901 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 *lvalp = (unsigned long)-val;
1903 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001904 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905 *lvalp = (unsigned long)val;
1906 }
1907 }
1908 return 0;
1909}
1910
Amerigo Wang00b7c332010-05-05 00:26:45 +00001911static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1912
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001913static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001914 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001915 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001916 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001917 int write, void *data),
1918 void *data)
1919{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001920 int *i, vleft, first = 1, err = 0;
1921 unsigned long page = 0;
1922 size_t left;
1923 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924
Amerigo Wang00b7c332010-05-05 00:26:45 +00001925 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926 *lenp = 0;
1927 return 0;
1928 }
1929
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001930 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931 vleft = table->maxlen / sizeof(*i);
1932 left = *lenp;
1933
1934 if (!conv)
1935 conv = do_proc_dointvec_conv;
1936
Linus Torvalds1da177e2005-04-16 15:20:36 -07001937 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001938 if (left > PAGE_SIZE - 1)
1939 left = PAGE_SIZE - 1;
1940 page = __get_free_page(GFP_TEMPORARY);
1941 kbuf = (char *) page;
1942 if (!kbuf)
1943 return -ENOMEM;
1944 if (copy_from_user(kbuf, buffer, left)) {
1945 err = -EFAULT;
1946 goto free;
1947 }
1948 kbuf[left] = 0;
1949 }
1950
1951 for (; left && vleft--; i++, first=0) {
1952 unsigned long lval;
1953 bool neg;
1954
1955 if (write) {
1956 left -= proc_skip_spaces(&kbuf);
1957
J. R. Okajima563b0462010-05-25 16:10:14 -07001958 if (!left)
1959 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001960 err = proc_get_long(&kbuf, &left, &lval, &neg,
1961 proc_wspace_sep,
1962 sizeof(proc_wspace_sep), NULL);
1963 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001965 if (conv(&neg, &lval, i, 1, data)) {
1966 err = -EINVAL;
1967 break;
1968 }
1969 } else {
1970 if (conv(&neg, &lval, i, 0, data)) {
1971 err = -EINVAL;
1972 break;
1973 }
1974 if (!first)
1975 err = proc_put_char(&buffer, &left, '\t');
1976 if (err)
1977 break;
1978 err = proc_put_long(&buffer, &left, lval, neg);
1979 if (err)
1980 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981 }
1982 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001983
1984 if (!write && !first && left && !err)
1985 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001986 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001987 left -= proc_skip_spaces(&kbuf);
1988free:
1989 if (write) {
1990 free_page(page);
1991 if (first)
1992 return err ? : -EINVAL;
1993 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994 *lenp -= left;
1995 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001996 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997}
1998
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001999static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002000 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002001 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002002 int write, void *data),
2003 void *data)
2004{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002005 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002006 buffer, lenp, ppos, conv, data);
2007}
2008
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009/**
2010 * proc_dointvec - read a vector of integers
2011 * @table: the sysctl table
2012 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013 * @buffer: the user buffer
2014 * @lenp: the size of the user buffer
2015 * @ppos: file position
2016 *
2017 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2018 * values from/to the user buffer, treated as an ASCII string.
2019 *
2020 * Returns 0 on success.
2021 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002022int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 void __user *buffer, size_t *lenp, loff_t *ppos)
2024{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002025 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026 NULL,NULL);
2027}
2028
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002029/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002030 * Taint values can only be increased
2031 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002032 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002033static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002034 void __user *buffer, size_t *lenp, loff_t *ppos)
2035{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002036 struct ctl_table t;
2037 unsigned long tmptaint = get_taint();
2038 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002039
Bastian Blank91fcd412007-04-23 14:41:14 -07002040 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002041 return -EPERM;
2042
Andi Kleen25ddbb12008-10-15 22:01:41 -07002043 t = *table;
2044 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002045 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002046 if (err < 0)
2047 return err;
2048
2049 if (write) {
2050 /*
2051 * Poor man's atomic or. Not worth adding a primitive
2052 * to everyone's atomic.h for this
2053 */
2054 int i;
2055 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2056 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302057 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002058 }
2059 }
2060
2061 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002062}
2063
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002064#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002065static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002066 void __user *buffer, size_t *lenp, loff_t *ppos)
2067{
2068 if (write && !capable(CAP_SYS_ADMIN))
2069 return -EPERM;
2070
2071 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2072}
2073#endif
2074
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075struct do_proc_dointvec_minmax_conv_param {
2076 int *min;
2077 int *max;
2078};
2079
Amerigo Wang00b7c332010-05-05 00:26:45 +00002080static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2081 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082 int write, void *data)
2083{
2084 struct do_proc_dointvec_minmax_conv_param *param = data;
2085 if (write) {
2086 int val = *negp ? -*lvalp : *lvalp;
2087 if ((param->min && *param->min > val) ||
2088 (param->max && *param->max < val))
2089 return -EINVAL;
2090 *valp = val;
2091 } else {
2092 int val = *valp;
2093 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002094 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 *lvalp = (unsigned long)-val;
2096 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002097 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 *lvalp = (unsigned long)val;
2099 }
2100 }
2101 return 0;
2102}
2103
2104/**
2105 * proc_dointvec_minmax - read a vector of integers with min/max values
2106 * @table: the sysctl table
2107 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 * @buffer: the user buffer
2109 * @lenp: the size of the user buffer
2110 * @ppos: file position
2111 *
2112 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2113 * values from/to the user buffer, treated as an ASCII string.
2114 *
2115 * This routine will ensure the values are within the range specified by
2116 * table->extra1 (min) and table->extra2 (max).
2117 *
2118 * Returns 0 on success.
2119 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002120int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 void __user *buffer, size_t *lenp, loff_t *ppos)
2122{
2123 struct do_proc_dointvec_minmax_conv_param param = {
2124 .min = (int *) table->extra1,
2125 .max = (int *) table->extra2,
2126 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002127 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128 do_proc_dointvec_minmax_conv, &param);
2129}
2130
Kees Cook54b50192012-07-30 14:39:18 -07002131static void validate_coredump_safety(void)
2132{
Alex Kelly046d6622012-10-04 17:15:23 -07002133#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002134 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002135 core_pattern[0] != '/' && core_pattern[0] != '|') {
2136 printk(KERN_WARNING "Unsafe core_pattern used with "\
2137 "suid_dumpable=2. Pipe handler or fully qualified "\
2138 "core dump path required.\n");
2139 }
Alex Kelly046d6622012-10-04 17:15:23 -07002140#endif
Kees Cook54b50192012-07-30 14:39:18 -07002141}
2142
2143static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2144 void __user *buffer, size_t *lenp, loff_t *ppos)
2145{
2146 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2147 if (!error)
2148 validate_coredump_safety();
2149 return error;
2150}
2151
Alex Kelly046d6622012-10-04 17:15:23 -07002152#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002153static int proc_dostring_coredump(struct ctl_table *table, int write,
2154 void __user *buffer, size_t *lenp, loff_t *ppos)
2155{
2156 int error = proc_dostring(table, write, buffer, lenp, ppos);
2157 if (!error)
2158 validate_coredump_safety();
2159 return error;
2160}
Alex Kelly046d6622012-10-04 17:15:23 -07002161#endif
Kees Cook54b50192012-07-30 14:39:18 -07002162
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002163static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 void __user *buffer,
2165 size_t *lenp, loff_t *ppos,
2166 unsigned long convmul,
2167 unsigned long convdiv)
2168{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002169 unsigned long *i, *min, *max;
2170 int vleft, first = 1, err = 0;
2171 unsigned long page = 0;
2172 size_t left;
2173 char *kbuf;
2174
2175 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176 *lenp = 0;
2177 return 0;
2178 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002179
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002180 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181 min = (unsigned long *) table->extra1;
2182 max = (unsigned long *) table->extra2;
2183 vleft = table->maxlen / sizeof(unsigned long);
2184 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185
2186 if (write) {
2187 if (left > PAGE_SIZE - 1)
2188 left = PAGE_SIZE - 1;
2189 page = __get_free_page(GFP_TEMPORARY);
2190 kbuf = (char *) page;
2191 if (!kbuf)
2192 return -ENOMEM;
2193 if (copy_from_user(kbuf, buffer, left)) {
2194 err = -EFAULT;
2195 goto free;
2196 }
2197 kbuf[left] = 0;
2198 }
2199
Eric Dumazet27b3d802010-10-07 12:59:29 -07002200 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002201 unsigned long val;
2202
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002204 bool neg;
2205
2206 left -= proc_skip_spaces(&kbuf);
2207
2208 err = proc_get_long(&kbuf, &left, &val, &neg,
2209 proc_wspace_sep,
2210 sizeof(proc_wspace_sep), NULL);
2211 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 break;
2213 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214 continue;
2215 if ((min && val < *min) || (max && val > *max))
2216 continue;
2217 *i = val;
2218 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002219 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002220 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002221 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002222 if (err)
2223 break;
2224 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002225 err = proc_put_long(&buffer, &left, val, false);
2226 if (err)
2227 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 }
2229 }
2230
Amerigo Wang00b7c332010-05-05 00:26:45 +00002231 if (!write && !first && left && !err)
2232 err = proc_put_char(&buffer, &left, '\n');
2233 if (write && !err)
2234 left -= proc_skip_spaces(&kbuf);
2235free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002237 free_page(page);
2238 if (first)
2239 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 *lenp -= left;
2242 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002243 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244}
2245
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002246static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002247 void __user *buffer,
2248 size_t *lenp, loff_t *ppos,
2249 unsigned long convmul,
2250 unsigned long convdiv)
2251{
2252 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002253 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002254}
2255
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256/**
2257 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2258 * @table: the sysctl table
2259 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 * @buffer: the user buffer
2261 * @lenp: the size of the user buffer
2262 * @ppos: file position
2263 *
2264 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2265 * values from/to the user buffer, treated as an ASCII string.
2266 *
2267 * This routine will ensure the values are within the range specified by
2268 * table->extra1 (min) and table->extra2 (max).
2269 *
2270 * Returns 0 on success.
2271 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002272int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 void __user *buffer, size_t *lenp, loff_t *ppos)
2274{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002275 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276}
2277
2278/**
2279 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2280 * @table: the sysctl table
2281 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 * @buffer: the user buffer
2283 * @lenp: the size of the user buffer
2284 * @ppos: file position
2285 *
2286 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2287 * values from/to the user buffer, treated as an ASCII string. The values
2288 * are treated as milliseconds, and converted to jiffies when they are stored.
2289 *
2290 * This routine will ensure the values are within the range specified by
2291 * table->extra1 (min) and table->extra2 (max).
2292 *
2293 * Returns 0 on success.
2294 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002295int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 void __user *buffer,
2297 size_t *lenp, loff_t *ppos)
2298{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002299 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 lenp, ppos, HZ, 1000l);
2301}
2302
2303
Amerigo Wang00b7c332010-05-05 00:26:45 +00002304static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 int *valp,
2306 int write, void *data)
2307{
2308 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002309 if (*lvalp > LONG_MAX / HZ)
2310 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2312 } else {
2313 int val = *valp;
2314 unsigned long lval;
2315 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002316 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 lval = (unsigned long)-val;
2318 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002319 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320 lval = (unsigned long)val;
2321 }
2322 *lvalp = lval / HZ;
2323 }
2324 return 0;
2325}
2326
Amerigo Wang00b7c332010-05-05 00:26:45 +00002327static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 int *valp,
2329 int write, void *data)
2330{
2331 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002332 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2333 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2335 } else {
2336 int val = *valp;
2337 unsigned long lval;
2338 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002339 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 lval = (unsigned long)-val;
2341 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002342 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002343 lval = (unsigned long)val;
2344 }
2345 *lvalp = jiffies_to_clock_t(lval);
2346 }
2347 return 0;
2348}
2349
Amerigo Wang00b7c332010-05-05 00:26:45 +00002350static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 int *valp,
2352 int write, void *data)
2353{
2354 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002355 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2356
2357 if (jif > INT_MAX)
2358 return 1;
2359 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 } else {
2361 int val = *valp;
2362 unsigned long lval;
2363 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002364 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365 lval = (unsigned long)-val;
2366 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002367 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368 lval = (unsigned long)val;
2369 }
2370 *lvalp = jiffies_to_msecs(lval);
2371 }
2372 return 0;
2373}
2374
2375/**
2376 * proc_dointvec_jiffies - read a vector of integers as seconds
2377 * @table: the sysctl table
2378 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379 * @buffer: the user buffer
2380 * @lenp: the size of the user buffer
2381 * @ppos: file position
2382 *
2383 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2384 * values from/to the user buffer, treated as an ASCII string.
2385 * The values read are assumed to be in seconds, and are converted into
2386 * jiffies.
2387 *
2388 * Returns 0 on success.
2389 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002390int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 void __user *buffer, size_t *lenp, loff_t *ppos)
2392{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002393 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 do_proc_dointvec_jiffies_conv,NULL);
2395}
2396
2397/**
2398 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2399 * @table: the sysctl table
2400 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 * @buffer: the user buffer
2402 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002403 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 *
2405 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2406 * values from/to the user buffer, treated as an ASCII string.
2407 * The values read are assumed to be in 1/USER_HZ seconds, and
2408 * are converted into jiffies.
2409 *
2410 * Returns 0 on success.
2411 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002412int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 void __user *buffer, size_t *lenp, loff_t *ppos)
2414{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002415 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416 do_proc_dointvec_userhz_jiffies_conv,NULL);
2417}
2418
2419/**
2420 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2421 * @table: the sysctl table
2422 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 * @buffer: the user buffer
2424 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002425 * @ppos: file position
2426 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 *
2428 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2429 * values from/to the user buffer, treated as an ASCII string.
2430 * The values read are assumed to be in 1/1000 seconds, and
2431 * are converted into jiffies.
2432 *
2433 * Returns 0 on success.
2434 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002435int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 void __user *buffer, size_t *lenp, loff_t *ppos)
2437{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002438 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 do_proc_dointvec_ms_jiffies_conv, NULL);
2440}
2441
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002442static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002443 void __user *buffer, size_t *lenp, loff_t *ppos)
2444{
2445 struct pid *new_pid;
2446 pid_t tmp;
2447 int r;
2448
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002449 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002450
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002451 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002452 lenp, ppos, NULL, NULL);
2453 if (r || !write)
2454 return r;
2455
2456 new_pid = find_get_pid(tmp);
2457 if (!new_pid)
2458 return -ESRCH;
2459
2460 put_pid(xchg(&cad_pid, new_pid));
2461 return 0;
2462}
2463
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002464/**
2465 * proc_do_large_bitmap - read/write from/to a large bitmap
2466 * @table: the sysctl table
2467 * @write: %TRUE if this is a write to the sysctl file
2468 * @buffer: the user buffer
2469 * @lenp: the size of the user buffer
2470 * @ppos: file position
2471 *
2472 * The bitmap is stored at table->data and the bitmap length (in bits)
2473 * in table->maxlen.
2474 *
2475 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2476 * large bitmaps may be represented in a compact manner. Writing into
2477 * the file will clear the bitmap then update it with the given input.
2478 *
2479 * Returns 0 on success.
2480 */
2481int proc_do_large_bitmap(struct ctl_table *table, int write,
2482 void __user *buffer, size_t *lenp, loff_t *ppos)
2483{
2484 int err = 0;
2485 bool first = 1;
2486 size_t left = *lenp;
2487 unsigned long bitmap_len = table->maxlen;
2488 unsigned long *bitmap = (unsigned long *) table->data;
2489 unsigned long *tmp_bitmap = NULL;
2490 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2491
2492 if (!bitmap_len || !left || (*ppos && !write)) {
2493 *lenp = 0;
2494 return 0;
2495 }
2496
2497 if (write) {
2498 unsigned long page = 0;
2499 char *kbuf;
2500
2501 if (left > PAGE_SIZE - 1)
2502 left = PAGE_SIZE - 1;
2503
2504 page = __get_free_page(GFP_TEMPORARY);
2505 kbuf = (char *) page;
2506 if (!kbuf)
2507 return -ENOMEM;
2508 if (copy_from_user(kbuf, buffer, left)) {
2509 free_page(page);
2510 return -EFAULT;
2511 }
2512 kbuf[left] = 0;
2513
2514 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2515 GFP_KERNEL);
2516 if (!tmp_bitmap) {
2517 free_page(page);
2518 return -ENOMEM;
2519 }
2520 proc_skip_char(&kbuf, &left, '\n');
2521 while (!err && left) {
2522 unsigned long val_a, val_b;
2523 bool neg;
2524
2525 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2526 sizeof(tr_a), &c);
2527 if (err)
2528 break;
2529 if (val_a >= bitmap_len || neg) {
2530 err = -EINVAL;
2531 break;
2532 }
2533
2534 val_b = val_a;
2535 if (left) {
2536 kbuf++;
2537 left--;
2538 }
2539
2540 if (c == '-') {
2541 err = proc_get_long(&kbuf, &left, &val_b,
2542 &neg, tr_b, sizeof(tr_b),
2543 &c);
2544 if (err)
2545 break;
2546 if (val_b >= bitmap_len || neg ||
2547 val_a > val_b) {
2548 err = -EINVAL;
2549 break;
2550 }
2551 if (left) {
2552 kbuf++;
2553 left--;
2554 }
2555 }
2556
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002557 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002558 first = 0;
2559 proc_skip_char(&kbuf, &left, '\n');
2560 }
2561 free_page(page);
2562 } else {
2563 unsigned long bit_a, bit_b = 0;
2564
2565 while (left) {
2566 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2567 if (bit_a >= bitmap_len)
2568 break;
2569 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2570 bit_a + 1) - 1;
2571
2572 if (!first) {
2573 err = proc_put_char(&buffer, &left, ',');
2574 if (err)
2575 break;
2576 }
2577 err = proc_put_long(&buffer, &left, bit_a, false);
2578 if (err)
2579 break;
2580 if (bit_a != bit_b) {
2581 err = proc_put_char(&buffer, &left, '-');
2582 if (err)
2583 break;
2584 err = proc_put_long(&buffer, &left, bit_b, false);
2585 if (err)
2586 break;
2587 }
2588
2589 first = 0; bit_b++;
2590 }
2591 if (!err)
2592 err = proc_put_char(&buffer, &left, '\n');
2593 }
2594
2595 if (!err) {
2596 if (write) {
2597 if (*ppos)
2598 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2599 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002600 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002601 }
2602 kfree(tmp_bitmap);
2603 *lenp -= left;
2604 *ppos += *lenp;
2605 return 0;
2606 } else {
2607 kfree(tmp_bitmap);
2608 return err;
2609 }
2610}
2611
Jovi Zhang55610502011-01-12 17:00:45 -08002612#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002614int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615 void __user *buffer, size_t *lenp, loff_t *ppos)
2616{
2617 return -ENOSYS;
2618}
2619
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002620int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621 void __user *buffer, size_t *lenp, loff_t *ppos)
2622{
2623 return -ENOSYS;
2624}
2625
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002626int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627 void __user *buffer, size_t *lenp, loff_t *ppos)
2628{
2629 return -ENOSYS;
2630}
2631
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002632int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 void __user *buffer, size_t *lenp, loff_t *ppos)
2634{
2635 return -ENOSYS;
2636}
2637
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002638int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 void __user *buffer, size_t *lenp, loff_t *ppos)
2640{
2641 return -ENOSYS;
2642}
2643
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002644int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 void __user *buffer, size_t *lenp, loff_t *ppos)
2646{
2647 return -ENOSYS;
2648}
2649
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002650int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 void __user *buffer, size_t *lenp, loff_t *ppos)
2652{
2653 return -ENOSYS;
2654}
2655
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002656int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 void __user *buffer,
2658 size_t *lenp, loff_t *ppos)
2659{
2660 return -ENOSYS;
2661}
2662
2663
Jovi Zhang55610502011-01-12 17:00:45 -08002664#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666/*
2667 * No sense putting this after each symbol definition, twice,
2668 * exception granted :-)
2669 */
2670EXPORT_SYMBOL(proc_dointvec);
2671EXPORT_SYMBOL(proc_dointvec_jiffies);
2672EXPORT_SYMBOL(proc_dointvec_minmax);
2673EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2674EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2675EXPORT_SYMBOL(proc_dostring);
2676EXPORT_SYMBOL(proc_doulongvec_minmax);
2677EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);