blob: 48a68cc258c12fdbffe6912810fe22c21bfcc1db [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 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200356 .procname = "numa_balancing_scan_delay_ms",
357 .data = &sysctl_numa_balancing_scan_delay,
358 .maxlen = sizeof(unsigned int),
359 .mode = 0644,
360 .proc_handler = proc_dointvec,
361 },
362 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200363 .procname = "numa_balancing_scan_period_min_ms",
364 .data = &sysctl_numa_balancing_scan_period_min,
365 .maxlen = sizeof(unsigned int),
366 .mode = 0644,
367 .proc_handler = proc_dointvec,
368 },
369 {
370 .procname = "numa_balancing_scan_period_max_ms",
371 .data = &sysctl_numa_balancing_scan_period_max,
372 .maxlen = sizeof(unsigned int),
373 .mode = 0644,
374 .proc_handler = proc_dointvec,
375 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200376 {
377 .procname = "numa_balancing_scan_size_mb",
378 .data = &sysctl_numa_balancing_scan_size,
379 .maxlen = sizeof(unsigned int),
380 .mode = 0644,
381 .proc_handler = proc_dointvec,
382 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200383#endif /* CONFIG_NUMA_BALANCING */
384#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200385 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100386 .procname = "sched_rt_period_us",
387 .data = &sysctl_sched_rt_period,
388 .maxlen = sizeof(unsigned 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 },
392 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100393 .procname = "sched_rt_runtime_us",
394 .data = &sysctl_sched_rt_runtime,
395 .maxlen = sizeof(int),
396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800397 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100398 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100399#ifdef CONFIG_SCHED_AUTOGROUP
400 {
401 .procname = "sched_autogroup_enabled",
402 .data = &sysctl_sched_autogroup_enabled,
403 .maxlen = sizeof(unsigned int),
404 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800405 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100406 .extra1 = &zero,
407 .extra2 = &one,
408 },
409#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700410#ifdef CONFIG_CFS_BANDWIDTH
411 {
412 .procname = "sched_cfs_bandwidth_slice_us",
413 .data = &sysctl_sched_cfs_bandwidth_slice,
414 .maxlen = sizeof(unsigned int),
415 .mode = 0644,
416 .proc_handler = proc_dointvec_minmax,
417 .extra1 = &one,
418 },
419#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700420#ifdef CONFIG_PROVE_LOCKING
421 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700422 .procname = "prove_locking",
423 .data = &prove_locking,
424 .maxlen = sizeof(int),
425 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800426 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700427 },
428#endif
429#ifdef CONFIG_LOCK_STAT
430 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700431 .procname = "lock_stat",
432 .data = &lock_stat,
433 .maxlen = sizeof(int),
434 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800435 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700436 },
437#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 .procname = "panic",
440 .data = &panic_timeout,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 },
Alex Kelly046d6622012-10-04 17:15:23 -0700445#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 .procname = "core_uses_pid",
448 .data = &core_uses_pid,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 },
453 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 .procname = "core_pattern",
455 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700456 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700458 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 },
Neil Hormana2939802009-09-23 15:56:56 -0700460 {
Neil Hormana2939802009-09-23 15:56:56 -0700461 .procname = "core_pipe_limit",
462 .data = &core_pipe_limit,
463 .maxlen = sizeof(unsigned int),
464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800465 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700466 },
Alex Kelly046d6622012-10-04 17:15:23 -0700467#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800468#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700471 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800473 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800475#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100476#ifdef CONFIG_LATENCYTOP
477 {
478 .procname = "latencytop",
479 .data = &latencytop_enabled,
480 .maxlen = sizeof(int),
481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800482 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100483 },
484#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485#ifdef CONFIG_BLK_DEV_INITRD
486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "real-root-dev",
488 .data = &real_root_dev,
489 .maxlen = sizeof(int),
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
493#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700494 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700495 .procname = "print-fatal-signals",
496 .data = &print_fatal_signals,
497 .maxlen = sizeof(int),
498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700500 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700501#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "reboot-cmd",
504 .data = reboot_command,
505 .maxlen = 256,
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 },
509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "stop-a",
511 .data = &stop_a_enabled,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 .procname = "scons-poweroff",
518 .data = &scons_pwroff,
519 .maxlen = sizeof (int),
520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800521 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 },
523#endif
David S. Miller08714202008-11-16 23:49:24 -0800524#ifdef CONFIG_SPARC64
525 {
David S. Miller08714202008-11-16 23:49:24 -0800526 .procname = "tsb-ratio",
527 .data = &sysctl_tsb_ratio,
528 .maxlen = sizeof (int),
529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800530 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800531 },
532#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533#ifdef __hppa__
534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "soft-power",
536 .data = &pwrsw_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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .procname = "unaligned-trap",
543 .data = &unaligned_enabled,
544 .maxlen = sizeof (int),
545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 },
548#endif
549 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 .procname = "ctrl-alt-del",
551 .data = &C_A_D,
552 .maxlen = sizeof(int),
553 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800554 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400556#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200557 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200558 .procname = "ftrace_enabled",
559 .data = &ftrace_enabled,
560 .maxlen = sizeof(int),
561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200563 },
564#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500565#ifdef CONFIG_STACK_TRACER
566 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500567 .procname = "stack_tracer_enabled",
568 .data = &stack_tracer_enabled,
569 .maxlen = sizeof(int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500572 },
573#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400574#ifdef CONFIG_TRACING
575 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100576 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400577 .data = &ftrace_dump_on_oops,
578 .maxlen = sizeof(int),
579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800580 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400581 },
582#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200583#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .procname = "modprobe",
586 .data = &modprobe_path,
587 .maxlen = KMOD_PATH_LEN,
588 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 },
Kees Cook3d433212009-04-02 15:49:29 -0700591 {
Kees Cook3d433212009-04-02 15:49:29 -0700592 .procname = "modules_disabled",
593 .data = &modules_disabled,
594 .maxlen = sizeof(int),
595 .mode = 0644,
596 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700598 .extra1 = &one,
599 .extra2 = &one,
600 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100602#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100605 .data = &uevent_helper,
606 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 },
610#endif
611#ifdef CONFIG_CHR_DEV_SG
612 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 .procname = "sg-big-buff",
614 .data = &sg_big_buff,
615 .maxlen = sizeof (int),
616 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 },
619#endif
620#ifdef CONFIG_BSD_PROCESS_ACCT
621 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 .procname = "acct",
623 .data = &acct_parm,
624 .maxlen = 3*sizeof(int),
625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 },
628#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629#ifdef CONFIG_MAGIC_SYSRQ
630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800632 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .maxlen = sizeof (int),
634 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700635 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 },
637#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700638#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700641 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .maxlen = sizeof (int),
643 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800644 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700646#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "threads-max",
649 .data = &max_threads,
650 .maxlen = sizeof(int),
651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800652 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 },
654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "random",
656 .mode = 0555,
657 .child = random_table,
658 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 {
Eric Paris17f60a72011-04-01 17:07:50 -0400660 .procname = "usermodehelper",
661 .mode = 0555,
662 .child = usermodehelper_table,
663 },
664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "overflowuid",
666 .data = &overflowuid,
667 .maxlen = sizeof(int),
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .extra1 = &minolduid,
671 .extra2 = &maxolduid,
672 },
673 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .procname = "overflowgid",
675 .data = &overflowgid,
676 .maxlen = sizeof(int),
677 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800678 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .extra1 = &minolduid,
680 .extra2 = &maxolduid,
681 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800682#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683#ifdef CONFIG_MATHEMU
684 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .procname = "ieee_emulation_warnings",
686 .data = &sysctl_ieee_emulation_warnings,
687 .maxlen = sizeof(int),
688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 },
691#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200694 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .maxlen = sizeof(int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699#endif
700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "pid_max",
702 .data = &pid_max,
703 .maxlen = sizeof (int),
704 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800705 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .extra1 = &pid_max_min,
707 .extra2 = &pid_max_max,
708 },
709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "panic_on_oops",
711 .data = &panic_on_oops,
712 .maxlen = sizeof(int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800716#if defined CONFIG_PRINTK
717 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800718 .procname = "printk",
719 .data = &console_loglevel,
720 .maxlen = 4*sizeof(int),
721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800723 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700726 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 },
731 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700733 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .maxlen = sizeof(int),
735 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800736 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 },
Dave Youngaf913222009-09-22 16:43:33 -0700738 {
Dave Youngaf913222009-09-22 16:43:33 -0700739 .procname = "printk_delay",
740 .data = &printk_delay_msec,
741 .maxlen = sizeof(int),
742 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800743 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700744 .extra1 = &zero,
745 .extra2 = &ten_thousand,
746 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800748 .procname = "dmesg_restrict",
749 .data = &dmesg_restrict,
750 .maxlen = sizeof(int),
751 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700752 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800753 .extra1 = &zero,
754 .extra2 = &one,
755 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800756 {
757 .procname = "kptr_restrict",
758 .data = &kptr_restrict,
759 .maxlen = sizeof(int),
760 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700761 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800762 .extra1 = &zero,
763 .extra2 = &two,
764 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800765#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800766 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 .procname = "ngroups_max",
768 .data = &ngroups_max,
769 .maxlen = sizeof (int),
770 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800771 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 },
Dan Ballard73efc032011-10-31 17:11:20 -0700773 {
774 .procname = "cap_last_cap",
775 .data = (void *)&cap_last_cap,
776 .maxlen = sizeof(int),
777 .mode = 0444,
778 .proc_handler = proc_dointvec,
779 },
Don Zickus58687ac2010-05-07 17:11:44 -0400780#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500781 {
Don Zickus58687ac2010-05-07 17:11:44 -0400782 .procname = "watchdog",
783 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500784 .maxlen = sizeof (int),
785 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700786 .proc_handler = proc_dowatchdog,
787 .extra1 = &zero,
788 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400789 },
790 {
791 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700792 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400793 .maxlen = sizeof(int),
794 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700795 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400796 .extra1 = &neg_one,
797 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500798 },
Don Zickus2508ce12010-05-07 17:11:46 -0400799 {
800 .procname = "softlockup_panic",
801 .data = &softlockup_panic,
802 .maxlen = sizeof(int),
803 .mode = 0644,
804 .proc_handler = proc_dointvec_minmax,
805 .extra1 = &zero,
806 .extra2 = &one,
807 },
Don Zickus5dc30552010-11-29 17:07:17 -0500808 {
809 .procname = "nmi_watchdog",
810 .data = &watchdog_enabled,
811 .maxlen = sizeof (int),
812 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700813 .proc_handler = proc_dowatchdog,
814 .extra1 = &zero,
815 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500816 },
817#endif
818#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
819 {
820 .procname = "unknown_nmi_panic",
821 .data = &unknown_nmi_panic,
822 .maxlen = sizeof (int),
823 .mode = 0644,
824 .proc_handler = proc_dointvec,
825 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500826#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827#if defined(CONFIG_X86)
828 {
Don Zickus8da5add2006-09-26 10:52:27 +0200829 .procname = "panic_on_unrecovered_nmi",
830 .data = &panic_on_unrecovered_nmi,
831 .maxlen = sizeof(int),
832 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800833 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200834 },
835 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700836 .procname = "panic_on_io_nmi",
837 .data = &panic_on_io_nmi,
838 .maxlen = sizeof(int),
839 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800840 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700841 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900842#ifdef CONFIG_DEBUG_STACKOVERFLOW
843 {
844 .procname = "panic_on_stackoverflow",
845 .data = &sysctl_panic_on_stackoverflow,
846 .maxlen = sizeof(int),
847 .mode = 0644,
848 .proc_handler = proc_dointvec,
849 },
850#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700851 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 .procname = "bootloader_type",
853 .data = &bootloader_type,
854 .maxlen = sizeof (int),
855 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800856 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100858 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700859 .procname = "bootloader_version",
860 .data = &bootloader_version,
861 .maxlen = sizeof (int),
862 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800863 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700864 },
865 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100866 .procname = "kstack_depth_to_print",
867 .data = &kstack_depth_to_print,
868 .maxlen = sizeof(int),
869 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800870 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100871 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100872 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100873 .procname = "io_delay_type",
874 .data = &io_delay_type,
875 .maxlen = sizeof(int),
876 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800877 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100878 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800880#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 .procname = "randomize_va_space",
883 .data = &randomize_va_space,
884 .maxlen = sizeof(int),
885 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800886 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800888#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800889#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700890 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700891 .procname = "spin_retry",
892 .data = &spin_retry,
893 .maxlen = sizeof (int),
894 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800895 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700896 },
897#endif
Len Brown673d5b42007-07-28 03:33:16 -0400898#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800899 {
Pavel Machekc255d842006-02-20 18:27:58 -0800900 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700901 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800902 .maxlen = sizeof (unsigned long),
903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800905 },
906#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800907#ifdef CONFIG_IA64
908 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800909 .procname = "ignore-unaligned-usertrap",
910 .data = &no_unaligned_warning,
911 .maxlen = sizeof (int),
912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800914 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800915 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800916 .procname = "unaligned-dump-stack",
917 .data = &unaligned_dump_stack,
918 .maxlen = sizeof (int),
919 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800920 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800921 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800922#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800923#ifdef CONFIG_DETECT_HUNG_TASK
924 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800925 .procname = "hung_task_panic",
926 .data = &sysctl_hung_task_panic,
927 .maxlen = sizeof(int),
928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800930 .extra1 = &zero,
931 .extra2 = &one,
932 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100933 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100934 .procname = "hung_task_check_count",
935 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100936 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100939 },
940 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100941 .procname = "hung_task_timeout_secs",
942 .data = &sysctl_hung_task_timeout_secs,
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_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100946 },
947 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100948 .procname = "hung_task_warnings",
949 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100950 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800952 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100953 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700954#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200955#ifdef CONFIG_COMPAT
956 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200957 .procname = "compat-log",
958 .data = &compat_log,
959 .maxlen = sizeof (int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200962 },
963#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700964#ifdef CONFIG_RT_MUTEXES
965 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700966 .procname = "max_lock_depth",
967 .data = &max_lock_depth,
968 .maxlen = sizeof(int),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700971 },
972#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700973 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700974 .procname = "poweroff_cmd",
975 .data = &poweroff_cmd,
976 .maxlen = POWEROFF_CMD_PATH_LEN,
977 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800978 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700979 },
David Howells0b77f5b2008-04-29 01:01:32 -0700980#ifdef CONFIG_KEYS
981 {
David Howells0b77f5b2008-04-29 01:01:32 -0700982 .procname = "keys",
983 .mode = 0555,
984 .child = key_sysctls,
985 },
986#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700987#ifdef CONFIG_RCU_TORTURE_TEST
988 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700989 .procname = "rcutorture_runnable",
990 .data = &rcutorture_runnable,
991 .maxlen = sizeof(int),
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700994 },
995#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200996#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400997 /*
998 * User-space scripts rely on the existence of this file
999 * as a feature check for perf_events being enabled.
1000 *
1001 * So it's an ABI, do not remove!
1002 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001003 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001004 .procname = "perf_event_paranoid",
1005 .data = &sysctl_perf_event_paranoid,
1006 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001007 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001008 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001009 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001010 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001011 .procname = "perf_event_mlock_kb",
1012 .data = &sysctl_perf_event_mlock,
1013 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001016 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001017 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001018 .procname = "perf_event_max_sample_rate",
1019 .data = &sysctl_perf_event_sample_rate,
1020 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001021 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001022 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001023 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001024#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001025#ifdef CONFIG_KMEMCHECK
1026 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001027 .procname = "kmemcheck",
1028 .data = &kmemcheck_enabled,
1029 .maxlen = sizeof(int),
1030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001032 },
1033#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001034#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001035 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001036 .procname = "blk_iopoll",
1037 .data = &blk_iopoll_enabled,
1038 .maxlen = sizeof(int),
1039 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001040 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001041 },
Jens Axboecb684b52009-09-15 21:53:11 +02001042#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001043 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044};
1045
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001046static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 .procname = "overcommit_memory",
1049 .data = &sysctl_overcommit_memory,
1050 .maxlen = sizeof(sysctl_overcommit_memory),
1051 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001052 .proc_handler = proc_dointvec_minmax,
1053 .extra1 = &zero,
1054 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 },
1056 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001057 .procname = "panic_on_oom",
1058 .data = &sysctl_panic_on_oom,
1059 .maxlen = sizeof(sysctl_panic_on_oom),
1060 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001061 .proc_handler = proc_dointvec_minmax,
1062 .extra1 = &zero,
1063 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001064 },
1065 {
David Rientjesfe071d72007-10-16 23:25:56 -07001066 .procname = "oom_kill_allocating_task",
1067 .data = &sysctl_oom_kill_allocating_task,
1068 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1069 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001070 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001071 },
1072 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001073 .procname = "oom_dump_tasks",
1074 .data = &sysctl_oom_dump_tasks,
1075 .maxlen = sizeof(sysctl_oom_dump_tasks),
1076 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001077 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001078 },
1079 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 .procname = "overcommit_ratio",
1081 .data = &sysctl_overcommit_ratio,
1082 .maxlen = sizeof(sysctl_overcommit_ratio),
1083 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001084 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 },
1086 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 .procname = "page-cluster",
1088 .data = &page_cluster,
1089 .maxlen = sizeof(int),
1090 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001091 .proc_handler = proc_dointvec_minmax,
1092 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 },
1094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "dirty_background_ratio",
1096 .data = &dirty_background_ratio,
1097 .maxlen = sizeof(dirty_background_ratio),
1098 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 .extra1 = &zero,
1101 .extra2 = &one_hundred,
1102 },
1103 {
David Rientjes2da02992009-01-06 14:39:31 -08001104 .procname = "dirty_background_bytes",
1105 .data = &dirty_background_bytes,
1106 .maxlen = sizeof(dirty_background_bytes),
1107 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001108 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001109 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001110 },
1111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .procname = "dirty_ratio",
1113 .data = &vm_dirty_ratio,
1114 .maxlen = sizeof(vm_dirty_ratio),
1115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 .extra1 = &zero,
1118 .extra2 = &one_hundred,
1119 },
1120 {
David Rientjes2da02992009-01-06 14:39:31 -08001121 .procname = "dirty_bytes",
1122 .data = &vm_dirty_bytes,
1123 .maxlen = sizeof(vm_dirty_bytes),
1124 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001126 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001127 },
1128 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001130 .data = &dirty_writeback_interval,
1131 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001133 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 },
1135 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001137 .data = &dirty_expire_interval,
1138 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001140 .proc_handler = proc_dointvec_minmax,
1141 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 },
1143 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001144 .procname = "nr_pdflush_threads",
1145 .mode = 0444 /* read-only */,
1146 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 },
1148 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 .procname = "swappiness",
1150 .data = &vm_swappiness,
1151 .maxlen = sizeof(vm_swappiness),
1152 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001153 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .extra1 = &zero,
1155 .extra2 = &one_hundred,
1156 },
1157#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001158 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001160 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .maxlen = sizeof(unsigned long),
1162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 .extra1 = (void *)&hugetlb_zero,
1165 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001166 },
1167#ifdef CONFIG_NUMA
1168 {
1169 .procname = "nr_hugepages_mempolicy",
1170 .data = NULL,
1171 .maxlen = sizeof(unsigned long),
1172 .mode = 0644,
1173 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1174 .extra1 = (void *)&hugetlb_zero,
1175 .extra2 = (void *)&hugetlb_infinity,
1176 },
1177#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .procname = "hugetlb_shm_group",
1180 .data = &sysctl_hugetlb_shm_group,
1181 .maxlen = sizeof(gid_t),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 },
Mel Gorman396faf02007-07-17 04:03:13 -07001185 {
Mel Gorman396faf02007-07-17 04:03:13 -07001186 .procname = "hugepages_treat_as_movable",
1187 .data = &hugepages_treat_as_movable,
1188 .maxlen = sizeof(int),
1189 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001190 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001191 },
Adam Litke54f9f802007-10-16 01:26:20 -07001192 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001193 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001194 .data = NULL,
1195 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001196 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001197 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001198 .extra1 = (void *)&hugetlb_zero,
1199 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001200 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201#endif
1202 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .procname = "lowmem_reserve_ratio",
1204 .data = &sysctl_lowmem_reserve_ratio,
1205 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 },
1209 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001210 .procname = "drop_caches",
1211 .data = &sysctl_drop_caches,
1212 .maxlen = sizeof(int),
1213 .mode = 0644,
1214 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001215 .extra1 = &one,
1216 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001217 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001218#ifdef CONFIG_COMPACTION
1219 {
1220 .procname = "compact_memory",
1221 .data = &sysctl_compact_memory,
1222 .maxlen = sizeof(int),
1223 .mode = 0200,
1224 .proc_handler = sysctl_compaction_handler,
1225 },
Mel Gorman5e771902010-05-24 14:32:31 -07001226 {
1227 .procname = "extfrag_threshold",
1228 .data = &sysctl_extfrag_threshold,
1229 .maxlen = sizeof(int),
1230 .mode = 0644,
1231 .proc_handler = sysctl_extfrag_handler,
1232 .extra1 = &min_extfrag_threshold,
1233 .extra2 = &max_extfrag_threshold,
1234 },
1235
Mel Gorman76ab0f52010-05-24 14:32:28 -07001236#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 .procname = "min_free_kbytes",
1239 .data = &min_free_kbytes,
1240 .maxlen = sizeof(min_free_kbytes),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .extra1 = &zero,
1244 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001245 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001246 .procname = "percpu_pagelist_fraction",
1247 .data = &percpu_pagelist_fraction,
1248 .maxlen = sizeof(percpu_pagelist_fraction),
1249 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001250 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001251 .extra1 = &min_percpu_pagelist_fract,
1252 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253#ifdef CONFIG_MMU
1254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .procname = "max_map_count",
1256 .data = &sysctl_max_map_count,
1257 .maxlen = sizeof(sysctl_max_map_count),
1258 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001259 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001260 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001262#else
1263 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001264 .procname = "nr_trim_pages",
1265 .data = &sysctl_nr_trim_pages,
1266 .maxlen = sizeof(sysctl_nr_trim_pages),
1267 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001268 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001269 .extra1 = &zero,
1270 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271#endif
1272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 .procname = "laptop_mode",
1274 .data = &laptop_mode,
1275 .maxlen = sizeof(laptop_mode),
1276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001277 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 },
1279 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 .procname = "block_dump",
1281 .data = &block_dump,
1282 .maxlen = sizeof(block_dump),
1283 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001284 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285 .extra1 = &zero,
1286 },
1287 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288 .procname = "vfs_cache_pressure",
1289 .data = &sysctl_vfs_cache_pressure,
1290 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 .extra1 = &zero,
1294 },
1295#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .procname = "legacy_va_layout",
1298 .data = &sysctl_legacy_va_layout,
1299 .maxlen = sizeof(sysctl_legacy_va_layout),
1300 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 .extra1 = &zero,
1303 },
1304#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001305#ifdef CONFIG_NUMA
1306 {
Christoph Lameter17436602006-01-18 17:42:32 -08001307 .procname = "zone_reclaim_mode",
1308 .data = &zone_reclaim_mode,
1309 .maxlen = sizeof(zone_reclaim_mode),
1310 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001312 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001313 },
Christoph Lameter96146342006-07-03 00:24:13 -07001314 {
Christoph Lameter96146342006-07-03 00:24:13 -07001315 .procname = "min_unmapped_ratio",
1316 .data = &sysctl_min_unmapped_ratio,
1317 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001320 .extra1 = &zero,
1321 .extra2 = &one_hundred,
1322 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001323 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001324 .procname = "min_slab_ratio",
1325 .data = &sysctl_min_slab_ratio,
1326 .maxlen = sizeof(sysctl_min_slab_ratio),
1327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001328 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001329 .extra1 = &zero,
1330 .extra2 = &one_hundred,
1331 },
Christoph Lameter17436602006-01-18 17:42:32 -08001332#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001333#ifdef CONFIG_SMP
1334 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001335 .procname = "stat_interval",
1336 .data = &sysctl_stat_interval,
1337 .maxlen = sizeof(sysctl_stat_interval),
1338 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001339 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001340 },
1341#endif
David Howells6e141542009-12-15 19:27:45 +00001342#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001343 {
Eric Parised032182007-06-28 15:55:21 -04001344 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001345 .data = &dac_mmap_min_addr,
1346 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001347 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001348 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001349 },
David Howells6e141542009-12-15 19:27:45 +00001350#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001351#ifdef CONFIG_NUMA
1352 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001353 .procname = "numa_zonelist_order",
1354 .data = &numa_zonelist_order,
1355 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001358 },
1359#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001360#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001361 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001362 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001363 .procname = "vdso_enabled",
1364 .data = &vdso_enabled,
1365 .maxlen = sizeof(vdso_enabled),
1366 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001367 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001368 .extra1 = &zero,
1369 },
1370#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001371#ifdef CONFIG_HIGHMEM
1372 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001373 .procname = "highmem_is_dirtyable",
1374 .data = &vm_highmem_is_dirtyable,
1375 .maxlen = sizeof(vm_highmem_is_dirtyable),
1376 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001377 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001378 .extra1 = &zero,
1379 .extra2 = &one,
1380 },
1381#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001382 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001383 .procname = "scan_unevictable_pages",
1384 .data = &scan_unevictable_pages,
1385 .maxlen = sizeof(scan_unevictable_pages),
1386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001388 },
Andi Kleen6a460792009-09-16 11:50:15 +02001389#ifdef CONFIG_MEMORY_FAILURE
1390 {
Andi Kleen6a460792009-09-16 11:50:15 +02001391 .procname = "memory_failure_early_kill",
1392 .data = &sysctl_memory_failure_early_kill,
1393 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1394 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001395 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001396 .extra1 = &zero,
1397 .extra2 = &one,
1398 },
1399 {
Andi Kleen6a460792009-09-16 11:50:15 +02001400 .procname = "memory_failure_recovery",
1401 .data = &sysctl_memory_failure_recovery,
1402 .maxlen = sizeof(sysctl_memory_failure_recovery),
1403 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001404 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001405 .extra1 = &zero,
1406 .extra2 = &one,
1407 },
1408#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001409 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410};
1411
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001412#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001413static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001414 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001415};
1416#endif
1417
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001418static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 .procname = "inode-nr",
1421 .data = &inodes_stat,
1422 .maxlen = 2*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 = "inode-state",
1428 .data = &inodes_stat,
1429 .maxlen = 7*sizeof(int),
1430 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001431 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 },
1433 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 .procname = "file-nr",
1435 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001436 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 },
1440 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 .procname = "file-max",
1442 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001443 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001445 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 },
1447 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001448 .procname = "nr_open",
1449 .data = &sysctl_nr_open,
1450 .maxlen = sizeof(int),
1451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001452 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001453 .extra1 = &sysctl_nr_open_min,
1454 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001455 },
1456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 .procname = "dentry-state",
1458 .data = &dentry_stat,
1459 .maxlen = 6*sizeof(int),
1460 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001461 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "overflowuid",
1465 .data = &fs_overflowuid,
1466 .maxlen = sizeof(int),
1467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001468 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .extra1 = &minolduid,
1470 .extra2 = &maxolduid,
1471 },
1472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 .procname = "overflowgid",
1474 .data = &fs_overflowgid,
1475 .maxlen = sizeof(int),
1476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001477 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .extra1 = &minolduid,
1479 .extra2 = &maxolduid,
1480 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001481#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 .procname = "leases-enable",
1484 .data = &leases_enable,
1485 .maxlen = sizeof(int),
1486 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001487 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001489#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490#ifdef CONFIG_DNOTIFY
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "dir-notify-enable",
1493 .data = &dir_notify_enable,
1494 .maxlen = sizeof(int),
1495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001496 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 },
1498#endif
1499#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001500#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 .procname = "lease-break-time",
1503 .data = &lease_break_time,
1504 .maxlen = sizeof(int),
1505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001506 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001508#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001509#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .procname = "aio-nr",
1512 .data = &aio_nr,
1513 .maxlen = sizeof(aio_nr),
1514 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 },
1517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 .procname = "aio-max-nr",
1519 .data = &aio_max_nr,
1520 .maxlen = sizeof(aio_max_nr),
1521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001522 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001524#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001525#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001526 {
Robert Love0399cb02005-07-13 12:38:18 -04001527 .procname = "inotify",
1528 .mode = 0555,
1529 .child = inotify_table,
1530 },
1531#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001532#ifdef CONFIG_EPOLL
1533 {
1534 .procname = "epoll",
1535 .mode = 0555,
1536 .child = epoll_table,
1537 },
1538#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001540 {
Kees Cook800179c2012-07-25 17:29:07 -07001541 .procname = "protected_symlinks",
1542 .data = &sysctl_protected_symlinks,
1543 .maxlen = sizeof(int),
1544 .mode = 0600,
1545 .proc_handler = proc_dointvec_minmax,
1546 .extra1 = &zero,
1547 .extra2 = &one,
1548 },
1549 {
1550 .procname = "protected_hardlinks",
1551 .data = &sysctl_protected_hardlinks,
1552 .maxlen = sizeof(int),
1553 .mode = 0600,
1554 .proc_handler = proc_dointvec_minmax,
1555 .extra1 = &zero,
1556 .extra2 = &one,
1557 },
1558 {
Alan Coxd6e71142005-06-23 00:09:43 -07001559 .procname = "suid_dumpable",
1560 .data = &suid_dumpable,
1561 .maxlen = sizeof(int),
1562 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001563 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001564 .extra1 = &zero,
1565 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001566 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001567#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1568 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001569 .procname = "binfmt_misc",
1570 .mode = 0555,
1571 .child = binfmt_misc_table,
1572 },
1573#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001574 {
Jens Axboeff9da692010-06-03 14:54:39 +02001575 .procname = "pipe-max-size",
1576 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001577 .maxlen = sizeof(int),
1578 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001579 .proc_handler = &pipe_proc_fn,
1580 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001581 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001582 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583};
1584
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001585static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001586#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001587 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001588 .procname = "exception-trace",
1589 .data = &show_unhandled_signals,
1590 .maxlen = sizeof(int),
1591 .mode = 0644,
1592 .proc_handler = proc_dointvec
1593 },
1594#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001595#if defined(CONFIG_OPTPROBES)
1596 {
1597 .procname = "kprobes-optimization",
1598 .data = &sysctl_kprobes_optimization,
1599 .maxlen = sizeof(int),
1600 .mode = 0644,
1601 .proc_handler = proc_kprobes_optimization_handler,
1602 .extra1 = &zero,
1603 .extra2 = &one,
1604 },
1605#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001606 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607};
1608
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001609static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001610 { }
Robert Love0eeca282005-07-12 17:06:03 -04001611};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001612
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001613int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001614{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001615 struct ctl_table_header *hdr;
1616
1617 hdr = register_sysctl_table(sysctl_base_table);
1618 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001619 return 0;
1620}
1621
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001622#endif /* CONFIG_SYSCTL */
1623
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624/*
1625 * /proc/sys support
1626 */
1627
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001628#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001630static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001631 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001632 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001633{
1634 size_t len;
1635 char __user *p;
1636 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001637
1638 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001639 *lenp = 0;
1640 return 0;
1641 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001642
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001643 if (write) {
1644 len = 0;
1645 p = buffer;
1646 while (len < *lenp) {
1647 if (get_user(c, p++))
1648 return -EFAULT;
1649 if (c == 0 || c == '\n')
1650 break;
1651 len++;
1652 }
1653 if (len >= maxlen)
1654 len = maxlen-1;
1655 if(copy_from_user(data, buffer, len))
1656 return -EFAULT;
1657 ((char *) data)[len] = 0;
1658 *ppos += *lenp;
1659 } else {
1660 len = strlen(data);
1661 if (len > maxlen)
1662 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001663
1664 if (*ppos > len) {
1665 *lenp = 0;
1666 return 0;
1667 }
1668
1669 data += *ppos;
1670 len -= *ppos;
1671
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001672 if (len > *lenp)
1673 len = *lenp;
1674 if (len)
1675 if(copy_to_user(buffer, data, len))
1676 return -EFAULT;
1677 if (len < *lenp) {
1678 if(put_user('\n', ((char __user *) buffer) + len))
1679 return -EFAULT;
1680 len++;
1681 }
1682 *lenp = len;
1683 *ppos += len;
1684 }
1685 return 0;
1686}
1687
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688/**
1689 * proc_dostring - read a string sysctl
1690 * @table: the sysctl table
1691 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 * @buffer: the user buffer
1693 * @lenp: the size of the user buffer
1694 * @ppos: file position
1695 *
1696 * Reads/writes a string from/to the user buffer. If the kernel
1697 * buffer provided is not large enough to hold the string, the
1698 * string is truncated. The copied string is %NULL-terminated.
1699 * If the string is being read by the user process, it is copied
1700 * and a newline '\n' is added. It is truncated if the buffer is
1701 * not large enough.
1702 *
1703 * Returns 0 on success.
1704 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001705int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 void __user *buffer, size_t *lenp, loff_t *ppos)
1707{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001708 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001709 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710}
1711
Amerigo Wang00b7c332010-05-05 00:26:45 +00001712static size_t proc_skip_spaces(char **buf)
1713{
1714 size_t ret;
1715 char *tmp = skip_spaces(*buf);
1716 ret = tmp - *buf;
1717 *buf = tmp;
1718 return ret;
1719}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001721static void proc_skip_char(char **buf, size_t *size, const char v)
1722{
1723 while (*size) {
1724 if (**buf != v)
1725 break;
1726 (*size)--;
1727 (*buf)++;
1728 }
1729}
1730
Amerigo Wang00b7c332010-05-05 00:26:45 +00001731#define TMPBUFLEN 22
1732/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001733 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001734 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001735 * @buf: a kernel buffer
1736 * @size: size of the kernel buffer
1737 * @val: this is where the number will be stored
1738 * @neg: set to %TRUE if number is negative
1739 * @perm_tr: a vector which contains the allowed trailers
1740 * @perm_tr_len: size of the perm_tr vector
1741 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001742 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001743 * In case of success %0 is returned and @buf and @size are updated with
1744 * the amount of bytes read. If @tr is non-NULL and a trailing
1745 * character exists (size is non-zero after returning from this
1746 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001747 */
1748static int proc_get_long(char **buf, size_t *size,
1749 unsigned long *val, bool *neg,
1750 const char *perm_tr, unsigned perm_tr_len, char *tr)
1751{
1752 int len;
1753 char *p, tmp[TMPBUFLEN];
1754
1755 if (!*size)
1756 return -EINVAL;
1757
1758 len = *size;
1759 if (len > TMPBUFLEN - 1)
1760 len = TMPBUFLEN - 1;
1761
1762 memcpy(tmp, *buf, len);
1763
1764 tmp[len] = 0;
1765 p = tmp;
1766 if (*p == '-' && *size > 1) {
1767 *neg = true;
1768 p++;
1769 } else
1770 *neg = false;
1771 if (!isdigit(*p))
1772 return -EINVAL;
1773
1774 *val = simple_strtoul(p, &p, 0);
1775
1776 len = p - tmp;
1777
1778 /* We don't know if the next char is whitespace thus we may accept
1779 * invalid integers (e.g. 1234...a) or two integers instead of one
1780 * (e.g. 123...1). So lets not allow such large numbers. */
1781 if (len == TMPBUFLEN - 1)
1782 return -EINVAL;
1783
1784 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1785 return -EINVAL;
1786
1787 if (tr && (len < *size))
1788 *tr = *p;
1789
1790 *buf += len;
1791 *size -= len;
1792
1793 return 0;
1794}
1795
1796/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001797 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001798 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001799 * @buf: the user buffer
1800 * @size: the size of the user buffer
1801 * @val: the integer to be converted
1802 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001803 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001804 * In case of success %0 is returned and @buf and @size are updated with
1805 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001806 */
1807static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1808 bool neg)
1809{
1810 int len;
1811 char tmp[TMPBUFLEN], *p = tmp;
1812
1813 sprintf(p, "%s%lu", neg ? "-" : "", val);
1814 len = strlen(tmp);
1815 if (len > *size)
1816 len = *size;
1817 if (copy_to_user(*buf, tmp, len))
1818 return -EFAULT;
1819 *size -= len;
1820 *buf += len;
1821 return 0;
1822}
1823#undef TMPBUFLEN
1824
1825static int proc_put_char(void __user **buf, size_t *size, char c)
1826{
1827 if (*size) {
1828 char __user **buffer = (char __user **)buf;
1829 if (put_user(c, *buffer))
1830 return -EFAULT;
1831 (*size)--, (*buffer)++;
1832 *buf = *buffer;
1833 }
1834 return 0;
1835}
1836
1837static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 int *valp,
1839 int write, void *data)
1840{
1841 if (write) {
1842 *valp = *negp ? -*lvalp : *lvalp;
1843 } else {
1844 int val = *valp;
1845 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001846 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847 *lvalp = (unsigned long)-val;
1848 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001849 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 *lvalp = (unsigned long)val;
1851 }
1852 }
1853 return 0;
1854}
1855
Amerigo Wang00b7c332010-05-05 00:26:45 +00001856static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1857
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001858static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001859 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001860 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 int write, void *data),
1863 void *data)
1864{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001865 int *i, vleft, first = 1, err = 0;
1866 unsigned long page = 0;
1867 size_t left;
1868 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869
Amerigo Wang00b7c332010-05-05 00:26:45 +00001870 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871 *lenp = 0;
1872 return 0;
1873 }
1874
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001875 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 vleft = table->maxlen / sizeof(*i);
1877 left = *lenp;
1878
1879 if (!conv)
1880 conv = do_proc_dointvec_conv;
1881
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001883 if (left > PAGE_SIZE - 1)
1884 left = PAGE_SIZE - 1;
1885 page = __get_free_page(GFP_TEMPORARY);
1886 kbuf = (char *) page;
1887 if (!kbuf)
1888 return -ENOMEM;
1889 if (copy_from_user(kbuf, buffer, left)) {
1890 err = -EFAULT;
1891 goto free;
1892 }
1893 kbuf[left] = 0;
1894 }
1895
1896 for (; left && vleft--; i++, first=0) {
1897 unsigned long lval;
1898 bool neg;
1899
1900 if (write) {
1901 left -= proc_skip_spaces(&kbuf);
1902
J. R. Okajima563b0462010-05-25 16:10:14 -07001903 if (!left)
1904 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001905 err = proc_get_long(&kbuf, &left, &lval, &neg,
1906 proc_wspace_sep,
1907 sizeof(proc_wspace_sep), NULL);
1908 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001909 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001910 if (conv(&neg, &lval, i, 1, data)) {
1911 err = -EINVAL;
1912 break;
1913 }
1914 } else {
1915 if (conv(&neg, &lval, i, 0, data)) {
1916 err = -EINVAL;
1917 break;
1918 }
1919 if (!first)
1920 err = proc_put_char(&buffer, &left, '\t');
1921 if (err)
1922 break;
1923 err = proc_put_long(&buffer, &left, lval, neg);
1924 if (err)
1925 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926 }
1927 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001928
1929 if (!write && !first && left && !err)
1930 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001931 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001932 left -= proc_skip_spaces(&kbuf);
1933free:
1934 if (write) {
1935 free_page(page);
1936 if (first)
1937 return err ? : -EINVAL;
1938 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001939 *lenp -= left;
1940 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001941 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001942}
1943
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001944static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001945 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001946 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001947 int write, void *data),
1948 void *data)
1949{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001950 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001951 buffer, lenp, ppos, conv, data);
1952}
1953
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954/**
1955 * proc_dointvec - read a vector of integers
1956 * @table: the sysctl table
1957 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958 * @buffer: the user buffer
1959 * @lenp: the size of the user buffer
1960 * @ppos: file position
1961 *
1962 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1963 * values from/to the user buffer, treated as an ASCII string.
1964 *
1965 * Returns 0 on success.
1966 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001967int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 void __user *buffer, size_t *lenp, loff_t *ppos)
1969{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001970 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001971 NULL,NULL);
1972}
1973
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001974/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07001975 * Taint values can only be increased
1976 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001977 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001978static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001979 void __user *buffer, size_t *lenp, loff_t *ppos)
1980{
Andi Kleen25ddbb12008-10-15 22:01:41 -07001981 struct ctl_table t;
1982 unsigned long tmptaint = get_taint();
1983 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001984
Bastian Blank91fcd412007-04-23 14:41:14 -07001985 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001986 return -EPERM;
1987
Andi Kleen25ddbb12008-10-15 22:01:41 -07001988 t = *table;
1989 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001990 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07001991 if (err < 0)
1992 return err;
1993
1994 if (write) {
1995 /*
1996 * Poor man's atomic or. Not worth adding a primitive
1997 * to everyone's atomic.h for this
1998 */
1999 int i;
2000 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2001 if ((tmptaint >> i) & 1)
2002 add_taint(i);
2003 }
2004 }
2005
2006 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002007}
2008
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002009#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002010static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002011 void __user *buffer, size_t *lenp, loff_t *ppos)
2012{
2013 if (write && !capable(CAP_SYS_ADMIN))
2014 return -EPERM;
2015
2016 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2017}
2018#endif
2019
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020struct do_proc_dointvec_minmax_conv_param {
2021 int *min;
2022 int *max;
2023};
2024
Amerigo Wang00b7c332010-05-05 00:26:45 +00002025static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2026 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 int write, void *data)
2028{
2029 struct do_proc_dointvec_minmax_conv_param *param = data;
2030 if (write) {
2031 int val = *negp ? -*lvalp : *lvalp;
2032 if ((param->min && *param->min > val) ||
2033 (param->max && *param->max < val))
2034 return -EINVAL;
2035 *valp = val;
2036 } else {
2037 int val = *valp;
2038 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002039 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 *lvalp = (unsigned long)-val;
2041 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002042 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043 *lvalp = (unsigned long)val;
2044 }
2045 }
2046 return 0;
2047}
2048
2049/**
2050 * proc_dointvec_minmax - read a vector of integers with min/max values
2051 * @table: the sysctl table
2052 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 * @buffer: the user buffer
2054 * @lenp: the size of the user buffer
2055 * @ppos: file position
2056 *
2057 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2058 * values from/to the user buffer, treated as an ASCII string.
2059 *
2060 * This routine will ensure the values are within the range specified by
2061 * table->extra1 (min) and table->extra2 (max).
2062 *
2063 * Returns 0 on success.
2064 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002065int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066 void __user *buffer, size_t *lenp, loff_t *ppos)
2067{
2068 struct do_proc_dointvec_minmax_conv_param param = {
2069 .min = (int *) table->extra1,
2070 .max = (int *) table->extra2,
2071 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002072 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 do_proc_dointvec_minmax_conv, &param);
2074}
2075
Kees Cook54b50192012-07-30 14:39:18 -07002076static void validate_coredump_safety(void)
2077{
Alex Kelly046d6622012-10-04 17:15:23 -07002078#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002079 if (suid_dumpable == SUID_DUMPABLE_SAFE &&
2080 core_pattern[0] != '/' && core_pattern[0] != '|') {
2081 printk(KERN_WARNING "Unsafe core_pattern used with "\
2082 "suid_dumpable=2. Pipe handler or fully qualified "\
2083 "core dump path required.\n");
2084 }
Alex Kelly046d6622012-10-04 17:15:23 -07002085#endif
Kees Cook54b50192012-07-30 14:39:18 -07002086}
2087
2088static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2089 void __user *buffer, size_t *lenp, loff_t *ppos)
2090{
2091 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2092 if (!error)
2093 validate_coredump_safety();
2094 return error;
2095}
2096
Alex Kelly046d6622012-10-04 17:15:23 -07002097#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002098static int proc_dostring_coredump(struct ctl_table *table, int write,
2099 void __user *buffer, size_t *lenp, loff_t *ppos)
2100{
2101 int error = proc_dostring(table, write, buffer, lenp, ppos);
2102 if (!error)
2103 validate_coredump_safety();
2104 return error;
2105}
Alex Kelly046d6622012-10-04 17:15:23 -07002106#endif
Kees Cook54b50192012-07-30 14:39:18 -07002107
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002108static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109 void __user *buffer,
2110 size_t *lenp, loff_t *ppos,
2111 unsigned long convmul,
2112 unsigned long convdiv)
2113{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002114 unsigned long *i, *min, *max;
2115 int vleft, first = 1, err = 0;
2116 unsigned long page = 0;
2117 size_t left;
2118 char *kbuf;
2119
2120 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 *lenp = 0;
2122 return 0;
2123 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002124
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002125 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126 min = (unsigned long *) table->extra1;
2127 max = (unsigned long *) table->extra2;
2128 vleft = table->maxlen / sizeof(unsigned long);
2129 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002130
2131 if (write) {
2132 if (left > PAGE_SIZE - 1)
2133 left = PAGE_SIZE - 1;
2134 page = __get_free_page(GFP_TEMPORARY);
2135 kbuf = (char *) page;
2136 if (!kbuf)
2137 return -ENOMEM;
2138 if (copy_from_user(kbuf, buffer, left)) {
2139 err = -EFAULT;
2140 goto free;
2141 }
2142 kbuf[left] = 0;
2143 }
2144
Eric Dumazet27b3d802010-10-07 12:59:29 -07002145 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002146 unsigned long val;
2147
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002149 bool neg;
2150
2151 left -= proc_skip_spaces(&kbuf);
2152
2153 err = proc_get_long(&kbuf, &left, &val, &neg,
2154 proc_wspace_sep,
2155 sizeof(proc_wspace_sep), NULL);
2156 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 break;
2158 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 continue;
2160 if ((min && val < *min) || (max && val > *max))
2161 continue;
2162 *i = val;
2163 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002164 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002166 err = proc_put_char(&buffer, &left, '\t');
2167 err = proc_put_long(&buffer, &left, val, false);
2168 if (err)
2169 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 }
2171 }
2172
Amerigo Wang00b7c332010-05-05 00:26:45 +00002173 if (!write && !first && left && !err)
2174 err = proc_put_char(&buffer, &left, '\n');
2175 if (write && !err)
2176 left -= proc_skip_spaces(&kbuf);
2177free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002179 free_page(page);
2180 if (first)
2181 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183 *lenp -= left;
2184 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186}
2187
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002188static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002189 void __user *buffer,
2190 size_t *lenp, loff_t *ppos,
2191 unsigned long convmul,
2192 unsigned long convdiv)
2193{
2194 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002195 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002196}
2197
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198/**
2199 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2200 * @table: the sysctl table
2201 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 * @buffer: the user buffer
2203 * @lenp: the size of the user buffer
2204 * @ppos: file position
2205 *
2206 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2207 * values from/to the user buffer, treated as an ASCII string.
2208 *
2209 * This routine will ensure the values are within the range specified by
2210 * table->extra1 (min) and table->extra2 (max).
2211 *
2212 * Returns 0 on success.
2213 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002214int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215 void __user *buffer, size_t *lenp, loff_t *ppos)
2216{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002217 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218}
2219
2220/**
2221 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2222 * @table: the sysctl table
2223 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224 * @buffer: the user buffer
2225 * @lenp: the size of the user buffer
2226 * @ppos: file position
2227 *
2228 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2229 * values from/to the user buffer, treated as an ASCII string. The values
2230 * are treated as milliseconds, and converted to jiffies when they are stored.
2231 *
2232 * This routine will ensure the values are within the range specified by
2233 * table->extra1 (min) and table->extra2 (max).
2234 *
2235 * Returns 0 on success.
2236 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002237int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 void __user *buffer,
2239 size_t *lenp, loff_t *ppos)
2240{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002241 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002242 lenp, ppos, HZ, 1000l);
2243}
2244
2245
Amerigo Wang00b7c332010-05-05 00:26:45 +00002246static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002247 int *valp,
2248 int write, void *data)
2249{
2250 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002251 if (*lvalp > LONG_MAX / HZ)
2252 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2254 } else {
2255 int val = *valp;
2256 unsigned long lval;
2257 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 lval = (unsigned long)-val;
2260 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002261 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 lval = (unsigned long)val;
2263 }
2264 *lvalp = lval / HZ;
2265 }
2266 return 0;
2267}
2268
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 int *valp,
2271 int write, void *data)
2272{
2273 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002274 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2275 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2277 } else {
2278 int val = *valp;
2279 unsigned long lval;
2280 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002281 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 lval = (unsigned long)-val;
2283 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 lval = (unsigned long)val;
2286 }
2287 *lvalp = jiffies_to_clock_t(lval);
2288 }
2289 return 0;
2290}
2291
Amerigo Wang00b7c332010-05-05 00:26:45 +00002292static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293 int *valp,
2294 int write, void *data)
2295{
2296 if (write) {
2297 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2298 } else {
2299 int val = *valp;
2300 unsigned long lval;
2301 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002302 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 lval = (unsigned long)-val;
2304 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002305 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 lval = (unsigned long)val;
2307 }
2308 *lvalp = jiffies_to_msecs(lval);
2309 }
2310 return 0;
2311}
2312
2313/**
2314 * proc_dointvec_jiffies - read a vector of integers as seconds
2315 * @table: the sysctl table
2316 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002317 * @buffer: the user buffer
2318 * @lenp: the size of the user buffer
2319 * @ppos: file position
2320 *
2321 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2322 * values from/to the user buffer, treated as an ASCII string.
2323 * The values read are assumed to be in seconds, and are converted into
2324 * jiffies.
2325 *
2326 * Returns 0 on success.
2327 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002328int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 void __user *buffer, size_t *lenp, loff_t *ppos)
2330{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002331 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 do_proc_dointvec_jiffies_conv,NULL);
2333}
2334
2335/**
2336 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2337 * @table: the sysctl table
2338 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 * @buffer: the user buffer
2340 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002341 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 *
2343 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2344 * values from/to the user buffer, treated as an ASCII string.
2345 * The values read are assumed to be in 1/USER_HZ seconds, and
2346 * are converted into jiffies.
2347 *
2348 * Returns 0 on success.
2349 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002350int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 void __user *buffer, size_t *lenp, loff_t *ppos)
2352{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002353 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 do_proc_dointvec_userhz_jiffies_conv,NULL);
2355}
2356
2357/**
2358 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2359 * @table: the sysctl table
2360 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361 * @buffer: the user buffer
2362 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002363 * @ppos: file position
2364 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365 *
2366 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2367 * values from/to the user buffer, treated as an ASCII string.
2368 * The values read are assumed to be in 1/1000 seconds, and
2369 * are converted into jiffies.
2370 *
2371 * Returns 0 on success.
2372 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002373int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374 void __user *buffer, size_t *lenp, loff_t *ppos)
2375{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002376 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 do_proc_dointvec_ms_jiffies_conv, NULL);
2378}
2379
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002380static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002381 void __user *buffer, size_t *lenp, loff_t *ppos)
2382{
2383 struct pid *new_pid;
2384 pid_t tmp;
2385 int r;
2386
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002387 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002388
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002389 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002390 lenp, ppos, NULL, NULL);
2391 if (r || !write)
2392 return r;
2393
2394 new_pid = find_get_pid(tmp);
2395 if (!new_pid)
2396 return -ESRCH;
2397
2398 put_pid(xchg(&cad_pid, new_pid));
2399 return 0;
2400}
2401
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002402/**
2403 * proc_do_large_bitmap - read/write from/to a large bitmap
2404 * @table: the sysctl table
2405 * @write: %TRUE if this is a write to the sysctl file
2406 * @buffer: the user buffer
2407 * @lenp: the size of the user buffer
2408 * @ppos: file position
2409 *
2410 * The bitmap is stored at table->data and the bitmap length (in bits)
2411 * in table->maxlen.
2412 *
2413 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2414 * large bitmaps may be represented in a compact manner. Writing into
2415 * the file will clear the bitmap then update it with the given input.
2416 *
2417 * Returns 0 on success.
2418 */
2419int proc_do_large_bitmap(struct ctl_table *table, int write,
2420 void __user *buffer, size_t *lenp, loff_t *ppos)
2421{
2422 int err = 0;
2423 bool first = 1;
2424 size_t left = *lenp;
2425 unsigned long bitmap_len = table->maxlen;
2426 unsigned long *bitmap = (unsigned long *) table->data;
2427 unsigned long *tmp_bitmap = NULL;
2428 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2429
2430 if (!bitmap_len || !left || (*ppos && !write)) {
2431 *lenp = 0;
2432 return 0;
2433 }
2434
2435 if (write) {
2436 unsigned long page = 0;
2437 char *kbuf;
2438
2439 if (left > PAGE_SIZE - 1)
2440 left = PAGE_SIZE - 1;
2441
2442 page = __get_free_page(GFP_TEMPORARY);
2443 kbuf = (char *) page;
2444 if (!kbuf)
2445 return -ENOMEM;
2446 if (copy_from_user(kbuf, buffer, left)) {
2447 free_page(page);
2448 return -EFAULT;
2449 }
2450 kbuf[left] = 0;
2451
2452 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2453 GFP_KERNEL);
2454 if (!tmp_bitmap) {
2455 free_page(page);
2456 return -ENOMEM;
2457 }
2458 proc_skip_char(&kbuf, &left, '\n');
2459 while (!err && left) {
2460 unsigned long val_a, val_b;
2461 bool neg;
2462
2463 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2464 sizeof(tr_a), &c);
2465 if (err)
2466 break;
2467 if (val_a >= bitmap_len || neg) {
2468 err = -EINVAL;
2469 break;
2470 }
2471
2472 val_b = val_a;
2473 if (left) {
2474 kbuf++;
2475 left--;
2476 }
2477
2478 if (c == '-') {
2479 err = proc_get_long(&kbuf, &left, &val_b,
2480 &neg, tr_b, sizeof(tr_b),
2481 &c);
2482 if (err)
2483 break;
2484 if (val_b >= bitmap_len || neg ||
2485 val_a > val_b) {
2486 err = -EINVAL;
2487 break;
2488 }
2489 if (left) {
2490 kbuf++;
2491 left--;
2492 }
2493 }
2494
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002495 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002496 first = 0;
2497 proc_skip_char(&kbuf, &left, '\n');
2498 }
2499 free_page(page);
2500 } else {
2501 unsigned long bit_a, bit_b = 0;
2502
2503 while (left) {
2504 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2505 if (bit_a >= bitmap_len)
2506 break;
2507 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2508 bit_a + 1) - 1;
2509
2510 if (!first) {
2511 err = proc_put_char(&buffer, &left, ',');
2512 if (err)
2513 break;
2514 }
2515 err = proc_put_long(&buffer, &left, bit_a, false);
2516 if (err)
2517 break;
2518 if (bit_a != bit_b) {
2519 err = proc_put_char(&buffer, &left, '-');
2520 if (err)
2521 break;
2522 err = proc_put_long(&buffer, &left, bit_b, false);
2523 if (err)
2524 break;
2525 }
2526
2527 first = 0; bit_b++;
2528 }
2529 if (!err)
2530 err = proc_put_char(&buffer, &left, '\n');
2531 }
2532
2533 if (!err) {
2534 if (write) {
2535 if (*ppos)
2536 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2537 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002538 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002539 }
2540 kfree(tmp_bitmap);
2541 *lenp -= left;
2542 *ppos += *lenp;
2543 return 0;
2544 } else {
2545 kfree(tmp_bitmap);
2546 return err;
2547 }
2548}
2549
Jovi Zhang55610502011-01-12 17:00:45 -08002550#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002552int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 void __user *buffer, size_t *lenp, loff_t *ppos)
2554{
2555 return -ENOSYS;
2556}
2557
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002558int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 void __user *buffer, size_t *lenp, loff_t *ppos)
2560{
2561 return -ENOSYS;
2562}
2563
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002564int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 void __user *buffer, size_t *lenp, loff_t *ppos)
2566{
2567 return -ENOSYS;
2568}
2569
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 void __user *buffer, size_t *lenp, loff_t *ppos)
2572{
2573 return -ENOSYS;
2574}
2575
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002576int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577 void __user *buffer, size_t *lenp, loff_t *ppos)
2578{
2579 return -ENOSYS;
2580}
2581
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002582int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 void __user *buffer, size_t *lenp, loff_t *ppos)
2584{
2585 return -ENOSYS;
2586}
2587
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002588int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589 void __user *buffer, size_t *lenp, loff_t *ppos)
2590{
2591 return -ENOSYS;
2592}
2593
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002594int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 void __user *buffer,
2596 size_t *lenp, loff_t *ppos)
2597{
2598 return -ENOSYS;
2599}
2600
2601
Jovi Zhang55610502011-01-12 17:00:45 -08002602#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604/*
2605 * No sense putting this after each symbol definition, twice,
2606 * exception granted :-)
2607 */
2608EXPORT_SYMBOL(proc_dointvec);
2609EXPORT_SYMBOL(proc_dointvec_jiffies);
2610EXPORT_SYMBOL(proc_dointvec_minmax);
2611EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2612EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2613EXPORT_SYMBOL(proc_dostring);
2614EXPORT_SYMBOL(proc_doulongvec_minmax);
2615EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);