blob: 6daabb72bdb5445f0985fc7aa25ff1c101e767e7 [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 Zijlstra4b96a29b2012-10-25 14:16:47 +0200361 .procname = "numa_balancing_scan_delay_ms",
362 .data = &sysctl_numa_balancing_scan_delay,
363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
365 .proc_handler = proc_dointvec,
366 },
367 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200368 .procname = "numa_balancing_scan_period_min_ms",
369 .data = &sysctl_numa_balancing_scan_period_min,
370 .maxlen = sizeof(unsigned int),
371 .mode = 0644,
372 .proc_handler = proc_dointvec,
373 },
374 {
Mel Gormanb8593bf2012-11-21 01:18:23 +0000375 .procname = "numa_balancing_scan_period_reset",
376 .data = &sysctl_numa_balancing_scan_period_reset,
377 .maxlen = sizeof(unsigned int),
378 .mode = 0644,
379 .proc_handler = proc_dointvec,
380 },
381 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200382 .procname = "numa_balancing_scan_period_max_ms",
383 .data = &sysctl_numa_balancing_scan_period_max,
384 .maxlen = sizeof(unsigned int),
385 .mode = 0644,
386 .proc_handler = proc_dointvec,
387 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200388 {
389 .procname = "numa_balancing_scan_size_mb",
390 .data = &sysctl_numa_balancing_scan_size,
391 .maxlen = sizeof(unsigned int),
392 .mode = 0644,
393 .proc_handler = proc_dointvec,
394 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200395#endif /* CONFIG_NUMA_BALANCING */
396#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200397 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100398 .procname = "sched_rt_period_us",
399 .data = &sysctl_sched_rt_period,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800402 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100403 },
404 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100405 .procname = "sched_rt_runtime_us",
406 .data = &sysctl_sched_rt_runtime,
407 .maxlen = sizeof(int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100410 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600411 {
412 .procname = "sched_rr_timeslice_ms",
413 .data = &sched_rr_timeslice,
414 .maxlen = sizeof(int),
415 .mode = 0644,
416 .proc_handler = sched_rr_handler,
417 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100418#ifdef CONFIG_SCHED_AUTOGROUP
419 {
420 .procname = "sched_autogroup_enabled",
421 .data = &sysctl_sched_autogroup_enabled,
422 .maxlen = sizeof(unsigned int),
423 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800424 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100425 .extra1 = &zero,
426 .extra2 = &one,
427 },
428#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700429#ifdef CONFIG_CFS_BANDWIDTH
430 {
431 .procname = "sched_cfs_bandwidth_slice_us",
432 .data = &sysctl_sched_cfs_bandwidth_slice,
433 .maxlen = sizeof(unsigned int),
434 .mode = 0644,
435 .proc_handler = proc_dointvec_minmax,
436 .extra1 = &one,
437 },
438#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700439#ifdef CONFIG_PROVE_LOCKING
440 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700441 .procname = "prove_locking",
442 .data = &prove_locking,
443 .maxlen = sizeof(int),
444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800445 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446 },
447#endif
448#ifdef CONFIG_LOCK_STAT
449 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700450 .procname = "lock_stat",
451 .data = &lock_stat,
452 .maxlen = sizeof(int),
453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800454 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 },
456#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200457 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 .procname = "panic",
459 .data = &panic_timeout,
460 .maxlen = sizeof(int),
461 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800462 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 },
Alex Kelly046d6622012-10-04 17:15:23 -0700464#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 .procname = "core_uses_pid",
467 .data = &core_uses_pid,
468 .maxlen = sizeof(int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 },
472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "core_pattern",
474 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700475 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700477 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
Neil Hormana2939802009-09-23 15:56:56 -0700479 {
Neil Hormana2939802009-09-23 15:56:56 -0700480 .procname = "core_pipe_limit",
481 .data = &core_pipe_limit,
482 .maxlen = sizeof(unsigned int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700485 },
Alex Kelly046d6622012-10-04 17:15:23 -0700486#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800487#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700490 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800494#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100495#ifdef CONFIG_LATENCYTOP
496 {
497 .procname = "latencytop",
498 .data = &latencytop_enabled,
499 .maxlen = sizeof(int),
500 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800501 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100502 },
503#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504#ifdef CONFIG_BLK_DEV_INITRD
505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 .procname = "real-root-dev",
507 .data = &real_root_dev,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 },
512#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700513 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700514 .procname = "print-fatal-signals",
515 .data = &print_fatal_signals,
516 .maxlen = sizeof(int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700519 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700520#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 .procname = "reboot-cmd",
523 .data = reboot_command,
524 .maxlen = 256,
525 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800526 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 },
528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .procname = "stop-a",
530 .data = &stop_a_enabled,
531 .maxlen = sizeof (int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 .procname = "scons-poweroff",
537 .data = &scons_pwroff,
538 .maxlen = sizeof (int),
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 },
542#endif
David S. Miller08714202008-11-16 23:49:24 -0800543#ifdef CONFIG_SPARC64
544 {
David S. Miller08714202008-11-16 23:49:24 -0800545 .procname = "tsb-ratio",
546 .data = &sysctl_tsb_ratio,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800550 },
551#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552#ifdef __hppa__
553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 .procname = "soft-power",
555 .data = &pwrsw_enabled,
556 .maxlen = sizeof (int),
557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800558 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530560#endif
561#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 .procname = "unaligned-trap",
564 .data = &unaligned_enabled,
565 .maxlen = sizeof (int),
566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 },
569#endif
570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .procname = "ctrl-alt-del",
572 .data = &C_A_D,
573 .maxlen = sizeof(int),
574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800575 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400577#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200578 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200579 .procname = "ftrace_enabled",
580 .data = &ftrace_enabled,
581 .maxlen = sizeof(int),
582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200584 },
585#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500586#ifdef CONFIG_STACK_TRACER
587 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500588 .procname = "stack_tracer_enabled",
589 .data = &stack_tracer_enabled,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500593 },
594#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400595#ifdef CONFIG_TRACING
596 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100597 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400598 .data = &ftrace_dump_on_oops,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400602 },
603#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200604#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "modprobe",
607 .data = &modprobe_path,
608 .maxlen = KMOD_PATH_LEN,
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
Kees Cook3d433212009-04-02 15:49:29 -0700612 {
Kees Cook3d433212009-04-02 15:49:29 -0700613 .procname = "modules_disabled",
614 .data = &modules_disabled,
615 .maxlen = sizeof(int),
616 .mode = 0644,
617 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700619 .extra1 = &one,
620 .extra2 = &one,
621 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500623
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100626 .data = &uevent_helper,
627 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500631
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632#ifdef CONFIG_CHR_DEV_SG
633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "sg-big-buff",
635 .data = &sg_big_buff,
636 .maxlen = sizeof (int),
637 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800638 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 },
640#endif
641#ifdef CONFIG_BSD_PROCESS_ACCT
642 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 .procname = "acct",
644 .data = &acct_parm,
645 .maxlen = 3*sizeof(int),
646 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800647 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 },
649#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650#ifdef CONFIG_MAGIC_SYSRQ
651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800653 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .maxlen = sizeof (int),
655 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700656 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 },
658#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700659#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700662 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .maxlen = sizeof (int),
664 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700667#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "threads-max",
670 .data = &max_threads,
671 .maxlen = sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "random",
677 .mode = 0555,
678 .child = random_table,
679 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 {
Eric Paris17f60a72011-04-01 17:07:50 -0400681 .procname = "usermodehelper",
682 .mode = 0555,
683 .child = usermodehelper_table,
684 },
685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "overflowuid",
687 .data = &overflowuid,
688 .maxlen = sizeof(int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 .extra1 = &minolduid,
692 .extra2 = &maxolduid,
693 },
694 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .procname = "overflowgid",
696 .data = &overflowgid,
697 .maxlen = sizeof(int),
698 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800699 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .extra1 = &minolduid,
701 .extra2 = &maxolduid,
702 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800703#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704#ifdef CONFIG_MATHEMU
705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .procname = "ieee_emulation_warnings",
707 .data = &sysctl_ieee_emulation_warnings,
708 .maxlen = sizeof(int),
709 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800710 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 },
712#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200715 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .maxlen = sizeof(int),
717 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800718 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 },
720#endif
721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .procname = "pid_max",
723 .data = &pid_max,
724 .maxlen = sizeof (int),
725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800726 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .extra1 = &pid_max_min,
728 .extra2 = &pid_max_max,
729 },
730 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 .procname = "panic_on_oops",
732 .data = &panic_on_oops,
733 .maxlen = sizeof(int),
734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800737#if defined CONFIG_PRINTK
738 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800739 .procname = "printk",
740 .data = &console_loglevel,
741 .maxlen = 4*sizeof(int),
742 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800743 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800744 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700747 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .maxlen = sizeof(int),
749 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 },
752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700754 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .maxlen = sizeof(int),
756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800757 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
Dave Youngaf913222009-09-22 16:43:33 -0700759 {
Dave Youngaf913222009-09-22 16:43:33 -0700760 .procname = "printk_delay",
761 .data = &printk_delay_msec,
762 .maxlen = sizeof(int),
763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700765 .extra1 = &zero,
766 .extra2 = &ten_thousand,
767 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800769 .procname = "dmesg_restrict",
770 .data = &dmesg_restrict,
771 .maxlen = sizeof(int),
772 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700773 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800774 .extra1 = &zero,
775 .extra2 = &one,
776 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800777 {
778 .procname = "kptr_restrict",
779 .data = &kptr_restrict,
780 .maxlen = sizeof(int),
781 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700782 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800783 .extra1 = &zero,
784 .extra2 = &two,
785 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800786#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800787 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 .procname = "ngroups_max",
789 .data = &ngroups_max,
790 .maxlen = sizeof (int),
791 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 },
Dan Ballard73efc032011-10-31 17:11:20 -0700794 {
795 .procname = "cap_last_cap",
796 .data = (void *)&cap_last_cap,
797 .maxlen = sizeof(int),
798 .mode = 0444,
799 .proc_handler = proc_dointvec,
800 },
Don Zickus58687ac2010-05-07 17:11:44 -0400801#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500802 {
Don Zickus58687ac2010-05-07 17:11:44 -0400803 .procname = "watchdog",
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
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001432 {
1433 .procname = "user_reserve_kbytes",
1434 .data = &sysctl_user_reserve_kbytes,
1435 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1436 .mode = 0644,
1437 .proc_handler = proc_doulongvec_minmax,
1438 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001439 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440};
1441
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001442#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001443static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001444 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001445};
1446#endif
1447
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001448static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "inode-nr",
1451 .data = &inodes_stat,
1452 .maxlen = 2*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 = "inode-state",
1458 .data = &inodes_stat,
1459 .maxlen = 7*sizeof(int),
1460 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001461 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "file-nr",
1465 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001466 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001468 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 },
1470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 .procname = "file-max",
1472 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001473 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001475 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 },
1477 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001478 .procname = "nr_open",
1479 .data = &sysctl_nr_open,
1480 .maxlen = sizeof(int),
1481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001483 .extra1 = &sysctl_nr_open_min,
1484 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001485 },
1486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 .procname = "dentry-state",
1488 .data = &dentry_stat,
1489 .maxlen = 6*sizeof(int),
1490 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001491 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 },
1493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .procname = "overflowuid",
1495 .data = &fs_overflowuid,
1496 .maxlen = sizeof(int),
1497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001498 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 .extra1 = &minolduid,
1500 .extra2 = &maxolduid,
1501 },
1502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 .procname = "overflowgid",
1504 .data = &fs_overflowgid,
1505 .maxlen = sizeof(int),
1506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001507 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 .extra1 = &minolduid,
1509 .extra2 = &maxolduid,
1510 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001511#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001512 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 .procname = "leases-enable",
1514 .data = &leases_enable,
1515 .maxlen = sizeof(int),
1516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001517 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001519#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520#ifdef CONFIG_DNOTIFY
1521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 .procname = "dir-notify-enable",
1523 .data = &dir_notify_enable,
1524 .maxlen = sizeof(int),
1525 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001526 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 },
1528#endif
1529#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001530#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 .procname = "lease-break-time",
1533 .data = &lease_break_time,
1534 .maxlen = sizeof(int),
1535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001536 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001538#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001539#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541 .procname = "aio-nr",
1542 .data = &aio_nr,
1543 .maxlen = sizeof(aio_nr),
1544 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001545 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 },
1547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 .procname = "aio-max-nr",
1549 .data = &aio_max_nr,
1550 .maxlen = sizeof(aio_max_nr),
1551 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001554#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001555#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001556 {
Robert Love0399cb02005-07-13 12:38:18 -04001557 .procname = "inotify",
1558 .mode = 0555,
1559 .child = inotify_table,
1560 },
1561#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001562#ifdef CONFIG_EPOLL
1563 {
1564 .procname = "epoll",
1565 .mode = 0555,
1566 .child = epoll_table,
1567 },
1568#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001570 {
Kees Cook800179c2012-07-25 17:29:07 -07001571 .procname = "protected_symlinks",
1572 .data = &sysctl_protected_symlinks,
1573 .maxlen = sizeof(int),
1574 .mode = 0600,
1575 .proc_handler = proc_dointvec_minmax,
1576 .extra1 = &zero,
1577 .extra2 = &one,
1578 },
1579 {
1580 .procname = "protected_hardlinks",
1581 .data = &sysctl_protected_hardlinks,
1582 .maxlen = sizeof(int),
1583 .mode = 0600,
1584 .proc_handler = proc_dointvec_minmax,
1585 .extra1 = &zero,
1586 .extra2 = &one,
1587 },
1588 {
Alan Coxd6e71142005-06-23 00:09:43 -07001589 .procname = "suid_dumpable",
1590 .data = &suid_dumpable,
1591 .maxlen = sizeof(int),
1592 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001593 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001594 .extra1 = &zero,
1595 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001596 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001597#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1598 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001599 .procname = "binfmt_misc",
1600 .mode = 0555,
1601 .child = binfmt_misc_table,
1602 },
1603#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001604 {
Jens Axboeff9da692010-06-03 14:54:39 +02001605 .procname = "pipe-max-size",
1606 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001607 .maxlen = sizeof(int),
1608 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001609 .proc_handler = &pipe_proc_fn,
1610 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001611 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001612 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613};
1614
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001615static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001616#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001617 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001618 .procname = "exception-trace",
1619 .data = &show_unhandled_signals,
1620 .maxlen = sizeof(int),
1621 .mode = 0644,
1622 .proc_handler = proc_dointvec
1623 },
1624#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001625#if defined(CONFIG_OPTPROBES)
1626 {
1627 .procname = "kprobes-optimization",
1628 .data = &sysctl_kprobes_optimization,
1629 .maxlen = sizeof(int),
1630 .mode = 0644,
1631 .proc_handler = proc_kprobes_optimization_handler,
1632 .extra1 = &zero,
1633 .extra2 = &one,
1634 },
1635#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001636 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637};
1638
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001639static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001640 { }
Robert Love0eeca282005-07-12 17:06:03 -04001641};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001643int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001644{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001645 struct ctl_table_header *hdr;
1646
1647 hdr = register_sysctl_table(sysctl_base_table);
1648 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001649 return 0;
1650}
1651
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001652#endif /* CONFIG_SYSCTL */
1653
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654/*
1655 * /proc/sys support
1656 */
1657
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001658#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001660static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001661 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001662 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001663{
1664 size_t len;
1665 char __user *p;
1666 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001667
1668 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001669 *lenp = 0;
1670 return 0;
1671 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001672
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001673 if (write) {
1674 len = 0;
1675 p = buffer;
1676 while (len < *lenp) {
1677 if (get_user(c, p++))
1678 return -EFAULT;
1679 if (c == 0 || c == '\n')
1680 break;
1681 len++;
1682 }
1683 if (len >= maxlen)
1684 len = maxlen-1;
1685 if(copy_from_user(data, buffer, len))
1686 return -EFAULT;
1687 ((char *) data)[len] = 0;
1688 *ppos += *lenp;
1689 } else {
1690 len = strlen(data);
1691 if (len > maxlen)
1692 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001693
1694 if (*ppos > len) {
1695 *lenp = 0;
1696 return 0;
1697 }
1698
1699 data += *ppos;
1700 len -= *ppos;
1701
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001702 if (len > *lenp)
1703 len = *lenp;
1704 if (len)
1705 if(copy_to_user(buffer, data, len))
1706 return -EFAULT;
1707 if (len < *lenp) {
1708 if(put_user('\n', ((char __user *) buffer) + len))
1709 return -EFAULT;
1710 len++;
1711 }
1712 *lenp = len;
1713 *ppos += len;
1714 }
1715 return 0;
1716}
1717
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718/**
1719 * proc_dostring - read a string sysctl
1720 * @table: the sysctl table
1721 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 * @buffer: the user buffer
1723 * @lenp: the size of the user buffer
1724 * @ppos: file position
1725 *
1726 * Reads/writes a string from/to the user buffer. If the kernel
1727 * buffer provided is not large enough to hold the string, the
1728 * string is truncated. The copied string is %NULL-terminated.
1729 * If the string is being read by the user process, it is copied
1730 * and a newline '\n' is added. It is truncated if the buffer is
1731 * not large enough.
1732 *
1733 * Returns 0 on success.
1734 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001735int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 void __user *buffer, size_t *lenp, loff_t *ppos)
1737{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001738 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001739 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740}
1741
Amerigo Wang00b7c332010-05-05 00:26:45 +00001742static size_t proc_skip_spaces(char **buf)
1743{
1744 size_t ret;
1745 char *tmp = skip_spaces(*buf);
1746 ret = tmp - *buf;
1747 *buf = tmp;
1748 return ret;
1749}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001751static void proc_skip_char(char **buf, size_t *size, const char v)
1752{
1753 while (*size) {
1754 if (**buf != v)
1755 break;
1756 (*size)--;
1757 (*buf)++;
1758 }
1759}
1760
Amerigo Wang00b7c332010-05-05 00:26:45 +00001761#define TMPBUFLEN 22
1762/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001763 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001764 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001765 * @buf: a kernel buffer
1766 * @size: size of the kernel buffer
1767 * @val: this is where the number will be stored
1768 * @neg: set to %TRUE if number is negative
1769 * @perm_tr: a vector which contains the allowed trailers
1770 * @perm_tr_len: size of the perm_tr vector
1771 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001772 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001773 * In case of success %0 is returned and @buf and @size are updated with
1774 * the amount of bytes read. If @tr is non-NULL and a trailing
1775 * character exists (size is non-zero after returning from this
1776 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001777 */
1778static int proc_get_long(char **buf, size_t *size,
1779 unsigned long *val, bool *neg,
1780 const char *perm_tr, unsigned perm_tr_len, char *tr)
1781{
1782 int len;
1783 char *p, tmp[TMPBUFLEN];
1784
1785 if (!*size)
1786 return -EINVAL;
1787
1788 len = *size;
1789 if (len > TMPBUFLEN - 1)
1790 len = TMPBUFLEN - 1;
1791
1792 memcpy(tmp, *buf, len);
1793
1794 tmp[len] = 0;
1795 p = tmp;
1796 if (*p == '-' && *size > 1) {
1797 *neg = true;
1798 p++;
1799 } else
1800 *neg = false;
1801 if (!isdigit(*p))
1802 return -EINVAL;
1803
1804 *val = simple_strtoul(p, &p, 0);
1805
1806 len = p - tmp;
1807
1808 /* We don't know if the next char is whitespace thus we may accept
1809 * invalid integers (e.g. 1234...a) or two integers instead of one
1810 * (e.g. 123...1). So lets not allow such large numbers. */
1811 if (len == TMPBUFLEN - 1)
1812 return -EINVAL;
1813
1814 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1815 return -EINVAL;
1816
1817 if (tr && (len < *size))
1818 *tr = *p;
1819
1820 *buf += len;
1821 *size -= len;
1822
1823 return 0;
1824}
1825
1826/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001827 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001828 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001829 * @buf: the user buffer
1830 * @size: the size of the user buffer
1831 * @val: the integer to be converted
1832 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001833 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001834 * In case of success %0 is returned and @buf and @size are updated with
1835 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001836 */
1837static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1838 bool neg)
1839{
1840 int len;
1841 char tmp[TMPBUFLEN], *p = tmp;
1842
1843 sprintf(p, "%s%lu", neg ? "-" : "", val);
1844 len = strlen(tmp);
1845 if (len > *size)
1846 len = *size;
1847 if (copy_to_user(*buf, tmp, len))
1848 return -EFAULT;
1849 *size -= len;
1850 *buf += len;
1851 return 0;
1852}
1853#undef TMPBUFLEN
1854
1855static int proc_put_char(void __user **buf, size_t *size, char c)
1856{
1857 if (*size) {
1858 char __user **buffer = (char __user **)buf;
1859 if (put_user(c, *buffer))
1860 return -EFAULT;
1861 (*size)--, (*buffer)++;
1862 *buf = *buffer;
1863 }
1864 return 0;
1865}
1866
1867static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868 int *valp,
1869 int write, void *data)
1870{
1871 if (write) {
1872 *valp = *negp ? -*lvalp : *lvalp;
1873 } else {
1874 int val = *valp;
1875 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001876 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 *lvalp = (unsigned long)-val;
1878 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001879 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001880 *lvalp = (unsigned long)val;
1881 }
1882 }
1883 return 0;
1884}
1885
Amerigo Wang00b7c332010-05-05 00:26:45 +00001886static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1887
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001888static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001889 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001890 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001891 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 int write, void *data),
1893 void *data)
1894{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001895 int *i, vleft, first = 1, err = 0;
1896 unsigned long page = 0;
1897 size_t left;
1898 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899
Amerigo Wang00b7c332010-05-05 00:26:45 +00001900 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901 *lenp = 0;
1902 return 0;
1903 }
1904
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001905 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 vleft = table->maxlen / sizeof(*i);
1907 left = *lenp;
1908
1909 if (!conv)
1910 conv = do_proc_dointvec_conv;
1911
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001913 if (left > PAGE_SIZE - 1)
1914 left = PAGE_SIZE - 1;
1915 page = __get_free_page(GFP_TEMPORARY);
1916 kbuf = (char *) page;
1917 if (!kbuf)
1918 return -ENOMEM;
1919 if (copy_from_user(kbuf, buffer, left)) {
1920 err = -EFAULT;
1921 goto free;
1922 }
1923 kbuf[left] = 0;
1924 }
1925
1926 for (; left && vleft--; i++, first=0) {
1927 unsigned long lval;
1928 bool neg;
1929
1930 if (write) {
1931 left -= proc_skip_spaces(&kbuf);
1932
J. R. Okajima563b0462010-05-25 16:10:14 -07001933 if (!left)
1934 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001935 err = proc_get_long(&kbuf, &left, &lval, &neg,
1936 proc_wspace_sep,
1937 sizeof(proc_wspace_sep), NULL);
1938 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001940 if (conv(&neg, &lval, i, 1, data)) {
1941 err = -EINVAL;
1942 break;
1943 }
1944 } else {
1945 if (conv(&neg, &lval, i, 0, data)) {
1946 err = -EINVAL;
1947 break;
1948 }
1949 if (!first)
1950 err = proc_put_char(&buffer, &left, '\t');
1951 if (err)
1952 break;
1953 err = proc_put_long(&buffer, &left, lval, neg);
1954 if (err)
1955 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956 }
1957 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001958
1959 if (!write && !first && left && !err)
1960 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001961 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001962 left -= proc_skip_spaces(&kbuf);
1963free:
1964 if (write) {
1965 free_page(page);
1966 if (first)
1967 return err ? : -EINVAL;
1968 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001969 *lenp -= left;
1970 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001971 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972}
1973
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001974static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001975 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001976 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001977 int write, void *data),
1978 void *data)
1979{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001980 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001981 buffer, lenp, ppos, conv, data);
1982}
1983
Linus Torvalds1da177e2005-04-16 15:20:36 -07001984/**
1985 * proc_dointvec - read a vector of integers
1986 * @table: the sysctl table
1987 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988 * @buffer: the user buffer
1989 * @lenp: the size of the user buffer
1990 * @ppos: file position
1991 *
1992 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1993 * values from/to the user buffer, treated as an ASCII string.
1994 *
1995 * Returns 0 on success.
1996 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001997int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998 void __user *buffer, size_t *lenp, loff_t *ppos)
1999{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002000 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001 NULL,NULL);
2002}
2003
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002004/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002005 * Taint values can only be increased
2006 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002007 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002008static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002009 void __user *buffer, size_t *lenp, loff_t *ppos)
2010{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002011 struct ctl_table t;
2012 unsigned long tmptaint = get_taint();
2013 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002014
Bastian Blank91fcd412007-04-23 14:41:14 -07002015 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002016 return -EPERM;
2017
Andi Kleen25ddbb12008-10-15 22:01:41 -07002018 t = *table;
2019 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002020 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002021 if (err < 0)
2022 return err;
2023
2024 if (write) {
2025 /*
2026 * Poor man's atomic or. Not worth adding a primitive
2027 * to everyone's atomic.h for this
2028 */
2029 int i;
2030 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2031 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302032 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002033 }
2034 }
2035
2036 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002037}
2038
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002039#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002040static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002041 void __user *buffer, size_t *lenp, loff_t *ppos)
2042{
2043 if (write && !capable(CAP_SYS_ADMIN))
2044 return -EPERM;
2045
2046 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2047}
2048#endif
2049
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050struct do_proc_dointvec_minmax_conv_param {
2051 int *min;
2052 int *max;
2053};
2054
Amerigo Wang00b7c332010-05-05 00:26:45 +00002055static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2056 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057 int write, void *data)
2058{
2059 struct do_proc_dointvec_minmax_conv_param *param = data;
2060 if (write) {
2061 int val = *negp ? -*lvalp : *lvalp;
2062 if ((param->min && *param->min > val) ||
2063 (param->max && *param->max < val))
2064 return -EINVAL;
2065 *valp = val;
2066 } else {
2067 int val = *valp;
2068 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002069 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002070 *lvalp = (unsigned long)-val;
2071 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002072 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 *lvalp = (unsigned long)val;
2074 }
2075 }
2076 return 0;
2077}
2078
2079/**
2080 * proc_dointvec_minmax - read a vector of integers with min/max values
2081 * @table: the sysctl table
2082 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083 * @buffer: the user buffer
2084 * @lenp: the size of the user buffer
2085 * @ppos: file position
2086 *
2087 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2088 * values from/to the user buffer, treated as an ASCII string.
2089 *
2090 * This routine will ensure the values are within the range specified by
2091 * table->extra1 (min) and table->extra2 (max).
2092 *
2093 * Returns 0 on success.
2094 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002095int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096 void __user *buffer, size_t *lenp, loff_t *ppos)
2097{
2098 struct do_proc_dointvec_minmax_conv_param param = {
2099 .min = (int *) table->extra1,
2100 .max = (int *) table->extra2,
2101 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002102 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 do_proc_dointvec_minmax_conv, &param);
2104}
2105
Kees Cook54b50192012-07-30 14:39:18 -07002106static void validate_coredump_safety(void)
2107{
Alex Kelly046d6622012-10-04 17:15:23 -07002108#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002109 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002110 core_pattern[0] != '/' && core_pattern[0] != '|') {
2111 printk(KERN_WARNING "Unsafe core_pattern used with "\
2112 "suid_dumpable=2. Pipe handler or fully qualified "\
2113 "core dump path required.\n");
2114 }
Alex Kelly046d6622012-10-04 17:15:23 -07002115#endif
Kees Cook54b50192012-07-30 14:39:18 -07002116}
2117
2118static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2119 void __user *buffer, size_t *lenp, loff_t *ppos)
2120{
2121 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2122 if (!error)
2123 validate_coredump_safety();
2124 return error;
2125}
2126
Alex Kelly046d6622012-10-04 17:15:23 -07002127#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002128static int proc_dostring_coredump(struct ctl_table *table, int write,
2129 void __user *buffer, size_t *lenp, loff_t *ppos)
2130{
2131 int error = proc_dostring(table, write, buffer, lenp, ppos);
2132 if (!error)
2133 validate_coredump_safety();
2134 return error;
2135}
Alex Kelly046d6622012-10-04 17:15:23 -07002136#endif
Kees Cook54b50192012-07-30 14:39:18 -07002137
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002138static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139 void __user *buffer,
2140 size_t *lenp, loff_t *ppos,
2141 unsigned long convmul,
2142 unsigned long convdiv)
2143{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002144 unsigned long *i, *min, *max;
2145 int vleft, first = 1, err = 0;
2146 unsigned long page = 0;
2147 size_t left;
2148 char *kbuf;
2149
2150 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002151 *lenp = 0;
2152 return 0;
2153 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002154
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002155 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 min = (unsigned long *) table->extra1;
2157 max = (unsigned long *) table->extra2;
2158 vleft = table->maxlen / sizeof(unsigned long);
2159 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002160
2161 if (write) {
2162 if (left > PAGE_SIZE - 1)
2163 left = PAGE_SIZE - 1;
2164 page = __get_free_page(GFP_TEMPORARY);
2165 kbuf = (char *) page;
2166 if (!kbuf)
2167 return -ENOMEM;
2168 if (copy_from_user(kbuf, buffer, left)) {
2169 err = -EFAULT;
2170 goto free;
2171 }
2172 kbuf[left] = 0;
2173 }
2174
Eric Dumazet27b3d802010-10-07 12:59:29 -07002175 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002176 unsigned long val;
2177
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002179 bool neg;
2180
2181 left -= proc_skip_spaces(&kbuf);
2182
2183 err = proc_get_long(&kbuf, &left, &val, &neg,
2184 proc_wspace_sep,
2185 sizeof(proc_wspace_sep), NULL);
2186 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 break;
2188 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189 continue;
2190 if ((min && val < *min) || (max && val > *max))
2191 continue;
2192 *i = val;
2193 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002196 err = proc_put_char(&buffer, &left, '\t');
2197 err = proc_put_long(&buffer, &left, val, false);
2198 if (err)
2199 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 }
2201 }
2202
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 if (!write && !first && left && !err)
2204 err = proc_put_char(&buffer, &left, '\n');
2205 if (write && !err)
2206 left -= proc_skip_spaces(&kbuf);
2207free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002209 free_page(page);
2210 if (first)
2211 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213 *lenp -= left;
2214 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002215 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216}
2217
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002218static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002219 void __user *buffer,
2220 size_t *lenp, loff_t *ppos,
2221 unsigned long convmul,
2222 unsigned long convdiv)
2223{
2224 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002225 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002226}
2227
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228/**
2229 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2230 * @table: the sysctl table
2231 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 * @buffer: the user buffer
2233 * @lenp: the size of the user buffer
2234 * @ppos: file position
2235 *
2236 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2237 * values from/to the user buffer, treated as an ASCII string.
2238 *
2239 * This routine will ensure the values are within the range specified by
2240 * table->extra1 (min) and table->extra2 (max).
2241 *
2242 * Returns 0 on success.
2243 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002244int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 void __user *buffer, size_t *lenp, loff_t *ppos)
2246{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002247 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248}
2249
2250/**
2251 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2252 * @table: the sysctl table
2253 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254 * @buffer: the user buffer
2255 * @lenp: the size of the user buffer
2256 * @ppos: file position
2257 *
2258 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2259 * values from/to the user buffer, treated as an ASCII string. The values
2260 * are treated as milliseconds, and converted to jiffies when they are stored.
2261 *
2262 * This routine will ensure the values are within the range specified by
2263 * table->extra1 (min) and table->extra2 (max).
2264 *
2265 * Returns 0 on success.
2266 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002267int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 void __user *buffer,
2269 size_t *lenp, loff_t *ppos)
2270{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002271 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 lenp, ppos, HZ, 1000l);
2273}
2274
2275
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 int *valp,
2278 int write, void *data)
2279{
2280 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002281 if (*lvalp > LONG_MAX / HZ)
2282 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2284 } else {
2285 int val = *valp;
2286 unsigned long lval;
2287 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002288 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 lval = (unsigned long)-val;
2290 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002291 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 lval = (unsigned long)val;
2293 }
2294 *lvalp = lval / HZ;
2295 }
2296 return 0;
2297}
2298
Amerigo Wang00b7c332010-05-05 00:26:45 +00002299static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 int *valp,
2301 int write, void *data)
2302{
2303 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002304 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2305 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2307 } else {
2308 int val = *valp;
2309 unsigned long lval;
2310 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002311 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 lval = (unsigned long)-val;
2313 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002314 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 lval = (unsigned long)val;
2316 }
2317 *lvalp = jiffies_to_clock_t(lval);
2318 }
2319 return 0;
2320}
2321
Amerigo Wang00b7c332010-05-05 00:26:45 +00002322static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002323 int *valp,
2324 int write, void *data)
2325{
2326 if (write) {
2327 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2328 } else {
2329 int val = *valp;
2330 unsigned long lval;
2331 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002332 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 lval = (unsigned long)-val;
2334 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 lval = (unsigned long)val;
2337 }
2338 *lvalp = jiffies_to_msecs(lval);
2339 }
2340 return 0;
2341}
2342
2343/**
2344 * proc_dointvec_jiffies - read a vector of integers as seconds
2345 * @table: the sysctl table
2346 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 * @buffer: the user buffer
2348 * @lenp: the size of the user buffer
2349 * @ppos: file position
2350 *
2351 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2352 * values from/to the user buffer, treated as an ASCII string.
2353 * The values read are assumed to be in seconds, and are converted into
2354 * jiffies.
2355 *
2356 * Returns 0 on success.
2357 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002358int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359 void __user *buffer, size_t *lenp, loff_t *ppos)
2360{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002361 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 do_proc_dointvec_jiffies_conv,NULL);
2363}
2364
2365/**
2366 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2367 * @table: the sysctl table
2368 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 * @buffer: the user buffer
2370 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002371 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 *
2373 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2374 * values from/to the user buffer, treated as an ASCII string.
2375 * The values read are assumed to be in 1/USER_HZ seconds, and
2376 * are converted into jiffies.
2377 *
2378 * Returns 0 on success.
2379 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002380int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 void __user *buffer, size_t *lenp, loff_t *ppos)
2382{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002383 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 do_proc_dointvec_userhz_jiffies_conv,NULL);
2385}
2386
2387/**
2388 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2389 * @table: the sysctl table
2390 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 * @buffer: the user buffer
2392 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002393 * @ppos: file position
2394 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 *
2396 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2397 * values from/to the user buffer, treated as an ASCII string.
2398 * The values read are assumed to be in 1/1000 seconds, and
2399 * are converted into jiffies.
2400 *
2401 * Returns 0 on success.
2402 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 void __user *buffer, size_t *lenp, loff_t *ppos)
2405{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002406 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 do_proc_dointvec_ms_jiffies_conv, NULL);
2408}
2409
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002410static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002411 void __user *buffer, size_t *lenp, loff_t *ppos)
2412{
2413 struct pid *new_pid;
2414 pid_t tmp;
2415 int r;
2416
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002417 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002418
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002419 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002420 lenp, ppos, NULL, NULL);
2421 if (r || !write)
2422 return r;
2423
2424 new_pid = find_get_pid(tmp);
2425 if (!new_pid)
2426 return -ESRCH;
2427
2428 put_pid(xchg(&cad_pid, new_pid));
2429 return 0;
2430}
2431
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002432/**
2433 * proc_do_large_bitmap - read/write from/to a large bitmap
2434 * @table: the sysctl table
2435 * @write: %TRUE if this is a write to the sysctl file
2436 * @buffer: the user buffer
2437 * @lenp: the size of the user buffer
2438 * @ppos: file position
2439 *
2440 * The bitmap is stored at table->data and the bitmap length (in bits)
2441 * in table->maxlen.
2442 *
2443 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2444 * large bitmaps may be represented in a compact manner. Writing into
2445 * the file will clear the bitmap then update it with the given input.
2446 *
2447 * Returns 0 on success.
2448 */
2449int proc_do_large_bitmap(struct ctl_table *table, int write,
2450 void __user *buffer, size_t *lenp, loff_t *ppos)
2451{
2452 int err = 0;
2453 bool first = 1;
2454 size_t left = *lenp;
2455 unsigned long bitmap_len = table->maxlen;
2456 unsigned long *bitmap = (unsigned long *) table->data;
2457 unsigned long *tmp_bitmap = NULL;
2458 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2459
2460 if (!bitmap_len || !left || (*ppos && !write)) {
2461 *lenp = 0;
2462 return 0;
2463 }
2464
2465 if (write) {
2466 unsigned long page = 0;
2467 char *kbuf;
2468
2469 if (left > PAGE_SIZE - 1)
2470 left = PAGE_SIZE - 1;
2471
2472 page = __get_free_page(GFP_TEMPORARY);
2473 kbuf = (char *) page;
2474 if (!kbuf)
2475 return -ENOMEM;
2476 if (copy_from_user(kbuf, buffer, left)) {
2477 free_page(page);
2478 return -EFAULT;
2479 }
2480 kbuf[left] = 0;
2481
2482 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2483 GFP_KERNEL);
2484 if (!tmp_bitmap) {
2485 free_page(page);
2486 return -ENOMEM;
2487 }
2488 proc_skip_char(&kbuf, &left, '\n');
2489 while (!err && left) {
2490 unsigned long val_a, val_b;
2491 bool neg;
2492
2493 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2494 sizeof(tr_a), &c);
2495 if (err)
2496 break;
2497 if (val_a >= bitmap_len || neg) {
2498 err = -EINVAL;
2499 break;
2500 }
2501
2502 val_b = val_a;
2503 if (left) {
2504 kbuf++;
2505 left--;
2506 }
2507
2508 if (c == '-') {
2509 err = proc_get_long(&kbuf, &left, &val_b,
2510 &neg, tr_b, sizeof(tr_b),
2511 &c);
2512 if (err)
2513 break;
2514 if (val_b >= bitmap_len || neg ||
2515 val_a > val_b) {
2516 err = -EINVAL;
2517 break;
2518 }
2519 if (left) {
2520 kbuf++;
2521 left--;
2522 }
2523 }
2524
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002525 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002526 first = 0;
2527 proc_skip_char(&kbuf, &left, '\n');
2528 }
2529 free_page(page);
2530 } else {
2531 unsigned long bit_a, bit_b = 0;
2532
2533 while (left) {
2534 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2535 if (bit_a >= bitmap_len)
2536 break;
2537 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2538 bit_a + 1) - 1;
2539
2540 if (!first) {
2541 err = proc_put_char(&buffer, &left, ',');
2542 if (err)
2543 break;
2544 }
2545 err = proc_put_long(&buffer, &left, bit_a, false);
2546 if (err)
2547 break;
2548 if (bit_a != bit_b) {
2549 err = proc_put_char(&buffer, &left, '-');
2550 if (err)
2551 break;
2552 err = proc_put_long(&buffer, &left, bit_b, false);
2553 if (err)
2554 break;
2555 }
2556
2557 first = 0; bit_b++;
2558 }
2559 if (!err)
2560 err = proc_put_char(&buffer, &left, '\n');
2561 }
2562
2563 if (!err) {
2564 if (write) {
2565 if (*ppos)
2566 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2567 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002568 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002569 }
2570 kfree(tmp_bitmap);
2571 *lenp -= left;
2572 *ppos += *lenp;
2573 return 0;
2574 } else {
2575 kfree(tmp_bitmap);
2576 return err;
2577 }
2578}
2579
Jovi Zhang55610502011-01-12 17:00:45 -08002580#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002582int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 void __user *buffer, size_t *lenp, loff_t *ppos)
2584{
2585 return -ENOSYS;
2586}
2587
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002588int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589 void __user *buffer, size_t *lenp, loff_t *ppos)
2590{
2591 return -ENOSYS;
2592}
2593
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002594int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 void __user *buffer, size_t *lenp, loff_t *ppos)
2596{
2597 return -ENOSYS;
2598}
2599
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002600int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 void __user *buffer, size_t *lenp, loff_t *ppos)
2602{
2603 return -ENOSYS;
2604}
2605
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002606int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 void __user *buffer, size_t *lenp, loff_t *ppos)
2608{
2609 return -ENOSYS;
2610}
2611
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002612int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 void __user *buffer, size_t *lenp, loff_t *ppos)
2614{
2615 return -ENOSYS;
2616}
2617
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002618int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 void __user *buffer, size_t *lenp, loff_t *ppos)
2620{
2621 return -ENOSYS;
2622}
2623
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002624int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 void __user *buffer,
2626 size_t *lenp, loff_t *ppos)
2627{
2628 return -ENOSYS;
2629}
2630
2631
Jovi Zhang55610502011-01-12 17:00:45 -08002632#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634/*
2635 * No sense putting this after each symbol definition, twice,
2636 * exception granted :-)
2637 */
2638EXPORT_SYMBOL(proc_dointvec);
2639EXPORT_SYMBOL(proc_dointvec_jiffies);
2640EXPORT_SYMBOL(proc_dointvec_minmax);
2641EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2642EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2643EXPORT_SYMBOL(proc_dostring);
2644EXPORT_SYMBOL(proc_doulongvec_minmax);
2645EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);