blob: 025e1ae50ef1942247485939eab28ef805c94ba4 [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 */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200259#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100260static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
261static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200262#endif /* CONFIG_SMP */
263#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200264
Mel Gorman5e771902010-05-24 14:32:31 -0700265#ifdef CONFIG_COMPACTION
266static int min_extfrag_threshold;
267static int max_extfrag_threshold = 1000;
268#endif
269
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700270static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200271 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200272 .procname = "sched_child_runs_first",
273 .data = &sysctl_sched_child_runs_first,
274 .maxlen = sizeof(unsigned int),
275 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800276 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200277 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200278#ifdef CONFIG_SCHED_DEBUG
279 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100280 .procname = "sched_min_granularity_ns",
281 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200282 .maxlen = sizeof(unsigned int),
283 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800284 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100285 .extra1 = &min_sched_granularity_ns,
286 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200287 },
288 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200289 .procname = "sched_latency_ns",
290 .data = &sysctl_sched_latency,
291 .maxlen = sizeof(unsigned int),
292 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800293 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200294 .extra1 = &min_sched_granularity_ns,
295 .extra2 = &max_sched_granularity_ns,
296 },
297 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200298 .procname = "sched_wakeup_granularity_ns",
299 .data = &sysctl_sched_wakeup_granularity,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800302 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200303 .extra1 = &min_wakeup_granularity_ns,
304 .extra2 = &max_wakeup_granularity_ns,
305 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200306#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200307 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100308 .procname = "sched_tunable_scaling",
309 .data = &sysctl_sched_tunable_scaling,
310 .maxlen = sizeof(enum sched_tunable_scaling),
311 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800312 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100313 .extra1 = &min_sched_tunable_scaling,
314 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200315 },
316 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900317 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200318 .data = &sysctl_sched_migration_cost,
319 .maxlen = sizeof(unsigned int),
320 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800321 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200322 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100323 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100324 .procname = "sched_nr_migrate",
325 .data = &sysctl_sched_nr_migrate,
326 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800328 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100329 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530330 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900331 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200332 .data = &sysctl_sched_time_avg,
333 .maxlen = sizeof(unsigned int),
334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800335 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200336 },
337 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900338 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800339 .data = &sysctl_sched_shares_window,
340 .maxlen = sizeof(unsigned int),
341 .mode = 0644,
342 .proc_handler = proc_dointvec,
343 },
344 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530345 .procname = "timer_migration",
346 .data = &sysctl_timer_migration,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800349 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530350 .extra1 = &zero,
351 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530352 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200353#endif /* CONFIG_SMP */
354#ifdef CONFIG_NUMA_BALANCING
355 {
356 .procname = "numa_balancing_scan_period_min_ms",
357 .data = &sysctl_numa_balancing_scan_period_min,
358 .maxlen = sizeof(unsigned int),
359 .mode = 0644,
360 .proc_handler = proc_dointvec,
361 },
362 {
363 .procname = "numa_balancing_scan_period_max_ms",
364 .data = &sysctl_numa_balancing_scan_period_max,
365 .maxlen = sizeof(unsigned int),
366 .mode = 0644,
367 .proc_handler = proc_dointvec,
368 },
369#endif /* CONFIG_NUMA_BALANCING */
370#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200371 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100372 .procname = "sched_rt_period_us",
373 .data = &sysctl_sched_rt_period,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800376 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100377 },
378 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100379 .procname = "sched_rt_runtime_us",
380 .data = &sysctl_sched_rt_runtime,
381 .maxlen = sizeof(int),
382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800383 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100384 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100385#ifdef CONFIG_SCHED_AUTOGROUP
386 {
387 .procname = "sched_autogroup_enabled",
388 .data = &sysctl_sched_autogroup_enabled,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800391 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100392 .extra1 = &zero,
393 .extra2 = &one,
394 },
395#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700396#ifdef CONFIG_CFS_BANDWIDTH
397 {
398 .procname = "sched_cfs_bandwidth_slice_us",
399 .data = &sysctl_sched_cfs_bandwidth_slice,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
402 .proc_handler = proc_dointvec_minmax,
403 .extra1 = &one,
404 },
405#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700406#ifdef CONFIG_PROVE_LOCKING
407 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700408 .procname = "prove_locking",
409 .data = &prove_locking,
410 .maxlen = sizeof(int),
411 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800412 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700413 },
414#endif
415#ifdef CONFIG_LOCK_STAT
416 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700417 .procname = "lock_stat",
418 .data = &lock_stat,
419 .maxlen = sizeof(int),
420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800421 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700422 },
423#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 .procname = "panic",
426 .data = &panic_timeout,
427 .maxlen = sizeof(int),
428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800429 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 },
Alex Kelly046d6622012-10-04 17:15:23 -0700431#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 .procname = "core_uses_pid",
434 .data = &core_uses_pid,
435 .maxlen = sizeof(int),
436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800437 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 },
439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 .procname = "core_pattern",
441 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700442 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700444 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 },
Neil Hormana2939802009-09-23 15:56:56 -0700446 {
Neil Hormana2939802009-09-23 15:56:56 -0700447 .procname = "core_pipe_limit",
448 .data = &core_pipe_limit,
449 .maxlen = sizeof(unsigned int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700452 },
Alex Kelly046d6622012-10-04 17:15:23 -0700453#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800454#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700457 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800461#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100462#ifdef CONFIG_LATENCYTOP
463 {
464 .procname = "latencytop",
465 .data = &latencytop_enabled,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100469 },
470#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471#ifdef CONFIG_BLK_DEV_INITRD
472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "real-root-dev",
474 .data = &real_root_dev,
475 .maxlen = sizeof(int),
476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800477 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
479#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700480 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700481 .procname = "print-fatal-signals",
482 .data = &print_fatal_signals,
483 .maxlen = sizeof(int),
484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800485 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700486 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700487#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "reboot-cmd",
490 .data = reboot_command,
491 .maxlen = 256,
492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800493 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 },
495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .procname = "stop-a",
497 .data = &stop_a_enabled,
498 .maxlen = sizeof (int),
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 },
502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "scons-poweroff",
504 .data = &scons_pwroff,
505 .maxlen = sizeof (int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 },
509#endif
David S. Miller08714202008-11-16 23:49:24 -0800510#ifdef CONFIG_SPARC64
511 {
David S. Miller08714202008-11-16 23:49:24 -0800512 .procname = "tsb-ratio",
513 .data = &sysctl_tsb_ratio,
514 .maxlen = sizeof (int),
515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800516 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800517 },
518#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519#ifdef __hppa__
520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 .procname = "soft-power",
522 .data = &pwrsw_enabled,
523 .maxlen = sizeof (int),
524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 },
527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "unaligned-trap",
529 .data = &unaligned_enabled,
530 .maxlen = sizeof (int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
534#endif
535 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 .procname = "ctrl-alt-del",
537 .data = &C_A_D,
538 .maxlen = sizeof(int),
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400542#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200543 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200544 .procname = "ftrace_enabled",
545 .data = &ftrace_enabled,
546 .maxlen = sizeof(int),
547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200549 },
550#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500551#ifdef CONFIG_STACK_TRACER
552 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500553 .procname = "stack_tracer_enabled",
554 .data = &stack_tracer_enabled,
555 .maxlen = sizeof(int),
556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500558 },
559#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400560#ifdef CONFIG_TRACING
561 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100562 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400563 .data = &ftrace_dump_on_oops,
564 .maxlen = sizeof(int),
565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800566 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400567 },
568#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200569#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .procname = "modprobe",
572 .data = &modprobe_path,
573 .maxlen = KMOD_PATH_LEN,
574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800575 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 },
Kees Cook3d433212009-04-02 15:49:29 -0700577 {
Kees Cook3d433212009-04-02 15:49:29 -0700578 .procname = "modules_disabled",
579 .data = &modules_disabled,
580 .maxlen = sizeof(int),
581 .mode = 0644,
582 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700584 .extra1 = &one,
585 .extra2 = &one,
586 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100588#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100591 .data = &uevent_helper,
592 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800594 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 },
596#endif
597#ifdef CONFIG_CHR_DEV_SG
598 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .procname = "sg-big-buff",
600 .data = &sg_big_buff,
601 .maxlen = sizeof (int),
602 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800603 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 },
605#endif
606#ifdef CONFIG_BSD_PROCESS_ACCT
607 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 .procname = "acct",
609 .data = &acct_parm,
610 .maxlen = 3*sizeof(int),
611 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800612 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 },
614#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615#ifdef CONFIG_MAGIC_SYSRQ
616 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800618 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 .maxlen = sizeof (int),
620 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700621 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 },
623#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700624#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700627 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 .maxlen = sizeof (int),
629 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800630 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700632#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "threads-max",
635 .data = &max_threads,
636 .maxlen = sizeof(int),
637 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800638 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 },
640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "random",
642 .mode = 0555,
643 .child = random_table,
644 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 {
Eric Paris17f60a72011-04-01 17:07:50 -0400646 .procname = "usermodehelper",
647 .mode = 0555,
648 .child = usermodehelper_table,
649 },
650 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .procname = "overflowuid",
652 .data = &overflowuid,
653 .maxlen = sizeof(int),
654 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800655 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .extra1 = &minolduid,
657 .extra2 = &maxolduid,
658 },
659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .procname = "overflowgid",
661 .data = &overflowgid,
662 .maxlen = sizeof(int),
663 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800664 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .extra1 = &minolduid,
666 .extra2 = &maxolduid,
667 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800668#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669#ifdef CONFIG_MATHEMU
670 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .procname = "ieee_emulation_warnings",
672 .data = &sysctl_ieee_emulation_warnings,
673 .maxlen = sizeof(int),
674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800675 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 },
677#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200680 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 .maxlen = sizeof(int),
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 },
685#endif
686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "pid_max",
688 .data = &pid_max,
689 .maxlen = sizeof (int),
690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800691 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .extra1 = &pid_max_min,
693 .extra2 = &pid_max_max,
694 },
695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .procname = "panic_on_oops",
697 .data = &panic_on_oops,
698 .maxlen = sizeof(int),
699 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800700 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800702#if defined CONFIG_PRINTK
703 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800704 .procname = "printk",
705 .data = &console_loglevel,
706 .maxlen = 4*sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800709 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700712 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .maxlen = sizeof(int),
714 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800715 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 },
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700719 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .maxlen = sizeof(int),
721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
Dave Youngaf913222009-09-22 16:43:33 -0700724 {
Dave Youngaf913222009-09-22 16:43:33 -0700725 .procname = "printk_delay",
726 .data = &printk_delay_msec,
727 .maxlen = sizeof(int),
728 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800729 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700730 .extra1 = &zero,
731 .extra2 = &ten_thousand,
732 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800734 .procname = "dmesg_restrict",
735 .data = &dmesg_restrict,
736 .maxlen = sizeof(int),
737 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700738 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800739 .extra1 = &zero,
740 .extra2 = &one,
741 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800742 {
743 .procname = "kptr_restrict",
744 .data = &kptr_restrict,
745 .maxlen = sizeof(int),
746 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700747 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800748 .extra1 = &zero,
749 .extra2 = &two,
750 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800751#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .procname = "ngroups_max",
754 .data = &ngroups_max,
755 .maxlen = sizeof (int),
756 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800757 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
Dan Ballard73efc032011-10-31 17:11:20 -0700759 {
760 .procname = "cap_last_cap",
761 .data = (void *)&cap_last_cap,
762 .maxlen = sizeof(int),
763 .mode = 0444,
764 .proc_handler = proc_dointvec,
765 },
Don Zickus58687ac2010-05-07 17:11:44 -0400766#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500767 {
Don Zickus58687ac2010-05-07 17:11:44 -0400768 .procname = "watchdog",
769 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500770 .maxlen = sizeof (int),
771 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700772 .proc_handler = proc_dowatchdog,
773 .extra1 = &zero,
774 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400775 },
776 {
777 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700778 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400779 .maxlen = sizeof(int),
780 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700781 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400782 .extra1 = &neg_one,
783 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500784 },
Don Zickus2508ce12010-05-07 17:11:46 -0400785 {
786 .procname = "softlockup_panic",
787 .data = &softlockup_panic,
788 .maxlen = sizeof(int),
789 .mode = 0644,
790 .proc_handler = proc_dointvec_minmax,
791 .extra1 = &zero,
792 .extra2 = &one,
793 },
Don Zickus5dc30552010-11-29 17:07:17 -0500794 {
795 .procname = "nmi_watchdog",
796 .data = &watchdog_enabled,
797 .maxlen = sizeof (int),
798 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700799 .proc_handler = proc_dowatchdog,
800 .extra1 = &zero,
801 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500802 },
803#endif
804#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
805 {
806 .procname = "unknown_nmi_panic",
807 .data = &unknown_nmi_panic,
808 .maxlen = sizeof (int),
809 .mode = 0644,
810 .proc_handler = proc_dointvec,
811 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500812#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813#if defined(CONFIG_X86)
814 {
Don Zickus8da5add2006-09-26 10:52:27 +0200815 .procname = "panic_on_unrecovered_nmi",
816 .data = &panic_on_unrecovered_nmi,
817 .maxlen = sizeof(int),
818 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800819 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200820 },
821 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700822 .procname = "panic_on_io_nmi",
823 .data = &panic_on_io_nmi,
824 .maxlen = sizeof(int),
825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700827 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900828#ifdef CONFIG_DEBUG_STACKOVERFLOW
829 {
830 .procname = "panic_on_stackoverflow",
831 .data = &sysctl_panic_on_stackoverflow,
832 .maxlen = sizeof(int),
833 .mode = 0644,
834 .proc_handler = proc_dointvec,
835 },
836#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700837 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .procname = "bootloader_type",
839 .data = &bootloader_type,
840 .maxlen = sizeof (int),
841 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800842 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100844 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700845 .procname = "bootloader_version",
846 .data = &bootloader_version,
847 .maxlen = sizeof (int),
848 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800849 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700850 },
851 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100852 .procname = "kstack_depth_to_print",
853 .data = &kstack_depth_to_print,
854 .maxlen = sizeof(int),
855 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800856 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100857 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100858 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100859 .procname = "io_delay_type",
860 .data = &io_delay_type,
861 .maxlen = sizeof(int),
862 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800863 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100864 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800866#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 .procname = "randomize_va_space",
869 .data = &randomize_va_space,
870 .maxlen = sizeof(int),
871 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800872 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800874#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800875#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700876 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700877 .procname = "spin_retry",
878 .data = &spin_retry,
879 .maxlen = sizeof (int),
880 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800881 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700882 },
883#endif
Len Brown673d5b42007-07-28 03:33:16 -0400884#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800885 {
Pavel Machekc255d842006-02-20 18:27:58 -0800886 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700887 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800888 .maxlen = sizeof (unsigned long),
889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800891 },
892#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800893#ifdef CONFIG_IA64
894 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800895 .procname = "ignore-unaligned-usertrap",
896 .data = &no_unaligned_warning,
897 .maxlen = sizeof (int),
898 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800899 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800900 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800901 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800902 .procname = "unaligned-dump-stack",
903 .data = &unaligned_dump_stack,
904 .maxlen = sizeof (int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800907 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800908#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800909#ifdef CONFIG_DETECT_HUNG_TASK
910 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800911 .procname = "hung_task_panic",
912 .data = &sysctl_hung_task_panic,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800916 .extra1 = &zero,
917 .extra2 = &one,
918 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100919 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100920 .procname = "hung_task_check_count",
921 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100922 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100925 },
926 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100927 .procname = "hung_task_timeout_secs",
928 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100929 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100930 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800931 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100932 },
933 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100934 .procname = "hung_task_warnings",
935 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100936 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100939 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700940#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200941#ifdef CONFIG_COMPAT
942 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200943 .procname = "compat-log",
944 .data = &compat_log,
945 .maxlen = sizeof (int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200948 },
949#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700950#ifdef CONFIG_RT_MUTEXES
951 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700952 .procname = "max_lock_depth",
953 .data = &max_lock_depth,
954 .maxlen = sizeof(int),
955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800956 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700957 },
958#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700959 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700960 .procname = "poweroff_cmd",
961 .data = &poweroff_cmd,
962 .maxlen = POWEROFF_CMD_PATH_LEN,
963 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800964 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700965 },
David Howells0b77f5b2008-04-29 01:01:32 -0700966#ifdef CONFIG_KEYS
967 {
David Howells0b77f5b2008-04-29 01:01:32 -0700968 .procname = "keys",
969 .mode = 0555,
970 .child = key_sysctls,
971 },
972#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700973#ifdef CONFIG_RCU_TORTURE_TEST
974 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700975 .procname = "rcutorture_runnable",
976 .data = &rcutorture_runnable,
977 .maxlen = sizeof(int),
978 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800979 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700980 },
981#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200982#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400983 /*
984 * User-space scripts rely on the existence of this file
985 * as a feature check for perf_events being enabled.
986 *
987 * So it's an ABI, do not remove!
988 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200989 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200990 .procname = "perf_event_paranoid",
991 .data = &sysctl_perf_event_paranoid,
992 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200993 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800994 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200995 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200996 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200997 .procname = "perf_event_mlock_kb",
998 .data = &sysctl_perf_event_mlock,
999 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001000 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001001 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001002 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001003 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001004 .procname = "perf_event_max_sample_rate",
1005 .data = &sysctl_perf_event_sample_rate,
1006 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001007 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001008 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001009 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001010#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001011#ifdef CONFIG_KMEMCHECK
1012 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001013 .procname = "kmemcheck",
1014 .data = &kmemcheck_enabled,
1015 .maxlen = sizeof(int),
1016 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001017 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001018 },
1019#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001020#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001021 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001022 .procname = "blk_iopoll",
1023 .data = &blk_iopoll_enabled,
1024 .maxlen = sizeof(int),
1025 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001026 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001027 },
Jens Axboecb684b52009-09-15 21:53:11 +02001028#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001029 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030};
1031
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001032static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 .procname = "overcommit_memory",
1035 .data = &sysctl_overcommit_memory,
1036 .maxlen = sizeof(sysctl_overcommit_memory),
1037 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001038 .proc_handler = proc_dointvec_minmax,
1039 .extra1 = &zero,
1040 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 },
1042 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001043 .procname = "panic_on_oom",
1044 .data = &sysctl_panic_on_oom,
1045 .maxlen = sizeof(sysctl_panic_on_oom),
1046 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001047 .proc_handler = proc_dointvec_minmax,
1048 .extra1 = &zero,
1049 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001050 },
1051 {
David Rientjesfe071d72007-10-16 23:25:56 -07001052 .procname = "oom_kill_allocating_task",
1053 .data = &sysctl_oom_kill_allocating_task,
1054 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1055 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001056 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001057 },
1058 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001059 .procname = "oom_dump_tasks",
1060 .data = &sysctl_oom_dump_tasks,
1061 .maxlen = sizeof(sysctl_oom_dump_tasks),
1062 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001063 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001064 },
1065 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 .procname = "overcommit_ratio",
1067 .data = &sysctl_overcommit_ratio,
1068 .maxlen = sizeof(sysctl_overcommit_ratio),
1069 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001070 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 },
1072 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 .procname = "page-cluster",
1074 .data = &page_cluster,
1075 .maxlen = sizeof(int),
1076 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001077 .proc_handler = proc_dointvec_minmax,
1078 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 },
1080 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081 .procname = "dirty_background_ratio",
1082 .data = &dirty_background_ratio,
1083 .maxlen = sizeof(dirty_background_ratio),
1084 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001085 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 .extra1 = &zero,
1087 .extra2 = &one_hundred,
1088 },
1089 {
David Rientjes2da02992009-01-06 14:39:31 -08001090 .procname = "dirty_background_bytes",
1091 .data = &dirty_background_bytes,
1092 .maxlen = sizeof(dirty_background_bytes),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001095 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001096 },
1097 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 .procname = "dirty_ratio",
1099 .data = &vm_dirty_ratio,
1100 .maxlen = sizeof(vm_dirty_ratio),
1101 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001102 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 .extra1 = &zero,
1104 .extra2 = &one_hundred,
1105 },
1106 {
David Rientjes2da02992009-01-06 14:39:31 -08001107 .procname = "dirty_bytes",
1108 .data = &vm_dirty_bytes,
1109 .maxlen = sizeof(vm_dirty_bytes),
1110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001112 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001113 },
1114 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001116 .data = &dirty_writeback_interval,
1117 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001119 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 },
1121 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001123 .data = &dirty_expire_interval,
1124 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001126 .proc_handler = proc_dointvec_minmax,
1127 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 },
1129 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001130 .procname = "nr_pdflush_threads",
1131 .mode = 0444 /* read-only */,
1132 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 },
1134 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 .procname = "swappiness",
1136 .data = &vm_swappiness,
1137 .maxlen = sizeof(vm_swappiness),
1138 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001139 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .extra1 = &zero,
1141 .extra2 = &one_hundred,
1142 },
1143#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001144 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001146 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 .maxlen = sizeof(unsigned long),
1148 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001149 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 .extra1 = (void *)&hugetlb_zero,
1151 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001152 },
1153#ifdef CONFIG_NUMA
1154 {
1155 .procname = "nr_hugepages_mempolicy",
1156 .data = NULL,
1157 .maxlen = sizeof(unsigned long),
1158 .mode = 0644,
1159 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1160 .extra1 = (void *)&hugetlb_zero,
1161 .extra2 = (void *)&hugetlb_infinity,
1162 },
1163#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 .procname = "hugetlb_shm_group",
1166 .data = &sysctl_hugetlb_shm_group,
1167 .maxlen = sizeof(gid_t),
1168 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001169 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 },
Mel Gorman396faf02007-07-17 04:03:13 -07001171 {
Mel Gorman396faf02007-07-17 04:03:13 -07001172 .procname = "hugepages_treat_as_movable",
1173 .data = &hugepages_treat_as_movable,
1174 .maxlen = sizeof(int),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001177 },
Adam Litke54f9f802007-10-16 01:26:20 -07001178 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001179 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001180 .data = NULL,
1181 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001184 .extra1 = (void *)&hugetlb_zero,
1185 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001186 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187#endif
1188 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 .procname = "lowmem_reserve_ratio",
1190 .data = &sysctl_lowmem_reserve_ratio,
1191 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1192 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001193 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 },
1195 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001196 .procname = "drop_caches",
1197 .data = &sysctl_drop_caches,
1198 .maxlen = sizeof(int),
1199 .mode = 0644,
1200 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001201 .extra1 = &one,
1202 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001203 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001204#ifdef CONFIG_COMPACTION
1205 {
1206 .procname = "compact_memory",
1207 .data = &sysctl_compact_memory,
1208 .maxlen = sizeof(int),
1209 .mode = 0200,
1210 .proc_handler = sysctl_compaction_handler,
1211 },
Mel Gorman5e771902010-05-24 14:32:31 -07001212 {
1213 .procname = "extfrag_threshold",
1214 .data = &sysctl_extfrag_threshold,
1215 .maxlen = sizeof(int),
1216 .mode = 0644,
1217 .proc_handler = sysctl_extfrag_handler,
1218 .extra1 = &min_extfrag_threshold,
1219 .extra2 = &max_extfrag_threshold,
1220 },
1221
Mel Gorman76ab0f52010-05-24 14:32:28 -07001222#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001223 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 .procname = "min_free_kbytes",
1225 .data = &min_free_kbytes,
1226 .maxlen = sizeof(min_free_kbytes),
1227 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001228 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 .extra1 = &zero,
1230 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001231 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001232 .procname = "percpu_pagelist_fraction",
1233 .data = &percpu_pagelist_fraction,
1234 .maxlen = sizeof(percpu_pagelist_fraction),
1235 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001236 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001237 .extra1 = &min_percpu_pagelist_fract,
1238 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239#ifdef CONFIG_MMU
1240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 .procname = "max_map_count",
1242 .data = &sysctl_max_map_count,
1243 .maxlen = sizeof(sysctl_max_map_count),
1244 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001245 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001246 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001248#else
1249 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001250 .procname = "nr_trim_pages",
1251 .data = &sysctl_nr_trim_pages,
1252 .maxlen = sizeof(sysctl_nr_trim_pages),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001255 .extra1 = &zero,
1256 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257#endif
1258 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 .procname = "laptop_mode",
1260 .data = &laptop_mode,
1261 .maxlen = sizeof(laptop_mode),
1262 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001263 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 },
1265 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266 .procname = "block_dump",
1267 .data = &block_dump,
1268 .maxlen = sizeof(block_dump),
1269 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001270 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 .extra1 = &zero,
1272 },
1273 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 .procname = "vfs_cache_pressure",
1275 .data = &sysctl_vfs_cache_pressure,
1276 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001278 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 .extra1 = &zero,
1280 },
1281#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1282 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283 .procname = "legacy_va_layout",
1284 .data = &sysctl_legacy_va_layout,
1285 .maxlen = sizeof(sysctl_legacy_va_layout),
1286 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001287 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288 .extra1 = &zero,
1289 },
1290#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001291#ifdef CONFIG_NUMA
1292 {
Christoph Lameter17436602006-01-18 17:42:32 -08001293 .procname = "zone_reclaim_mode",
1294 .data = &zone_reclaim_mode,
1295 .maxlen = sizeof(zone_reclaim_mode),
1296 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001297 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001298 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001299 },
Christoph Lameter96146342006-07-03 00:24:13 -07001300 {
Christoph Lameter96146342006-07-03 00:24:13 -07001301 .procname = "min_unmapped_ratio",
1302 .data = &sysctl_min_unmapped_ratio,
1303 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1304 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001305 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001306 .extra1 = &zero,
1307 .extra2 = &one_hundred,
1308 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001309 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001310 .procname = "min_slab_ratio",
1311 .data = &sysctl_min_slab_ratio,
1312 .maxlen = sizeof(sysctl_min_slab_ratio),
1313 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001314 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001315 .extra1 = &zero,
1316 .extra2 = &one_hundred,
1317 },
Christoph Lameter17436602006-01-18 17:42:32 -08001318#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001319#ifdef CONFIG_SMP
1320 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001321 .procname = "stat_interval",
1322 .data = &sysctl_stat_interval,
1323 .maxlen = sizeof(sysctl_stat_interval),
1324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001325 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001326 },
1327#endif
David Howells6e141542009-12-15 19:27:45 +00001328#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001329 {
Eric Parised032182007-06-28 15:55:21 -04001330 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001331 .data = &dac_mmap_min_addr,
1332 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001335 },
David Howells6e141542009-12-15 19:27:45 +00001336#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001337#ifdef CONFIG_NUMA
1338 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001339 .procname = "numa_zonelist_order",
1340 .data = &numa_zonelist_order,
1341 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001344 },
1345#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001346#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001347 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001348 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001349 .procname = "vdso_enabled",
1350 .data = &vdso_enabled,
1351 .maxlen = sizeof(vdso_enabled),
1352 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001353 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001354 .extra1 = &zero,
1355 },
1356#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001357#ifdef CONFIG_HIGHMEM
1358 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001359 .procname = "highmem_is_dirtyable",
1360 .data = &vm_highmem_is_dirtyable,
1361 .maxlen = sizeof(vm_highmem_is_dirtyable),
1362 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001363 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001364 .extra1 = &zero,
1365 .extra2 = &one,
1366 },
1367#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001368 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001369 .procname = "scan_unevictable_pages",
1370 .data = &scan_unevictable_pages,
1371 .maxlen = sizeof(scan_unevictable_pages),
1372 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001373 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001374 },
Andi Kleen6a460792009-09-16 11:50:15 +02001375#ifdef CONFIG_MEMORY_FAILURE
1376 {
Andi Kleen6a460792009-09-16 11:50:15 +02001377 .procname = "memory_failure_early_kill",
1378 .data = &sysctl_memory_failure_early_kill,
1379 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1380 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001381 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001382 .extra1 = &zero,
1383 .extra2 = &one,
1384 },
1385 {
Andi Kleen6a460792009-09-16 11:50:15 +02001386 .procname = "memory_failure_recovery",
1387 .data = &sysctl_memory_failure_recovery,
1388 .maxlen = sizeof(sysctl_memory_failure_recovery),
1389 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001390 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001391 .extra1 = &zero,
1392 .extra2 = &one,
1393 },
1394#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001395 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396};
1397
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001398#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001399static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001400 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001401};
1402#endif
1403
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001404static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 .procname = "inode-nr",
1407 .data = &inodes_stat,
1408 .maxlen = 2*sizeof(int),
1409 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001410 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 },
1412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 .procname = "inode-state",
1414 .data = &inodes_stat,
1415 .maxlen = 7*sizeof(int),
1416 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001417 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418 },
1419 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 .procname = "file-nr",
1421 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001422 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001424 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425 },
1426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 .procname = "file-max",
1428 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001429 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001431 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 },
1433 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001434 .procname = "nr_open",
1435 .data = &sysctl_nr_open,
1436 .maxlen = sizeof(int),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001439 .extra1 = &sysctl_nr_open_min,
1440 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001441 },
1442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 .procname = "dentry-state",
1444 .data = &dentry_stat,
1445 .maxlen = 6*sizeof(int),
1446 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001447 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 },
1449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "overflowuid",
1451 .data = &fs_overflowuid,
1452 .maxlen = sizeof(int),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 .extra1 = &minolduid,
1456 .extra2 = &maxolduid,
1457 },
1458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .procname = "overflowgid",
1460 .data = &fs_overflowgid,
1461 .maxlen = sizeof(int),
1462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001463 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .extra1 = &minolduid,
1465 .extra2 = &maxolduid,
1466 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001467#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .procname = "leases-enable",
1470 .data = &leases_enable,
1471 .maxlen = sizeof(int),
1472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001473 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001475#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476#ifdef CONFIG_DNOTIFY
1477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "dir-notify-enable",
1479 .data = &dir_notify_enable,
1480 .maxlen = sizeof(int),
1481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 },
1484#endif
1485#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001486#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "lease-break-time",
1489 .data = &lease_break_time,
1490 .maxlen = sizeof(int),
1491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001492 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001494#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001495#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 .procname = "aio-nr",
1498 .data = &aio_nr,
1499 .maxlen = sizeof(aio_nr),
1500 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001501 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 },
1503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 .procname = "aio-max-nr",
1505 .data = &aio_max_nr,
1506 .maxlen = sizeof(aio_max_nr),
1507 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001508 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001510#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001511#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001512 {
Robert Love0399cb02005-07-13 12:38:18 -04001513 .procname = "inotify",
1514 .mode = 0555,
1515 .child = inotify_table,
1516 },
1517#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001518#ifdef CONFIG_EPOLL
1519 {
1520 .procname = "epoll",
1521 .mode = 0555,
1522 .child = epoll_table,
1523 },
1524#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001526 {
Kees Cook800179c2012-07-25 17:29:07 -07001527 .procname = "protected_symlinks",
1528 .data = &sysctl_protected_symlinks,
1529 .maxlen = sizeof(int),
1530 .mode = 0600,
1531 .proc_handler = proc_dointvec_minmax,
1532 .extra1 = &zero,
1533 .extra2 = &one,
1534 },
1535 {
1536 .procname = "protected_hardlinks",
1537 .data = &sysctl_protected_hardlinks,
1538 .maxlen = sizeof(int),
1539 .mode = 0600,
1540 .proc_handler = proc_dointvec_minmax,
1541 .extra1 = &zero,
1542 .extra2 = &one,
1543 },
1544 {
Alan Coxd6e71142005-06-23 00:09:43 -07001545 .procname = "suid_dumpable",
1546 .data = &suid_dumpable,
1547 .maxlen = sizeof(int),
1548 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001549 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001550 .extra1 = &zero,
1551 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001552 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001553#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1554 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001555 .procname = "binfmt_misc",
1556 .mode = 0555,
1557 .child = binfmt_misc_table,
1558 },
1559#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001560 {
Jens Axboeff9da692010-06-03 14:54:39 +02001561 .procname = "pipe-max-size",
1562 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001563 .maxlen = sizeof(int),
1564 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001565 .proc_handler = &pipe_proc_fn,
1566 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001567 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001568 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569};
1570
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001571static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001572#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001573 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001574 .procname = "exception-trace",
1575 .data = &show_unhandled_signals,
1576 .maxlen = sizeof(int),
1577 .mode = 0644,
1578 .proc_handler = proc_dointvec
1579 },
1580#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001581#if defined(CONFIG_OPTPROBES)
1582 {
1583 .procname = "kprobes-optimization",
1584 .data = &sysctl_kprobes_optimization,
1585 .maxlen = sizeof(int),
1586 .mode = 0644,
1587 .proc_handler = proc_kprobes_optimization_handler,
1588 .extra1 = &zero,
1589 .extra2 = &one,
1590 },
1591#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001592 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593};
1594
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001595static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001596 { }
Robert Love0eeca282005-07-12 17:06:03 -04001597};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001599int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001600{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001601 struct ctl_table_header *hdr;
1602
1603 hdr = register_sysctl_table(sysctl_base_table);
1604 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001605 return 0;
1606}
1607
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001608#endif /* CONFIG_SYSCTL */
1609
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610/*
1611 * /proc/sys support
1612 */
1613
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001614#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001616static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001617 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001618 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001619{
1620 size_t len;
1621 char __user *p;
1622 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001623
1624 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001625 *lenp = 0;
1626 return 0;
1627 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001628
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001629 if (write) {
1630 len = 0;
1631 p = buffer;
1632 while (len < *lenp) {
1633 if (get_user(c, p++))
1634 return -EFAULT;
1635 if (c == 0 || c == '\n')
1636 break;
1637 len++;
1638 }
1639 if (len >= maxlen)
1640 len = maxlen-1;
1641 if(copy_from_user(data, buffer, len))
1642 return -EFAULT;
1643 ((char *) data)[len] = 0;
1644 *ppos += *lenp;
1645 } else {
1646 len = strlen(data);
1647 if (len > maxlen)
1648 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001649
1650 if (*ppos > len) {
1651 *lenp = 0;
1652 return 0;
1653 }
1654
1655 data += *ppos;
1656 len -= *ppos;
1657
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001658 if (len > *lenp)
1659 len = *lenp;
1660 if (len)
1661 if(copy_to_user(buffer, data, len))
1662 return -EFAULT;
1663 if (len < *lenp) {
1664 if(put_user('\n', ((char __user *) buffer) + len))
1665 return -EFAULT;
1666 len++;
1667 }
1668 *lenp = len;
1669 *ppos += len;
1670 }
1671 return 0;
1672}
1673
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674/**
1675 * proc_dostring - read a string sysctl
1676 * @table: the sysctl table
1677 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 * @buffer: the user buffer
1679 * @lenp: the size of the user buffer
1680 * @ppos: file position
1681 *
1682 * Reads/writes a string from/to the user buffer. If the kernel
1683 * buffer provided is not large enough to hold the string, the
1684 * string is truncated. The copied string is %NULL-terminated.
1685 * If the string is being read by the user process, it is copied
1686 * and a newline '\n' is added. It is truncated if the buffer is
1687 * not large enough.
1688 *
1689 * Returns 0 on success.
1690 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001691int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 void __user *buffer, size_t *lenp, loff_t *ppos)
1693{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001694 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001695 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696}
1697
Amerigo Wang00b7c332010-05-05 00:26:45 +00001698static size_t proc_skip_spaces(char **buf)
1699{
1700 size_t ret;
1701 char *tmp = skip_spaces(*buf);
1702 ret = tmp - *buf;
1703 *buf = tmp;
1704 return ret;
1705}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001707static void proc_skip_char(char **buf, size_t *size, const char v)
1708{
1709 while (*size) {
1710 if (**buf != v)
1711 break;
1712 (*size)--;
1713 (*buf)++;
1714 }
1715}
1716
Amerigo Wang00b7c332010-05-05 00:26:45 +00001717#define TMPBUFLEN 22
1718/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001719 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001720 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001721 * @buf: a kernel buffer
1722 * @size: size of the kernel buffer
1723 * @val: this is where the number will be stored
1724 * @neg: set to %TRUE if number is negative
1725 * @perm_tr: a vector which contains the allowed trailers
1726 * @perm_tr_len: size of the perm_tr vector
1727 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001728 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001729 * In case of success %0 is returned and @buf and @size are updated with
1730 * the amount of bytes read. If @tr is non-NULL and a trailing
1731 * character exists (size is non-zero after returning from this
1732 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001733 */
1734static int proc_get_long(char **buf, size_t *size,
1735 unsigned long *val, bool *neg,
1736 const char *perm_tr, unsigned perm_tr_len, char *tr)
1737{
1738 int len;
1739 char *p, tmp[TMPBUFLEN];
1740
1741 if (!*size)
1742 return -EINVAL;
1743
1744 len = *size;
1745 if (len > TMPBUFLEN - 1)
1746 len = TMPBUFLEN - 1;
1747
1748 memcpy(tmp, *buf, len);
1749
1750 tmp[len] = 0;
1751 p = tmp;
1752 if (*p == '-' && *size > 1) {
1753 *neg = true;
1754 p++;
1755 } else
1756 *neg = false;
1757 if (!isdigit(*p))
1758 return -EINVAL;
1759
1760 *val = simple_strtoul(p, &p, 0);
1761
1762 len = p - tmp;
1763
1764 /* We don't know if the next char is whitespace thus we may accept
1765 * invalid integers (e.g. 1234...a) or two integers instead of one
1766 * (e.g. 123...1). So lets not allow such large numbers. */
1767 if (len == TMPBUFLEN - 1)
1768 return -EINVAL;
1769
1770 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1771 return -EINVAL;
1772
1773 if (tr && (len < *size))
1774 *tr = *p;
1775
1776 *buf += len;
1777 *size -= len;
1778
1779 return 0;
1780}
1781
1782/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001783 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001784 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001785 * @buf: the user buffer
1786 * @size: the size of the user buffer
1787 * @val: the integer to be converted
1788 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001789 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001790 * In case of success %0 is returned and @buf and @size are updated with
1791 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001792 */
1793static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1794 bool neg)
1795{
1796 int len;
1797 char tmp[TMPBUFLEN], *p = tmp;
1798
1799 sprintf(p, "%s%lu", neg ? "-" : "", val);
1800 len = strlen(tmp);
1801 if (len > *size)
1802 len = *size;
1803 if (copy_to_user(*buf, tmp, len))
1804 return -EFAULT;
1805 *size -= len;
1806 *buf += len;
1807 return 0;
1808}
1809#undef TMPBUFLEN
1810
1811static int proc_put_char(void __user **buf, size_t *size, char c)
1812{
1813 if (*size) {
1814 char __user **buffer = (char __user **)buf;
1815 if (put_user(c, *buffer))
1816 return -EFAULT;
1817 (*size)--, (*buffer)++;
1818 *buf = *buffer;
1819 }
1820 return 0;
1821}
1822
1823static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824 int *valp,
1825 int write, void *data)
1826{
1827 if (write) {
1828 *valp = *negp ? -*lvalp : *lvalp;
1829 } else {
1830 int val = *valp;
1831 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001832 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833 *lvalp = (unsigned long)-val;
1834 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001835 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836 *lvalp = (unsigned long)val;
1837 }
1838 }
1839 return 0;
1840}
1841
Amerigo Wang00b7c332010-05-05 00:26:45 +00001842static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1843
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001844static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001845 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001846 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001847 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 int write, void *data),
1849 void *data)
1850{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001851 int *i, vleft, first = 1, err = 0;
1852 unsigned long page = 0;
1853 size_t left;
1854 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001855
Amerigo Wang00b7c332010-05-05 00:26:45 +00001856 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857 *lenp = 0;
1858 return 0;
1859 }
1860
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001861 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 vleft = table->maxlen / sizeof(*i);
1863 left = *lenp;
1864
1865 if (!conv)
1866 conv = do_proc_dointvec_conv;
1867
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001869 if (left > PAGE_SIZE - 1)
1870 left = PAGE_SIZE - 1;
1871 page = __get_free_page(GFP_TEMPORARY);
1872 kbuf = (char *) page;
1873 if (!kbuf)
1874 return -ENOMEM;
1875 if (copy_from_user(kbuf, buffer, left)) {
1876 err = -EFAULT;
1877 goto free;
1878 }
1879 kbuf[left] = 0;
1880 }
1881
1882 for (; left && vleft--; i++, first=0) {
1883 unsigned long lval;
1884 bool neg;
1885
1886 if (write) {
1887 left -= proc_skip_spaces(&kbuf);
1888
J. R. Okajima563b0462010-05-25 16:10:14 -07001889 if (!left)
1890 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001891 err = proc_get_long(&kbuf, &left, &lval, &neg,
1892 proc_wspace_sep,
1893 sizeof(proc_wspace_sep), NULL);
1894 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001896 if (conv(&neg, &lval, i, 1, data)) {
1897 err = -EINVAL;
1898 break;
1899 }
1900 } else {
1901 if (conv(&neg, &lval, i, 0, data)) {
1902 err = -EINVAL;
1903 break;
1904 }
1905 if (!first)
1906 err = proc_put_char(&buffer, &left, '\t');
1907 if (err)
1908 break;
1909 err = proc_put_long(&buffer, &left, lval, neg);
1910 if (err)
1911 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912 }
1913 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001914
1915 if (!write && !first && left && !err)
1916 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001917 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001918 left -= proc_skip_spaces(&kbuf);
1919free:
1920 if (write) {
1921 free_page(page);
1922 if (first)
1923 return err ? : -EINVAL;
1924 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 *lenp -= left;
1926 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001927 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928}
1929
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001930static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001931 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001932 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001933 int write, void *data),
1934 void *data)
1935{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001936 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001937 buffer, lenp, ppos, conv, data);
1938}
1939
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940/**
1941 * proc_dointvec - read a vector of integers
1942 * @table: the sysctl table
1943 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944 * @buffer: the user buffer
1945 * @lenp: the size of the user buffer
1946 * @ppos: file position
1947 *
1948 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1949 * values from/to the user buffer, treated as an ASCII string.
1950 *
1951 * Returns 0 on success.
1952 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001953int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954 void __user *buffer, size_t *lenp, loff_t *ppos)
1955{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001956 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 NULL,NULL);
1958}
1959
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001960/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001961 * Taint values can only be increased
1962 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001963 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001964static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001965 void __user *buffer, size_t *lenp, loff_t *ppos)
1966{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001967 struct ctl_table t;
1968 unsigned long tmptaint = get_taint();
1969 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001970
Bastian Blank91fcd412007-04-23 14:41:14 -07001971 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001972 return -EPERM;
1973
Andi Kleen25ddbb12008-10-15 22:01:41 -07001974 t = *table;
1975 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001976 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001977 if (err < 0)
1978 return err;
1979
1980 if (write) {
1981 /*
1982 * Poor man's atomic or. Not worth adding a primitive
1983 * to everyone's atomic.h for this
1984 */
1985 int i;
1986 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
1987 if ((tmptaint >> i) & 1)
1988 add_taint(i);
1989 }
1990 }
1991
1992 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001993}
1994
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07001995#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07001996static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07001997 void __user *buffer, size_t *lenp, loff_t *ppos)
1998{
1999 if (write && !capable(CAP_SYS_ADMIN))
2000 return -EPERM;
2001
2002 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2003}
2004#endif
2005
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006struct do_proc_dointvec_minmax_conv_param {
2007 int *min;
2008 int *max;
2009};
2010
Amerigo Wang00b7c332010-05-05 00:26:45 +00002011static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2012 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013 int write, void *data)
2014{
2015 struct do_proc_dointvec_minmax_conv_param *param = data;
2016 if (write) {
2017 int val = *negp ? -*lvalp : *lvalp;
2018 if ((param->min && *param->min > val) ||
2019 (param->max && *param->max < val))
2020 return -EINVAL;
2021 *valp = val;
2022 } else {
2023 int val = *valp;
2024 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002025 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026 *lvalp = (unsigned long)-val;
2027 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002028 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029 *lvalp = (unsigned long)val;
2030 }
2031 }
2032 return 0;
2033}
2034
2035/**
2036 * proc_dointvec_minmax - read a vector of integers with min/max values
2037 * @table: the sysctl table
2038 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 * @buffer: the user buffer
2040 * @lenp: the size of the user buffer
2041 * @ppos: file position
2042 *
2043 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2044 * values from/to the user buffer, treated as an ASCII string.
2045 *
2046 * This routine will ensure the values are within the range specified by
2047 * table->extra1 (min) and table->extra2 (max).
2048 *
2049 * Returns 0 on success.
2050 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002051int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 void __user *buffer, size_t *lenp, loff_t *ppos)
2053{
2054 struct do_proc_dointvec_minmax_conv_param param = {
2055 .min = (int *) table->extra1,
2056 .max = (int *) table->extra2,
2057 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002058 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 do_proc_dointvec_minmax_conv, &param);
2060}
2061
Kees Cook54b50192012-07-30 14:39:18 -07002062static void validate_coredump_safety(void)
2063{
Alex Kelly046d6622012-10-04 17:15:23 -07002064#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002065 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2066 core_pattern[0] != '/' && core_pattern[0] != '|') {
2067 printk(KERN_WARNING "Unsafe core_pattern used with "\
2068 "suid_dumpable=2. Pipe handler or fully qualified "\
2069 "core dump path required.\n");
2070 }
Alex Kelly046d6622012-10-04 17:15:23 -07002071#endif
Kees Cook54b50192012-07-30 14:39:18 -07002072}
2073
2074static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2075 void __user *buffer, size_t *lenp, loff_t *ppos)
2076{
2077 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2078 if (!error)
2079 validate_coredump_safety();
2080 return error;
2081}
2082
Alex Kelly046d6622012-10-04 17:15:23 -07002083#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002084static int proc_dostring_coredump(struct ctl_table *table, int write,
2085 void __user *buffer, size_t *lenp, loff_t *ppos)
2086{
2087 int error = proc_dostring(table, write, buffer, lenp, ppos);
2088 if (!error)
2089 validate_coredump_safety();
2090 return error;
2091}
Alex Kelly046d6622012-10-04 17:15:23 -07002092#endif
Kees Cook54b50192012-07-30 14:39:18 -07002093
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002094static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 void __user *buffer,
2096 size_t *lenp, loff_t *ppos,
2097 unsigned long convmul,
2098 unsigned long convdiv)
2099{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002100 unsigned long *i, *min, *max;
2101 int vleft, first = 1, err = 0;
2102 unsigned long page = 0;
2103 size_t left;
2104 char *kbuf;
2105
2106 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107 *lenp = 0;
2108 return 0;
2109 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002110
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002111 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112 min = (unsigned long *) table->extra1;
2113 max = (unsigned long *) table->extra2;
2114 vleft = table->maxlen / sizeof(unsigned long);
2115 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002116
2117 if (write) {
2118 if (left > PAGE_SIZE - 1)
2119 left = PAGE_SIZE - 1;
2120 page = __get_free_page(GFP_TEMPORARY);
2121 kbuf = (char *) page;
2122 if (!kbuf)
2123 return -ENOMEM;
2124 if (copy_from_user(kbuf, buffer, left)) {
2125 err = -EFAULT;
2126 goto free;
2127 }
2128 kbuf[left] = 0;
2129 }
2130
Eric Dumazet27b3d802010-10-07 12:59:29 -07002131 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002132 unsigned long val;
2133
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002135 bool neg;
2136
2137 left -= proc_skip_spaces(&kbuf);
2138
2139 err = proc_get_long(&kbuf, &left, &val, &neg,
2140 proc_wspace_sep,
2141 sizeof(proc_wspace_sep), NULL);
2142 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002143 break;
2144 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145 continue;
2146 if ((min && val < *min) || (max && val > *max))
2147 continue;
2148 *i = val;
2149 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002150 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002151 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002152 err = proc_put_char(&buffer, &left, '\t');
2153 err = proc_put_long(&buffer, &left, val, false);
2154 if (err)
2155 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 }
2157 }
2158
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159 if (!write && !first && left && !err)
2160 err = proc_put_char(&buffer, &left, '\n');
2161 if (write && !err)
2162 left -= proc_skip_spaces(&kbuf);
2163free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002165 free_page(page);
2166 if (first)
2167 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002168 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169 *lenp -= left;
2170 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002171 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172}
2173
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002174static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002175 void __user *buffer,
2176 size_t *lenp, loff_t *ppos,
2177 unsigned long convmul,
2178 unsigned long convdiv)
2179{
2180 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002181 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002182}
2183
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184/**
2185 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2186 * @table: the sysctl table
2187 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 * @buffer: the user buffer
2189 * @lenp: the size of the user buffer
2190 * @ppos: file position
2191 *
2192 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2193 * values from/to the user buffer, treated as an ASCII string.
2194 *
2195 * This routine will ensure the values are within the range specified by
2196 * table->extra1 (min) and table->extra2 (max).
2197 *
2198 * Returns 0 on success.
2199 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002200int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 void __user *buffer, size_t *lenp, loff_t *ppos)
2202{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002203 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204}
2205
2206/**
2207 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2208 * @table: the sysctl table
2209 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 * @buffer: the user buffer
2211 * @lenp: the size of the user buffer
2212 * @ppos: file position
2213 *
2214 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2215 * values from/to the user buffer, treated as an ASCII string. The values
2216 * are treated as milliseconds, and converted to jiffies when they are stored.
2217 *
2218 * This routine will ensure the values are within the range specified by
2219 * table->extra1 (min) and table->extra2 (max).
2220 *
2221 * Returns 0 on success.
2222 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002223int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224 void __user *buffer,
2225 size_t *lenp, loff_t *ppos)
2226{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002227 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 lenp, ppos, HZ, 1000l);
2229}
2230
2231
Amerigo Wang00b7c332010-05-05 00:26:45 +00002232static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002233 int *valp,
2234 int write, void *data)
2235{
2236 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002237 if (*lvalp > LONG_MAX / HZ)
2238 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2240 } else {
2241 int val = *valp;
2242 unsigned long lval;
2243 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 lval = (unsigned long)-val;
2246 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002247 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248 lval = (unsigned long)val;
2249 }
2250 *lvalp = lval / HZ;
2251 }
2252 return 0;
2253}
2254
Amerigo Wang00b7c332010-05-05 00:26:45 +00002255static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 int *valp,
2257 int write, void *data)
2258{
2259 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002260 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2261 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2263 } else {
2264 int val = *valp;
2265 unsigned long lval;
2266 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002267 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 lval = (unsigned long)-val;
2269 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002270 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271 lval = (unsigned long)val;
2272 }
2273 *lvalp = jiffies_to_clock_t(lval);
2274 }
2275 return 0;
2276}
2277
Amerigo Wang00b7c332010-05-05 00:26:45 +00002278static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 int *valp,
2280 int write, void *data)
2281{
2282 if (write) {
2283 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2284 } else {
2285 int val = *valp;
2286 unsigned long lval;
2287 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002288 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 lval = (unsigned long)-val;
2290 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002291 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 lval = (unsigned long)val;
2293 }
2294 *lvalp = jiffies_to_msecs(lval);
2295 }
2296 return 0;
2297}
2298
2299/**
2300 * proc_dointvec_jiffies - read a vector of integers as seconds
2301 * @table: the sysctl table
2302 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 * @buffer: the user buffer
2304 * @lenp: the size of the user buffer
2305 * @ppos: file position
2306 *
2307 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2308 * values from/to the user buffer, treated as an ASCII string.
2309 * The values read are assumed to be in seconds, and are converted into
2310 * jiffies.
2311 *
2312 * Returns 0 on success.
2313 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002314int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 void __user *buffer, size_t *lenp, loff_t *ppos)
2316{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002317 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 do_proc_dointvec_jiffies_conv,NULL);
2319}
2320
2321/**
2322 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2323 * @table: the sysctl table
2324 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 * @buffer: the user buffer
2326 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002327 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 *
2329 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2330 * values from/to the user buffer, treated as an ASCII string.
2331 * The values read are assumed to be in 1/USER_HZ seconds, and
2332 * are converted into jiffies.
2333 *
2334 * Returns 0 on success.
2335 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002336int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 void __user *buffer, size_t *lenp, loff_t *ppos)
2338{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002339 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 do_proc_dointvec_userhz_jiffies_conv,NULL);
2341}
2342
2343/**
2344 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2345 * @table: the sysctl table
2346 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 * @buffer: the user buffer
2348 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002349 * @ppos: file position
2350 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 *
2352 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2353 * values from/to the user buffer, treated as an ASCII string.
2354 * The values read are assumed to be in 1/1000 seconds, and
2355 * are converted into jiffies.
2356 *
2357 * Returns 0 on success.
2358 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002359int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 void __user *buffer, size_t *lenp, loff_t *ppos)
2361{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002362 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002363 do_proc_dointvec_ms_jiffies_conv, NULL);
2364}
2365
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002366static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002367 void __user *buffer, size_t *lenp, loff_t *ppos)
2368{
2369 struct pid *new_pid;
2370 pid_t tmp;
2371 int r;
2372
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002373 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002374
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002375 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002376 lenp, ppos, NULL, NULL);
2377 if (r || !write)
2378 return r;
2379
2380 new_pid = find_get_pid(tmp);
2381 if (!new_pid)
2382 return -ESRCH;
2383
2384 put_pid(xchg(&cad_pid, new_pid));
2385 return 0;
2386}
2387
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002388/**
2389 * proc_do_large_bitmap - read/write from/to a large bitmap
2390 * @table: the sysctl table
2391 * @write: %TRUE if this is a write to the sysctl file
2392 * @buffer: the user buffer
2393 * @lenp: the size of the user buffer
2394 * @ppos: file position
2395 *
2396 * The bitmap is stored at table->data and the bitmap length (in bits)
2397 * in table->maxlen.
2398 *
2399 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2400 * large bitmaps may be represented in a compact manner. Writing into
2401 * the file will clear the bitmap then update it with the given input.
2402 *
2403 * Returns 0 on success.
2404 */
2405int proc_do_large_bitmap(struct ctl_table *table, int write,
2406 void __user *buffer, size_t *lenp, loff_t *ppos)
2407{
2408 int err = 0;
2409 bool first = 1;
2410 size_t left = *lenp;
2411 unsigned long bitmap_len = table->maxlen;
2412 unsigned long *bitmap = (unsigned long *) table->data;
2413 unsigned long *tmp_bitmap = NULL;
2414 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2415
2416 if (!bitmap_len || !left || (*ppos && !write)) {
2417 *lenp = 0;
2418 return 0;
2419 }
2420
2421 if (write) {
2422 unsigned long page = 0;
2423 char *kbuf;
2424
2425 if (left > PAGE_SIZE - 1)
2426 left = PAGE_SIZE - 1;
2427
2428 page = __get_free_page(GFP_TEMPORARY);
2429 kbuf = (char *) page;
2430 if (!kbuf)
2431 return -ENOMEM;
2432 if (copy_from_user(kbuf, buffer, left)) {
2433 free_page(page);
2434 return -EFAULT;
2435 }
2436 kbuf[left] = 0;
2437
2438 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2439 GFP_KERNEL);
2440 if (!tmp_bitmap) {
2441 free_page(page);
2442 return -ENOMEM;
2443 }
2444 proc_skip_char(&kbuf, &left, '\n');
2445 while (!err && left) {
2446 unsigned long val_a, val_b;
2447 bool neg;
2448
2449 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2450 sizeof(tr_a), &c);
2451 if (err)
2452 break;
2453 if (val_a >= bitmap_len || neg) {
2454 err = -EINVAL;
2455 break;
2456 }
2457
2458 val_b = val_a;
2459 if (left) {
2460 kbuf++;
2461 left--;
2462 }
2463
2464 if (c == '-') {
2465 err = proc_get_long(&kbuf, &left, &val_b,
2466 &neg, tr_b, sizeof(tr_b),
2467 &c);
2468 if (err)
2469 break;
2470 if (val_b >= bitmap_len || neg ||
2471 val_a > val_b) {
2472 err = -EINVAL;
2473 break;
2474 }
2475 if (left) {
2476 kbuf++;
2477 left--;
2478 }
2479 }
2480
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002481 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002482 first = 0;
2483 proc_skip_char(&kbuf, &left, '\n');
2484 }
2485 free_page(page);
2486 } else {
2487 unsigned long bit_a, bit_b = 0;
2488
2489 while (left) {
2490 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2491 if (bit_a >= bitmap_len)
2492 break;
2493 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2494 bit_a + 1) - 1;
2495
2496 if (!first) {
2497 err = proc_put_char(&buffer, &left, ',');
2498 if (err)
2499 break;
2500 }
2501 err = proc_put_long(&buffer, &left, bit_a, false);
2502 if (err)
2503 break;
2504 if (bit_a != bit_b) {
2505 err = proc_put_char(&buffer, &left, '-');
2506 if (err)
2507 break;
2508 err = proc_put_long(&buffer, &left, bit_b, false);
2509 if (err)
2510 break;
2511 }
2512
2513 first = 0; bit_b++;
2514 }
2515 if (!err)
2516 err = proc_put_char(&buffer, &left, '\n');
2517 }
2518
2519 if (!err) {
2520 if (write) {
2521 if (*ppos)
2522 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2523 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002524 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002525 }
2526 kfree(tmp_bitmap);
2527 *lenp -= left;
2528 *ppos += *lenp;
2529 return 0;
2530 } else {
2531 kfree(tmp_bitmap);
2532 return err;
2533 }
2534}
2535
Jovi Zhang55610502011-01-12 17:00:45 -08002536#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002538int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 void __user *buffer, size_t *lenp, loff_t *ppos)
2540{
2541 return -ENOSYS;
2542}
2543
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002544int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 void __user *buffer, size_t *lenp, loff_t *ppos)
2546{
2547 return -ENOSYS;
2548}
2549
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002550int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 void __user *buffer, size_t *lenp, loff_t *ppos)
2552{
2553 return -ENOSYS;
2554}
2555
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002556int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557 void __user *buffer, size_t *lenp, loff_t *ppos)
2558{
2559 return -ENOSYS;
2560}
2561
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002562int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 void __user *buffer, size_t *lenp, loff_t *ppos)
2564{
2565 return -ENOSYS;
2566}
2567
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002568int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 void __user *buffer, size_t *lenp, loff_t *ppos)
2570{
2571 return -ENOSYS;
2572}
2573
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002574int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 void __user *buffer, size_t *lenp, loff_t *ppos)
2576{
2577 return -ENOSYS;
2578}
2579
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002580int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581 void __user *buffer,
2582 size_t *lenp, loff_t *ppos)
2583{
2584 return -ENOSYS;
2585}
2586
2587
Jovi Zhang55610502011-01-12 17:00:45 -08002588#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590/*
2591 * No sense putting this after each symbol definition, twice,
2592 * exception granted :-)
2593 */
2594EXPORT_SYMBOL(proc_dointvec);
2595EXPORT_SYMBOL(proc_dointvec_jiffies);
2596EXPORT_SYMBOL(proc_dointvec_minmax);
2597EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2598EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2599EXPORT_SYMBOL(proc_dostring);
2600EXPORT_SYMBOL(proc_doulongvec_minmax);
2601EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);