blob: b0805652c4ff7db36e7861ffe1779fbd1f2cda53 [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;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200123static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124#endif
125
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700127static int __maybe_unused one = 1;
128static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700129static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800130static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700132#ifdef CONFIG_PRINTK
133static int ten_thousand = 10000;
134#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700135
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700136/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
137static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
140static int maxolduid = 65535;
141static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800142static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Dave Youngd14f1722010-02-25 20:28:57 -0500147#ifdef CONFIG_INOTIFY_USER
148#include <linux/inotify.h>
149#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700150#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif
152
David S. Miller08714202008-11-16 23:49:24 -0800153#ifdef CONFIG_SPARC64
154extern int sysctl_tsb_ratio;
155#endif
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#ifdef __hppa__
158extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530159#endif
160
161#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162extern int unaligned_enabled;
163#endif
164
Jes Sorensend2b176e2006-02-28 09:42:23 -0800165#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800166extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#endif
168
Vineet Guptab6fca722013-01-09 20:06:28 +0530169#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
170extern int no_unaligned_warning;
171#endif
172
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700173#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700174static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700175 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700176static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800177 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700178#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700179
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700180#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700181static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700182 void __user *buffer, size_t *lenp, loff_t *ppos);
183#endif
184
Kees Cook54b50192012-07-30 14:39:18 -0700185static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700187#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700188static int proc_dostring_coredump(struct ctl_table *table, int write,
189 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700190#endif
Kees Cook54b50192012-07-30 14:39:18 -0700191
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700192#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800193/* Note: sysrq code uses it's own private copy */
194static int __sysrq_enabled = 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 {
Mel Gormanb8593bf2012-11-21 01:18:23 +0000375 .procname = "numa_balancing_scan_period_reset",
376 .data = &sysctl_numa_balancing_scan_period_reset,
377 .maxlen = sizeof(unsigned int),
378 .mode = 0644,
379 .proc_handler = proc_dointvec,
380 },
381 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200382 .procname = "numa_balancing_scan_period_max_ms",
383 .data = &sysctl_numa_balancing_scan_period_max,
384 .maxlen = sizeof(unsigned int),
385 .mode = 0644,
386 .proc_handler = proc_dointvec,
387 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200388 {
389 .procname = "numa_balancing_scan_size_mb",
390 .data = &sysctl_numa_balancing_scan_size,
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 Rostedtf38f1d22008-12-16 23:06:40 -0500586#ifdef CONFIG_STACK_TRACER
587 {
Steven Rostedtf38f1d22008-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 Rostedtf38f1d22008-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 },
603#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200604#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "modprobe",
607 .data = &modprobe_path,
608 .maxlen = KMOD_PATH_LEN,
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
Kees Cook3d433212009-04-02 15:49:29 -0700612 {
Kees Cook3d433212009-04-02 15:49:29 -0700613 .procname = "modules_disabled",
614 .data = &modules_disabled,
615 .maxlen = sizeof(int),
616 .mode = 0644,
617 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700619 .extra1 = &one,
620 .extra2 = &one,
621 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500623
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100626 .data = &uevent_helper,
627 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500631
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632#ifdef CONFIG_CHR_DEV_SG
633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "sg-big-buff",
635 .data = &sg_big_buff,
636 .maxlen = sizeof (int),
637 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800638 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 },
640#endif
641#ifdef CONFIG_BSD_PROCESS_ACCT
642 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 .procname = "acct",
644 .data = &acct_parm,
645 .maxlen = 3*sizeof(int),
646 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800647 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 },
649#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650#ifdef CONFIG_MAGIC_SYSRQ
651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800653 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .maxlen = sizeof (int),
655 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700656 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 },
658#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700659#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700662 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .maxlen = sizeof (int),
664 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700667#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "threads-max",
670 .data = &max_threads,
671 .maxlen = sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "random",
677 .mode = 0555,
678 .child = random_table,
679 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 {
Eric Paris17f60a72011-04-01 17:07:50 -0400681 .procname = "usermodehelper",
682 .mode = 0555,
683 .child = usermodehelper_table,
684 },
685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "overflowuid",
687 .data = &overflowuid,
688 .maxlen = sizeof(int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 .extra1 = &minolduid,
692 .extra2 = &maxolduid,
693 },
694 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .procname = "overflowgid",
696 .data = &overflowgid,
697 .maxlen = sizeof(int),
698 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800699 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .extra1 = &minolduid,
701 .extra2 = &maxolduid,
702 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800703#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704#ifdef CONFIG_MATHEMU
705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .procname = "ieee_emulation_warnings",
707 .data = &sysctl_ieee_emulation_warnings,
708 .maxlen = sizeof(int),
709 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800710 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 },
712#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200715 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .maxlen = sizeof(int),
717 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800718 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 },
720#endif
721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .procname = "pid_max",
723 .data = &pid_max,
724 .maxlen = sizeof (int),
725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800726 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .extra1 = &pid_max_min,
728 .extra2 = &pid_max_max,
729 },
730 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 .procname = "panic_on_oops",
732 .data = &panic_on_oops,
733 .maxlen = sizeof(int),
734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800737#if defined CONFIG_PRINTK
738 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800739 .procname = "printk",
740 .data = &console_loglevel,
741 .maxlen = 4*sizeof(int),
742 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800743 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800744 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700747 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .maxlen = sizeof(int),
749 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 },
752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700754 .data = &printk_ratelimit_state.burst,
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,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
Dave Youngaf913222009-09-22 16:43:33 -0700759 {
Dave Youngaf913222009-09-22 16:43:33 -0700760 .procname = "printk_delay",
761 .data = &printk_delay_msec,
762 .maxlen = sizeof(int),
763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700765 .extra1 = &zero,
766 .extra2 = &ten_thousand,
767 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800769 .procname = "dmesg_restrict",
770 .data = &dmesg_restrict,
771 .maxlen = sizeof(int),
772 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700773 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800774 .extra1 = &zero,
775 .extra2 = &one,
776 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800777 {
778 .procname = "kptr_restrict",
779 .data = &kptr_restrict,
780 .maxlen = sizeof(int),
781 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700782 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800783 .extra1 = &zero,
784 .extra2 = &two,
785 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800786#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800787 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 .procname = "ngroups_max",
789 .data = &ngroups_max,
790 .maxlen = sizeof (int),
791 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 },
Dan Ballard73efc032011-10-31 17:11:20 -0700794 {
795 .procname = "cap_last_cap",
796 .data = (void *)&cap_last_cap,
797 .maxlen = sizeof(int),
798 .mode = 0444,
799 .proc_handler = proc_dointvec,
800 },
Don Zickus58687ac2010-05-07 17:11:44 -0400801#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500802 {
Don Zickus58687ac2010-05-07 17:11:44 -0400803 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200804 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500805 .maxlen = sizeof (int),
806 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700807 .proc_handler = proc_dowatchdog,
808 .extra1 = &zero,
809 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400810 },
811 {
812 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700813 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400814 .maxlen = sizeof(int),
815 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700816 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400817 .extra1 = &neg_one,
818 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500819 },
Don Zickus2508ce12010-05-07 17:11:46 -0400820 {
821 .procname = "softlockup_panic",
822 .data = &softlockup_panic,
823 .maxlen = sizeof(int),
824 .mode = 0644,
825 .proc_handler = proc_dointvec_minmax,
826 .extra1 = &zero,
827 .extra2 = &one,
828 },
Don Zickus5dc30552010-11-29 17:07:17 -0500829 {
830 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200831 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500832 .maxlen = sizeof (int),
833 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700834 .proc_handler = proc_dowatchdog,
835 .extra1 = &zero,
836 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500837 },
838#endif
839#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
840 {
841 .procname = "unknown_nmi_panic",
842 .data = &unknown_nmi_panic,
843 .maxlen = sizeof (int),
844 .mode = 0644,
845 .proc_handler = proc_dointvec,
846 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500847#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848#if defined(CONFIG_X86)
849 {
Don Zickus8da5adda2006-09-26 10:52:27 +0200850 .procname = "panic_on_unrecovered_nmi",
851 .data = &panic_on_unrecovered_nmi,
852 .maxlen = sizeof(int),
853 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800854 .proc_handler = proc_dointvec,
Don Zickus8da5adda2006-09-26 10:52:27 +0200855 },
856 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700857 .procname = "panic_on_io_nmi",
858 .data = &panic_on_io_nmi,
859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700862 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900863#ifdef CONFIG_DEBUG_STACKOVERFLOW
864 {
865 .procname = "panic_on_stackoverflow",
866 .data = &sysctl_panic_on_stackoverflow,
867 .maxlen = sizeof(int),
868 .mode = 0644,
869 .proc_handler = proc_dointvec,
870 },
871#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700872 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 .procname = "bootloader_type",
874 .data = &bootloader_type,
875 .maxlen = sizeof (int),
876 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800877 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100879 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700880 .procname = "bootloader_version",
881 .data = &bootloader_version,
882 .maxlen = sizeof (int),
883 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800884 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700885 },
886 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100887 .procname = "kstack_depth_to_print",
888 .data = &kstack_depth_to_print,
889 .maxlen = sizeof(int),
890 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800891 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100892 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100893 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100894 .procname = "io_delay_type",
895 .data = &io_delay_type,
896 .maxlen = sizeof(int),
897 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800898 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100899 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800901#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 .procname = "randomize_va_space",
904 .data = &randomize_va_space,
905 .maxlen = sizeof(int),
906 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800907 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800909#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800910#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700911 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700912 .procname = "spin_retry",
913 .data = &spin_retry,
914 .maxlen = sizeof (int),
915 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800916 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700917 },
918#endif
Len Brown673d5b42007-07-28 03:33:16 -0400919#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800920 {
Pavel Machekc255d842006-02-20 18:27:58 -0800921 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700922 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800923 .maxlen = sizeof (unsigned long),
924 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800925 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800926 },
927#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530928#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800929 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800930 .procname = "ignore-unaligned-usertrap",
931 .data = &no_unaligned_warning,
932 .maxlen = sizeof (int),
933 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800934 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800935 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530936#endif
937#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800938 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800939 .procname = "unaligned-dump-stack",
940 .data = &unaligned_dump_stack,
941 .maxlen = sizeof (int),
942 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800943 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800944 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800945#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800946#ifdef CONFIG_DETECT_HUNG_TASK
947 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800948 .procname = "hung_task_panic",
949 .data = &sysctl_hung_task_panic,
950 .maxlen = sizeof(int),
951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800952 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800953 .extra1 = &zero,
954 .extra2 = &one,
955 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100956 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100957 .procname = "hung_task_check_count",
958 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100959 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100962 },
963 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100964 .procname = "hung_task_timeout_secs",
965 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100966 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100967 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800968 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100969 },
970 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100971 .procname = "hung_task_warnings",
972 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100973 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100974 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800975 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100976 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700977#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200978#ifdef CONFIG_COMPAT
979 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200980 .procname = "compat-log",
981 .data = &compat_log,
982 .maxlen = sizeof (int),
983 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200985 },
986#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700987#ifdef CONFIG_RT_MUTEXES
988 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700989 .procname = "max_lock_depth",
990 .data = &max_lock_depth,
991 .maxlen = sizeof(int),
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700994 },
995#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700996 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700997 .procname = "poweroff_cmd",
998 .data = &poweroff_cmd,
999 .maxlen = POWEROFF_CMD_PATH_LEN,
1000 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001001 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001002 },
David Howells0b77f5b2008-04-29 01:01:32 -07001003#ifdef CONFIG_KEYS
1004 {
David Howells0b77f5b2008-04-29 01:01:32 -07001005 .procname = "keys",
1006 .mode = 0555,
1007 .child = key_sysctls,
1008 },
1009#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001010#ifdef CONFIG_RCU_TORTURE_TEST
1011 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001012 .procname = "rcutorture_runnable",
1013 .data = &rcutorture_runnable,
1014 .maxlen = sizeof(int),
1015 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001016 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001017 },
1018#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001019#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001020 /*
1021 * User-space scripts rely on the existence of this file
1022 * as a feature check for perf_events being enabled.
1023 *
1024 * So it's an ABI, do not remove!
1025 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001026 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001027 .procname = "perf_event_paranoid",
1028 .data = &sysctl_perf_event_paranoid,
1029 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001032 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001033 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001034 .procname = "perf_event_mlock_kb",
1035 .data = &sysctl_perf_event_mlock,
1036 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001037 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001039 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001040 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001041 .procname = "perf_event_max_sample_rate",
1042 .data = &sysctl_perf_event_sample_rate,
1043 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001044 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001045 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001046 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001047#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001048#ifdef CONFIG_KMEMCHECK
1049 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001050 .procname = "kmemcheck",
1051 .data = &kmemcheck_enabled,
1052 .maxlen = sizeof(int),
1053 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001054 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001055 },
1056#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001057#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001058 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001059 .procname = "blk_iopoll",
1060 .data = &blk_iopoll_enabled,
1061 .maxlen = sizeof(int),
1062 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001063 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001064 },
Jens Axboecb684b52009-09-15 21:53:11 +02001065#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001066 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067};
1068
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001069static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 .procname = "overcommit_memory",
1072 .data = &sysctl_overcommit_memory,
1073 .maxlen = sizeof(sysctl_overcommit_memory),
1074 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001075 .proc_handler = proc_dointvec_minmax,
1076 .extra1 = &zero,
1077 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 },
1079 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001080 .procname = "panic_on_oom",
1081 .data = &sysctl_panic_on_oom,
1082 .maxlen = sizeof(sysctl_panic_on_oom),
1083 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001084 .proc_handler = proc_dointvec_minmax,
1085 .extra1 = &zero,
1086 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001087 },
1088 {
David Rientjesfe071d72007-10-16 23:25:56 -07001089 .procname = "oom_kill_allocating_task",
1090 .data = &sysctl_oom_kill_allocating_task,
1091 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1092 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001093 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001094 },
1095 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001096 .procname = "oom_dump_tasks",
1097 .data = &sysctl_oom_dump_tasks,
1098 .maxlen = sizeof(sysctl_oom_dump_tasks),
1099 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001100 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001101 },
1102 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 .procname = "overcommit_ratio",
1104 .data = &sysctl_overcommit_ratio,
1105 .maxlen = sizeof(sysctl_overcommit_ratio),
1106 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001107 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 },
1109 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .procname = "page-cluster",
1111 .data = &page_cluster,
1112 .maxlen = sizeof(int),
1113 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001114 .proc_handler = proc_dointvec_minmax,
1115 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 },
1117 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 .procname = "dirty_background_ratio",
1119 .data = &dirty_background_ratio,
1120 .maxlen = sizeof(dirty_background_ratio),
1121 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001122 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 .extra1 = &zero,
1124 .extra2 = &one_hundred,
1125 },
1126 {
David Rientjes2da02992009-01-06 14:39:31 -08001127 .procname = "dirty_background_bytes",
1128 .data = &dirty_background_bytes,
1129 .maxlen = sizeof(dirty_background_bytes),
1130 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001131 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001132 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001133 },
1134 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 .procname = "dirty_ratio",
1136 .data = &vm_dirty_ratio,
1137 .maxlen = sizeof(vm_dirty_ratio),
1138 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001139 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .extra1 = &zero,
1141 .extra2 = &one_hundred,
1142 },
1143 {
David Rientjes2da02992009-01-06 14:39:31 -08001144 .procname = "dirty_bytes",
1145 .data = &vm_dirty_bytes,
1146 .maxlen = sizeof(vm_dirty_bytes),
1147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001148 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001149 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001150 },
1151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001153 .data = &dirty_writeback_interval,
1154 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 },
1158 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001160 .data = &dirty_expire_interval,
1161 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001163 .proc_handler = proc_dointvec_minmax,
1164 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 },
1166 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001167 .procname = "nr_pdflush_threads",
1168 .mode = 0444 /* read-only */,
1169 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 },
1171 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .procname = "swappiness",
1173 .data = &vm_swappiness,
1174 .maxlen = sizeof(vm_swappiness),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 .extra1 = &zero,
1178 .extra2 = &one_hundred,
1179 },
1180#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001181 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001183 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 .maxlen = sizeof(unsigned long),
1185 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001186 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 .extra1 = (void *)&hugetlb_zero,
1188 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001189 },
1190#ifdef CONFIG_NUMA
1191 {
1192 .procname = "nr_hugepages_mempolicy",
1193 .data = NULL,
1194 .maxlen = sizeof(unsigned long),
1195 .mode = 0644,
1196 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1197 .extra1 = (void *)&hugetlb_zero,
1198 .extra2 = (void *)&hugetlb_infinity,
1199 },
1200#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 .procname = "hugetlb_shm_group",
1203 .data = &sysctl_hugetlb_shm_group,
1204 .maxlen = sizeof(gid_t),
1205 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001206 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 },
Mel Gorman396faf02007-07-17 04:03:13 -07001208 {
Mel Gorman396faf02007-07-17 04:03:13 -07001209 .procname = "hugepages_treat_as_movable",
1210 .data = &hugepages_treat_as_movable,
1211 .maxlen = sizeof(int),
1212 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001213 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001214 },
Adam Litke54f9f802007-10-16 01:26:20 -07001215 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001216 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001217 .data = NULL,
1218 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001219 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001220 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001221 .extra1 = (void *)&hugetlb_zero,
1222 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001223 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224#endif
1225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 .procname = "lowmem_reserve_ratio",
1227 .data = &sysctl_lowmem_reserve_ratio,
1228 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1229 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001230 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 },
1232 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001233 .procname = "drop_caches",
1234 .data = &sysctl_drop_caches,
1235 .maxlen = sizeof(int),
1236 .mode = 0644,
1237 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001238 .extra1 = &one,
1239 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001240 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001241#ifdef CONFIG_COMPACTION
1242 {
1243 .procname = "compact_memory",
1244 .data = &sysctl_compact_memory,
1245 .maxlen = sizeof(int),
1246 .mode = 0200,
1247 .proc_handler = sysctl_compaction_handler,
1248 },
Mel Gorman5e771902010-05-24 14:32:31 -07001249 {
1250 .procname = "extfrag_threshold",
1251 .data = &sysctl_extfrag_threshold,
1252 .maxlen = sizeof(int),
1253 .mode = 0644,
1254 .proc_handler = sysctl_extfrag_handler,
1255 .extra1 = &min_extfrag_threshold,
1256 .extra2 = &max_extfrag_threshold,
1257 },
1258
Mel Gorman76ab0f52010-05-24 14:32:28 -07001259#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001260 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261 .procname = "min_free_kbytes",
1262 .data = &min_free_kbytes,
1263 .maxlen = sizeof(min_free_kbytes),
1264 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001265 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266 .extra1 = &zero,
1267 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001268 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001269 .procname = "percpu_pagelist_fraction",
1270 .data = &percpu_pagelist_fraction,
1271 .maxlen = sizeof(percpu_pagelist_fraction),
1272 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001273 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001274 .extra1 = &min_percpu_pagelist_fract,
1275 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276#ifdef CONFIG_MMU
1277 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 .procname = "max_map_count",
1279 .data = &sysctl_max_map_count,
1280 .maxlen = sizeof(sysctl_max_map_count),
1281 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001282 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001283 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001285#else
1286 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001287 .procname = "nr_trim_pages",
1288 .data = &sysctl_nr_trim_pages,
1289 .maxlen = sizeof(sysctl_nr_trim_pages),
1290 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001291 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001292 .extra1 = &zero,
1293 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294#endif
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "laptop_mode",
1297 .data = &laptop_mode,
1298 .maxlen = sizeof(laptop_mode),
1299 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001300 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 },
1302 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 .procname = "block_dump",
1304 .data = &block_dump,
1305 .maxlen = sizeof(block_dump),
1306 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 .extra1 = &zero,
1309 },
1310 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 .procname = "vfs_cache_pressure",
1312 .data = &sysctl_vfs_cache_pressure,
1313 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1314 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 .extra1 = &zero,
1317 },
1318#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "legacy_va_layout",
1321 .data = &sysctl_legacy_va_layout,
1322 .maxlen = sizeof(sysctl_legacy_va_layout),
1323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .extra1 = &zero,
1326 },
1327#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001328#ifdef CONFIG_NUMA
1329 {
Christoph Lameter17436602006-01-18 17:42:32 -08001330 .procname = "zone_reclaim_mode",
1331 .data = &zone_reclaim_mode,
1332 .maxlen = sizeof(zone_reclaim_mode),
1333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001335 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001336 },
Christoph Lameter96146342006-07-03 00:24:13 -07001337 {
Christoph Lameter96146342006-07-03 00:24:13 -07001338 .procname = "min_unmapped_ratio",
1339 .data = &sysctl_min_unmapped_ratio,
1340 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001343 .extra1 = &zero,
1344 .extra2 = &one_hundred,
1345 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001346 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001347 .procname = "min_slab_ratio",
1348 .data = &sysctl_min_slab_ratio,
1349 .maxlen = sizeof(sysctl_min_slab_ratio),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001352 .extra1 = &zero,
1353 .extra2 = &one_hundred,
1354 },
Christoph Lameter17436602006-01-18 17:42:32 -08001355#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001356#ifdef CONFIG_SMP
1357 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001358 .procname = "stat_interval",
1359 .data = &sysctl_stat_interval,
1360 .maxlen = sizeof(sysctl_stat_interval),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001363 },
1364#endif
David Howells6e141542009-12-15 19:27:45 +00001365#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001366 {
Eric Parised032182007-06-28 15:55:21 -04001367 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001368 .data = &dac_mmap_min_addr,
1369 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001372 },
David Howells6e141542009-12-15 19:27:45 +00001373#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001374#ifdef CONFIG_NUMA
1375 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001376 .procname = "numa_zonelist_order",
1377 .data = &numa_zonelist_order,
1378 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1379 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001380 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001381 },
1382#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001383#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001384 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001385 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001386 .procname = "vdso_enabled",
1387 .data = &vdso_enabled,
1388 .maxlen = sizeof(vdso_enabled),
1389 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001390 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001391 .extra1 = &zero,
1392 },
1393#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001394#ifdef CONFIG_HIGHMEM
1395 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001396 .procname = "highmem_is_dirtyable",
1397 .data = &vm_highmem_is_dirtyable,
1398 .maxlen = sizeof(vm_highmem_is_dirtyable),
1399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001400 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001401 .extra1 = &zero,
1402 .extra2 = &one,
1403 },
1404#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001405 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001406 .procname = "scan_unevictable_pages",
1407 .data = &scan_unevictable_pages,
1408 .maxlen = sizeof(scan_unevictable_pages),
1409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001410 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001411 },
Andi Kleen6a460792009-09-16 11:50:15 +02001412#ifdef CONFIG_MEMORY_FAILURE
1413 {
Andi Kleen6a460792009-09-16 11:50:15 +02001414 .procname = "memory_failure_early_kill",
1415 .data = &sysctl_memory_failure_early_kill,
1416 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001419 .extra1 = &zero,
1420 .extra2 = &one,
1421 },
1422 {
Andi Kleen6a460792009-09-16 11:50:15 +02001423 .procname = "memory_failure_recovery",
1424 .data = &sysctl_memory_failure_recovery,
1425 .maxlen = sizeof(sysctl_memory_failure_recovery),
1426 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001427 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001428 .extra1 = &zero,
1429 .extra2 = &one,
1430 },
1431#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001432 {
1433 .procname = "user_reserve_kbytes",
1434 .data = &sysctl_user_reserve_kbytes,
1435 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1436 .mode = 0644,
1437 .proc_handler = proc_doulongvec_minmax,
1438 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001439 {
1440 .procname = "admin_reserve_kbytes",
1441 .data = &sysctl_admin_reserve_kbytes,
1442 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1443 .mode = 0644,
1444 .proc_handler = proc_doulongvec_minmax,
1445 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001446 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447};
1448
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001449#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001450static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001451 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001452};
1453#endif
1454
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001455static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 .procname = "inode-nr",
1458 .data = &inodes_stat,
1459 .maxlen = 2*sizeof(int),
1460 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001461 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "inode-state",
1465 .data = &inodes_stat,
1466 .maxlen = 7*sizeof(int),
1467 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001468 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 },
1470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 .procname = "file-nr",
1472 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001473 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001475 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 },
1477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "file-max",
1479 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001480 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001482 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 },
1484 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001485 .procname = "nr_open",
1486 .data = &sysctl_nr_open,
1487 .maxlen = sizeof(int),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001490 .extra1 = &sysctl_nr_open_min,
1491 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001492 },
1493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .procname = "dentry-state",
1495 .data = &dentry_stat,
1496 .maxlen = 6*sizeof(int),
1497 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001498 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 },
1500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .procname = "overflowuid",
1502 .data = &fs_overflowuid,
1503 .maxlen = sizeof(int),
1504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001505 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .extra1 = &minolduid,
1507 .extra2 = &maxolduid,
1508 },
1509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 .procname = "overflowgid",
1511 .data = &fs_overflowgid,
1512 .maxlen = sizeof(int),
1513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001514 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 .extra1 = &minolduid,
1516 .extra2 = &maxolduid,
1517 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001518#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 .procname = "leases-enable",
1521 .data = &leases_enable,
1522 .maxlen = sizeof(int),
1523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001524 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001526#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527#ifdef CONFIG_DNOTIFY
1528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 .procname = "dir-notify-enable",
1530 .data = &dir_notify_enable,
1531 .maxlen = sizeof(int),
1532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 },
1535#endif
1536#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001537#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 .procname = "lease-break-time",
1540 .data = &lease_break_time,
1541 .maxlen = sizeof(int),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001545#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001546#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 .procname = "aio-nr",
1549 .data = &aio_nr,
1550 .maxlen = sizeof(aio_nr),
1551 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 },
1554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 .procname = "aio-max-nr",
1556 .data = &aio_max_nr,
1557 .maxlen = sizeof(aio_max_nr),
1558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001559 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001561#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001562#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001563 {
Robert Love0399cb02005-07-13 12:38:18 -04001564 .procname = "inotify",
1565 .mode = 0555,
1566 .child = inotify_table,
1567 },
1568#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001569#ifdef CONFIG_EPOLL
1570 {
1571 .procname = "epoll",
1572 .mode = 0555,
1573 .child = epoll_table,
1574 },
1575#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001577 {
Kees Cook800179c2012-07-25 17:29:07 -07001578 .procname = "protected_symlinks",
1579 .data = &sysctl_protected_symlinks,
1580 .maxlen = sizeof(int),
1581 .mode = 0600,
1582 .proc_handler = proc_dointvec_minmax,
1583 .extra1 = &zero,
1584 .extra2 = &one,
1585 },
1586 {
1587 .procname = "protected_hardlinks",
1588 .data = &sysctl_protected_hardlinks,
1589 .maxlen = sizeof(int),
1590 .mode = 0600,
1591 .proc_handler = proc_dointvec_minmax,
1592 .extra1 = &zero,
1593 .extra2 = &one,
1594 },
1595 {
Alan Coxd6e71142005-06-23 00:09:43 -07001596 .procname = "suid_dumpable",
1597 .data = &suid_dumpable,
1598 .maxlen = sizeof(int),
1599 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001600 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001601 .extra1 = &zero,
1602 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001603 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001604#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1605 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001606 .procname = "binfmt_misc",
1607 .mode = 0555,
1608 .child = binfmt_misc_table,
1609 },
1610#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001611 {
Jens Axboeff9da692010-06-03 14:54:39 +02001612 .procname = "pipe-max-size",
1613 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001614 .maxlen = sizeof(int),
1615 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001616 .proc_handler = &pipe_proc_fn,
1617 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001618 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001619 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620};
1621
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001622static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001623#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001624 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001625 .procname = "exception-trace",
1626 .data = &show_unhandled_signals,
1627 .maxlen = sizeof(int),
1628 .mode = 0644,
1629 .proc_handler = proc_dointvec
1630 },
1631#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001632#if defined(CONFIG_OPTPROBES)
1633 {
1634 .procname = "kprobes-optimization",
1635 .data = &sysctl_kprobes_optimization,
1636 .maxlen = sizeof(int),
1637 .mode = 0644,
1638 .proc_handler = proc_kprobes_optimization_handler,
1639 .extra1 = &zero,
1640 .extra2 = &one,
1641 },
1642#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001643 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644};
1645
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001646static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001647 { }
Robert Love0eeca282005-07-12 17:06:03 -04001648};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001650int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001651{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001652 struct ctl_table_header *hdr;
1653
1654 hdr = register_sysctl_table(sysctl_base_table);
1655 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001656 return 0;
1657}
1658
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001659#endif /* CONFIG_SYSCTL */
1660
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661/*
1662 * /proc/sys support
1663 */
1664
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001665#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001667static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001668 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001669 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001670{
1671 size_t len;
1672 char __user *p;
1673 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001674
1675 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001676 *lenp = 0;
1677 return 0;
1678 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001679
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001680 if (write) {
1681 len = 0;
1682 p = buffer;
1683 while (len < *lenp) {
1684 if (get_user(c, p++))
1685 return -EFAULT;
1686 if (c == 0 || c == '\n')
1687 break;
1688 len++;
1689 }
1690 if (len >= maxlen)
1691 len = maxlen-1;
1692 if(copy_from_user(data, buffer, len))
1693 return -EFAULT;
1694 ((char *) data)[len] = 0;
1695 *ppos += *lenp;
1696 } else {
1697 len = strlen(data);
1698 if (len > maxlen)
1699 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001700
1701 if (*ppos > len) {
1702 *lenp = 0;
1703 return 0;
1704 }
1705
1706 data += *ppos;
1707 len -= *ppos;
1708
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001709 if (len > *lenp)
1710 len = *lenp;
1711 if (len)
1712 if(copy_to_user(buffer, data, len))
1713 return -EFAULT;
1714 if (len < *lenp) {
1715 if(put_user('\n', ((char __user *) buffer) + len))
1716 return -EFAULT;
1717 len++;
1718 }
1719 *lenp = len;
1720 *ppos += len;
1721 }
1722 return 0;
1723}
1724
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725/**
1726 * proc_dostring - read a string sysctl
1727 * @table: the sysctl table
1728 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 * @buffer: the user buffer
1730 * @lenp: the size of the user buffer
1731 * @ppos: file position
1732 *
1733 * Reads/writes a string from/to the user buffer. If the kernel
1734 * buffer provided is not large enough to hold the string, the
1735 * string is truncated. The copied string is %NULL-terminated.
1736 * If the string is being read by the user process, it is copied
1737 * and a newline '\n' is added. It is truncated if the buffer is
1738 * not large enough.
1739 *
1740 * Returns 0 on success.
1741 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001742int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 void __user *buffer, size_t *lenp, loff_t *ppos)
1744{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001745 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001746 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747}
1748
Amerigo Wang00b7c332010-05-05 00:26:45 +00001749static size_t proc_skip_spaces(char **buf)
1750{
1751 size_t ret;
1752 char *tmp = skip_spaces(*buf);
1753 ret = tmp - *buf;
1754 *buf = tmp;
1755 return ret;
1756}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001758static void proc_skip_char(char **buf, size_t *size, const char v)
1759{
1760 while (*size) {
1761 if (**buf != v)
1762 break;
1763 (*size)--;
1764 (*buf)++;
1765 }
1766}
1767
Amerigo Wang00b7c332010-05-05 00:26:45 +00001768#define TMPBUFLEN 22
1769/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001770 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001771 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001772 * @buf: a kernel buffer
1773 * @size: size of the kernel buffer
1774 * @val: this is where the number will be stored
1775 * @neg: set to %TRUE if number is negative
1776 * @perm_tr: a vector which contains the allowed trailers
1777 * @perm_tr_len: size of the perm_tr vector
1778 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001779 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001780 * In case of success %0 is returned and @buf and @size are updated with
1781 * the amount of bytes read. If @tr is non-NULL and a trailing
1782 * character exists (size is non-zero after returning from this
1783 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001784 */
1785static int proc_get_long(char **buf, size_t *size,
1786 unsigned long *val, bool *neg,
1787 const char *perm_tr, unsigned perm_tr_len, char *tr)
1788{
1789 int len;
1790 char *p, tmp[TMPBUFLEN];
1791
1792 if (!*size)
1793 return -EINVAL;
1794
1795 len = *size;
1796 if (len > TMPBUFLEN - 1)
1797 len = TMPBUFLEN - 1;
1798
1799 memcpy(tmp, *buf, len);
1800
1801 tmp[len] = 0;
1802 p = tmp;
1803 if (*p == '-' && *size > 1) {
1804 *neg = true;
1805 p++;
1806 } else
1807 *neg = false;
1808 if (!isdigit(*p))
1809 return -EINVAL;
1810
1811 *val = simple_strtoul(p, &p, 0);
1812
1813 len = p - tmp;
1814
1815 /* We don't know if the next char is whitespace thus we may accept
1816 * invalid integers (e.g. 1234...a) or two integers instead of one
1817 * (e.g. 123...1). So lets not allow such large numbers. */
1818 if (len == TMPBUFLEN - 1)
1819 return -EINVAL;
1820
1821 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1822 return -EINVAL;
1823
1824 if (tr && (len < *size))
1825 *tr = *p;
1826
1827 *buf += len;
1828 *size -= len;
1829
1830 return 0;
1831}
1832
1833/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001834 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001835 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001836 * @buf: the user buffer
1837 * @size: the size of the user buffer
1838 * @val: the integer to be converted
1839 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001840 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001841 * In case of success %0 is returned and @buf and @size are updated with
1842 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001843 */
1844static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1845 bool neg)
1846{
1847 int len;
1848 char tmp[TMPBUFLEN], *p = tmp;
1849
1850 sprintf(p, "%s%lu", neg ? "-" : "", val);
1851 len = strlen(tmp);
1852 if (len > *size)
1853 len = *size;
1854 if (copy_to_user(*buf, tmp, len))
1855 return -EFAULT;
1856 *size -= len;
1857 *buf += len;
1858 return 0;
1859}
1860#undef TMPBUFLEN
1861
1862static int proc_put_char(void __user **buf, size_t *size, char c)
1863{
1864 if (*size) {
1865 char __user **buffer = (char __user **)buf;
1866 if (put_user(c, *buffer))
1867 return -EFAULT;
1868 (*size)--, (*buffer)++;
1869 *buf = *buffer;
1870 }
1871 return 0;
1872}
1873
1874static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875 int *valp,
1876 int write, void *data)
1877{
1878 if (write) {
1879 *valp = *negp ? -*lvalp : *lvalp;
1880 } else {
1881 int val = *valp;
1882 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001883 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884 *lvalp = (unsigned long)-val;
1885 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001886 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887 *lvalp = (unsigned long)val;
1888 }
1889 }
1890 return 0;
1891}
1892
Amerigo Wang00b7c332010-05-05 00:26:45 +00001893static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1894
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001895static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001896 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001897 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001898 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 int write, void *data),
1900 void *data)
1901{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001902 int *i, vleft, first = 1, err = 0;
1903 unsigned long page = 0;
1904 size_t left;
1905 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906
Amerigo Wang00b7c332010-05-05 00:26:45 +00001907 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908 *lenp = 0;
1909 return 0;
1910 }
1911
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001912 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 vleft = table->maxlen / sizeof(*i);
1914 left = *lenp;
1915
1916 if (!conv)
1917 conv = do_proc_dointvec_conv;
1918
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001920 if (left > PAGE_SIZE - 1)
1921 left = PAGE_SIZE - 1;
1922 page = __get_free_page(GFP_TEMPORARY);
1923 kbuf = (char *) page;
1924 if (!kbuf)
1925 return -ENOMEM;
1926 if (copy_from_user(kbuf, buffer, left)) {
1927 err = -EFAULT;
1928 goto free;
1929 }
1930 kbuf[left] = 0;
1931 }
1932
1933 for (; left && vleft--; i++, first=0) {
1934 unsigned long lval;
1935 bool neg;
1936
1937 if (write) {
1938 left -= proc_skip_spaces(&kbuf);
1939
J. R. Okajima563b0462010-05-25 16:10:14 -07001940 if (!left)
1941 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001942 err = proc_get_long(&kbuf, &left, &lval, &neg,
1943 proc_wspace_sep,
1944 sizeof(proc_wspace_sep), NULL);
1945 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001946 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001947 if (conv(&neg, &lval, i, 1, data)) {
1948 err = -EINVAL;
1949 break;
1950 }
1951 } else {
1952 if (conv(&neg, &lval, i, 0, data)) {
1953 err = -EINVAL;
1954 break;
1955 }
1956 if (!first)
1957 err = proc_put_char(&buffer, &left, '\t');
1958 if (err)
1959 break;
1960 err = proc_put_long(&buffer, &left, lval, neg);
1961 if (err)
1962 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 }
1964 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001965
1966 if (!write && !first && left && !err)
1967 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001968 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001969 left -= proc_skip_spaces(&kbuf);
1970free:
1971 if (write) {
1972 free_page(page);
1973 if (first)
1974 return err ? : -EINVAL;
1975 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 *lenp -= left;
1977 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001978 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001979}
1980
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001981static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001982 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001983 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001984 int write, void *data),
1985 void *data)
1986{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001987 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001988 buffer, lenp, ppos, conv, data);
1989}
1990
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991/**
1992 * proc_dointvec - read a vector of integers
1993 * @table: the sysctl table
1994 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995 * @buffer: the user buffer
1996 * @lenp: the size of the user buffer
1997 * @ppos: file position
1998 *
1999 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2000 * values from/to the user buffer, treated as an ASCII string.
2001 *
2002 * Returns 0 on success.
2003 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002004int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005 void __user *buffer, size_t *lenp, loff_t *ppos)
2006{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002007 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002008 NULL,NULL);
2009}
2010
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002011/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002012 * Taint values can only be increased
2013 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002014 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002015static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002016 void __user *buffer, size_t *lenp, loff_t *ppos)
2017{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002018 struct ctl_table t;
2019 unsigned long tmptaint = get_taint();
2020 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002021
Bastian Blank91fcd412007-04-23 14:41:14 -07002022 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002023 return -EPERM;
2024
Andi Kleen25ddbb12008-10-15 22:01:41 -07002025 t = *table;
2026 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002027 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002028 if (err < 0)
2029 return err;
2030
2031 if (write) {
2032 /*
2033 * Poor man's atomic or. Not worth adding a primitive
2034 * to everyone's atomic.h for this
2035 */
2036 int i;
2037 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2038 if ((tmptaint >> i) & 1)
Rusty Russell373d4d092013-01-21 17:17:39 +10302039 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002040 }
2041 }
2042
2043 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002044}
2045
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002046#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002047static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002048 void __user *buffer, size_t *lenp, loff_t *ppos)
2049{
2050 if (write && !capable(CAP_SYS_ADMIN))
2051 return -EPERM;
2052
2053 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2054}
2055#endif
2056
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057struct do_proc_dointvec_minmax_conv_param {
2058 int *min;
2059 int *max;
2060};
2061
Amerigo Wang00b7c332010-05-05 00:26:45 +00002062static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2063 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064 int write, void *data)
2065{
2066 struct do_proc_dointvec_minmax_conv_param *param = data;
2067 if (write) {
2068 int val = *negp ? -*lvalp : *lvalp;
2069 if ((param->min && *param->min > val) ||
2070 (param->max && *param->max < val))
2071 return -EINVAL;
2072 *valp = val;
2073 } else {
2074 int val = *valp;
2075 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002076 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077 *lvalp = (unsigned long)-val;
2078 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002079 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080 *lvalp = (unsigned long)val;
2081 }
2082 }
2083 return 0;
2084}
2085
2086/**
2087 * proc_dointvec_minmax - read a vector of integers with min/max values
2088 * @table: the sysctl table
2089 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090 * @buffer: the user buffer
2091 * @lenp: the size of the user buffer
2092 * @ppos: file position
2093 *
2094 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2095 * values from/to the user buffer, treated as an ASCII string.
2096 *
2097 * This routine will ensure the values are within the range specified by
2098 * table->extra1 (min) and table->extra2 (max).
2099 *
2100 * Returns 0 on success.
2101 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002102int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 void __user *buffer, size_t *lenp, loff_t *ppos)
2104{
2105 struct do_proc_dointvec_minmax_conv_param param = {
2106 .min = (int *) table->extra1,
2107 .max = (int *) table->extra2,
2108 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002109 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110 do_proc_dointvec_minmax_conv, &param);
2111}
2112
Kees Cook54b50192012-07-30 14:39:18 -07002113static void validate_coredump_safety(void)
2114{
Alex Kelly046d6622012-10-04 17:15:23 -07002115#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002116 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002117 core_pattern[0] != '/' && core_pattern[0] != '|') {
2118 printk(KERN_WARNING "Unsafe core_pattern used with "\
2119 "suid_dumpable=2. Pipe handler or fully qualified "\
2120 "core dump path required.\n");
2121 }
Alex Kelly046d6622012-10-04 17:15:23 -07002122#endif
Kees Cook54b50192012-07-30 14:39:18 -07002123}
2124
2125static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2126 void __user *buffer, size_t *lenp, loff_t *ppos)
2127{
2128 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2129 if (!error)
2130 validate_coredump_safety();
2131 return error;
2132}
2133
Alex Kelly046d6622012-10-04 17:15:23 -07002134#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002135static int proc_dostring_coredump(struct ctl_table *table, int write,
2136 void __user *buffer, size_t *lenp, loff_t *ppos)
2137{
2138 int error = proc_dostring(table, write, buffer, lenp, ppos);
2139 if (!error)
2140 validate_coredump_safety();
2141 return error;
2142}
Alex Kelly046d6622012-10-04 17:15:23 -07002143#endif
Kees Cook54b50192012-07-30 14:39:18 -07002144
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002145static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146 void __user *buffer,
2147 size_t *lenp, loff_t *ppos,
2148 unsigned long convmul,
2149 unsigned long convdiv)
2150{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002151 unsigned long *i, *min, *max;
2152 int vleft, first = 1, err = 0;
2153 unsigned long page = 0;
2154 size_t left;
2155 char *kbuf;
2156
2157 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 *lenp = 0;
2159 return 0;
2160 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002161
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002162 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163 min = (unsigned long *) table->extra1;
2164 max = (unsigned long *) table->extra2;
2165 vleft = table->maxlen / sizeof(unsigned long);
2166 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002167
2168 if (write) {
2169 if (left > PAGE_SIZE - 1)
2170 left = PAGE_SIZE - 1;
2171 page = __get_free_page(GFP_TEMPORARY);
2172 kbuf = (char *) page;
2173 if (!kbuf)
2174 return -ENOMEM;
2175 if (copy_from_user(kbuf, buffer, left)) {
2176 err = -EFAULT;
2177 goto free;
2178 }
2179 kbuf[left] = 0;
2180 }
2181
Eric Dumazet27b3d802010-10-07 12:59:29 -07002182 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002183 unsigned long val;
2184
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002186 bool neg;
2187
2188 left -= proc_skip_spaces(&kbuf);
2189
2190 err = proc_get_long(&kbuf, &left, &val, &neg,
2191 proc_wspace_sep,
2192 sizeof(proc_wspace_sep), NULL);
2193 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 break;
2195 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 continue;
2197 if ((min && val < *min) || (max && val > *max))
2198 continue;
2199 *i = val;
2200 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002201 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 err = proc_put_char(&buffer, &left, '\t');
2204 err = proc_put_long(&buffer, &left, val, false);
2205 if (err)
2206 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 }
2208 }
2209
Amerigo Wang00b7c332010-05-05 00:26:45 +00002210 if (!write && !first && left && !err)
2211 err = proc_put_char(&buffer, &left, '\n');
2212 if (write && !err)
2213 left -= proc_skip_spaces(&kbuf);
2214free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002216 free_page(page);
2217 if (first)
2218 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220 *lenp -= left;
2221 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002222 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223}
2224
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002225static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002226 void __user *buffer,
2227 size_t *lenp, loff_t *ppos,
2228 unsigned long convmul,
2229 unsigned long convdiv)
2230{
2231 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002232 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002233}
2234
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235/**
2236 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2237 * @table: the sysctl table
2238 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 * @buffer: the user buffer
2240 * @lenp: the size of the user buffer
2241 * @ppos: file position
2242 *
2243 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2244 * values from/to the user buffer, treated as an ASCII string.
2245 *
2246 * This routine will ensure the values are within the range specified by
2247 * table->extra1 (min) and table->extra2 (max).
2248 *
2249 * Returns 0 on success.
2250 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002251int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 void __user *buffer, size_t *lenp, loff_t *ppos)
2253{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002254 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255}
2256
2257/**
2258 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2259 * @table: the sysctl table
2260 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 * @buffer: the user buffer
2262 * @lenp: the size of the user buffer
2263 * @ppos: file position
2264 *
2265 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2266 * values from/to the user buffer, treated as an ASCII string. The values
2267 * are treated as milliseconds, and converted to jiffies when they are stored.
2268 *
2269 * This routine will ensure the values are within the range specified by
2270 * table->extra1 (min) and table->extra2 (max).
2271 *
2272 * Returns 0 on success.
2273 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002274int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 void __user *buffer,
2276 size_t *lenp, loff_t *ppos)
2277{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002278 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 lenp, ppos, HZ, 1000l);
2280}
2281
2282
Amerigo Wang00b7c332010-05-05 00:26:45 +00002283static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 int *valp,
2285 int write, void *data)
2286{
2287 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002288 if (*lvalp > LONG_MAX / HZ)
2289 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2291 } else {
2292 int val = *valp;
2293 unsigned long lval;
2294 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002295 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 lval = (unsigned long)-val;
2297 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002298 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 lval = (unsigned long)val;
2300 }
2301 *lvalp = lval / HZ;
2302 }
2303 return 0;
2304}
2305
Amerigo Wang00b7c332010-05-05 00:26:45 +00002306static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 int *valp,
2308 int write, void *data)
2309{
2310 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002311 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2312 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2314 } else {
2315 int val = *valp;
2316 unsigned long lval;
2317 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002318 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 lval = (unsigned long)-val;
2320 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002321 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 lval = (unsigned long)val;
2323 }
2324 *lvalp = jiffies_to_clock_t(lval);
2325 }
2326 return 0;
2327}
2328
Amerigo Wang00b7c332010-05-05 00:26:45 +00002329static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330 int *valp,
2331 int write, void *data)
2332{
2333 if (write) {
2334 *valp = msecs_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_msecs(lval);
2346 }
2347 return 0;
2348}
2349
2350/**
2351 * proc_dointvec_jiffies - read a vector of integers as seconds
2352 * @table: the sysctl table
2353 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 * @buffer: the user buffer
2355 * @lenp: the size of the user buffer
2356 * @ppos: file position
2357 *
2358 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2359 * values from/to the user buffer, treated as an ASCII string.
2360 * The values read are assumed to be in seconds, and are converted into
2361 * jiffies.
2362 *
2363 * Returns 0 on success.
2364 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002365int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 void __user *buffer, size_t *lenp, loff_t *ppos)
2367{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002368 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 do_proc_dointvec_jiffies_conv,NULL);
2370}
2371
2372/**
2373 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2374 * @table: the sysctl table
2375 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 * @buffer: the user buffer
2377 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002378 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379 *
2380 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2381 * values from/to the user buffer, treated as an ASCII string.
2382 * The values read are assumed to be in 1/USER_HZ seconds, and
2383 * are converted into jiffies.
2384 *
2385 * Returns 0 on success.
2386 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002387int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 void __user *buffer, size_t *lenp, loff_t *ppos)
2389{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002390 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 do_proc_dointvec_userhz_jiffies_conv,NULL);
2392}
2393
2394/**
2395 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2396 * @table: the sysctl table
2397 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 * @buffer: the user buffer
2399 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002400 * @ppos: file position
2401 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 *
2403 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2404 * values from/to the user buffer, treated as an ASCII string.
2405 * The values read are assumed to be in 1/1000 seconds, and
2406 * are converted into jiffies.
2407 *
2408 * Returns 0 on success.
2409 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002410int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 void __user *buffer, size_t *lenp, loff_t *ppos)
2412{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002413 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 do_proc_dointvec_ms_jiffies_conv, NULL);
2415}
2416
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002417static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002418 void __user *buffer, size_t *lenp, loff_t *ppos)
2419{
2420 struct pid *new_pid;
2421 pid_t tmp;
2422 int r;
2423
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002424 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002425
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002426 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002427 lenp, ppos, NULL, NULL);
2428 if (r || !write)
2429 return r;
2430
2431 new_pid = find_get_pid(tmp);
2432 if (!new_pid)
2433 return -ESRCH;
2434
2435 put_pid(xchg(&cad_pid, new_pid));
2436 return 0;
2437}
2438
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002439/**
2440 * proc_do_large_bitmap - read/write from/to a large bitmap
2441 * @table: the sysctl table
2442 * @write: %TRUE if this is a write to the sysctl file
2443 * @buffer: the user buffer
2444 * @lenp: the size of the user buffer
2445 * @ppos: file position
2446 *
2447 * The bitmap is stored at table->data and the bitmap length (in bits)
2448 * in table->maxlen.
2449 *
2450 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2451 * large bitmaps may be represented in a compact manner. Writing into
2452 * the file will clear the bitmap then update it with the given input.
2453 *
2454 * Returns 0 on success.
2455 */
2456int proc_do_large_bitmap(struct ctl_table *table, int write,
2457 void __user *buffer, size_t *lenp, loff_t *ppos)
2458{
2459 int err = 0;
2460 bool first = 1;
2461 size_t left = *lenp;
2462 unsigned long bitmap_len = table->maxlen;
2463 unsigned long *bitmap = (unsigned long *) table->data;
2464 unsigned long *tmp_bitmap = NULL;
2465 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2466
2467 if (!bitmap_len || !left || (*ppos && !write)) {
2468 *lenp = 0;
2469 return 0;
2470 }
2471
2472 if (write) {
2473 unsigned long page = 0;
2474 char *kbuf;
2475
2476 if (left > PAGE_SIZE - 1)
2477 left = PAGE_SIZE - 1;
2478
2479 page = __get_free_page(GFP_TEMPORARY);
2480 kbuf = (char *) page;
2481 if (!kbuf)
2482 return -ENOMEM;
2483 if (copy_from_user(kbuf, buffer, left)) {
2484 free_page(page);
2485 return -EFAULT;
2486 }
2487 kbuf[left] = 0;
2488
2489 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2490 GFP_KERNEL);
2491 if (!tmp_bitmap) {
2492 free_page(page);
2493 return -ENOMEM;
2494 }
2495 proc_skip_char(&kbuf, &left, '\n');
2496 while (!err && left) {
2497 unsigned long val_a, val_b;
2498 bool neg;
2499
2500 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2501 sizeof(tr_a), &c);
2502 if (err)
2503 break;
2504 if (val_a >= bitmap_len || neg) {
2505 err = -EINVAL;
2506 break;
2507 }
2508
2509 val_b = val_a;
2510 if (left) {
2511 kbuf++;
2512 left--;
2513 }
2514
2515 if (c == '-') {
2516 err = proc_get_long(&kbuf, &left, &val_b,
2517 &neg, tr_b, sizeof(tr_b),
2518 &c);
2519 if (err)
2520 break;
2521 if (val_b >= bitmap_len || neg ||
2522 val_a > val_b) {
2523 err = -EINVAL;
2524 break;
2525 }
2526 if (left) {
2527 kbuf++;
2528 left--;
2529 }
2530 }
2531
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002532 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002533 first = 0;
2534 proc_skip_char(&kbuf, &left, '\n');
2535 }
2536 free_page(page);
2537 } else {
2538 unsigned long bit_a, bit_b = 0;
2539
2540 while (left) {
2541 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2542 if (bit_a >= bitmap_len)
2543 break;
2544 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2545 bit_a + 1) - 1;
2546
2547 if (!first) {
2548 err = proc_put_char(&buffer, &left, ',');
2549 if (err)
2550 break;
2551 }
2552 err = proc_put_long(&buffer, &left, bit_a, false);
2553 if (err)
2554 break;
2555 if (bit_a != bit_b) {
2556 err = proc_put_char(&buffer, &left, '-');
2557 if (err)
2558 break;
2559 err = proc_put_long(&buffer, &left, bit_b, false);
2560 if (err)
2561 break;
2562 }
2563
2564 first = 0; bit_b++;
2565 }
2566 if (!err)
2567 err = proc_put_char(&buffer, &left, '\n');
2568 }
2569
2570 if (!err) {
2571 if (write) {
2572 if (*ppos)
2573 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2574 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002575 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002576 }
2577 kfree(tmp_bitmap);
2578 *lenp -= left;
2579 *ppos += *lenp;
2580 return 0;
2581 } else {
2582 kfree(tmp_bitmap);
2583 return err;
2584 }
2585}
2586
Jovi Zhang55610502011-01-12 17:00:45 -08002587#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002589int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 void __user *buffer, size_t *lenp, loff_t *ppos)
2591{
2592 return -ENOSYS;
2593}
2594
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002595int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 void __user *buffer, size_t *lenp, loff_t *ppos)
2597{
2598 return -ENOSYS;
2599}
2600
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002601int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 void __user *buffer, size_t *lenp, loff_t *ppos)
2603{
2604 return -ENOSYS;
2605}
2606
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002607int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 void __user *buffer, size_t *lenp, loff_t *ppos)
2609{
2610 return -ENOSYS;
2611}
2612
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002613int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 void __user *buffer, size_t *lenp, loff_t *ppos)
2615{
2616 return -ENOSYS;
2617}
2618
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002619int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 void __user *buffer, size_t *lenp, loff_t *ppos)
2621{
2622 return -ENOSYS;
2623}
2624
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002625int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626 void __user *buffer, size_t *lenp, loff_t *ppos)
2627{
2628 return -ENOSYS;
2629}
2630
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002631int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 void __user *buffer,
2633 size_t *lenp, loff_t *ppos)
2634{
2635 return -ENOSYS;
2636}
2637
2638
Jovi Zhang55610502011-01-12 17:00:45 -08002639#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641/*
2642 * No sense putting this after each symbol definition, twice,
2643 * exception granted :-)
2644 */
2645EXPORT_SYMBOL(proc_dointvec);
2646EXPORT_SYMBOL(proc_dointvec_jiffies);
2647EXPORT_SYMBOL(proc_dointvec_minmax);
2648EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2649EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2650EXPORT_SYMBOL(proc_dostring);
2651EXPORT_SYMBOL(proc_doulongvec_minmax);
2652EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);