blob: c2a2f8084bad0c95fbfc77ec08b2ee806d338097 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#include <asm/uaccess.h>
66#include <asm/processor.h>
67
Andi Kleen29cbc782006-09-30 01:47:55 +020068#ifdef CONFIG_X86
69#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010070#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010071#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020072#endif
David Howellsd550bbd2012-03-28 18:30:03 +010073#ifdef CONFIG_SPARC
74#include <asm/setup.h>
75#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080076#ifdef CONFIG_BSD_PROCESS_ACCT
77#include <linux/acct.h>
78#endif
Dave Young4f0e0562010-03-10 15:24:09 -080079#ifdef CONFIG_RT_MUTEXES
80#include <linux/rtmutex.h>
81#endif
Dave Young2edf5e42010-03-10 15:24:10 -080082#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
83#include <linux/lockdep.h>
84#endif
Dave Young15485a42010-03-10 15:24:07 -080085#ifdef CONFIG_CHR_DEV_SG
86#include <scsi/sg.h>
87#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020088
Don Zickus58687ac2010-05-07 17:11:44 -040089#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050090#include <linux/nmi.h>
91#endif
92
Eric W. Biederman7058cb02007-10-18 03:05:58 -070093
Linus Torvalds1da177e2005-04-16 15:20:36 -070094#if defined(CONFIG_SYSCTL)
95
96/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern int sysctl_overcommit_memory;
98extern int sysctl_overcommit_ratio;
99extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700100extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700101#ifdef CONFIG_COREDUMP
102extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700104extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700105#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max;
107extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800109extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200111extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100112extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400113extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000114#ifndef CONFIG_MMU
115extern int sysctl_nr_trim_pages;
116#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200117#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200118extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400122#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200124static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125#endif
126
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700127static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700128static int __maybe_unused one = 1;
129static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700130static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800131static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800143static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Dave Youngd14f1722010-02-25 20:28:57 -0500148#ifdef CONFIG_INOTIFY_USER
149#include <linux/inotify.h>
150#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700151#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif
153
David S. Miller08714202008-11-16 23:49:24 -0800154#ifdef CONFIG_SPARC64
155extern int sysctl_tsb_ratio;
156#endif
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#ifdef __hppa__
159extern int pwrsw_enabled;
160extern int unaligned_enabled;
161#endif
162
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#ifdef CONFIG_IA64
164extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800165extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#endif
167
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700168#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700169static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700170 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700171static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800172 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700173#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700174
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700175#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700176static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700177 void __user *buffer, size_t *lenp, loff_t *ppos);
178#endif
179
Kees Cook54b50192012-07-30 14:39:18 -0700180static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
181 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700182#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700183static int proc_dostring_coredump(struct ctl_table *table, int write,
184 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700185#endif
Kees Cook54b50192012-07-30 14:39:18 -0700186
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700187#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800188/* Note: sysrq code uses it's own private copy */
189static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700190
191static int sysrq_sysctl_handler(ctl_table *table, int write,
192 void __user *buffer, size_t *lenp,
193 loff_t *ppos)
194{
195 int error;
196
197 error = proc_dointvec(table, write, buffer, lenp, ppos);
198 if (error)
199 return error;
200
201 if (write)
202 sysrq_toggle_support(__sysrq_enabled);
203
204 return 0;
205}
206
207#endif
208
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700209static struct ctl_table kern_table[];
210static struct ctl_table vm_table[];
211static struct ctl_table fs_table[];
212static struct ctl_table debug_table[];
213static struct ctl_table dev_table[];
214extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800215#ifdef CONFIG_EPOLL
216extern struct ctl_table epoll_table[];
217#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
220int sysctl_legacy_va_layout;
221#endif
222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223/* The default sysctl tables: */
224
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800225static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 .procname = "kernel",
228 .mode = 0555,
229 .child = kern_table,
230 },
231 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 .procname = "vm",
233 .mode = 0555,
234 .child = vm_table,
235 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 .procname = "fs",
238 .mode = 0555,
239 .child = fs_table,
240 },
241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .procname = "debug",
243 .mode = 0555,
244 .child = debug_table,
245 },
246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .procname = "dev",
248 .mode = 0555,
249 .child = dev_table,
250 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700251 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252};
253
Ingo Molnar77e54a12007-07-09 18:52:00 +0200254#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100255static int min_sched_granularity_ns = 100000; /* 100 usecs */
256static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
257static int min_wakeup_granularity_ns; /* 0 usecs */
258static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100259static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
260static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200261#endif
262
Mel Gorman5e771902010-05-24 14:32:31 -0700263#ifdef CONFIG_COMPACTION
264static int min_extfrag_threshold;
265static int max_extfrag_threshold = 1000;
266#endif
267
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700268static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200269 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200270 .procname = "sched_child_runs_first",
271 .data = &sysctl_sched_child_runs_first,
272 .maxlen = sizeof(unsigned int),
273 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800274 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200275 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200276#ifdef CONFIG_SCHED_DEBUG
277 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100278 .procname = "sched_min_granularity_ns",
279 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280 .maxlen = sizeof(unsigned int),
281 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800282 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100283 .extra1 = &min_sched_granularity_ns,
284 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285 },
286 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200287 .procname = "sched_latency_ns",
288 .data = &sysctl_sched_latency,
289 .maxlen = sizeof(unsigned int),
290 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800291 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200292 .extra1 = &min_sched_granularity_ns,
293 .extra2 = &max_sched_granularity_ns,
294 },
295 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200296 .procname = "sched_wakeup_granularity_ns",
297 .data = &sysctl_sched_wakeup_granularity,
298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800300 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200301 .extra1 = &min_wakeup_granularity_ns,
302 .extra2 = &max_wakeup_granularity_ns,
303 },
304 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100305 .procname = "sched_tunable_scaling",
306 .data = &sysctl_sched_tunable_scaling,
307 .maxlen = sizeof(enum sched_tunable_scaling),
308 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800309 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100310 .extra1 = &min_sched_tunable_scaling,
311 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200312 },
313 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900314 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200315 .data = &sysctl_sched_migration_cost,
316 .maxlen = sizeof(unsigned int),
317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800318 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200319 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100320 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100321 .procname = "sched_nr_migrate",
322 .data = &sysctl_sched_nr_migrate,
323 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800325 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100326 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530327 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900328 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200329 .data = &sysctl_sched_time_avg,
330 .maxlen = sizeof(unsigned int),
331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800332 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200333 },
334 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900335 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800336 .data = &sysctl_sched_shares_window,
337 .maxlen = sizeof(unsigned int),
338 .mode = 0644,
339 .proc_handler = proc_dointvec,
340 },
341 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530342 .procname = "timer_migration",
343 .data = &sysctl_timer_migration,
344 .maxlen = sizeof(unsigned int),
345 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800346 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530347 .extra1 = &zero,
348 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530349 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200350#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200351 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100352 .procname = "sched_rt_period_us",
353 .data = &sysctl_sched_rt_period,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800356 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100357 },
358 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100359 .procname = "sched_rt_runtime_us",
360 .data = &sysctl_sched_rt_runtime,
361 .maxlen = sizeof(int),
362 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800363 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100364 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100365#ifdef CONFIG_SCHED_AUTOGROUP
366 {
367 .procname = "sched_autogroup_enabled",
368 .data = &sysctl_sched_autogroup_enabled,
369 .maxlen = sizeof(unsigned int),
370 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800371 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100372 .extra1 = &zero,
373 .extra2 = &one,
374 },
375#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700376#ifdef CONFIG_CFS_BANDWIDTH
377 {
378 .procname = "sched_cfs_bandwidth_slice_us",
379 .data = &sysctl_sched_cfs_bandwidth_slice,
380 .maxlen = sizeof(unsigned int),
381 .mode = 0644,
382 .proc_handler = proc_dointvec_minmax,
383 .extra1 = &one,
384 },
385#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700386#ifdef CONFIG_PROVE_LOCKING
387 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700388 .procname = "prove_locking",
389 .data = &prove_locking,
390 .maxlen = sizeof(int),
391 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800392 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700393 },
394#endif
395#ifdef CONFIG_LOCK_STAT
396 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700397 .procname = "lock_stat",
398 .data = &lock_stat,
399 .maxlen = sizeof(int),
400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700402 },
403#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200404 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 .procname = "panic",
406 .data = &panic_timeout,
407 .maxlen = sizeof(int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 },
Alex Kelly046d6622012-10-04 17:15:23 -0700411#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 .procname = "core_uses_pid",
414 .data = &core_uses_pid,
415 .maxlen = sizeof(int),
416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800417 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 },
419 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 .procname = "core_pattern",
421 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700422 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700424 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 },
Neil Hormana2939802009-09-23 15:56:56 -0700426 {
Neil Hormana2939802009-09-23 15:56:56 -0700427 .procname = "core_pipe_limit",
428 .data = &core_pipe_limit,
429 .maxlen = sizeof(unsigned int),
430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800431 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700432 },
Alex Kelly046d6622012-10-04 17:15:23 -0700433#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800434#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700437 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800439 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800441#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100442#ifdef CONFIG_LATENCYTOP
443 {
444 .procname = "latencytop",
445 .data = &latencytop_enabled,
446 .maxlen = sizeof(int),
447 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800448 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100449 },
450#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451#ifdef CONFIG_BLK_DEV_INITRD
452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 .procname = "real-root-dev",
454 .data = &real_root_dev,
455 .maxlen = sizeof(int),
456 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800457 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 },
459#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700460 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700461 .procname = "print-fatal-signals",
462 .data = &print_fatal_signals,
463 .maxlen = sizeof(int),
464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800465 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700466 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700467#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 .procname = "reboot-cmd",
470 .data = reboot_command,
471 .maxlen = 256,
472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800473 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 },
475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 .procname = "stop-a",
477 .data = &stop_a_enabled,
478 .maxlen = sizeof (int),
479 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800480 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 },
482 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 .procname = "scons-poweroff",
484 .data = &scons_pwroff,
485 .maxlen = sizeof (int),
486 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800487 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 },
489#endif
David S. Miller08714202008-11-16 23:49:24 -0800490#ifdef CONFIG_SPARC64
491 {
David S. Miller08714202008-11-16 23:49:24 -0800492 .procname = "tsb-ratio",
493 .data = &sysctl_tsb_ratio,
494 .maxlen = sizeof (int),
495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800496 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800497 },
498#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499#ifdef __hppa__
500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 .procname = "soft-power",
502 .data = &pwrsw_enabled,
503 .maxlen = sizeof (int),
504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 },
507 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 .procname = "unaligned-trap",
509 .data = &unaligned_enabled,
510 .maxlen = sizeof (int),
511 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800512 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 },
514#endif
515 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 .procname = "ctrl-alt-del",
517 .data = &C_A_D,
518 .maxlen = sizeof(int),
519 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800520 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400522#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200523 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200524 .procname = "ftrace_enabled",
525 .data = &ftrace_enabled,
526 .maxlen = sizeof(int),
527 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800528 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200529 },
530#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500531#ifdef CONFIG_STACK_TRACER
532 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500533 .procname = "stack_tracer_enabled",
534 .data = &stack_tracer_enabled,
535 .maxlen = sizeof(int),
536 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800537 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500538 },
539#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400540#ifdef CONFIG_TRACING
541 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100542 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400543 .data = &ftrace_dump_on_oops,
544 .maxlen = sizeof(int),
545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400547 },
548#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200549#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 .procname = "modprobe",
552 .data = &modprobe_path,
553 .maxlen = KMOD_PATH_LEN,
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 },
Kees Cook3d433212009-04-02 15:49:29 -0700557 {
Kees Cook3d433212009-04-02 15:49:29 -0700558 .procname = "modules_disabled",
559 .data = &modules_disabled,
560 .maxlen = sizeof(int),
561 .mode = 0644,
562 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800563 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700564 .extra1 = &one,
565 .extra2 = &one,
566 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100568#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100571 .data = &uevent_helper,
572 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 },
576#endif
577#ifdef CONFIG_CHR_DEV_SG
578 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .procname = "sg-big-buff",
580 .data = &sg_big_buff,
581 .maxlen = sizeof (int),
582 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 },
585#endif
586#ifdef CONFIG_BSD_PROCESS_ACCT
587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 .procname = "acct",
589 .data = &acct_parm,
590 .maxlen = 3*sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 },
594#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595#ifdef CONFIG_MAGIC_SYSRQ
596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800598 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .maxlen = sizeof (int),
600 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700601 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 },
603#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700604#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700607 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 .maxlen = sizeof (int),
609 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700612#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "threads-max",
615 .data = &max_threads,
616 .maxlen = sizeof(int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 },
620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .procname = "random",
622 .mode = 0555,
623 .child = random_table,
624 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 {
Eric Paris17f60a72011-04-01 17:07:50 -0400626 .procname = "usermodehelper",
627 .mode = 0555,
628 .child = usermodehelper_table,
629 },
630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .procname = "overflowuid",
632 .data = &overflowuid,
633 .maxlen = sizeof(int),
634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800635 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 .extra1 = &minolduid,
637 .extra2 = &maxolduid,
638 },
639 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .procname = "overflowgid",
641 .data = &overflowgid,
642 .maxlen = sizeof(int),
643 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800644 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 .extra1 = &minolduid,
646 .extra2 = &maxolduid,
647 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800648#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649#ifdef CONFIG_MATHEMU
650 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .procname = "ieee_emulation_warnings",
652 .data = &sysctl_ieee_emulation_warnings,
653 .maxlen = sizeof(int),
654 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800655 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 },
657#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200660 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .maxlen = sizeof(int),
662 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800663 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 },
665#endif
666 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .procname = "pid_max",
668 .data = &pid_max,
669 .maxlen = sizeof (int),
670 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800671 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .extra1 = &pid_max_min,
673 .extra2 = &pid_max_max,
674 },
675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "panic_on_oops",
677 .data = &panic_on_oops,
678 .maxlen = sizeof(int),
679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800682#if defined CONFIG_PRINTK
683 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800684 .procname = "printk",
685 .data = &console_loglevel,
686 .maxlen = 4*sizeof(int),
687 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800688 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800689 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700692 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .maxlen = sizeof(int),
694 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800695 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 },
697 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700699 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .maxlen = sizeof(int),
701 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800702 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 },
Dave Youngaf913222009-09-22 16:43:33 -0700704 {
Dave Youngaf913222009-09-22 16:43:33 -0700705 .procname = "printk_delay",
706 .data = &printk_delay_msec,
707 .maxlen = sizeof(int),
708 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800709 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700710 .extra1 = &zero,
711 .extra2 = &ten_thousand,
712 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800714 .procname = "dmesg_restrict",
715 .data = &dmesg_restrict,
716 .maxlen = sizeof(int),
717 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700718 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800719 .extra1 = &zero,
720 .extra2 = &one,
721 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800722 {
723 .procname = "kptr_restrict",
724 .data = &kptr_restrict,
725 .maxlen = sizeof(int),
726 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700727 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800728 .extra1 = &zero,
729 .extra2 = &two,
730 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800731#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800732 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 .procname = "ngroups_max",
734 .data = &ngroups_max,
735 .maxlen = sizeof (int),
736 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800737 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 },
Dan Ballard73efc032011-10-31 17:11:20 -0700739 {
740 .procname = "cap_last_cap",
741 .data = (void *)&cap_last_cap,
742 .maxlen = sizeof(int),
743 .mode = 0444,
744 .proc_handler = proc_dointvec,
745 },
Don Zickus58687ac2010-05-07 17:11:44 -0400746#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500747 {
Don Zickus58687ac2010-05-07 17:11:44 -0400748 .procname = "watchdog",
749 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500750 .maxlen = sizeof (int),
751 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700752 .proc_handler = proc_dowatchdog,
753 .extra1 = &zero,
754 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400755 },
756 {
757 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700758 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400759 .maxlen = sizeof(int),
760 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700761 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400762 .extra1 = &neg_one,
763 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500764 },
Don Zickus2508ce12010-05-07 17:11:46 -0400765 {
766 .procname = "softlockup_panic",
767 .data = &softlockup_panic,
768 .maxlen = sizeof(int),
769 .mode = 0644,
770 .proc_handler = proc_dointvec_minmax,
771 .extra1 = &zero,
772 .extra2 = &one,
773 },
Don Zickus5dc30552010-11-29 17:07:17 -0500774 {
775 .procname = "nmi_watchdog",
776 .data = &watchdog_enabled,
777 .maxlen = sizeof (int),
778 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700779 .proc_handler = proc_dowatchdog,
780 .extra1 = &zero,
781 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500782 },
783#endif
784#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
785 {
786 .procname = "unknown_nmi_panic",
787 .data = &unknown_nmi_panic,
788 .maxlen = sizeof (int),
789 .mode = 0644,
790 .proc_handler = proc_dointvec,
791 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500792#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793#if defined(CONFIG_X86)
794 {
Don Zickus8da5add2006-09-26 10:52:27 +0200795 .procname = "panic_on_unrecovered_nmi",
796 .data = &panic_on_unrecovered_nmi,
797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200800 },
801 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700802 .procname = "panic_on_io_nmi",
803 .data = &panic_on_io_nmi,
804 .maxlen = sizeof(int),
805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700807 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900808#ifdef CONFIG_DEBUG_STACKOVERFLOW
809 {
810 .procname = "panic_on_stackoverflow",
811 .data = &sysctl_panic_on_stackoverflow,
812 .maxlen = sizeof(int),
813 .mode = 0644,
814 .proc_handler = proc_dointvec,
815 },
816#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700817 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 .procname = "bootloader_type",
819 .data = &bootloader_type,
820 .maxlen = sizeof (int),
821 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800822 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100824 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700825 .procname = "bootloader_version",
826 .data = &bootloader_version,
827 .maxlen = sizeof (int),
828 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800829 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700830 },
831 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100832 .procname = "kstack_depth_to_print",
833 .data = &kstack_depth_to_print,
834 .maxlen = sizeof(int),
835 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800836 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100837 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100838 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100839 .procname = "io_delay_type",
840 .data = &io_delay_type,
841 .maxlen = sizeof(int),
842 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800843 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100844 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800846#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 .procname = "randomize_va_space",
849 .data = &randomize_va_space,
850 .maxlen = sizeof(int),
851 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800852 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800854#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800855#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700856 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700857 .procname = "spin_retry",
858 .data = &spin_retry,
859 .maxlen = sizeof (int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700862 },
863#endif
Len Brown673d5b42007-07-28 03:33:16 -0400864#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800865 {
Pavel Machekc255d842006-02-20 18:27:58 -0800866 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700867 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800868 .maxlen = sizeof (unsigned long),
869 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800870 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800871 },
872#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800873#ifdef CONFIG_IA64
874 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800875 .procname = "ignore-unaligned-usertrap",
876 .data = &no_unaligned_warning,
877 .maxlen = sizeof (int),
878 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800879 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800880 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800881 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800882 .procname = "unaligned-dump-stack",
883 .data = &unaligned_dump_stack,
884 .maxlen = sizeof (int),
885 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800886 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800887 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800888#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800889#ifdef CONFIG_DETECT_HUNG_TASK
890 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800891 .procname = "hung_task_panic",
892 .data = &sysctl_hung_task_panic,
893 .maxlen = sizeof(int),
894 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800895 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800896 .extra1 = &zero,
897 .extra2 = &one,
898 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100899 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100900 .procname = "hung_task_check_count",
901 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100902 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100905 },
906 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100907 .procname = "hung_task_timeout_secs",
908 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100909 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100910 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800911 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100912 },
913 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100914 .procname = "hung_task_warnings",
915 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100916 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100917 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800918 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100919 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700920#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200921#ifdef CONFIG_COMPAT
922 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200923 .procname = "compat-log",
924 .data = &compat_log,
925 .maxlen = sizeof (int),
926 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800927 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200928 },
929#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700930#ifdef CONFIG_RT_MUTEXES
931 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700932 .procname = "max_lock_depth",
933 .data = &max_lock_depth,
934 .maxlen = sizeof(int),
935 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800936 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700937 },
938#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700939 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700940 .procname = "poweroff_cmd",
941 .data = &poweroff_cmd,
942 .maxlen = POWEROFF_CMD_PATH_LEN,
943 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800944 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700945 },
David Howells0b77f5b2008-04-29 01:01:32 -0700946#ifdef CONFIG_KEYS
947 {
David Howells0b77f5b2008-04-29 01:01:32 -0700948 .procname = "keys",
949 .mode = 0555,
950 .child = key_sysctls,
951 },
952#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700953#ifdef CONFIG_RCU_TORTURE_TEST
954 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700955 .procname = "rcutorture_runnable",
956 .data = &rcutorture_runnable,
957 .maxlen = sizeof(int),
958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700960 },
961#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200962#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400963 /*
964 * User-space scripts rely on the existence of this file
965 * as a feature check for perf_events being enabled.
966 *
967 * So it's an ABI, do not remove!
968 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200969 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200970 .procname = "perf_event_paranoid",
971 .data = &sysctl_perf_event_paranoid,
972 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200973 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800974 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200975 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200976 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200977 .procname = "perf_event_mlock_kb",
978 .data = &sysctl_perf_event_mlock,
979 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200980 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800981 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200982 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200983 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200984 .procname = "perf_event_max_sample_rate",
985 .data = &sysctl_perf_event_sample_rate,
986 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200987 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100988 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200989 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200990#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200991#ifdef CONFIG_KMEMCHECK
992 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200993 .procname = "kmemcheck",
994 .data = &kmemcheck_enabled,
995 .maxlen = sizeof(int),
996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200998 },
999#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001000#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001001 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001002 .procname = "blk_iopoll",
1003 .data = &blk_iopoll_enabled,
1004 .maxlen = sizeof(int),
1005 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001006 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001007 },
Jens Axboecb684b52009-09-15 21:53:11 +02001008#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001009 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010};
1011
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001012static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 .procname = "overcommit_memory",
1015 .data = &sysctl_overcommit_memory,
1016 .maxlen = sizeof(sysctl_overcommit_memory),
1017 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001018 .proc_handler = proc_dointvec_minmax,
1019 .extra1 = &zero,
1020 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 },
1022 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001023 .procname = "panic_on_oom",
1024 .data = &sysctl_panic_on_oom,
1025 .maxlen = sizeof(sysctl_panic_on_oom),
1026 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001027 .proc_handler = proc_dointvec_minmax,
1028 .extra1 = &zero,
1029 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001030 },
1031 {
David Rientjesfe071d72007-10-16 23:25:56 -07001032 .procname = "oom_kill_allocating_task",
1033 .data = &sysctl_oom_kill_allocating_task,
1034 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1035 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001036 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001037 },
1038 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001039 .procname = "oom_dump_tasks",
1040 .data = &sysctl_oom_dump_tasks,
1041 .maxlen = sizeof(sysctl_oom_dump_tasks),
1042 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001043 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001044 },
1045 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 .procname = "overcommit_ratio",
1047 .data = &sysctl_overcommit_ratio,
1048 .maxlen = sizeof(sysctl_overcommit_ratio),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 },
1052 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 .procname = "page-cluster",
1054 .data = &page_cluster,
1055 .maxlen = sizeof(int),
1056 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001057 .proc_handler = proc_dointvec_minmax,
1058 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 },
1060 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 .procname = "dirty_background_ratio",
1062 .data = &dirty_background_ratio,
1063 .maxlen = sizeof(dirty_background_ratio),
1064 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001065 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 .extra1 = &zero,
1067 .extra2 = &one_hundred,
1068 },
1069 {
David Rientjes2da02992009-01-06 14:39:31 -08001070 .procname = "dirty_background_bytes",
1071 .data = &dirty_background_bytes,
1072 .maxlen = sizeof(dirty_background_bytes),
1073 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001074 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001075 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001076 },
1077 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 .procname = "dirty_ratio",
1079 .data = &vm_dirty_ratio,
1080 .maxlen = sizeof(vm_dirty_ratio),
1081 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001082 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 .extra1 = &zero,
1084 .extra2 = &one_hundred,
1085 },
1086 {
David Rientjes2da02992009-01-06 14:39:31 -08001087 .procname = "dirty_bytes",
1088 .data = &vm_dirty_bytes,
1089 .maxlen = sizeof(vm_dirty_bytes),
1090 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001091 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001092 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001093 },
1094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001096 .data = &dirty_writeback_interval,
1097 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 },
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001103 .data = &dirty_expire_interval,
1104 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001106 .proc_handler = proc_dointvec_minmax,
1107 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 },
1109 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001110 .procname = "nr_pdflush_threads",
1111 .mode = 0444 /* read-only */,
1112 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 },
1114 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .procname = "swappiness",
1116 .data = &vm_swappiness,
1117 .maxlen = sizeof(vm_swappiness),
1118 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001119 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 .extra1 = &zero,
1121 .extra2 = &one_hundred,
1122 },
1123#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001124 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001126 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 .maxlen = sizeof(unsigned long),
1128 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001129 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 .extra1 = (void *)&hugetlb_zero,
1131 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001132 },
1133#ifdef CONFIG_NUMA
1134 {
1135 .procname = "nr_hugepages_mempolicy",
1136 .data = NULL,
1137 .maxlen = sizeof(unsigned long),
1138 .mode = 0644,
1139 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1140 .extra1 = (void *)&hugetlb_zero,
1141 .extra2 = (void *)&hugetlb_infinity,
1142 },
1143#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 .procname = "hugetlb_shm_group",
1146 .data = &sysctl_hugetlb_shm_group,
1147 .maxlen = sizeof(gid_t),
1148 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001149 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 },
Mel Gorman396faf02007-07-17 04:03:13 -07001151 {
Mel Gorman396faf02007-07-17 04:03:13 -07001152 .procname = "hugepages_treat_as_movable",
1153 .data = &hugepages_treat_as_movable,
1154 .maxlen = sizeof(int),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001157 },
Adam Litke54f9f802007-10-16 01:26:20 -07001158 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001159 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001160 .data = NULL,
1161 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001164 .extra1 = (void *)&hugetlb_zero,
1165 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001166 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167#endif
1168 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .procname = "lowmem_reserve_ratio",
1170 .data = &sysctl_lowmem_reserve_ratio,
1171 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1172 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001173 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 },
1175 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001176 .procname = "drop_caches",
1177 .data = &sysctl_drop_caches,
1178 .maxlen = sizeof(int),
1179 .mode = 0644,
1180 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001181 .extra1 = &one,
1182 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001183 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001184#ifdef CONFIG_COMPACTION
1185 {
1186 .procname = "compact_memory",
1187 .data = &sysctl_compact_memory,
1188 .maxlen = sizeof(int),
1189 .mode = 0200,
1190 .proc_handler = sysctl_compaction_handler,
1191 },
Mel Gorman5e771902010-05-24 14:32:31 -07001192 {
1193 .procname = "extfrag_threshold",
1194 .data = &sysctl_extfrag_threshold,
1195 .maxlen = sizeof(int),
1196 .mode = 0644,
1197 .proc_handler = sysctl_extfrag_handler,
1198 .extra1 = &min_extfrag_threshold,
1199 .extra2 = &max_extfrag_threshold,
1200 },
1201
Mel Gorman76ab0f52010-05-24 14:32:28 -07001202#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001203 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 .procname = "min_free_kbytes",
1205 .data = &min_free_kbytes,
1206 .maxlen = sizeof(min_free_kbytes),
1207 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001208 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 .extra1 = &zero,
1210 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001211 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001212 .procname = "percpu_pagelist_fraction",
1213 .data = &percpu_pagelist_fraction,
1214 .maxlen = sizeof(percpu_pagelist_fraction),
1215 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001216 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001217 .extra1 = &min_percpu_pagelist_fract,
1218 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219#ifdef CONFIG_MMU
1220 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 .procname = "max_map_count",
1222 .data = &sysctl_max_map_count,
1223 .maxlen = sizeof(sysctl_max_map_count),
1224 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001225 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001226 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001228#else
1229 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001230 .procname = "nr_trim_pages",
1231 .data = &sysctl_nr_trim_pages,
1232 .maxlen = sizeof(sysctl_nr_trim_pages),
1233 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001234 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001235 .extra1 = &zero,
1236 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237#endif
1238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 .procname = "laptop_mode",
1240 .data = &laptop_mode,
1241 .maxlen = sizeof(laptop_mode),
1242 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001243 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244 },
1245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 .procname = "block_dump",
1247 .data = &block_dump,
1248 .maxlen = sizeof(block_dump),
1249 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001250 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251 .extra1 = &zero,
1252 },
1253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 .procname = "vfs_cache_pressure",
1255 .data = &sysctl_vfs_cache_pressure,
1256 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1257 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001258 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 .extra1 = &zero,
1260 },
1261#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 .procname = "legacy_va_layout",
1264 .data = &sysctl_legacy_va_layout,
1265 .maxlen = sizeof(sysctl_legacy_va_layout),
1266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 .extra1 = &zero,
1269 },
1270#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001271#ifdef CONFIG_NUMA
1272 {
Christoph Lameter17436602006-01-18 17:42:32 -08001273 .procname = "zone_reclaim_mode",
1274 .data = &zone_reclaim_mode,
1275 .maxlen = sizeof(zone_reclaim_mode),
1276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001277 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001278 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001279 },
Christoph Lameter96146342006-07-03 00:24:13 -07001280 {
Christoph Lameter96146342006-07-03 00:24:13 -07001281 .procname = "min_unmapped_ratio",
1282 .data = &sysctl_min_unmapped_ratio,
1283 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001285 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001286 .extra1 = &zero,
1287 .extra2 = &one_hundred,
1288 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001289 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001290 .procname = "min_slab_ratio",
1291 .data = &sysctl_min_slab_ratio,
1292 .maxlen = sizeof(sysctl_min_slab_ratio),
1293 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001294 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001295 .extra1 = &zero,
1296 .extra2 = &one_hundred,
1297 },
Christoph Lameter17436602006-01-18 17:42:32 -08001298#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001299#ifdef CONFIG_SMP
1300 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001301 .procname = "stat_interval",
1302 .data = &sysctl_stat_interval,
1303 .maxlen = sizeof(sysctl_stat_interval),
1304 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001305 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001306 },
1307#endif
David Howells6e141542009-12-15 19:27:45 +00001308#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001309 {
Eric Parised032182007-06-28 15:55:21 -04001310 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001311 .data = &dac_mmap_min_addr,
1312 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001313 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001314 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001315 },
David Howells6e141542009-12-15 19:27:45 +00001316#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001317#ifdef CONFIG_NUMA
1318 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001319 .procname = "numa_zonelist_order",
1320 .data = &numa_zonelist_order,
1321 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001323 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001324 },
1325#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001326#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001327 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001328 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001329 .procname = "vdso_enabled",
1330 .data = &vdso_enabled,
1331 .maxlen = sizeof(vdso_enabled),
1332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001333 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001334 .extra1 = &zero,
1335 },
1336#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001337#ifdef CONFIG_HIGHMEM
1338 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001339 .procname = "highmem_is_dirtyable",
1340 .data = &vm_highmem_is_dirtyable,
1341 .maxlen = sizeof(vm_highmem_is_dirtyable),
1342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001344 .extra1 = &zero,
1345 .extra2 = &one,
1346 },
1347#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001348 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001349 .procname = "scan_unevictable_pages",
1350 .data = &scan_unevictable_pages,
1351 .maxlen = sizeof(scan_unevictable_pages),
1352 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001353 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001354 },
Andi Kleen6a460792009-09-16 11:50:15 +02001355#ifdef CONFIG_MEMORY_FAILURE
1356 {
Andi Kleen6a460792009-09-16 11:50:15 +02001357 .procname = "memory_failure_early_kill",
1358 .data = &sysctl_memory_failure_early_kill,
1359 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1360 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001361 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001362 .extra1 = &zero,
1363 .extra2 = &one,
1364 },
1365 {
Andi Kleen6a460792009-09-16 11:50:15 +02001366 .procname = "memory_failure_recovery",
1367 .data = &sysctl_memory_failure_recovery,
1368 .maxlen = sizeof(sysctl_memory_failure_recovery),
1369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001371 .extra1 = &zero,
1372 .extra2 = &one,
1373 },
1374#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001375 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376};
1377
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001378#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001379static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001380 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001381};
1382#endif
1383
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001384static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 .procname = "inode-nr",
1387 .data = &inodes_stat,
1388 .maxlen = 2*sizeof(int),
1389 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001390 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 },
1392 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 .procname = "inode-state",
1394 .data = &inodes_stat,
1395 .maxlen = 7*sizeof(int),
1396 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001397 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 },
1399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 .procname = "file-nr",
1401 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001402 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001404 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 },
1406 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 .procname = "file-max",
1408 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001409 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001411 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412 },
1413 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001414 .procname = "nr_open",
1415 .data = &sysctl_nr_open,
1416 .maxlen = sizeof(int),
1417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001419 .extra1 = &sysctl_nr_open_min,
1420 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001421 },
1422 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 .procname = "dentry-state",
1424 .data = &dentry_stat,
1425 .maxlen = 6*sizeof(int),
1426 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001427 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 },
1429 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 .procname = "overflowuid",
1431 .data = &fs_overflowuid,
1432 .maxlen = sizeof(int),
1433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001434 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 .extra1 = &minolduid,
1436 .extra2 = &maxolduid,
1437 },
1438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .procname = "overflowgid",
1440 .data = &fs_overflowgid,
1441 .maxlen = sizeof(int),
1442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001443 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 .extra1 = &minolduid,
1445 .extra2 = &maxolduid,
1446 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001447#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 .procname = "leases-enable",
1450 .data = &leases_enable,
1451 .maxlen = sizeof(int),
1452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001453 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001455#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456#ifdef CONFIG_DNOTIFY
1457 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 .procname = "dir-notify-enable",
1459 .data = &dir_notify_enable,
1460 .maxlen = sizeof(int),
1461 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001462 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 },
1464#endif
1465#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001466#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 .procname = "lease-break-time",
1469 .data = &lease_break_time,
1470 .maxlen = sizeof(int),
1471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001472 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001474#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001475#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "aio-nr",
1478 .data = &aio_nr,
1479 .maxlen = sizeof(aio_nr),
1480 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001481 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 },
1483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .procname = "aio-max-nr",
1485 .data = &aio_max_nr,
1486 .maxlen = sizeof(aio_max_nr),
1487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001488 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001490#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001491#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001492 {
Robert Love0399cb02005-07-13 12:38:18 -04001493 .procname = "inotify",
1494 .mode = 0555,
1495 .child = inotify_table,
1496 },
1497#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001498#ifdef CONFIG_EPOLL
1499 {
1500 .procname = "epoll",
1501 .mode = 0555,
1502 .child = epoll_table,
1503 },
1504#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001506 {
Kees Cook800179c2012-07-25 17:29:07 -07001507 .procname = "protected_symlinks",
1508 .data = &sysctl_protected_symlinks,
1509 .maxlen = sizeof(int),
1510 .mode = 0600,
1511 .proc_handler = proc_dointvec_minmax,
1512 .extra1 = &zero,
1513 .extra2 = &one,
1514 },
1515 {
1516 .procname = "protected_hardlinks",
1517 .data = &sysctl_protected_hardlinks,
1518 .maxlen = sizeof(int),
1519 .mode = 0600,
1520 .proc_handler = proc_dointvec_minmax,
1521 .extra1 = &zero,
1522 .extra2 = &one,
1523 },
1524 {
Alan Coxd6e71142005-06-23 00:09:43 -07001525 .procname = "suid_dumpable",
1526 .data = &suid_dumpable,
1527 .maxlen = sizeof(int),
1528 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001529 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001530 .extra1 = &zero,
1531 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001532 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001533#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1534 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001535 .procname = "binfmt_misc",
1536 .mode = 0555,
1537 .child = binfmt_misc_table,
1538 },
1539#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001540 {
Jens Axboeff9da692010-06-03 14:54:39 +02001541 .procname = "pipe-max-size",
1542 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001543 .maxlen = sizeof(int),
1544 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001545 .proc_handler = &pipe_proc_fn,
1546 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001547 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001548 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549};
1550
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001551static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001552#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Catalin Marinas5c423362012-08-14 17:08:45 +01001553 defined(CONFIG_S390) || defined(CONFIG_TILE) || defined(CONFIG_ARM64)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001554 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001555 .procname = "exception-trace",
1556 .data = &show_unhandled_signals,
1557 .maxlen = sizeof(int),
1558 .mode = 0644,
1559 .proc_handler = proc_dointvec
1560 },
1561#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001562#if defined(CONFIG_OPTPROBES)
1563 {
1564 .procname = "kprobes-optimization",
1565 .data = &sysctl_kprobes_optimization,
1566 .maxlen = sizeof(int),
1567 .mode = 0644,
1568 .proc_handler = proc_kprobes_optimization_handler,
1569 .extra1 = &zero,
1570 .extra2 = &one,
1571 },
1572#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001573 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574};
1575
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001576static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001577 { }
Robert Love0eeca282005-07-12 17:06:03 -04001578};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001579
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001580int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001581{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001582 struct ctl_table_header *hdr;
1583
1584 hdr = register_sysctl_table(sysctl_base_table);
1585 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001586 return 0;
1587}
1588
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001589#endif /* CONFIG_SYSCTL */
1590
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591/*
1592 * /proc/sys support
1593 */
1594
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001595#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001597static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001598 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001599 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001600{
1601 size_t len;
1602 char __user *p;
1603 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001604
1605 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001606 *lenp = 0;
1607 return 0;
1608 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001609
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001610 if (write) {
1611 len = 0;
1612 p = buffer;
1613 while (len < *lenp) {
1614 if (get_user(c, p++))
1615 return -EFAULT;
1616 if (c == 0 || c == '\n')
1617 break;
1618 len++;
1619 }
1620 if (len >= maxlen)
1621 len = maxlen-1;
1622 if(copy_from_user(data, buffer, len))
1623 return -EFAULT;
1624 ((char *) data)[len] = 0;
1625 *ppos += *lenp;
1626 } else {
1627 len = strlen(data);
1628 if (len > maxlen)
1629 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001630
1631 if (*ppos > len) {
1632 *lenp = 0;
1633 return 0;
1634 }
1635
1636 data += *ppos;
1637 len -= *ppos;
1638
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001639 if (len > *lenp)
1640 len = *lenp;
1641 if (len)
1642 if(copy_to_user(buffer, data, len))
1643 return -EFAULT;
1644 if (len < *lenp) {
1645 if(put_user('\n', ((char __user *) buffer) + len))
1646 return -EFAULT;
1647 len++;
1648 }
1649 *lenp = len;
1650 *ppos += len;
1651 }
1652 return 0;
1653}
1654
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655/**
1656 * proc_dostring - read a string sysctl
1657 * @table: the sysctl table
1658 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 * @buffer: the user buffer
1660 * @lenp: the size of the user buffer
1661 * @ppos: file position
1662 *
1663 * Reads/writes a string from/to the user buffer. If the kernel
1664 * buffer provided is not large enough to hold the string, the
1665 * string is truncated. The copied string is %NULL-terminated.
1666 * If the string is being read by the user process, it is copied
1667 * and a newline '\n' is added. It is truncated if the buffer is
1668 * not large enough.
1669 *
1670 * Returns 0 on success.
1671 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001672int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 void __user *buffer, size_t *lenp, loff_t *ppos)
1674{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001675 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001676 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677}
1678
Amerigo Wang00b7c332010-05-05 00:26:45 +00001679static size_t proc_skip_spaces(char **buf)
1680{
1681 size_t ret;
1682 char *tmp = skip_spaces(*buf);
1683 ret = tmp - *buf;
1684 *buf = tmp;
1685 return ret;
1686}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001688static void proc_skip_char(char **buf, size_t *size, const char v)
1689{
1690 while (*size) {
1691 if (**buf != v)
1692 break;
1693 (*size)--;
1694 (*buf)++;
1695 }
1696}
1697
Amerigo Wang00b7c332010-05-05 00:26:45 +00001698#define TMPBUFLEN 22
1699/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001700 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001701 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001702 * @buf: a kernel buffer
1703 * @size: size of the kernel buffer
1704 * @val: this is where the number will be stored
1705 * @neg: set to %TRUE if number is negative
1706 * @perm_tr: a vector which contains the allowed trailers
1707 * @perm_tr_len: size of the perm_tr vector
1708 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001709 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001710 * In case of success %0 is returned and @buf and @size are updated with
1711 * the amount of bytes read. If @tr is non-NULL and a trailing
1712 * character exists (size is non-zero after returning from this
1713 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001714 */
1715static int proc_get_long(char **buf, size_t *size,
1716 unsigned long *val, bool *neg,
1717 const char *perm_tr, unsigned perm_tr_len, char *tr)
1718{
1719 int len;
1720 char *p, tmp[TMPBUFLEN];
1721
1722 if (!*size)
1723 return -EINVAL;
1724
1725 len = *size;
1726 if (len > TMPBUFLEN - 1)
1727 len = TMPBUFLEN - 1;
1728
1729 memcpy(tmp, *buf, len);
1730
1731 tmp[len] = 0;
1732 p = tmp;
1733 if (*p == '-' && *size > 1) {
1734 *neg = true;
1735 p++;
1736 } else
1737 *neg = false;
1738 if (!isdigit(*p))
1739 return -EINVAL;
1740
1741 *val = simple_strtoul(p, &p, 0);
1742
1743 len = p - tmp;
1744
1745 /* We don't know if the next char is whitespace thus we may accept
1746 * invalid integers (e.g. 1234...a) or two integers instead of one
1747 * (e.g. 123...1). So lets not allow such large numbers. */
1748 if (len == TMPBUFLEN - 1)
1749 return -EINVAL;
1750
1751 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1752 return -EINVAL;
1753
1754 if (tr && (len < *size))
1755 *tr = *p;
1756
1757 *buf += len;
1758 *size -= len;
1759
1760 return 0;
1761}
1762
1763/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001764 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001765 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001766 * @buf: the user buffer
1767 * @size: the size of the user buffer
1768 * @val: the integer to be converted
1769 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001770 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001771 * In case of success %0 is returned and @buf and @size are updated with
1772 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001773 */
1774static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1775 bool neg)
1776{
1777 int len;
1778 char tmp[TMPBUFLEN], *p = tmp;
1779
1780 sprintf(p, "%s%lu", neg ? "-" : "", val);
1781 len = strlen(tmp);
1782 if (len > *size)
1783 len = *size;
1784 if (copy_to_user(*buf, tmp, len))
1785 return -EFAULT;
1786 *size -= len;
1787 *buf += len;
1788 return 0;
1789}
1790#undef TMPBUFLEN
1791
1792static int proc_put_char(void __user **buf, size_t *size, char c)
1793{
1794 if (*size) {
1795 char __user **buffer = (char __user **)buf;
1796 if (put_user(c, *buffer))
1797 return -EFAULT;
1798 (*size)--, (*buffer)++;
1799 *buf = *buffer;
1800 }
1801 return 0;
1802}
1803
1804static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 int *valp,
1806 int write, void *data)
1807{
1808 if (write) {
1809 *valp = *negp ? -*lvalp : *lvalp;
1810 } else {
1811 int val = *valp;
1812 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001813 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 *lvalp = (unsigned long)-val;
1815 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001816 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 *lvalp = (unsigned long)val;
1818 }
1819 }
1820 return 0;
1821}
1822
Amerigo Wang00b7c332010-05-05 00:26:45 +00001823static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1824
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001825static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001826 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001827 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001828 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 int write, void *data),
1830 void *data)
1831{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001832 int *i, vleft, first = 1, err = 0;
1833 unsigned long page = 0;
1834 size_t left;
1835 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836
Amerigo Wang00b7c332010-05-05 00:26:45 +00001837 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 *lenp = 0;
1839 return 0;
1840 }
1841
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001842 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 vleft = table->maxlen / sizeof(*i);
1844 left = *lenp;
1845
1846 if (!conv)
1847 conv = do_proc_dointvec_conv;
1848
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001850 if (left > PAGE_SIZE - 1)
1851 left = PAGE_SIZE - 1;
1852 page = __get_free_page(GFP_TEMPORARY);
1853 kbuf = (char *) page;
1854 if (!kbuf)
1855 return -ENOMEM;
1856 if (copy_from_user(kbuf, buffer, left)) {
1857 err = -EFAULT;
1858 goto free;
1859 }
1860 kbuf[left] = 0;
1861 }
1862
1863 for (; left && vleft--; i++, first=0) {
1864 unsigned long lval;
1865 bool neg;
1866
1867 if (write) {
1868 left -= proc_skip_spaces(&kbuf);
1869
J. R. Okajima563b0462010-05-25 16:10:14 -07001870 if (!left)
1871 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001872 err = proc_get_long(&kbuf, &left, &lval, &neg,
1873 proc_wspace_sep,
1874 sizeof(proc_wspace_sep), NULL);
1875 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001877 if (conv(&neg, &lval, i, 1, data)) {
1878 err = -EINVAL;
1879 break;
1880 }
1881 } else {
1882 if (conv(&neg, &lval, i, 0, data)) {
1883 err = -EINVAL;
1884 break;
1885 }
1886 if (!first)
1887 err = proc_put_char(&buffer, &left, '\t');
1888 if (err)
1889 break;
1890 err = proc_put_long(&buffer, &left, lval, neg);
1891 if (err)
1892 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 }
1894 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001895
1896 if (!write && !first && left && !err)
1897 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001898 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001899 left -= proc_skip_spaces(&kbuf);
1900free:
1901 if (write) {
1902 free_page(page);
1903 if (first)
1904 return err ? : -EINVAL;
1905 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 *lenp -= left;
1907 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001908 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001909}
1910
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001911static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001912 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001913 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001914 int write, void *data),
1915 void *data)
1916{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001917 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001918 buffer, lenp, ppos, conv, data);
1919}
1920
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921/**
1922 * proc_dointvec - read a vector of integers
1923 * @table: the sysctl table
1924 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 * @buffer: the user buffer
1926 * @lenp: the size of the user buffer
1927 * @ppos: file position
1928 *
1929 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1930 * values from/to the user buffer, treated as an ASCII string.
1931 *
1932 * Returns 0 on success.
1933 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001934int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001935 void __user *buffer, size_t *lenp, loff_t *ppos)
1936{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001937 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001938 NULL,NULL);
1939}
1940
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001941/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001942 * Taint values can only be increased
1943 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001944 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001945static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001946 void __user *buffer, size_t *lenp, loff_t *ppos)
1947{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001948 struct ctl_table t;
1949 unsigned long tmptaint = get_taint();
1950 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001951
Bastian Blank91fcd412007-04-23 14:41:14 -07001952 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001953 return -EPERM;
1954
Andi Kleen25ddbb12008-10-15 22:01:41 -07001955 t = *table;
1956 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001957 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001958 if (err < 0)
1959 return err;
1960
1961 if (write) {
1962 /*
1963 * Poor man's atomic or. Not worth adding a primitive
1964 * to everyone's atomic.h for this
1965 */
1966 int i;
1967 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
1968 if ((tmptaint >> i) & 1)
1969 add_taint(i);
1970 }
1971 }
1972
1973 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001974}
1975
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07001976#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07001977static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07001978 void __user *buffer, size_t *lenp, loff_t *ppos)
1979{
1980 if (write && !capable(CAP_SYS_ADMIN))
1981 return -EPERM;
1982
1983 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1984}
1985#endif
1986
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987struct do_proc_dointvec_minmax_conv_param {
1988 int *min;
1989 int *max;
1990};
1991
Amerigo Wang00b7c332010-05-05 00:26:45 +00001992static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
1993 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994 int write, void *data)
1995{
1996 struct do_proc_dointvec_minmax_conv_param *param = data;
1997 if (write) {
1998 int val = *negp ? -*lvalp : *lvalp;
1999 if ((param->min && *param->min > val) ||
2000 (param->max && *param->max < val))
2001 return -EINVAL;
2002 *valp = val;
2003 } else {
2004 int val = *valp;
2005 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002006 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 *lvalp = (unsigned long)-val;
2008 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002009 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010 *lvalp = (unsigned long)val;
2011 }
2012 }
2013 return 0;
2014}
2015
2016/**
2017 * proc_dointvec_minmax - read a vector of integers with min/max values
2018 * @table: the sysctl table
2019 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020 * @buffer: the user buffer
2021 * @lenp: the size of the user buffer
2022 * @ppos: file position
2023 *
2024 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2025 * values from/to the user buffer, treated as an ASCII string.
2026 *
2027 * This routine will ensure the values are within the range specified by
2028 * table->extra1 (min) and table->extra2 (max).
2029 *
2030 * Returns 0 on success.
2031 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002032int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 void __user *buffer, size_t *lenp, loff_t *ppos)
2034{
2035 struct do_proc_dointvec_minmax_conv_param param = {
2036 .min = (int *) table->extra1,
2037 .max = (int *) table->extra2,
2038 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002039 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 do_proc_dointvec_minmax_conv, &param);
2041}
2042
Kees Cook54b50192012-07-30 14:39:18 -07002043static void validate_coredump_safety(void)
2044{
Alex Kelly046d6622012-10-04 17:15:23 -07002045#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002046 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2047 core_pattern[0] != '/' && core_pattern[0] != '|') {
2048 printk(KERN_WARNING "Unsafe core_pattern used with "\
2049 "suid_dumpable=2. Pipe handler or fully qualified "\
2050 "core dump path required.\n");
2051 }
Alex Kelly046d6622012-10-04 17:15:23 -07002052#endif
Kees Cook54b50192012-07-30 14:39:18 -07002053}
2054
2055static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2056 void __user *buffer, size_t *lenp, loff_t *ppos)
2057{
2058 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2059 if (!error)
2060 validate_coredump_safety();
2061 return error;
2062}
2063
Alex Kelly046d6622012-10-04 17:15:23 -07002064#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002065static int proc_dostring_coredump(struct ctl_table *table, int write,
2066 void __user *buffer, size_t *lenp, loff_t *ppos)
2067{
2068 int error = proc_dostring(table, write, buffer, lenp, ppos);
2069 if (!error)
2070 validate_coredump_safety();
2071 return error;
2072}
Alex Kelly046d6622012-10-04 17:15:23 -07002073#endif
Kees Cook54b50192012-07-30 14:39:18 -07002074
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002075static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076 void __user *buffer,
2077 size_t *lenp, loff_t *ppos,
2078 unsigned long convmul,
2079 unsigned long convdiv)
2080{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002081 unsigned long *i, *min, *max;
2082 int vleft, first = 1, err = 0;
2083 unsigned long page = 0;
2084 size_t left;
2085 char *kbuf;
2086
2087 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088 *lenp = 0;
2089 return 0;
2090 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002091
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002092 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 min = (unsigned long *) table->extra1;
2094 max = (unsigned long *) table->extra2;
2095 vleft = table->maxlen / sizeof(unsigned long);
2096 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002097
2098 if (write) {
2099 if (left > PAGE_SIZE - 1)
2100 left = PAGE_SIZE - 1;
2101 page = __get_free_page(GFP_TEMPORARY);
2102 kbuf = (char *) page;
2103 if (!kbuf)
2104 return -ENOMEM;
2105 if (copy_from_user(kbuf, buffer, left)) {
2106 err = -EFAULT;
2107 goto free;
2108 }
2109 kbuf[left] = 0;
2110 }
2111
Eric Dumazet27b3d802010-10-07 12:59:29 -07002112 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002113 unsigned long val;
2114
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002116 bool neg;
2117
2118 left -= proc_skip_spaces(&kbuf);
2119
2120 err = proc_get_long(&kbuf, &left, &val, &neg,
2121 proc_wspace_sep,
2122 sizeof(proc_wspace_sep), NULL);
2123 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124 break;
2125 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126 continue;
2127 if ((min && val < *min) || (max && val > *max))
2128 continue;
2129 *i = val;
2130 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002131 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002133 err = proc_put_char(&buffer, &left, '\t');
2134 err = proc_put_long(&buffer, &left, val, false);
2135 if (err)
2136 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 }
2138 }
2139
Amerigo Wang00b7c332010-05-05 00:26:45 +00002140 if (!write && !first && left && !err)
2141 err = proc_put_char(&buffer, &left, '\n');
2142 if (write && !err)
2143 left -= proc_skip_spaces(&kbuf);
2144free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002146 free_page(page);
2147 if (first)
2148 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 *lenp -= left;
2151 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002152 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153}
2154
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002155static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002156 void __user *buffer,
2157 size_t *lenp, loff_t *ppos,
2158 unsigned long convmul,
2159 unsigned long convdiv)
2160{
2161 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002162 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002163}
2164
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165/**
2166 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2167 * @table: the sysctl table
2168 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169 * @buffer: the user buffer
2170 * @lenp: the size of the user buffer
2171 * @ppos: file position
2172 *
2173 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2174 * values from/to the user buffer, treated as an ASCII string.
2175 *
2176 * This routine will ensure the values are within the range specified by
2177 * table->extra1 (min) and table->extra2 (max).
2178 *
2179 * Returns 0 on success.
2180 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002181int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 void __user *buffer, size_t *lenp, loff_t *ppos)
2183{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002184 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185}
2186
2187/**
2188 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2189 * @table: the sysctl table
2190 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 * @buffer: the user buffer
2192 * @lenp: the size of the user buffer
2193 * @ppos: file position
2194 *
2195 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2196 * values from/to the user buffer, treated as an ASCII string. The values
2197 * are treated as milliseconds, and converted to jiffies when they are stored.
2198 *
2199 * This routine will ensure the values are within the range specified by
2200 * table->extra1 (min) and table->extra2 (max).
2201 *
2202 * Returns 0 on success.
2203 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002204int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 void __user *buffer,
2206 size_t *lenp, loff_t *ppos)
2207{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002208 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 lenp, ppos, HZ, 1000l);
2210}
2211
2212
Amerigo Wang00b7c332010-05-05 00:26:45 +00002213static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214 int *valp,
2215 int write, void *data)
2216{
2217 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002218 if (*lvalp > LONG_MAX / HZ)
2219 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2221 } else {
2222 int val = *valp;
2223 unsigned long lval;
2224 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002225 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002226 lval = (unsigned long)-val;
2227 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002228 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229 lval = (unsigned long)val;
2230 }
2231 *lvalp = lval / HZ;
2232 }
2233 return 0;
2234}
2235
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002237 int *valp,
2238 int write, void *data)
2239{
2240 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002241 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2242 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2244 } else {
2245 int val = *valp;
2246 unsigned long lval;
2247 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002248 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249 lval = (unsigned long)-val;
2250 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002251 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 lval = (unsigned long)val;
2253 }
2254 *lvalp = jiffies_to_clock_t(lval);
2255 }
2256 return 0;
2257}
2258
Amerigo Wang00b7c332010-05-05 00:26:45 +00002259static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 int *valp,
2261 int write, void *data)
2262{
2263 if (write) {
2264 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2265 } else {
2266 int val = *valp;
2267 unsigned long lval;
2268 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 lval = (unsigned long)-val;
2271 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002272 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 lval = (unsigned long)val;
2274 }
2275 *lvalp = jiffies_to_msecs(lval);
2276 }
2277 return 0;
2278}
2279
2280/**
2281 * proc_dointvec_jiffies - read a vector of integers as seconds
2282 * @table: the sysctl table
2283 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 * @buffer: the user buffer
2285 * @lenp: the size of the user buffer
2286 * @ppos: file position
2287 *
2288 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2289 * values from/to the user buffer, treated as an ASCII string.
2290 * The values read are assumed to be in seconds, and are converted into
2291 * jiffies.
2292 *
2293 * Returns 0 on success.
2294 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002295int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 void __user *buffer, size_t *lenp, loff_t *ppos)
2297{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002298 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 do_proc_dointvec_jiffies_conv,NULL);
2300}
2301
2302/**
2303 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2304 * @table: the sysctl table
2305 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 * @buffer: the user buffer
2307 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002308 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309 *
2310 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2311 * values from/to the user buffer, treated as an ASCII string.
2312 * The values read are assumed to be in 1/USER_HZ seconds, and
2313 * are converted into jiffies.
2314 *
2315 * Returns 0 on success.
2316 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002317int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 void __user *buffer, size_t *lenp, loff_t *ppos)
2319{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002320 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 do_proc_dointvec_userhz_jiffies_conv,NULL);
2322}
2323
2324/**
2325 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2326 * @table: the sysctl table
2327 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 * @buffer: the user buffer
2329 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002330 * @ppos: file position
2331 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 *
2333 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2334 * values from/to the user buffer, treated as an ASCII string.
2335 * The values read are assumed to be in 1/1000 seconds, and
2336 * are converted into jiffies.
2337 *
2338 * Returns 0 on success.
2339 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002340int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 void __user *buffer, size_t *lenp, loff_t *ppos)
2342{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002343 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 do_proc_dointvec_ms_jiffies_conv, NULL);
2345}
2346
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002347static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002348 void __user *buffer, size_t *lenp, loff_t *ppos)
2349{
2350 struct pid *new_pid;
2351 pid_t tmp;
2352 int r;
2353
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002354 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002355
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002356 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002357 lenp, ppos, NULL, NULL);
2358 if (r || !write)
2359 return r;
2360
2361 new_pid = find_get_pid(tmp);
2362 if (!new_pid)
2363 return -ESRCH;
2364
2365 put_pid(xchg(&cad_pid, new_pid));
2366 return 0;
2367}
2368
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002369/**
2370 * proc_do_large_bitmap - read/write from/to a large bitmap
2371 * @table: the sysctl table
2372 * @write: %TRUE if this is a write to the sysctl file
2373 * @buffer: the user buffer
2374 * @lenp: the size of the user buffer
2375 * @ppos: file position
2376 *
2377 * The bitmap is stored at table->data and the bitmap length (in bits)
2378 * in table->maxlen.
2379 *
2380 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2381 * large bitmaps may be represented in a compact manner. Writing into
2382 * the file will clear the bitmap then update it with the given input.
2383 *
2384 * Returns 0 on success.
2385 */
2386int proc_do_large_bitmap(struct ctl_table *table, int write,
2387 void __user *buffer, size_t *lenp, loff_t *ppos)
2388{
2389 int err = 0;
2390 bool first = 1;
2391 size_t left = *lenp;
2392 unsigned long bitmap_len = table->maxlen;
2393 unsigned long *bitmap = (unsigned long *) table->data;
2394 unsigned long *tmp_bitmap = NULL;
2395 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2396
2397 if (!bitmap_len || !left || (*ppos && !write)) {
2398 *lenp = 0;
2399 return 0;
2400 }
2401
2402 if (write) {
2403 unsigned long page = 0;
2404 char *kbuf;
2405
2406 if (left > PAGE_SIZE - 1)
2407 left = PAGE_SIZE - 1;
2408
2409 page = __get_free_page(GFP_TEMPORARY);
2410 kbuf = (char *) page;
2411 if (!kbuf)
2412 return -ENOMEM;
2413 if (copy_from_user(kbuf, buffer, left)) {
2414 free_page(page);
2415 return -EFAULT;
2416 }
2417 kbuf[left] = 0;
2418
2419 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2420 GFP_KERNEL);
2421 if (!tmp_bitmap) {
2422 free_page(page);
2423 return -ENOMEM;
2424 }
2425 proc_skip_char(&kbuf, &left, '\n');
2426 while (!err && left) {
2427 unsigned long val_a, val_b;
2428 bool neg;
2429
2430 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2431 sizeof(tr_a), &c);
2432 if (err)
2433 break;
2434 if (val_a >= bitmap_len || neg) {
2435 err = -EINVAL;
2436 break;
2437 }
2438
2439 val_b = val_a;
2440 if (left) {
2441 kbuf++;
2442 left--;
2443 }
2444
2445 if (c == '-') {
2446 err = proc_get_long(&kbuf, &left, &val_b,
2447 &neg, tr_b, sizeof(tr_b),
2448 &c);
2449 if (err)
2450 break;
2451 if (val_b >= bitmap_len || neg ||
2452 val_a > val_b) {
2453 err = -EINVAL;
2454 break;
2455 }
2456 if (left) {
2457 kbuf++;
2458 left--;
2459 }
2460 }
2461
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002462 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002463 first = 0;
2464 proc_skip_char(&kbuf, &left, '\n');
2465 }
2466 free_page(page);
2467 } else {
2468 unsigned long bit_a, bit_b = 0;
2469
2470 while (left) {
2471 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2472 if (bit_a >= bitmap_len)
2473 break;
2474 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2475 bit_a + 1) - 1;
2476
2477 if (!first) {
2478 err = proc_put_char(&buffer, &left, ',');
2479 if (err)
2480 break;
2481 }
2482 err = proc_put_long(&buffer, &left, bit_a, false);
2483 if (err)
2484 break;
2485 if (bit_a != bit_b) {
2486 err = proc_put_char(&buffer, &left, '-');
2487 if (err)
2488 break;
2489 err = proc_put_long(&buffer, &left, bit_b, false);
2490 if (err)
2491 break;
2492 }
2493
2494 first = 0; bit_b++;
2495 }
2496 if (!err)
2497 err = proc_put_char(&buffer, &left, '\n');
2498 }
2499
2500 if (!err) {
2501 if (write) {
2502 if (*ppos)
2503 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2504 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002505 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002506 }
2507 kfree(tmp_bitmap);
2508 *lenp -= left;
2509 *ppos += *lenp;
2510 return 0;
2511 } else {
2512 kfree(tmp_bitmap);
2513 return err;
2514 }
2515}
2516
Jovi Zhang55610502011-01-12 17:00:45 -08002517#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002518
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002519int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002520 void __user *buffer, size_t *lenp, loff_t *ppos)
2521{
2522 return -ENOSYS;
2523}
2524
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002525int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 void __user *buffer, size_t *lenp, loff_t *ppos)
2527{
2528 return -ENOSYS;
2529}
2530
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002531int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532 void __user *buffer, size_t *lenp, loff_t *ppos)
2533{
2534 return -ENOSYS;
2535}
2536
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002537int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538 void __user *buffer, size_t *lenp, loff_t *ppos)
2539{
2540 return -ENOSYS;
2541}
2542
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002543int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 void __user *buffer, size_t *lenp, loff_t *ppos)
2545{
2546 return -ENOSYS;
2547}
2548
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002549int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 void __user *buffer, size_t *lenp, loff_t *ppos)
2551{
2552 return -ENOSYS;
2553}
2554
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002555int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 void __user *buffer, size_t *lenp, loff_t *ppos)
2557{
2558 return -ENOSYS;
2559}
2560
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002561int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 void __user *buffer,
2563 size_t *lenp, loff_t *ppos)
2564{
2565 return -ENOSYS;
2566}
2567
2568
Jovi Zhang55610502011-01-12 17:00:45 -08002569#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571/*
2572 * No sense putting this after each symbol definition, twice,
2573 * exception granted :-)
2574 */
2575EXPORT_SYMBOL(proc_dointvec);
2576EXPORT_SYMBOL(proc_dointvec_jiffies);
2577EXPORT_SYMBOL(proc_dointvec_minmax);
2578EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2579EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2580EXPORT_SYMBOL(proc_dostring);
2581EXPORT_SYMBOL(proc_doulongvec_minmax);
2582EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);