blob: 7d3a2e0475e51f29dac7a9674eb08b5b0e1b75db [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 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200369 {
370 .procname = "numa_balancing_scan_size_mb",
371 .data = &sysctl_numa_balancing_scan_size,
372 .maxlen = sizeof(unsigned int),
373 .mode = 0644,
374 .proc_handler = proc_dointvec,
375 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200376#endif /* CONFIG_NUMA_BALANCING */
377#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200378 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100379 .procname = "sched_rt_period_us",
380 .data = &sysctl_sched_rt_period,
381 .maxlen = sizeof(unsigned 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 },
385 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100386 .procname = "sched_rt_runtime_us",
387 .data = &sysctl_sched_rt_runtime,
388 .maxlen = sizeof(int),
389 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800390 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100391 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100392#ifdef CONFIG_SCHED_AUTOGROUP
393 {
394 .procname = "sched_autogroup_enabled",
395 .data = &sysctl_sched_autogroup_enabled,
396 .maxlen = sizeof(unsigned int),
397 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800398 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100399 .extra1 = &zero,
400 .extra2 = &one,
401 },
402#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700403#ifdef CONFIG_CFS_BANDWIDTH
404 {
405 .procname = "sched_cfs_bandwidth_slice_us",
406 .data = &sysctl_sched_cfs_bandwidth_slice,
407 .maxlen = sizeof(unsigned int),
408 .mode = 0644,
409 .proc_handler = proc_dointvec_minmax,
410 .extra1 = &one,
411 },
412#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700413#ifdef CONFIG_PROVE_LOCKING
414 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700415 .procname = "prove_locking",
416 .data = &prove_locking,
417 .maxlen = sizeof(int),
418 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800419 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700420 },
421#endif
422#ifdef CONFIG_LOCK_STAT
423 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700424 .procname = "lock_stat",
425 .data = &lock_stat,
426 .maxlen = sizeof(int),
427 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800428 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700429 },
430#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200431 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 .procname = "panic",
433 .data = &panic_timeout,
434 .maxlen = sizeof(int),
435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800436 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 },
Alex Kelly046d6622012-10-04 17:15:23 -0700438#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 .procname = "core_uses_pid",
441 .data = &core_uses_pid,
442 .maxlen = sizeof(int),
443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800444 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 },
446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 .procname = "core_pattern",
448 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700449 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700451 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 },
Neil Hormana2939802009-09-23 15:56:56 -0700453 {
Neil Hormana2939802009-09-23 15:56:56 -0700454 .procname = "core_pipe_limit",
455 .data = &core_pipe_limit,
456 .maxlen = sizeof(unsigned int),
457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800458 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700459 },
Alex Kelly046d6622012-10-04 17:15:23 -0700460#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800461#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700464 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800468#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100469#ifdef CONFIG_LATENCYTOP
470 {
471 .procname = "latencytop",
472 .data = &latencytop_enabled,
473 .maxlen = sizeof(int),
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100476 },
477#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478#ifdef CONFIG_BLK_DEV_INITRD
479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "real-root-dev",
481 .data = &real_root_dev,
482 .maxlen = sizeof(int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
486#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700487 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700488 .procname = "print-fatal-signals",
489 .data = &print_fatal_signals,
490 .maxlen = sizeof(int),
491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700493 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700494#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .procname = "reboot-cmd",
497 .data = reboot_command,
498 .maxlen = 256,
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 },
502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "stop-a",
504 .data = &stop_a_enabled,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "scons-poweroff",
511 .data = &scons_pwroff,
512 .maxlen = sizeof (int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 },
516#endif
David S. Miller08714202008-11-16 23:49:24 -0800517#ifdef CONFIG_SPARC64
518 {
David S. Miller08714202008-11-16 23:49:24 -0800519 .procname = "tsb-ratio",
520 .data = &sysctl_tsb_ratio,
521 .maxlen = sizeof (int),
522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800523 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800524 },
525#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526#ifdef __hppa__
527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "soft-power",
529 .data = &pwrsw_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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "unaligned-trap",
536 .data = &unaligned_enabled,
537 .maxlen = sizeof (int),
538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 },
541#endif
542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .procname = "ctrl-alt-del",
544 .data = &C_A_D,
545 .maxlen = sizeof(int),
546 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800547 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400549#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200550 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200551 .procname = "ftrace_enabled",
552 .data = &ftrace_enabled,
553 .maxlen = sizeof(int),
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200556 },
557#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500558#ifdef CONFIG_STACK_TRACER
559 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500560 .procname = "stack_tracer_enabled",
561 .data = &stack_tracer_enabled,
562 .maxlen = sizeof(int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500565 },
566#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400567#ifdef CONFIG_TRACING
568 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100569 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400570 .data = &ftrace_dump_on_oops,
571 .maxlen = sizeof(int),
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400574 },
575#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200576#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "modprobe",
579 .data = &modprobe_path,
580 .maxlen = KMOD_PATH_LEN,
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
Kees Cook3d433212009-04-02 15:49:29 -0700584 {
Kees Cook3d433212009-04-02 15:49:29 -0700585 .procname = "modules_disabled",
586 .data = &modules_disabled,
587 .maxlen = sizeof(int),
588 .mode = 0644,
589 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700591 .extra1 = &one,
592 .extra2 = &one,
593 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100595#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100598 .data = &uevent_helper,
599 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 },
603#endif
604#ifdef CONFIG_CHR_DEV_SG
605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "sg-big-buff",
607 .data = &sg_big_buff,
608 .maxlen = sizeof (int),
609 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
612#endif
613#ifdef CONFIG_BSD_PROCESS_ACCT
614 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 .procname = "acct",
616 .data = &acct_parm,
617 .maxlen = 3*sizeof(int),
618 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800619 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
621#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622#ifdef CONFIG_MAGIC_SYSRQ
623 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800625 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 .maxlen = sizeof (int),
627 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700628 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 },
630#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700631#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700634 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .maxlen = sizeof (int),
636 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800637 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700639#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "threads-max",
642 .data = &max_threads,
643 .maxlen = sizeof(int),
644 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800645 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 },
647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "random",
649 .mode = 0555,
650 .child = random_table,
651 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 {
Eric Paris17f60a72011-04-01 17:07:50 -0400653 .procname = "usermodehelper",
654 .mode = 0555,
655 .child = usermodehelper_table,
656 },
657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "overflowuid",
659 .data = &overflowuid,
660 .maxlen = sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .extra1 = &minolduid,
664 .extra2 = &maxolduid,
665 },
666 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .procname = "overflowgid",
668 .data = &overflowgid,
669 .maxlen = sizeof(int),
670 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800671 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .extra1 = &minolduid,
673 .extra2 = &maxolduid,
674 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800675#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676#ifdef CONFIG_MATHEMU
677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .procname = "ieee_emulation_warnings",
679 .data = &sysctl_ieee_emulation_warnings,
680 .maxlen = sizeof(int),
681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800682 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 },
684#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200687 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 .maxlen = sizeof(int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 },
692#endif
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "pid_max",
695 .data = &pid_max,
696 .maxlen = sizeof (int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .extra1 = &pid_max_min,
700 .extra2 = &pid_max_max,
701 },
702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .procname = "panic_on_oops",
704 .data = &panic_on_oops,
705 .maxlen = sizeof(int),
706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800707 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800709#if defined CONFIG_PRINTK
710 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800711 .procname = "printk",
712 .data = &console_loglevel,
713 .maxlen = 4*sizeof(int),
714 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800715 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800716 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700719 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700726 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .maxlen = sizeof(int),
728 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800729 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 },
Dave Youngaf913222009-09-22 16:43:33 -0700731 {
Dave Youngaf913222009-09-22 16:43:33 -0700732 .procname = "printk_delay",
733 .data = &printk_delay_msec,
734 .maxlen = sizeof(int),
735 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800736 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700737 .extra1 = &zero,
738 .extra2 = &ten_thousand,
739 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800741 .procname = "dmesg_restrict",
742 .data = &dmesg_restrict,
743 .maxlen = sizeof(int),
744 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700745 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800746 .extra1 = &zero,
747 .extra2 = &one,
748 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800749 {
750 .procname = "kptr_restrict",
751 .data = &kptr_restrict,
752 .maxlen = sizeof(int),
753 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700754 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800755 .extra1 = &zero,
756 .extra2 = &two,
757 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800758#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800759 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 .procname = "ngroups_max",
761 .data = &ngroups_max,
762 .maxlen = sizeof (int),
763 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 },
Dan Ballard73efc032011-10-31 17:11:20 -0700766 {
767 .procname = "cap_last_cap",
768 .data = (void *)&cap_last_cap,
769 .maxlen = sizeof(int),
770 .mode = 0444,
771 .proc_handler = proc_dointvec,
772 },
Don Zickus58687ac2010-05-07 17:11:44 -0400773#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500774 {
Don Zickus58687ac2010-05-07 17:11:44 -0400775 .procname = "watchdog",
776 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500777 .maxlen = sizeof (int),
778 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700779 .proc_handler = proc_dowatchdog,
780 .extra1 = &zero,
781 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400782 },
783 {
784 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700785 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400786 .maxlen = sizeof(int),
787 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700788 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400789 .extra1 = &neg_one,
790 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500791 },
Don Zickus2508ce12010-05-07 17:11:46 -0400792 {
793 .procname = "softlockup_panic",
794 .data = &softlockup_panic,
795 .maxlen = sizeof(int),
796 .mode = 0644,
797 .proc_handler = proc_dointvec_minmax,
798 .extra1 = &zero,
799 .extra2 = &one,
800 },
Don Zickus5dc30552010-11-29 17:07:17 -0500801 {
802 .procname = "nmi_watchdog",
803 .data = &watchdog_enabled,
804 .maxlen = sizeof (int),
805 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700806 .proc_handler = proc_dowatchdog,
807 .extra1 = &zero,
808 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500809 },
810#endif
811#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
812 {
813 .procname = "unknown_nmi_panic",
814 .data = &unknown_nmi_panic,
815 .maxlen = sizeof (int),
816 .mode = 0644,
817 .proc_handler = proc_dointvec,
818 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500819#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820#if defined(CONFIG_X86)
821 {
Don Zickus8da5add2006-09-26 10:52:27 +0200822 .procname = "panic_on_unrecovered_nmi",
823 .data = &panic_on_unrecovered_nmi,
824 .maxlen = sizeof(int),
825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200827 },
828 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700829 .procname = "panic_on_io_nmi",
830 .data = &panic_on_io_nmi,
831 .maxlen = sizeof(int),
832 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800833 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700834 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900835#ifdef CONFIG_DEBUG_STACKOVERFLOW
836 {
837 .procname = "panic_on_stackoverflow",
838 .data = &sysctl_panic_on_stackoverflow,
839 .maxlen = sizeof(int),
840 .mode = 0644,
841 .proc_handler = proc_dointvec,
842 },
843#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700844 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 .procname = "bootloader_type",
846 .data = &bootloader_type,
847 .maxlen = sizeof (int),
848 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800849 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100851 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700852 .procname = "bootloader_version",
853 .data = &bootloader_version,
854 .maxlen = sizeof (int),
855 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800856 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700857 },
858 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100859 .procname = "kstack_depth_to_print",
860 .data = &kstack_depth_to_print,
861 .maxlen = sizeof(int),
862 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800863 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100864 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100865 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100866 .procname = "io_delay_type",
867 .data = &io_delay_type,
868 .maxlen = sizeof(int),
869 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800870 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100871 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800873#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 .procname = "randomize_va_space",
876 .data = &randomize_va_space,
877 .maxlen = sizeof(int),
878 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800879 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800881#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800882#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700883 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700884 .procname = "spin_retry",
885 .data = &spin_retry,
886 .maxlen = sizeof (int),
887 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800888 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700889 },
890#endif
Len Brown673d5b42007-07-28 03:33:16 -0400891#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800892 {
Pavel Machekc255d842006-02-20 18:27:58 -0800893 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700894 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800895 .maxlen = sizeof (unsigned long),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800898 },
899#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800900#ifdef CONFIG_IA64
901 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800902 .procname = "ignore-unaligned-usertrap",
903 .data = &no_unaligned_warning,
904 .maxlen = sizeof (int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800907 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800908 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800909 .procname = "unaligned-dump-stack",
910 .data = &unaligned_dump_stack,
911 .maxlen = sizeof (int),
912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800914 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800915#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800916#ifdef CONFIG_DETECT_HUNG_TASK
917 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800918 .procname = "hung_task_panic",
919 .data = &sysctl_hung_task_panic,
920 .maxlen = sizeof(int),
921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800922 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800923 .extra1 = &zero,
924 .extra2 = &one,
925 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100926 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100927 .procname = "hung_task_check_count",
928 .data = &sysctl_hung_task_check_count,
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_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100932 },
933 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100934 .procname = "hung_task_timeout_secs",
935 .data = &sysctl_hung_task_timeout_secs,
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_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100939 },
940 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100941 .procname = "hung_task_warnings",
942 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100943 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100944 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800945 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100946 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700947#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200948#ifdef CONFIG_COMPAT
949 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200950 .procname = "compat-log",
951 .data = &compat_log,
952 .maxlen = sizeof (int),
953 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800954 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200955 },
956#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700957#ifdef CONFIG_RT_MUTEXES
958 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700959 .procname = "max_lock_depth",
960 .data = &max_lock_depth,
961 .maxlen = sizeof(int),
962 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700964 },
965#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700966 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700967 .procname = "poweroff_cmd",
968 .data = &poweroff_cmd,
969 .maxlen = POWEROFF_CMD_PATH_LEN,
970 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800971 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700972 },
David Howells0b77f5b2008-04-29 01:01:32 -0700973#ifdef CONFIG_KEYS
974 {
David Howells0b77f5b2008-04-29 01:01:32 -0700975 .procname = "keys",
976 .mode = 0555,
977 .child = key_sysctls,
978 },
979#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700980#ifdef CONFIG_RCU_TORTURE_TEST
981 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700982 .procname = "rcutorture_runnable",
983 .data = &rcutorture_runnable,
984 .maxlen = sizeof(int),
985 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800986 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700987 },
988#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200989#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400990 /*
991 * User-space scripts rely on the existence of this file
992 * as a feature check for perf_events being enabled.
993 *
994 * So it's an ABI, do not remove!
995 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200996 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200997 .procname = "perf_event_paranoid",
998 .data = &sysctl_perf_event_paranoid,
999 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001000 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001001 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001002 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001003 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001004 .procname = "perf_event_mlock_kb",
1005 .data = &sysctl_perf_event_mlock,
1006 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001007 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001008 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001009 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001010 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001011 .procname = "perf_event_max_sample_rate",
1012 .data = &sysctl_perf_event_sample_rate,
1013 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001014 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001015 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001016 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001017#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001018#ifdef CONFIG_KMEMCHECK
1019 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001020 .procname = "kmemcheck",
1021 .data = &kmemcheck_enabled,
1022 .maxlen = sizeof(int),
1023 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001024 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001025 },
1026#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001027#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001028 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001029 .procname = "blk_iopoll",
1030 .data = &blk_iopoll_enabled,
1031 .maxlen = sizeof(int),
1032 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001033 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001034 },
Jens Axboecb684b52009-09-15 21:53:11 +02001035#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001036 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037};
1038
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001039static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 .procname = "overcommit_memory",
1042 .data = &sysctl_overcommit_memory,
1043 .maxlen = sizeof(sysctl_overcommit_memory),
1044 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001045 .proc_handler = proc_dointvec_minmax,
1046 .extra1 = &zero,
1047 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 },
1049 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001050 .procname = "panic_on_oom",
1051 .data = &sysctl_panic_on_oom,
1052 .maxlen = sizeof(sysctl_panic_on_oom),
1053 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001054 .proc_handler = proc_dointvec_minmax,
1055 .extra1 = &zero,
1056 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001057 },
1058 {
David Rientjesfe071d72007-10-16 23:25:56 -07001059 .procname = "oom_kill_allocating_task",
1060 .data = &sysctl_oom_kill_allocating_task,
1061 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1062 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001063 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001064 },
1065 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001066 .procname = "oom_dump_tasks",
1067 .data = &sysctl_oom_dump_tasks,
1068 .maxlen = sizeof(sysctl_oom_dump_tasks),
1069 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001070 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001071 },
1072 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 .procname = "overcommit_ratio",
1074 .data = &sysctl_overcommit_ratio,
1075 .maxlen = sizeof(sysctl_overcommit_ratio),
1076 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001077 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 },
1079 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 .procname = "page-cluster",
1081 .data = &page_cluster,
1082 .maxlen = sizeof(int),
1083 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001084 .proc_handler = proc_dointvec_minmax,
1085 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 },
1087 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 .procname = "dirty_background_ratio",
1089 .data = &dirty_background_ratio,
1090 .maxlen = sizeof(dirty_background_ratio),
1091 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001092 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 .extra1 = &zero,
1094 .extra2 = &one_hundred,
1095 },
1096 {
David Rientjes2da02992009-01-06 14:39:31 -08001097 .procname = "dirty_background_bytes",
1098 .data = &dirty_background_bytes,
1099 .maxlen = sizeof(dirty_background_bytes),
1100 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001101 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001102 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001103 },
1104 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 .procname = "dirty_ratio",
1106 .data = &vm_dirty_ratio,
1107 .maxlen = sizeof(vm_dirty_ratio),
1108 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001109 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .extra1 = &zero,
1111 .extra2 = &one_hundred,
1112 },
1113 {
David Rientjes2da02992009-01-06 14:39:31 -08001114 .procname = "dirty_bytes",
1115 .data = &vm_dirty_bytes,
1116 .maxlen = sizeof(vm_dirty_bytes),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001119 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001120 },
1121 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001123 .data = &dirty_writeback_interval,
1124 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001126 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 },
1128 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001130 .data = &dirty_expire_interval,
1131 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001133 .proc_handler = proc_dointvec_minmax,
1134 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 },
1136 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001137 .procname = "nr_pdflush_threads",
1138 .mode = 0444 /* read-only */,
1139 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 },
1141 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 .procname = "swappiness",
1143 .data = &vm_swappiness,
1144 .maxlen = sizeof(vm_swappiness),
1145 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001146 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 .extra1 = &zero,
1148 .extra2 = &one_hundred,
1149 },
1150#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001153 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .maxlen = sizeof(unsigned long),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .extra1 = (void *)&hugetlb_zero,
1158 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001159 },
1160#ifdef CONFIG_NUMA
1161 {
1162 .procname = "nr_hugepages_mempolicy",
1163 .data = NULL,
1164 .maxlen = sizeof(unsigned long),
1165 .mode = 0644,
1166 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1167 .extra1 = (void *)&hugetlb_zero,
1168 .extra2 = (void *)&hugetlb_infinity,
1169 },
1170#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .procname = "hugetlb_shm_group",
1173 .data = &sysctl_hugetlb_shm_group,
1174 .maxlen = sizeof(gid_t),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 },
Mel Gorman396faf02007-07-17 04:03:13 -07001178 {
Mel Gorman396faf02007-07-17 04:03:13 -07001179 .procname = "hugepages_treat_as_movable",
1180 .data = &hugepages_treat_as_movable,
1181 .maxlen = sizeof(int),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001184 },
Adam Litke54f9f802007-10-16 01:26:20 -07001185 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001186 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001187 .data = NULL,
1188 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001189 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001190 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001191 .extra1 = (void *)&hugetlb_zero,
1192 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001193 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194#endif
1195 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 .procname = "lowmem_reserve_ratio",
1197 .data = &sysctl_lowmem_reserve_ratio,
1198 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1199 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001200 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 },
1202 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001203 .procname = "drop_caches",
1204 .data = &sysctl_drop_caches,
1205 .maxlen = sizeof(int),
1206 .mode = 0644,
1207 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001208 .extra1 = &one,
1209 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001210 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001211#ifdef CONFIG_COMPACTION
1212 {
1213 .procname = "compact_memory",
1214 .data = &sysctl_compact_memory,
1215 .maxlen = sizeof(int),
1216 .mode = 0200,
1217 .proc_handler = sysctl_compaction_handler,
1218 },
Mel Gorman5e771902010-05-24 14:32:31 -07001219 {
1220 .procname = "extfrag_threshold",
1221 .data = &sysctl_extfrag_threshold,
1222 .maxlen = sizeof(int),
1223 .mode = 0644,
1224 .proc_handler = sysctl_extfrag_handler,
1225 .extra1 = &min_extfrag_threshold,
1226 .extra2 = &max_extfrag_threshold,
1227 },
1228
Mel Gorman76ab0f52010-05-24 14:32:28 -07001229#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001230 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 .procname = "min_free_kbytes",
1232 .data = &min_free_kbytes,
1233 .maxlen = sizeof(min_free_kbytes),
1234 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001235 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236 .extra1 = &zero,
1237 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001238 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001239 .procname = "percpu_pagelist_fraction",
1240 .data = &percpu_pagelist_fraction,
1241 .maxlen = sizeof(percpu_pagelist_fraction),
1242 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001243 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001244 .extra1 = &min_percpu_pagelist_fract,
1245 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246#ifdef CONFIG_MMU
1247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 .procname = "max_map_count",
1249 .data = &sysctl_max_map_count,
1250 .maxlen = sizeof(sysctl_max_map_count),
1251 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001252 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001253 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001255#else
1256 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001257 .procname = "nr_trim_pages",
1258 .data = &sysctl_nr_trim_pages,
1259 .maxlen = sizeof(sysctl_nr_trim_pages),
1260 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001261 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001262 .extra1 = &zero,
1263 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264#endif
1265 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266 .procname = "laptop_mode",
1267 .data = &laptop_mode,
1268 .maxlen = sizeof(laptop_mode),
1269 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001270 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 },
1272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 .procname = "block_dump",
1274 .data = &block_dump,
1275 .maxlen = sizeof(block_dump),
1276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001277 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 .extra1 = &zero,
1279 },
1280 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 .procname = "vfs_cache_pressure",
1282 .data = &sysctl_vfs_cache_pressure,
1283 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1284 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001285 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 .extra1 = &zero,
1287 },
1288#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1289 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 .procname = "legacy_va_layout",
1291 .data = &sysctl_legacy_va_layout,
1292 .maxlen = sizeof(sysctl_legacy_va_layout),
1293 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001294 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .extra1 = &zero,
1296 },
1297#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001298#ifdef CONFIG_NUMA
1299 {
Christoph Lameter17436602006-01-18 17:42:32 -08001300 .procname = "zone_reclaim_mode",
1301 .data = &zone_reclaim_mode,
1302 .maxlen = sizeof(zone_reclaim_mode),
1303 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001304 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001305 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001306 },
Christoph Lameter96146342006-07-03 00:24:13 -07001307 {
Christoph Lameter96146342006-07-03 00:24:13 -07001308 .procname = "min_unmapped_ratio",
1309 .data = &sysctl_min_unmapped_ratio,
1310 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1311 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001312 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001313 .extra1 = &zero,
1314 .extra2 = &one_hundred,
1315 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001316 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001317 .procname = "min_slab_ratio",
1318 .data = &sysctl_min_slab_ratio,
1319 .maxlen = sizeof(sysctl_min_slab_ratio),
1320 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001321 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001322 .extra1 = &zero,
1323 .extra2 = &one_hundred,
1324 },
Christoph Lameter17436602006-01-18 17:42:32 -08001325#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001326#ifdef CONFIG_SMP
1327 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001328 .procname = "stat_interval",
1329 .data = &sysctl_stat_interval,
1330 .maxlen = sizeof(sysctl_stat_interval),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001333 },
1334#endif
David Howells6e141542009-12-15 19:27:45 +00001335#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001336 {
Eric Parised032182007-06-28 15:55:21 -04001337 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001338 .data = &dac_mmap_min_addr,
1339 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001342 },
David Howells6e141542009-12-15 19:27:45 +00001343#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001344#ifdef CONFIG_NUMA
1345 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001346 .procname = "numa_zonelist_order",
1347 .data = &numa_zonelist_order,
1348 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001350 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001351 },
1352#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001353#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001354 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001355 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001356 .procname = "vdso_enabled",
1357 .data = &vdso_enabled,
1358 .maxlen = sizeof(vdso_enabled),
1359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001361 .extra1 = &zero,
1362 },
1363#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001364#ifdef CONFIG_HIGHMEM
1365 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001366 .procname = "highmem_is_dirtyable",
1367 .data = &vm_highmem_is_dirtyable,
1368 .maxlen = sizeof(vm_highmem_is_dirtyable),
1369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001371 .extra1 = &zero,
1372 .extra2 = &one,
1373 },
1374#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001375 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001376 .procname = "scan_unevictable_pages",
1377 .data = &scan_unevictable_pages,
1378 .maxlen = sizeof(scan_unevictable_pages),
1379 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001380 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001381 },
Andi Kleen6a460792009-09-16 11:50:15 +02001382#ifdef CONFIG_MEMORY_FAILURE
1383 {
Andi Kleen6a460792009-09-16 11:50:15 +02001384 .procname = "memory_failure_early_kill",
1385 .data = &sysctl_memory_failure_early_kill,
1386 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1387 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001388 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001389 .extra1 = &zero,
1390 .extra2 = &one,
1391 },
1392 {
Andi Kleen6a460792009-09-16 11:50:15 +02001393 .procname = "memory_failure_recovery",
1394 .data = &sysctl_memory_failure_recovery,
1395 .maxlen = sizeof(sysctl_memory_failure_recovery),
1396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001397 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001398 .extra1 = &zero,
1399 .extra2 = &one,
1400 },
1401#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001402 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403};
1404
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001405#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001406static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001407 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001408};
1409#endif
1410
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001411static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 .procname = "inode-nr",
1414 .data = &inodes_stat,
1415 .maxlen = 2*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 = "inode-state",
1421 .data = &inodes_stat,
1422 .maxlen = 7*sizeof(int),
1423 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001424 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425 },
1426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 .procname = "file-nr",
1428 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001429 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001431 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 },
1433 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 .procname = "file-max",
1435 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001436 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001438 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 },
1440 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001441 .procname = "nr_open",
1442 .data = &sysctl_nr_open,
1443 .maxlen = sizeof(int),
1444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001445 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001446 .extra1 = &sysctl_nr_open_min,
1447 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001448 },
1449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "dentry-state",
1451 .data = &dentry_stat,
1452 .maxlen = 6*sizeof(int),
1453 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001454 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 },
1456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 .procname = "overflowuid",
1458 .data = &fs_overflowuid,
1459 .maxlen = sizeof(int),
1460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001461 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 .extra1 = &minolduid,
1463 .extra2 = &maxolduid,
1464 },
1465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 .procname = "overflowgid",
1467 .data = &fs_overflowgid,
1468 .maxlen = sizeof(int),
1469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001470 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 .extra1 = &minolduid,
1472 .extra2 = &maxolduid,
1473 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001474#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 .procname = "leases-enable",
1477 .data = &leases_enable,
1478 .maxlen = sizeof(int),
1479 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001480 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001482#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483#ifdef CONFIG_DNOTIFY
1484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "dir-notify-enable",
1486 .data = &dir_notify_enable,
1487 .maxlen = sizeof(int),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 },
1491#endif
1492#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001493#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "lease-break-time",
1496 .data = &lease_break_time,
1497 .maxlen = sizeof(int),
1498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001501#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001502#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 .procname = "aio-nr",
1505 .data = &aio_nr,
1506 .maxlen = sizeof(aio_nr),
1507 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001508 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 },
1510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .procname = "aio-max-nr",
1512 .data = &aio_max_nr,
1513 .maxlen = sizeof(aio_max_nr),
1514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001517#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001518#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001519 {
Robert Love0399cb02005-07-13 12:38:18 -04001520 .procname = "inotify",
1521 .mode = 0555,
1522 .child = inotify_table,
1523 },
1524#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001525#ifdef CONFIG_EPOLL
1526 {
1527 .procname = "epoll",
1528 .mode = 0555,
1529 .child = epoll_table,
1530 },
1531#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001533 {
Kees Cook800179c2012-07-25 17:29:07 -07001534 .procname = "protected_symlinks",
1535 .data = &sysctl_protected_symlinks,
1536 .maxlen = sizeof(int),
1537 .mode = 0600,
1538 .proc_handler = proc_dointvec_minmax,
1539 .extra1 = &zero,
1540 .extra2 = &one,
1541 },
1542 {
1543 .procname = "protected_hardlinks",
1544 .data = &sysctl_protected_hardlinks,
1545 .maxlen = sizeof(int),
1546 .mode = 0600,
1547 .proc_handler = proc_dointvec_minmax,
1548 .extra1 = &zero,
1549 .extra2 = &one,
1550 },
1551 {
Alan Coxd6e71142005-06-23 00:09:43 -07001552 .procname = "suid_dumpable",
1553 .data = &suid_dumpable,
1554 .maxlen = sizeof(int),
1555 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001556 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001557 .extra1 = &zero,
1558 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001559 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001560#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1561 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001562 .procname = "binfmt_misc",
1563 .mode = 0555,
1564 .child = binfmt_misc_table,
1565 },
1566#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001567 {
Jens Axboeff9da692010-06-03 14:54:39 +02001568 .procname = "pipe-max-size",
1569 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001570 .maxlen = sizeof(int),
1571 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001572 .proc_handler = &pipe_proc_fn,
1573 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001574 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001575 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576};
1577
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001578static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001579#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001580 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001581 .procname = "exception-trace",
1582 .data = &show_unhandled_signals,
1583 .maxlen = sizeof(int),
1584 .mode = 0644,
1585 .proc_handler = proc_dointvec
1586 },
1587#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001588#if defined(CONFIG_OPTPROBES)
1589 {
1590 .procname = "kprobes-optimization",
1591 .data = &sysctl_kprobes_optimization,
1592 .maxlen = sizeof(int),
1593 .mode = 0644,
1594 .proc_handler = proc_kprobes_optimization_handler,
1595 .extra1 = &zero,
1596 .extra2 = &one,
1597 },
1598#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001599 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001600};
1601
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001602static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001603 { }
Robert Love0eeca282005-07-12 17:06:03 -04001604};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001606int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001607{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001608 struct ctl_table_header *hdr;
1609
1610 hdr = register_sysctl_table(sysctl_base_table);
1611 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001612 return 0;
1613}
1614
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001615#endif /* CONFIG_SYSCTL */
1616
Linus Torvalds1da177e2005-04-16 15:20:36 -07001617/*
1618 * /proc/sys support
1619 */
1620
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001621#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001623static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001624 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001625 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001626{
1627 size_t len;
1628 char __user *p;
1629 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001630
1631 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001632 *lenp = 0;
1633 return 0;
1634 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001635
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001636 if (write) {
1637 len = 0;
1638 p = buffer;
1639 while (len < *lenp) {
1640 if (get_user(c, p++))
1641 return -EFAULT;
1642 if (c == 0 || c == '\n')
1643 break;
1644 len++;
1645 }
1646 if (len >= maxlen)
1647 len = maxlen-1;
1648 if(copy_from_user(data, buffer, len))
1649 return -EFAULT;
1650 ((char *) data)[len] = 0;
1651 *ppos += *lenp;
1652 } else {
1653 len = strlen(data);
1654 if (len > maxlen)
1655 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001656
1657 if (*ppos > len) {
1658 *lenp = 0;
1659 return 0;
1660 }
1661
1662 data += *ppos;
1663 len -= *ppos;
1664
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001665 if (len > *lenp)
1666 len = *lenp;
1667 if (len)
1668 if(copy_to_user(buffer, data, len))
1669 return -EFAULT;
1670 if (len < *lenp) {
1671 if(put_user('\n', ((char __user *) buffer) + len))
1672 return -EFAULT;
1673 len++;
1674 }
1675 *lenp = len;
1676 *ppos += len;
1677 }
1678 return 0;
1679}
1680
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681/**
1682 * proc_dostring - read a string sysctl
1683 * @table: the sysctl table
1684 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 * @buffer: the user buffer
1686 * @lenp: the size of the user buffer
1687 * @ppos: file position
1688 *
1689 * Reads/writes a string from/to the user buffer. If the kernel
1690 * buffer provided is not large enough to hold the string, the
1691 * string is truncated. The copied string is %NULL-terminated.
1692 * If the string is being read by the user process, it is copied
1693 * and a newline '\n' is added. It is truncated if the buffer is
1694 * not large enough.
1695 *
1696 * Returns 0 on success.
1697 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001698int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 void __user *buffer, size_t *lenp, loff_t *ppos)
1700{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001701 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001702 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703}
1704
Amerigo Wang00b7c332010-05-05 00:26:45 +00001705static size_t proc_skip_spaces(char **buf)
1706{
1707 size_t ret;
1708 char *tmp = skip_spaces(*buf);
1709 ret = tmp - *buf;
1710 *buf = tmp;
1711 return ret;
1712}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001714static void proc_skip_char(char **buf, size_t *size, const char v)
1715{
1716 while (*size) {
1717 if (**buf != v)
1718 break;
1719 (*size)--;
1720 (*buf)++;
1721 }
1722}
1723
Amerigo Wang00b7c332010-05-05 00:26:45 +00001724#define TMPBUFLEN 22
1725/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001726 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001727 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001728 * @buf: a kernel buffer
1729 * @size: size of the kernel buffer
1730 * @val: this is where the number will be stored
1731 * @neg: set to %TRUE if number is negative
1732 * @perm_tr: a vector which contains the allowed trailers
1733 * @perm_tr_len: size of the perm_tr vector
1734 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001735 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001736 * In case of success %0 is returned and @buf and @size are updated with
1737 * the amount of bytes read. If @tr is non-NULL and a trailing
1738 * character exists (size is non-zero after returning from this
1739 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001740 */
1741static int proc_get_long(char **buf, size_t *size,
1742 unsigned long *val, bool *neg,
1743 const char *perm_tr, unsigned perm_tr_len, char *tr)
1744{
1745 int len;
1746 char *p, tmp[TMPBUFLEN];
1747
1748 if (!*size)
1749 return -EINVAL;
1750
1751 len = *size;
1752 if (len > TMPBUFLEN - 1)
1753 len = TMPBUFLEN - 1;
1754
1755 memcpy(tmp, *buf, len);
1756
1757 tmp[len] = 0;
1758 p = tmp;
1759 if (*p == '-' && *size > 1) {
1760 *neg = true;
1761 p++;
1762 } else
1763 *neg = false;
1764 if (!isdigit(*p))
1765 return -EINVAL;
1766
1767 *val = simple_strtoul(p, &p, 0);
1768
1769 len = p - tmp;
1770
1771 /* We don't know if the next char is whitespace thus we may accept
1772 * invalid integers (e.g. 1234...a) or two integers instead of one
1773 * (e.g. 123...1). So lets not allow such large numbers. */
1774 if (len == TMPBUFLEN - 1)
1775 return -EINVAL;
1776
1777 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1778 return -EINVAL;
1779
1780 if (tr && (len < *size))
1781 *tr = *p;
1782
1783 *buf += len;
1784 *size -= len;
1785
1786 return 0;
1787}
1788
1789/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001790 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001791 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001792 * @buf: the user buffer
1793 * @size: the size of the user buffer
1794 * @val: the integer to be converted
1795 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001796 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001797 * In case of success %0 is returned and @buf and @size are updated with
1798 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001799 */
1800static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1801 bool neg)
1802{
1803 int len;
1804 char tmp[TMPBUFLEN], *p = tmp;
1805
1806 sprintf(p, "%s%lu", neg ? "-" : "", val);
1807 len = strlen(tmp);
1808 if (len > *size)
1809 len = *size;
1810 if (copy_to_user(*buf, tmp, len))
1811 return -EFAULT;
1812 *size -= len;
1813 *buf += len;
1814 return 0;
1815}
1816#undef TMPBUFLEN
1817
1818static int proc_put_char(void __user **buf, size_t *size, char c)
1819{
1820 if (*size) {
1821 char __user **buffer = (char __user **)buf;
1822 if (put_user(c, *buffer))
1823 return -EFAULT;
1824 (*size)--, (*buffer)++;
1825 *buf = *buffer;
1826 }
1827 return 0;
1828}
1829
1830static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 int *valp,
1832 int write, void *data)
1833{
1834 if (write) {
1835 *valp = *negp ? -*lvalp : *lvalp;
1836 } else {
1837 int val = *valp;
1838 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001839 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001840 *lvalp = (unsigned long)-val;
1841 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001842 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 *lvalp = (unsigned long)val;
1844 }
1845 }
1846 return 0;
1847}
1848
Amerigo Wang00b7c332010-05-05 00:26:45 +00001849static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1850
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001851static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001852 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001853 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001854 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001855 int write, void *data),
1856 void *data)
1857{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001858 int *i, vleft, first = 1, err = 0;
1859 unsigned long page = 0;
1860 size_t left;
1861 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862
Amerigo Wang00b7c332010-05-05 00:26:45 +00001863 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001864 *lenp = 0;
1865 return 0;
1866 }
1867
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001868 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 vleft = table->maxlen / sizeof(*i);
1870 left = *lenp;
1871
1872 if (!conv)
1873 conv = do_proc_dointvec_conv;
1874
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001876 if (left > PAGE_SIZE - 1)
1877 left = PAGE_SIZE - 1;
1878 page = __get_free_page(GFP_TEMPORARY);
1879 kbuf = (char *) page;
1880 if (!kbuf)
1881 return -ENOMEM;
1882 if (copy_from_user(kbuf, buffer, left)) {
1883 err = -EFAULT;
1884 goto free;
1885 }
1886 kbuf[left] = 0;
1887 }
1888
1889 for (; left && vleft--; i++, first=0) {
1890 unsigned long lval;
1891 bool neg;
1892
1893 if (write) {
1894 left -= proc_skip_spaces(&kbuf);
1895
J. R. Okajima563b0462010-05-25 16:10:14 -07001896 if (!left)
1897 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001898 err = proc_get_long(&kbuf, &left, &lval, &neg,
1899 proc_wspace_sep,
1900 sizeof(proc_wspace_sep), NULL);
1901 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001903 if (conv(&neg, &lval, i, 1, data)) {
1904 err = -EINVAL;
1905 break;
1906 }
1907 } else {
1908 if (conv(&neg, &lval, i, 0, data)) {
1909 err = -EINVAL;
1910 break;
1911 }
1912 if (!first)
1913 err = proc_put_char(&buffer, &left, '\t');
1914 if (err)
1915 break;
1916 err = proc_put_long(&buffer, &left, lval, neg);
1917 if (err)
1918 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001919 }
1920 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001921
1922 if (!write && !first && left && !err)
1923 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001924 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001925 left -= proc_skip_spaces(&kbuf);
1926free:
1927 if (write) {
1928 free_page(page);
1929 if (first)
1930 return err ? : -EINVAL;
1931 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 *lenp -= left;
1933 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001934 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001935}
1936
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001937static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001938 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001939 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001940 int write, void *data),
1941 void *data)
1942{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001943 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001944 buffer, lenp, ppos, conv, data);
1945}
1946
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947/**
1948 * proc_dointvec - read a vector of integers
1949 * @table: the sysctl table
1950 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001951 * @buffer: the user buffer
1952 * @lenp: the size of the user buffer
1953 * @ppos: file position
1954 *
1955 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1956 * values from/to the user buffer, treated as an ASCII string.
1957 *
1958 * Returns 0 on success.
1959 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001960int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 void __user *buffer, size_t *lenp, loff_t *ppos)
1962{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001963 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964 NULL,NULL);
1965}
1966
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001967/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001968 * Taint values can only be increased
1969 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001970 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001971static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001972 void __user *buffer, size_t *lenp, loff_t *ppos)
1973{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001974 struct ctl_table t;
1975 unsigned long tmptaint = get_taint();
1976 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001977
Bastian Blank91fcd412007-04-23 14:41:14 -07001978 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001979 return -EPERM;
1980
Andi Kleen25ddbb12008-10-15 22:01:41 -07001981 t = *table;
1982 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001983 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001984 if (err < 0)
1985 return err;
1986
1987 if (write) {
1988 /*
1989 * Poor man's atomic or. Not worth adding a primitive
1990 * to everyone's atomic.h for this
1991 */
1992 int i;
1993 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
1994 if ((tmptaint >> i) & 1)
1995 add_taint(i);
1996 }
1997 }
1998
1999 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002000}
2001
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002002#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002003static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002004 void __user *buffer, size_t *lenp, loff_t *ppos)
2005{
2006 if (write && !capable(CAP_SYS_ADMIN))
2007 return -EPERM;
2008
2009 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2010}
2011#endif
2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013struct do_proc_dointvec_minmax_conv_param {
2014 int *min;
2015 int *max;
2016};
2017
Amerigo Wang00b7c332010-05-05 00:26:45 +00002018static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2019 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020 int write, void *data)
2021{
2022 struct do_proc_dointvec_minmax_conv_param *param = data;
2023 if (write) {
2024 int val = *negp ? -*lvalp : *lvalp;
2025 if ((param->min && *param->min > val) ||
2026 (param->max && *param->max < val))
2027 return -EINVAL;
2028 *valp = val;
2029 } else {
2030 int val = *valp;
2031 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002032 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 *lvalp = (unsigned long)-val;
2034 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002035 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036 *lvalp = (unsigned long)val;
2037 }
2038 }
2039 return 0;
2040}
2041
2042/**
2043 * proc_dointvec_minmax - read a vector of integers with min/max values
2044 * @table: the sysctl table
2045 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046 * @buffer: the user buffer
2047 * @lenp: the size of the user buffer
2048 * @ppos: file position
2049 *
2050 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2051 * values from/to the user buffer, treated as an ASCII string.
2052 *
2053 * This routine will ensure the values are within the range specified by
2054 * table->extra1 (min) and table->extra2 (max).
2055 *
2056 * Returns 0 on success.
2057 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002058int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 void __user *buffer, size_t *lenp, loff_t *ppos)
2060{
2061 struct do_proc_dointvec_minmax_conv_param param = {
2062 .min = (int *) table->extra1,
2063 .max = (int *) table->extra2,
2064 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002065 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066 do_proc_dointvec_minmax_conv, &param);
2067}
2068
Kees Cook54b50192012-07-30 14:39:18 -07002069static void validate_coredump_safety(void)
2070{
Alex Kelly046d6622012-10-04 17:15:23 -07002071#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002072 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2073 core_pattern[0] != '/' && core_pattern[0] != '|') {
2074 printk(KERN_WARNING "Unsafe core_pattern used with "\
2075 "suid_dumpable=2. Pipe handler or fully qualified "\
2076 "core dump path required.\n");
2077 }
Alex Kelly046d6622012-10-04 17:15:23 -07002078#endif
Kees Cook54b50192012-07-30 14:39:18 -07002079}
2080
2081static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2082 void __user *buffer, size_t *lenp, loff_t *ppos)
2083{
2084 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2085 if (!error)
2086 validate_coredump_safety();
2087 return error;
2088}
2089
Alex Kelly046d6622012-10-04 17:15:23 -07002090#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002091static int proc_dostring_coredump(struct ctl_table *table, int write,
2092 void __user *buffer, size_t *lenp, loff_t *ppos)
2093{
2094 int error = proc_dostring(table, write, buffer, lenp, ppos);
2095 if (!error)
2096 validate_coredump_safety();
2097 return error;
2098}
Alex Kelly046d6622012-10-04 17:15:23 -07002099#endif
Kees Cook54b50192012-07-30 14:39:18 -07002100
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002101static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 void __user *buffer,
2103 size_t *lenp, loff_t *ppos,
2104 unsigned long convmul,
2105 unsigned long convdiv)
2106{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002107 unsigned long *i, *min, *max;
2108 int vleft, first = 1, err = 0;
2109 unsigned long page = 0;
2110 size_t left;
2111 char *kbuf;
2112
2113 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114 *lenp = 0;
2115 return 0;
2116 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002117
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002118 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 min = (unsigned long *) table->extra1;
2120 max = (unsigned long *) table->extra2;
2121 vleft = table->maxlen / sizeof(unsigned long);
2122 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002123
2124 if (write) {
2125 if (left > PAGE_SIZE - 1)
2126 left = PAGE_SIZE - 1;
2127 page = __get_free_page(GFP_TEMPORARY);
2128 kbuf = (char *) page;
2129 if (!kbuf)
2130 return -ENOMEM;
2131 if (copy_from_user(kbuf, buffer, left)) {
2132 err = -EFAULT;
2133 goto free;
2134 }
2135 kbuf[left] = 0;
2136 }
2137
Eric Dumazet27b3d802010-10-07 12:59:29 -07002138 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002139 unsigned long val;
2140
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002142 bool neg;
2143
2144 left -= proc_skip_spaces(&kbuf);
2145
2146 err = proc_get_long(&kbuf, &left, &val, &neg,
2147 proc_wspace_sep,
2148 sizeof(proc_wspace_sep), NULL);
2149 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 break;
2151 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002152 continue;
2153 if ((min && val < *min) || (max && val > *max))
2154 continue;
2155 *i = val;
2156 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002157 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159 err = proc_put_char(&buffer, &left, '\t');
2160 err = proc_put_long(&buffer, &left, val, false);
2161 if (err)
2162 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163 }
2164 }
2165
Amerigo Wang00b7c332010-05-05 00:26:45 +00002166 if (!write && !first && left && !err)
2167 err = proc_put_char(&buffer, &left, '\n');
2168 if (write && !err)
2169 left -= proc_skip_spaces(&kbuf);
2170free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 free_page(page);
2173 if (first)
2174 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176 *lenp -= left;
2177 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002178 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179}
2180
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002181static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002182 void __user *buffer,
2183 size_t *lenp, loff_t *ppos,
2184 unsigned long convmul,
2185 unsigned long convdiv)
2186{
2187 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002188 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002189}
2190
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191/**
2192 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2193 * @table: the sysctl table
2194 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 * @buffer: the user buffer
2196 * @lenp: the size of the user buffer
2197 * @ppos: file position
2198 *
2199 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2200 * values from/to the user buffer, treated as an ASCII string.
2201 *
2202 * This routine will ensure the values are within the range specified by
2203 * table->extra1 (min) and table->extra2 (max).
2204 *
2205 * Returns 0 on success.
2206 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002207int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 void __user *buffer, size_t *lenp, loff_t *ppos)
2209{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002210 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211}
2212
2213/**
2214 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2215 * @table: the sysctl table
2216 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217 * @buffer: the user buffer
2218 * @lenp: the size of the user buffer
2219 * @ppos: file position
2220 *
2221 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2222 * values from/to the user buffer, treated as an ASCII string. The values
2223 * are treated as milliseconds, and converted to jiffies when they are stored.
2224 *
2225 * This routine will ensure the values are within the range specified by
2226 * table->extra1 (min) and table->extra2 (max).
2227 *
2228 * Returns 0 on success.
2229 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002230int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231 void __user *buffer,
2232 size_t *lenp, loff_t *ppos)
2233{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002234 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 lenp, ppos, HZ, 1000l);
2236}
2237
2238
Amerigo Wang00b7c332010-05-05 00:26:45 +00002239static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 int *valp,
2241 int write, void *data)
2242{
2243 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002244 if (*lvalp > LONG_MAX / HZ)
2245 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2247 } else {
2248 int val = *valp;
2249 unsigned long lval;
2250 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002251 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 lval = (unsigned long)-val;
2253 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002254 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 lval = (unsigned long)val;
2256 }
2257 *lvalp = lval / HZ;
2258 }
2259 return 0;
2260}
2261
Amerigo Wang00b7c332010-05-05 00:26:45 +00002262static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 int *valp,
2264 int write, void *data)
2265{
2266 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002267 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2268 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2270 } else {
2271 int val = *valp;
2272 unsigned long lval;
2273 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002274 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 lval = (unsigned long)-val;
2276 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 lval = (unsigned long)val;
2279 }
2280 *lvalp = jiffies_to_clock_t(lval);
2281 }
2282 return 0;
2283}
2284
Amerigo Wang00b7c332010-05-05 00:26:45 +00002285static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286 int *valp,
2287 int write, void *data)
2288{
2289 if (write) {
2290 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2291 } else {
2292 int val = *valp;
2293 unsigned long lval;
2294 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002295 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 lval = (unsigned long)-val;
2297 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002298 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 lval = (unsigned long)val;
2300 }
2301 *lvalp = jiffies_to_msecs(lval);
2302 }
2303 return 0;
2304}
2305
2306/**
2307 * proc_dointvec_jiffies - read a vector of integers as seconds
2308 * @table: the sysctl table
2309 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 * @buffer: the user buffer
2311 * @lenp: the size of the user buffer
2312 * @ppos: file position
2313 *
2314 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2315 * values from/to the user buffer, treated as an ASCII string.
2316 * The values read are assumed to be in seconds, and are converted into
2317 * jiffies.
2318 *
2319 * Returns 0 on success.
2320 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002321int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 void __user *buffer, size_t *lenp, loff_t *ppos)
2323{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002324 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 do_proc_dointvec_jiffies_conv,NULL);
2326}
2327
2328/**
2329 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2330 * @table: the sysctl table
2331 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 * @buffer: the user buffer
2333 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002334 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335 *
2336 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2337 * values from/to the user buffer, treated as an ASCII string.
2338 * The values read are assumed to be in 1/USER_HZ seconds, and
2339 * are converted into jiffies.
2340 *
2341 * Returns 0 on success.
2342 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002343int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 void __user *buffer, size_t *lenp, loff_t *ppos)
2345{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002346 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 do_proc_dointvec_userhz_jiffies_conv,NULL);
2348}
2349
2350/**
2351 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2352 * @table: the sysctl table
2353 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 * @buffer: the user buffer
2355 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002356 * @ppos: file position
2357 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 *
2359 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2360 * values from/to the user buffer, treated as an ASCII string.
2361 * The values read are assumed to be in 1/1000 seconds, and
2362 * are converted into jiffies.
2363 *
2364 * Returns 0 on success.
2365 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002366int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 void __user *buffer, size_t *lenp, loff_t *ppos)
2368{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002369 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 do_proc_dointvec_ms_jiffies_conv, NULL);
2371}
2372
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002373static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002374 void __user *buffer, size_t *lenp, loff_t *ppos)
2375{
2376 struct pid *new_pid;
2377 pid_t tmp;
2378 int r;
2379
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002380 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002381
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002382 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002383 lenp, ppos, NULL, NULL);
2384 if (r || !write)
2385 return r;
2386
2387 new_pid = find_get_pid(tmp);
2388 if (!new_pid)
2389 return -ESRCH;
2390
2391 put_pid(xchg(&cad_pid, new_pid));
2392 return 0;
2393}
2394
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002395/**
2396 * proc_do_large_bitmap - read/write from/to a large bitmap
2397 * @table: the sysctl table
2398 * @write: %TRUE if this is a write to the sysctl file
2399 * @buffer: the user buffer
2400 * @lenp: the size of the user buffer
2401 * @ppos: file position
2402 *
2403 * The bitmap is stored at table->data and the bitmap length (in bits)
2404 * in table->maxlen.
2405 *
2406 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2407 * large bitmaps may be represented in a compact manner. Writing into
2408 * the file will clear the bitmap then update it with the given input.
2409 *
2410 * Returns 0 on success.
2411 */
2412int proc_do_large_bitmap(struct ctl_table *table, int write,
2413 void __user *buffer, size_t *lenp, loff_t *ppos)
2414{
2415 int err = 0;
2416 bool first = 1;
2417 size_t left = *lenp;
2418 unsigned long bitmap_len = table->maxlen;
2419 unsigned long *bitmap = (unsigned long *) table->data;
2420 unsigned long *tmp_bitmap = NULL;
2421 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2422
2423 if (!bitmap_len || !left || (*ppos && !write)) {
2424 *lenp = 0;
2425 return 0;
2426 }
2427
2428 if (write) {
2429 unsigned long page = 0;
2430 char *kbuf;
2431
2432 if (left > PAGE_SIZE - 1)
2433 left = PAGE_SIZE - 1;
2434
2435 page = __get_free_page(GFP_TEMPORARY);
2436 kbuf = (char *) page;
2437 if (!kbuf)
2438 return -ENOMEM;
2439 if (copy_from_user(kbuf, buffer, left)) {
2440 free_page(page);
2441 return -EFAULT;
2442 }
2443 kbuf[left] = 0;
2444
2445 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2446 GFP_KERNEL);
2447 if (!tmp_bitmap) {
2448 free_page(page);
2449 return -ENOMEM;
2450 }
2451 proc_skip_char(&kbuf, &left, '\n');
2452 while (!err && left) {
2453 unsigned long val_a, val_b;
2454 bool neg;
2455
2456 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2457 sizeof(tr_a), &c);
2458 if (err)
2459 break;
2460 if (val_a >= bitmap_len || neg) {
2461 err = -EINVAL;
2462 break;
2463 }
2464
2465 val_b = val_a;
2466 if (left) {
2467 kbuf++;
2468 left--;
2469 }
2470
2471 if (c == '-') {
2472 err = proc_get_long(&kbuf, &left, &val_b,
2473 &neg, tr_b, sizeof(tr_b),
2474 &c);
2475 if (err)
2476 break;
2477 if (val_b >= bitmap_len || neg ||
2478 val_a > val_b) {
2479 err = -EINVAL;
2480 break;
2481 }
2482 if (left) {
2483 kbuf++;
2484 left--;
2485 }
2486 }
2487
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002488 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002489 first = 0;
2490 proc_skip_char(&kbuf, &left, '\n');
2491 }
2492 free_page(page);
2493 } else {
2494 unsigned long bit_a, bit_b = 0;
2495
2496 while (left) {
2497 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2498 if (bit_a >= bitmap_len)
2499 break;
2500 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2501 bit_a + 1) - 1;
2502
2503 if (!first) {
2504 err = proc_put_char(&buffer, &left, ',');
2505 if (err)
2506 break;
2507 }
2508 err = proc_put_long(&buffer, &left, bit_a, false);
2509 if (err)
2510 break;
2511 if (bit_a != bit_b) {
2512 err = proc_put_char(&buffer, &left, '-');
2513 if (err)
2514 break;
2515 err = proc_put_long(&buffer, &left, bit_b, false);
2516 if (err)
2517 break;
2518 }
2519
2520 first = 0; bit_b++;
2521 }
2522 if (!err)
2523 err = proc_put_char(&buffer, &left, '\n');
2524 }
2525
2526 if (!err) {
2527 if (write) {
2528 if (*ppos)
2529 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2530 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002531 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002532 }
2533 kfree(tmp_bitmap);
2534 *lenp -= left;
2535 *ppos += *lenp;
2536 return 0;
2537 } else {
2538 kfree(tmp_bitmap);
2539 return err;
2540 }
2541}
2542
Jovi Zhang55610502011-01-12 17:00:45 -08002543#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002545int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 void __user *buffer, size_t *lenp, loff_t *ppos)
2547{
2548 return -ENOSYS;
2549}
2550
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002551int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 void __user *buffer, size_t *lenp, loff_t *ppos)
2553{
2554 return -ENOSYS;
2555}
2556
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002557int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558 void __user *buffer, size_t *lenp, loff_t *ppos)
2559{
2560 return -ENOSYS;
2561}
2562
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002563int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 void __user *buffer, size_t *lenp, loff_t *ppos)
2565{
2566 return -ENOSYS;
2567}
2568
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002569int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 void __user *buffer, size_t *lenp, loff_t *ppos)
2571{
2572 return -ENOSYS;
2573}
2574
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002575int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 void __user *buffer, size_t *lenp, loff_t *ppos)
2577{
2578 return -ENOSYS;
2579}
2580
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002581int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 void __user *buffer, size_t *lenp, loff_t *ppos)
2583{
2584 return -ENOSYS;
2585}
2586
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002587int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 void __user *buffer,
2589 size_t *lenp, loff_t *ppos)
2590{
2591 return -ENOSYS;
2592}
2593
2594
Jovi Zhang55610502011-01-12 17:00:45 -08002595#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597/*
2598 * No sense putting this after each symbol definition, twice,
2599 * exception granted :-)
2600 */
2601EXPORT_SYMBOL(proc_dointvec);
2602EXPORT_SYMBOL(proc_dointvec_jiffies);
2603EXPORT_SYMBOL(proc_dointvec_minmax);
2604EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2605EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2606EXPORT_SYMBOL(proc_dostring);
2607EXPORT_SYMBOL(proc_doulongvec_minmax);
2608EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);