blob: 3dadde52253cfa4d385ce0ce9ff3498427b72885 [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 Rostedtf38f1d2a2008-12-16 23:06:40 -0500586#ifdef CONFIG_STACK_TRACER
587 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500588 .procname = "stack_tracer_enabled",
589 .data = &stack_tracer_enabled,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500593 },
594#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400595#ifdef CONFIG_TRACING
596 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100597 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400598 .data = &ftrace_dump_on_oops,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400602 },
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",
804 .data = &watchdog_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",
831 .data = &watchdog_enabled,
832 .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 Zickus8da5add2006-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 Zickus8da5add2006-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 Molnar23f78d4a2006-06-27 02:54:53 -0700987#ifdef CONFIG_RT_MUTEXES
988 {
Ingo Molnar23f78d4a2006-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 Molnar23f78d4a2006-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 Gondwana195cf4532008-02-04 22:29:20 -08001394#ifdef CONFIG_HIGHMEM
1395 {
Bron Gondwana195cf4532008-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 Gondwana195cf4532008-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
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001432 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433};
1434
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001435#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001436static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001437 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001438};
1439#endif
1440
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001441static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 .procname = "inode-nr",
1444 .data = &inodes_stat,
1445 .maxlen = 2*sizeof(int),
1446 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001447 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 },
1449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "inode-state",
1451 .data = &inodes_stat,
1452 .maxlen = 7*sizeof(int),
1453 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001454 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 },
1456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 .procname = "file-nr",
1458 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001459 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001461 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "file-max",
1465 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001466 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001468 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 },
1470 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001471 .procname = "nr_open",
1472 .data = &sysctl_nr_open,
1473 .maxlen = sizeof(int),
1474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001475 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001476 .extra1 = &sysctl_nr_open_min,
1477 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001478 },
1479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 .procname = "dentry-state",
1481 .data = &dentry_stat,
1482 .maxlen = 6*sizeof(int),
1483 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001484 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 },
1486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 .procname = "overflowuid",
1488 .data = &fs_overflowuid,
1489 .maxlen = sizeof(int),
1490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001491 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .extra1 = &minolduid,
1493 .extra2 = &maxolduid,
1494 },
1495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 .procname = "overflowgid",
1497 .data = &fs_overflowgid,
1498 .maxlen = sizeof(int),
1499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001500 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .extra1 = &minolduid,
1502 .extra2 = &maxolduid,
1503 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001504#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .procname = "leases-enable",
1507 .data = &leases_enable,
1508 .maxlen = sizeof(int),
1509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001510 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001512#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513#ifdef CONFIG_DNOTIFY
1514 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 .procname = "dir-notify-enable",
1516 .data = &dir_notify_enable,
1517 .maxlen = sizeof(int),
1518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001519 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 },
1521#endif
1522#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001523#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 .procname = "lease-break-time",
1526 .data = &lease_break_time,
1527 .maxlen = sizeof(int),
1528 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001529 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001531#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001532#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 .procname = "aio-nr",
1535 .data = &aio_nr,
1536 .maxlen = sizeof(aio_nr),
1537 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001538 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 },
1540 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 .procname = "aio-max-nr",
1542 .data = &aio_max_nr,
1543 .maxlen = sizeof(aio_max_nr),
1544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001545 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001547#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001548#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001549 {
Robert Love0399cb02005-07-13 12:38:18 -04001550 .procname = "inotify",
1551 .mode = 0555,
1552 .child = inotify_table,
1553 },
1554#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001555#ifdef CONFIG_EPOLL
1556 {
1557 .procname = "epoll",
1558 .mode = 0555,
1559 .child = epoll_table,
1560 },
1561#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001563 {
Kees Cook800179c2012-07-25 17:29:07 -07001564 .procname = "protected_symlinks",
1565 .data = &sysctl_protected_symlinks,
1566 .maxlen = sizeof(int),
1567 .mode = 0600,
1568 .proc_handler = proc_dointvec_minmax,
1569 .extra1 = &zero,
1570 .extra2 = &one,
1571 },
1572 {
1573 .procname = "protected_hardlinks",
1574 .data = &sysctl_protected_hardlinks,
1575 .maxlen = sizeof(int),
1576 .mode = 0600,
1577 .proc_handler = proc_dointvec_minmax,
1578 .extra1 = &zero,
1579 .extra2 = &one,
1580 },
1581 {
Alan Coxd6e71142005-06-23 00:09:43 -07001582 .procname = "suid_dumpable",
1583 .data = &suid_dumpable,
1584 .maxlen = sizeof(int),
1585 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001586 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001587 .extra1 = &zero,
1588 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001589 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001590#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1591 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001592 .procname = "binfmt_misc",
1593 .mode = 0555,
1594 .child = binfmt_misc_table,
1595 },
1596#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001597 {
Jens Axboeff9da692010-06-03 14:54:39 +02001598 .procname = "pipe-max-size",
1599 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001600 .maxlen = sizeof(int),
1601 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001602 .proc_handler = &pipe_proc_fn,
1603 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001604 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001605 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001606};
1607
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001608static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001609#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001610 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001611 .procname = "exception-trace",
1612 .data = &show_unhandled_signals,
1613 .maxlen = sizeof(int),
1614 .mode = 0644,
1615 .proc_handler = proc_dointvec
1616 },
1617#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001618#if defined(CONFIG_OPTPROBES)
1619 {
1620 .procname = "kprobes-optimization",
1621 .data = &sysctl_kprobes_optimization,
1622 .maxlen = sizeof(int),
1623 .mode = 0644,
1624 .proc_handler = proc_kprobes_optimization_handler,
1625 .extra1 = &zero,
1626 .extra2 = &one,
1627 },
1628#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001629 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630};
1631
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001632static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001633 { }
Robert Love0eeca282005-07-12 17:06:03 -04001634};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001636int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001637{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001638 struct ctl_table_header *hdr;
1639
1640 hdr = register_sysctl_table(sysctl_base_table);
1641 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001642 return 0;
1643}
1644
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001645#endif /* CONFIG_SYSCTL */
1646
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647/*
1648 * /proc/sys support
1649 */
1650
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001651#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001653static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001654 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001655 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001656{
1657 size_t len;
1658 char __user *p;
1659 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001660
1661 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001662 *lenp = 0;
1663 return 0;
1664 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001665
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001666 if (write) {
1667 len = 0;
1668 p = buffer;
1669 while (len < *lenp) {
1670 if (get_user(c, p++))
1671 return -EFAULT;
1672 if (c == 0 || c == '\n')
1673 break;
1674 len++;
1675 }
1676 if (len >= maxlen)
1677 len = maxlen-1;
1678 if(copy_from_user(data, buffer, len))
1679 return -EFAULT;
1680 ((char *) data)[len] = 0;
1681 *ppos += *lenp;
1682 } else {
1683 len = strlen(data);
1684 if (len > maxlen)
1685 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001686
1687 if (*ppos > len) {
1688 *lenp = 0;
1689 return 0;
1690 }
1691
1692 data += *ppos;
1693 len -= *ppos;
1694
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001695 if (len > *lenp)
1696 len = *lenp;
1697 if (len)
1698 if(copy_to_user(buffer, data, len))
1699 return -EFAULT;
1700 if (len < *lenp) {
1701 if(put_user('\n', ((char __user *) buffer) + len))
1702 return -EFAULT;
1703 len++;
1704 }
1705 *lenp = len;
1706 *ppos += len;
1707 }
1708 return 0;
1709}
1710
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711/**
1712 * proc_dostring - read a string sysctl
1713 * @table: the sysctl table
1714 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715 * @buffer: the user buffer
1716 * @lenp: the size of the user buffer
1717 * @ppos: file position
1718 *
1719 * Reads/writes a string from/to the user buffer. If the kernel
1720 * buffer provided is not large enough to hold the string, the
1721 * string is truncated. The copied string is %NULL-terminated.
1722 * If the string is being read by the user process, it is copied
1723 * and a newline '\n' is added. It is truncated if the buffer is
1724 * not large enough.
1725 *
1726 * Returns 0 on success.
1727 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001728int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 void __user *buffer, size_t *lenp, loff_t *ppos)
1730{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001731 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001732 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733}
1734
Amerigo Wang00b7c332010-05-05 00:26:45 +00001735static size_t proc_skip_spaces(char **buf)
1736{
1737 size_t ret;
1738 char *tmp = skip_spaces(*buf);
1739 ret = tmp - *buf;
1740 *buf = tmp;
1741 return ret;
1742}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001744static void proc_skip_char(char **buf, size_t *size, const char v)
1745{
1746 while (*size) {
1747 if (**buf != v)
1748 break;
1749 (*size)--;
1750 (*buf)++;
1751 }
1752}
1753
Amerigo Wang00b7c332010-05-05 00:26:45 +00001754#define TMPBUFLEN 22
1755/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001756 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001757 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001758 * @buf: a kernel buffer
1759 * @size: size of the kernel buffer
1760 * @val: this is where the number will be stored
1761 * @neg: set to %TRUE if number is negative
1762 * @perm_tr: a vector which contains the allowed trailers
1763 * @perm_tr_len: size of the perm_tr vector
1764 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001765 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001766 * In case of success %0 is returned and @buf and @size are updated with
1767 * the amount of bytes read. If @tr is non-NULL and a trailing
1768 * character exists (size is non-zero after returning from this
1769 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001770 */
1771static int proc_get_long(char **buf, size_t *size,
1772 unsigned long *val, bool *neg,
1773 const char *perm_tr, unsigned perm_tr_len, char *tr)
1774{
1775 int len;
1776 char *p, tmp[TMPBUFLEN];
1777
1778 if (!*size)
1779 return -EINVAL;
1780
1781 len = *size;
1782 if (len > TMPBUFLEN - 1)
1783 len = TMPBUFLEN - 1;
1784
1785 memcpy(tmp, *buf, len);
1786
1787 tmp[len] = 0;
1788 p = tmp;
1789 if (*p == '-' && *size > 1) {
1790 *neg = true;
1791 p++;
1792 } else
1793 *neg = false;
1794 if (!isdigit(*p))
1795 return -EINVAL;
1796
1797 *val = simple_strtoul(p, &p, 0);
1798
1799 len = p - tmp;
1800
1801 /* We don't know if the next char is whitespace thus we may accept
1802 * invalid integers (e.g. 1234...a) or two integers instead of one
1803 * (e.g. 123...1). So lets not allow such large numbers. */
1804 if (len == TMPBUFLEN - 1)
1805 return -EINVAL;
1806
1807 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1808 return -EINVAL;
1809
1810 if (tr && (len < *size))
1811 *tr = *p;
1812
1813 *buf += len;
1814 *size -= len;
1815
1816 return 0;
1817}
1818
1819/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001820 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001821 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001822 * @buf: the user buffer
1823 * @size: the size of the user buffer
1824 * @val: the integer to be converted
1825 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001826 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001827 * In case of success %0 is returned and @buf and @size are updated with
1828 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001829 */
1830static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1831 bool neg)
1832{
1833 int len;
1834 char tmp[TMPBUFLEN], *p = tmp;
1835
1836 sprintf(p, "%s%lu", neg ? "-" : "", val);
1837 len = strlen(tmp);
1838 if (len > *size)
1839 len = *size;
1840 if (copy_to_user(*buf, tmp, len))
1841 return -EFAULT;
1842 *size -= len;
1843 *buf += len;
1844 return 0;
1845}
1846#undef TMPBUFLEN
1847
1848static int proc_put_char(void __user **buf, size_t *size, char c)
1849{
1850 if (*size) {
1851 char __user **buffer = (char __user **)buf;
1852 if (put_user(c, *buffer))
1853 return -EFAULT;
1854 (*size)--, (*buffer)++;
1855 *buf = *buffer;
1856 }
1857 return 0;
1858}
1859
1860static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001861 int *valp,
1862 int write, void *data)
1863{
1864 if (write) {
1865 *valp = *negp ? -*lvalp : *lvalp;
1866 } else {
1867 int val = *valp;
1868 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001869 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870 *lvalp = (unsigned long)-val;
1871 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001872 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873 *lvalp = (unsigned long)val;
1874 }
1875 }
1876 return 0;
1877}
1878
Amerigo Wang00b7c332010-05-05 00:26:45 +00001879static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1880
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001881static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001882 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001883 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001884 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885 int write, void *data),
1886 void *data)
1887{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001888 int *i, vleft, first = 1, err = 0;
1889 unsigned long page = 0;
1890 size_t left;
1891 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892
Amerigo Wang00b7c332010-05-05 00:26:45 +00001893 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 *lenp = 0;
1895 return 0;
1896 }
1897
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001898 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 vleft = table->maxlen / sizeof(*i);
1900 left = *lenp;
1901
1902 if (!conv)
1903 conv = do_proc_dointvec_conv;
1904
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001906 if (left > PAGE_SIZE - 1)
1907 left = PAGE_SIZE - 1;
1908 page = __get_free_page(GFP_TEMPORARY);
1909 kbuf = (char *) page;
1910 if (!kbuf)
1911 return -ENOMEM;
1912 if (copy_from_user(kbuf, buffer, left)) {
1913 err = -EFAULT;
1914 goto free;
1915 }
1916 kbuf[left] = 0;
1917 }
1918
1919 for (; left && vleft--; i++, first=0) {
1920 unsigned long lval;
1921 bool neg;
1922
1923 if (write) {
1924 left -= proc_skip_spaces(&kbuf);
1925
J. R. Okajima563b0462010-05-25 16:10:14 -07001926 if (!left)
1927 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001928 err = proc_get_long(&kbuf, &left, &lval, &neg,
1929 proc_wspace_sep,
1930 sizeof(proc_wspace_sep), NULL);
1931 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001933 if (conv(&neg, &lval, i, 1, data)) {
1934 err = -EINVAL;
1935 break;
1936 }
1937 } else {
1938 if (conv(&neg, &lval, i, 0, data)) {
1939 err = -EINVAL;
1940 break;
1941 }
1942 if (!first)
1943 err = proc_put_char(&buffer, &left, '\t');
1944 if (err)
1945 break;
1946 err = proc_put_long(&buffer, &left, lval, neg);
1947 if (err)
1948 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001949 }
1950 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001951
1952 if (!write && !first && left && !err)
1953 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001954 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001955 left -= proc_skip_spaces(&kbuf);
1956free:
1957 if (write) {
1958 free_page(page);
1959 if (first)
1960 return err ? : -EINVAL;
1961 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962 *lenp -= left;
1963 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001964 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965}
1966
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001967static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001968 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001969 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001970 int write, void *data),
1971 void *data)
1972{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001973 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001974 buffer, lenp, ppos, conv, data);
1975}
1976
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977/**
1978 * proc_dointvec - read a vector of integers
1979 * @table: the sysctl table
1980 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981 * @buffer: the user buffer
1982 * @lenp: the size of the user buffer
1983 * @ppos: file position
1984 *
1985 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1986 * values from/to the user buffer, treated as an ASCII string.
1987 *
1988 * Returns 0 on success.
1989 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001990int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991 void __user *buffer, size_t *lenp, loff_t *ppos)
1992{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001993 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994 NULL,NULL);
1995}
1996
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001997/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001998 * Taint values can only be increased
1999 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002000 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002001static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002002 void __user *buffer, size_t *lenp, loff_t *ppos)
2003{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002004 struct ctl_table t;
2005 unsigned long tmptaint = get_taint();
2006 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002007
Bastian Blank91fcd412007-04-23 14:41:14 -07002008 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002009 return -EPERM;
2010
Andi Kleen25ddbb12008-10-15 22:01:41 -07002011 t = *table;
2012 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002013 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002014 if (err < 0)
2015 return err;
2016
2017 if (write) {
2018 /*
2019 * Poor man's atomic or. Not worth adding a primitive
2020 * to everyone's atomic.h for this
2021 */
2022 int i;
2023 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2024 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302025 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002026 }
2027 }
2028
2029 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002030}
2031
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002032#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002033static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002034 void __user *buffer, size_t *lenp, loff_t *ppos)
2035{
2036 if (write && !capable(CAP_SYS_ADMIN))
2037 return -EPERM;
2038
2039 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2040}
2041#endif
2042
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043struct do_proc_dointvec_minmax_conv_param {
2044 int *min;
2045 int *max;
2046};
2047
Amerigo Wang00b7c332010-05-05 00:26:45 +00002048static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2049 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050 int write, void *data)
2051{
2052 struct do_proc_dointvec_minmax_conv_param *param = data;
2053 if (write) {
2054 int val = *negp ? -*lvalp : *lvalp;
2055 if ((param->min && *param->min > val) ||
2056 (param->max && *param->max < val))
2057 return -EINVAL;
2058 *valp = val;
2059 } else {
2060 int val = *valp;
2061 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002062 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063 *lvalp = (unsigned long)-val;
2064 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002065 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066 *lvalp = (unsigned long)val;
2067 }
2068 }
2069 return 0;
2070}
2071
2072/**
2073 * proc_dointvec_minmax - read a vector of integers with min/max values
2074 * @table: the sysctl table
2075 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076 * @buffer: the user buffer
2077 * @lenp: the size of the user buffer
2078 * @ppos: file position
2079 *
2080 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2081 * values from/to the user buffer, treated as an ASCII string.
2082 *
2083 * This routine will ensure the values are within the range specified by
2084 * table->extra1 (min) and table->extra2 (max).
2085 *
2086 * Returns 0 on success.
2087 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002088int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 void __user *buffer, size_t *lenp, loff_t *ppos)
2090{
2091 struct do_proc_dointvec_minmax_conv_param param = {
2092 .min = (int *) table->extra1,
2093 .max = (int *) table->extra2,
2094 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002095 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096 do_proc_dointvec_minmax_conv, &param);
2097}
2098
Kees Cook54b50192012-07-30 14:39:18 -07002099static void validate_coredump_safety(void)
2100{
Alex Kelly046d6622012-10-04 17:15:23 -07002101#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002102 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002103 core_pattern[0] != '/' && core_pattern[0] != '|') {
2104 printk(KERN_WARNING "Unsafe core_pattern used with "\
2105 "suid_dumpable=2. Pipe handler or fully qualified "\
2106 "core dump path required.\n");
2107 }
Alex Kelly046d6622012-10-04 17:15:23 -07002108#endif
Kees Cook54b50192012-07-30 14:39:18 -07002109}
2110
2111static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2112 void __user *buffer, size_t *lenp, loff_t *ppos)
2113{
2114 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2115 if (!error)
2116 validate_coredump_safety();
2117 return error;
2118}
2119
Alex Kelly046d6622012-10-04 17:15:23 -07002120#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002121static int proc_dostring_coredump(struct ctl_table *table, int write,
2122 void __user *buffer, size_t *lenp, loff_t *ppos)
2123{
2124 int error = proc_dostring(table, write, buffer, lenp, ppos);
2125 if (!error)
2126 validate_coredump_safety();
2127 return error;
2128}
Alex Kelly046d6622012-10-04 17:15:23 -07002129#endif
Kees Cook54b50192012-07-30 14:39:18 -07002130
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002131static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132 void __user *buffer,
2133 size_t *lenp, loff_t *ppos,
2134 unsigned long convmul,
2135 unsigned long convdiv)
2136{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002137 unsigned long *i, *min, *max;
2138 int vleft, first = 1, err = 0;
2139 unsigned long page = 0;
2140 size_t left;
2141 char *kbuf;
2142
2143 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 *lenp = 0;
2145 return 0;
2146 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002147
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002148 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 min = (unsigned long *) table->extra1;
2150 max = (unsigned long *) table->extra2;
2151 vleft = table->maxlen / sizeof(unsigned long);
2152 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002153
2154 if (write) {
2155 if (left > PAGE_SIZE - 1)
2156 left = PAGE_SIZE - 1;
2157 page = __get_free_page(GFP_TEMPORARY);
2158 kbuf = (char *) page;
2159 if (!kbuf)
2160 return -ENOMEM;
2161 if (copy_from_user(kbuf, buffer, left)) {
2162 err = -EFAULT;
2163 goto free;
2164 }
2165 kbuf[left] = 0;
2166 }
2167
Eric Dumazet27b3d802010-10-07 12:59:29 -07002168 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002169 unsigned long val;
2170
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 bool neg;
2173
2174 left -= proc_skip_spaces(&kbuf);
2175
2176 err = proc_get_long(&kbuf, &left, &val, &neg,
2177 proc_wspace_sep,
2178 sizeof(proc_wspace_sep), NULL);
2179 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 break;
2181 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 continue;
2183 if ((min && val < *min) || (max && val > *max))
2184 continue;
2185 *i = val;
2186 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002189 err = proc_put_char(&buffer, &left, '\t');
2190 err = proc_put_long(&buffer, &left, val, false);
2191 if (err)
2192 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193 }
2194 }
2195
Amerigo Wang00b7c332010-05-05 00:26:45 +00002196 if (!write && !first && left && !err)
2197 err = proc_put_char(&buffer, &left, '\n');
2198 if (write && !err)
2199 left -= proc_skip_spaces(&kbuf);
2200free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002202 free_page(page);
2203 if (first)
2204 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 *lenp -= left;
2207 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002208 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209}
2210
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002211static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002212 void __user *buffer,
2213 size_t *lenp, loff_t *ppos,
2214 unsigned long convmul,
2215 unsigned long convdiv)
2216{
2217 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002218 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002219}
2220
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221/**
2222 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2223 * @table: the sysctl table
2224 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225 * @buffer: the user buffer
2226 * @lenp: the size of the user buffer
2227 * @ppos: file position
2228 *
2229 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2230 * values from/to the user buffer, treated as an ASCII string.
2231 *
2232 * This routine will ensure the values are within the range specified by
2233 * table->extra1 (min) and table->extra2 (max).
2234 *
2235 * Returns 0 on success.
2236 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002237int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 void __user *buffer, size_t *lenp, loff_t *ppos)
2239{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002240 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241}
2242
2243/**
2244 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2245 * @table: the sysctl table
2246 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002247 * @buffer: the user buffer
2248 * @lenp: the size of the user buffer
2249 * @ppos: file position
2250 *
2251 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2252 * values from/to the user buffer, treated as an ASCII string. The values
2253 * are treated as milliseconds, and converted to jiffies when they are stored.
2254 *
2255 * This routine will ensure the values are within the range specified by
2256 * table->extra1 (min) and table->extra2 (max).
2257 *
2258 * Returns 0 on success.
2259 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002260int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 void __user *buffer,
2262 size_t *lenp, loff_t *ppos)
2263{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002264 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 lenp, ppos, HZ, 1000l);
2266}
2267
2268
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 int *valp,
2271 int write, void *data)
2272{
2273 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002274 if (*lvalp > LONG_MAX / HZ)
2275 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2277 } else {
2278 int val = *valp;
2279 unsigned long lval;
2280 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002281 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 lval = (unsigned long)-val;
2283 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 lval = (unsigned long)val;
2286 }
2287 *lvalp = lval / HZ;
2288 }
2289 return 0;
2290}
2291
Amerigo Wang00b7c332010-05-05 00:26:45 +00002292static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293 int *valp,
2294 int write, void *data)
2295{
2296 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002297 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2298 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2300 } else {
2301 int val = *valp;
2302 unsigned long lval;
2303 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002304 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 lval = (unsigned long)-val;
2306 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002307 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002308 lval = (unsigned long)val;
2309 }
2310 *lvalp = jiffies_to_clock_t(lval);
2311 }
2312 return 0;
2313}
2314
Amerigo Wang00b7c332010-05-05 00:26:45 +00002315static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 int *valp,
2317 int write, void *data)
2318{
2319 if (write) {
2320 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2321 } else {
2322 int val = *valp;
2323 unsigned long lval;
2324 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002325 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326 lval = (unsigned long)-val;
2327 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002328 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 lval = (unsigned long)val;
2330 }
2331 *lvalp = jiffies_to_msecs(lval);
2332 }
2333 return 0;
2334}
2335
2336/**
2337 * proc_dointvec_jiffies - read a vector of integers as seconds
2338 * @table: the sysctl table
2339 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 * @buffer: the user buffer
2341 * @lenp: the size of the user buffer
2342 * @ppos: file position
2343 *
2344 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2345 * values from/to the user buffer, treated as an ASCII string.
2346 * The values read are assumed to be in seconds, and are converted into
2347 * jiffies.
2348 *
2349 * Returns 0 on success.
2350 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002351int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002352 void __user *buffer, size_t *lenp, loff_t *ppos)
2353{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002354 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355 do_proc_dointvec_jiffies_conv,NULL);
2356}
2357
2358/**
2359 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2360 * @table: the sysctl table
2361 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 * @buffer: the user buffer
2363 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002364 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365 *
2366 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2367 * values from/to the user buffer, treated as an ASCII string.
2368 * The values read are assumed to be in 1/USER_HZ seconds, and
2369 * are converted into jiffies.
2370 *
2371 * Returns 0 on success.
2372 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002373int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374 void __user *buffer, size_t *lenp, loff_t *ppos)
2375{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002376 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 do_proc_dointvec_userhz_jiffies_conv,NULL);
2378}
2379
2380/**
2381 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2382 * @table: the sysctl table
2383 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 * @buffer: the user buffer
2385 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002386 * @ppos: file position
2387 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 *
2389 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2390 * values from/to the user buffer, treated as an ASCII string.
2391 * The values read are assumed to be in 1/1000 seconds, and
2392 * are converted into jiffies.
2393 *
2394 * Returns 0 on success.
2395 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002396int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 void __user *buffer, size_t *lenp, loff_t *ppos)
2398{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002399 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 do_proc_dointvec_ms_jiffies_conv, NULL);
2401}
2402
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002404 void __user *buffer, size_t *lenp, loff_t *ppos)
2405{
2406 struct pid *new_pid;
2407 pid_t tmp;
2408 int r;
2409
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002410 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002411
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002412 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002413 lenp, ppos, NULL, NULL);
2414 if (r || !write)
2415 return r;
2416
2417 new_pid = find_get_pid(tmp);
2418 if (!new_pid)
2419 return -ESRCH;
2420
2421 put_pid(xchg(&cad_pid, new_pid));
2422 return 0;
2423}
2424
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002425/**
2426 * proc_do_large_bitmap - read/write from/to a large bitmap
2427 * @table: the sysctl table
2428 * @write: %TRUE if this is a write to the sysctl file
2429 * @buffer: the user buffer
2430 * @lenp: the size of the user buffer
2431 * @ppos: file position
2432 *
2433 * The bitmap is stored at table->data and the bitmap length (in bits)
2434 * in table->maxlen.
2435 *
2436 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2437 * large bitmaps may be represented in a compact manner. Writing into
2438 * the file will clear the bitmap then update it with the given input.
2439 *
2440 * Returns 0 on success.
2441 */
2442int proc_do_large_bitmap(struct ctl_table *table, int write,
2443 void __user *buffer, size_t *lenp, loff_t *ppos)
2444{
2445 int err = 0;
2446 bool first = 1;
2447 size_t left = *lenp;
2448 unsigned long bitmap_len = table->maxlen;
2449 unsigned long *bitmap = (unsigned long *) table->data;
2450 unsigned long *tmp_bitmap = NULL;
2451 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2452
2453 if (!bitmap_len || !left || (*ppos && !write)) {
2454 *lenp = 0;
2455 return 0;
2456 }
2457
2458 if (write) {
2459 unsigned long page = 0;
2460 char *kbuf;
2461
2462 if (left > PAGE_SIZE - 1)
2463 left = PAGE_SIZE - 1;
2464
2465 page = __get_free_page(GFP_TEMPORARY);
2466 kbuf = (char *) page;
2467 if (!kbuf)
2468 return -ENOMEM;
2469 if (copy_from_user(kbuf, buffer, left)) {
2470 free_page(page);
2471 return -EFAULT;
2472 }
2473 kbuf[left] = 0;
2474
2475 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2476 GFP_KERNEL);
2477 if (!tmp_bitmap) {
2478 free_page(page);
2479 return -ENOMEM;
2480 }
2481 proc_skip_char(&kbuf, &left, '\n');
2482 while (!err && left) {
2483 unsigned long val_a, val_b;
2484 bool neg;
2485
2486 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2487 sizeof(tr_a), &c);
2488 if (err)
2489 break;
2490 if (val_a >= bitmap_len || neg) {
2491 err = -EINVAL;
2492 break;
2493 }
2494
2495 val_b = val_a;
2496 if (left) {
2497 kbuf++;
2498 left--;
2499 }
2500
2501 if (c == '-') {
2502 err = proc_get_long(&kbuf, &left, &val_b,
2503 &neg, tr_b, sizeof(tr_b),
2504 &c);
2505 if (err)
2506 break;
2507 if (val_b >= bitmap_len || neg ||
2508 val_a > val_b) {
2509 err = -EINVAL;
2510 break;
2511 }
2512 if (left) {
2513 kbuf++;
2514 left--;
2515 }
2516 }
2517
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002518 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002519 first = 0;
2520 proc_skip_char(&kbuf, &left, '\n');
2521 }
2522 free_page(page);
2523 } else {
2524 unsigned long bit_a, bit_b = 0;
2525
2526 while (left) {
2527 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2528 if (bit_a >= bitmap_len)
2529 break;
2530 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2531 bit_a + 1) - 1;
2532
2533 if (!first) {
2534 err = proc_put_char(&buffer, &left, ',');
2535 if (err)
2536 break;
2537 }
2538 err = proc_put_long(&buffer, &left, bit_a, false);
2539 if (err)
2540 break;
2541 if (bit_a != bit_b) {
2542 err = proc_put_char(&buffer, &left, '-');
2543 if (err)
2544 break;
2545 err = proc_put_long(&buffer, &left, bit_b, false);
2546 if (err)
2547 break;
2548 }
2549
2550 first = 0; bit_b++;
2551 }
2552 if (!err)
2553 err = proc_put_char(&buffer, &left, '\n');
2554 }
2555
2556 if (!err) {
2557 if (write) {
2558 if (*ppos)
2559 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2560 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002561 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002562 }
2563 kfree(tmp_bitmap);
2564 *lenp -= left;
2565 *ppos += *lenp;
2566 return 0;
2567 } else {
2568 kfree(tmp_bitmap);
2569 return err;
2570 }
2571}
2572
Jovi Zhang55610502011-01-12 17:00:45 -08002573#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002575int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 void __user *buffer, size_t *lenp, loff_t *ppos)
2577{
2578 return -ENOSYS;
2579}
2580
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002581int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 void __user *buffer, size_t *lenp, loff_t *ppos)
2583{
2584 return -ENOSYS;
2585}
2586
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002587int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 void __user *buffer, size_t *lenp, loff_t *ppos)
2589{
2590 return -ENOSYS;
2591}
2592
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002593int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 void __user *buffer, size_t *lenp, loff_t *ppos)
2595{
2596 return -ENOSYS;
2597}
2598
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002599int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 void __user *buffer, size_t *lenp, loff_t *ppos)
2601{
2602 return -ENOSYS;
2603}
2604
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002605int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 void __user *buffer, size_t *lenp, loff_t *ppos)
2607{
2608 return -ENOSYS;
2609}
2610
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002611int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 void __user *buffer, size_t *lenp, loff_t *ppos)
2613{
2614 return -ENOSYS;
2615}
2616
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002617int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618 void __user *buffer,
2619 size_t *lenp, loff_t *ppos)
2620{
2621 return -ENOSYS;
2622}
2623
2624
Jovi Zhang55610502011-01-12 17:00:45 -08002625#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627/*
2628 * No sense putting this after each symbol definition, twice,
2629 * exception granted :-)
2630 */
2631EXPORT_SYMBOL(proc_dointvec);
2632EXPORT_SYMBOL(proc_dointvec_jiffies);
2633EXPORT_SYMBOL(proc_dointvec_minmax);
2634EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2635EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2636EXPORT_SYMBOL(proc_dostring);
2637EXPORT_SYMBOL(proc_doulongvec_minmax);
2638EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);