blob: b0a1f99907f376f9a4dcd602c9044557bc3d0ea6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070026#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080027#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080028#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070030#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020032#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070033#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070034#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/init.h>
36#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010037#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030038#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/sysrq.h>
40#include <linux/highuid.h>
41#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020042#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070043#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070046#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/times.h>
48#include <linux/limits.h>
49#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020050#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070052#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080053#include <linux/nfs_fs.h>
54#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070055#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020056#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020057#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050058#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020059#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070060#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040061#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070062#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000063#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060064#include <linux/sched/sysctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#include <asm/uaccess.h>
67#include <asm/processor.h>
68
Andi Kleen29cbc782006-09-30 01:47:55 +020069#ifdef CONFIG_X86
70#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010071#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010072#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020073#endif
David Howellsd550bbd2012-03-28 18:30:03 +010074#ifdef CONFIG_SPARC
75#include <asm/setup.h>
76#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080077#ifdef CONFIG_BSD_PROCESS_ACCT
78#include <linux/acct.h>
79#endif
Dave Young4f0e0562010-03-10 15:24:09 -080080#ifdef CONFIG_RT_MUTEXES
81#include <linux/rtmutex.h>
82#endif
Dave Young2edf5e42010-03-10 15:24:10 -080083#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
84#include <linux/lockdep.h>
85#endif
Dave Young15485a42010-03-10 15:24:07 -080086#ifdef CONFIG_CHR_DEV_SG
87#include <scsi/sg.h>
88#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020089
Don Zickus58687ac2010-05-07 17:11:44 -040090#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050091#include <linux/nmi.h>
92#endif
93
Eric W. Biederman7058cb02007-10-18 03:05:58 -070094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#if defined(CONFIG_SYSCTL)
96
97/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern int sysctl_overcommit_memory;
99extern int sysctl_overcommit_ratio;
100extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200110extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100111extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400112extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000113#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages;
115#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200116#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200117extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200118#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400121#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700122static int sixty = 60;
123#endif
124
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700126static int __maybe_unused one = 1;
127static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700128static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800129static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700130static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700131#ifdef CONFIG_PRINTK
132static int ten_thousand = 10000;
133#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700134
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700135/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
136static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
139static int maxolduid = 65535;
140static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800141static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700144static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Dave Youngd14f1722010-02-25 20:28:57 -0500146#ifdef CONFIG_INOTIFY_USER
147#include <linux/inotify.h>
148#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700149#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#endif
151
David S. Miller08714202008-11-16 23:49:24 -0800152#ifdef CONFIG_SPARC64
153extern int sysctl_tsb_ratio;
154#endif
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#ifdef __hppa__
157extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530158#endif
159
160#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161extern int unaligned_enabled;
162#endif
163
Jes Sorensend2b176e2006-02-28 09:42:23 -0800164#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800165extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#endif
167
Vineet Guptab6fca722013-01-09 20:06:28 +0530168#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
169extern int no_unaligned_warning;
170#endif
171
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700172#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700173static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700174 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700175static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800176 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700177#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700178
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700179#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700180static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700181 void __user *buffer, size_t *lenp, loff_t *ppos);
182#endif
183
Kees Cook54b50192012-07-30 14:39:18 -0700184static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
185 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700186#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700187static int proc_dostring_coredump(struct ctl_table *table, int write,
188 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700189#endif
Kees Cook54b50192012-07-30 14:39:18 -0700190
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700191#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800192/* Note: sysrq code uses it's own private copy */
193static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700194
195static int sysrq_sysctl_handler(ctl_table *table, int write,
196 void __user *buffer, size_t *lenp,
197 loff_t *ppos)
198{
199 int error;
200
201 error = proc_dointvec(table, write, buffer, lenp, ppos);
202 if (error)
203 return error;
204
205 if (write)
206 sysrq_toggle_support(__sysrq_enabled);
207
208 return 0;
209}
210
211#endif
212
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700213static struct ctl_table kern_table[];
214static struct ctl_table vm_table[];
215static struct ctl_table fs_table[];
216static struct ctl_table debug_table[];
217static struct ctl_table dev_table[];
218extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800219#ifdef CONFIG_EPOLL
220extern struct ctl_table epoll_table[];
221#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
224int sysctl_legacy_va_layout;
225#endif
226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227/* The default sysctl tables: */
228
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800229static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 .procname = "kernel",
232 .mode = 0555,
233 .child = kern_table,
234 },
235 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 .procname = "vm",
237 .mode = 0555,
238 .child = vm_table,
239 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "fs",
242 .mode = 0555,
243 .child = fs_table,
244 },
245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "debug",
247 .mode = 0555,
248 .child = debug_table,
249 },
250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "dev",
252 .mode = 0555,
253 .child = dev_table,
254 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700255 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256};
257
Ingo Molnar77e54a12007-07-09 18:52:00 +0200258#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100259static int min_sched_granularity_ns = 100000; /* 100 usecs */
260static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
261static int min_wakeup_granularity_ns; /* 0 usecs */
262static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200263#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100264static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
265static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200266#endif /* CONFIG_SMP */
267#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200268
Mel Gorman5e771902010-05-24 14:32:31 -0700269#ifdef CONFIG_COMPACTION
270static int min_extfrag_threshold;
271static int max_extfrag_threshold = 1000;
272#endif
273
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700274static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200275 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200276 .procname = "sched_child_runs_first",
277 .data = &sysctl_sched_child_runs_first,
278 .maxlen = sizeof(unsigned int),
279 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800280 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200281 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200282#ifdef CONFIG_SCHED_DEBUG
283 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100284 .procname = "sched_min_granularity_ns",
285 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200286 .maxlen = sizeof(unsigned int),
287 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800288 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100289 .extra1 = &min_sched_granularity_ns,
290 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200291 },
292 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200293 .procname = "sched_latency_ns",
294 .data = &sysctl_sched_latency,
295 .maxlen = sizeof(unsigned int),
296 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800297 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200298 .extra1 = &min_sched_granularity_ns,
299 .extra2 = &max_sched_granularity_ns,
300 },
301 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200302 .procname = "sched_wakeup_granularity_ns",
303 .data = &sysctl_sched_wakeup_granularity,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800306 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200307 .extra1 = &min_wakeup_granularity_ns,
308 .extra2 = &max_wakeup_granularity_ns,
309 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200310#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200311 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100312 .procname = "sched_tunable_scaling",
313 .data = &sysctl_sched_tunable_scaling,
314 .maxlen = sizeof(enum sched_tunable_scaling),
315 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800316 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100317 .extra1 = &min_sched_tunable_scaling,
318 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200319 },
320 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900321 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200322 .data = &sysctl_sched_migration_cost,
323 .maxlen = sizeof(unsigned int),
324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800325 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200326 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100327 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100328 .procname = "sched_nr_migrate",
329 .data = &sysctl_sched_nr_migrate,
330 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800332 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100333 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530334 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900335 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200336 .data = &sysctl_sched_time_avg,
337 .maxlen = sizeof(unsigned int),
338 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800339 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200340 },
341 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900342 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800343 .data = &sysctl_sched_shares_window,
344 .maxlen = sizeof(unsigned int),
345 .mode = 0644,
346 .proc_handler = proc_dointvec,
347 },
348 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530349 .procname = "timer_migration",
350 .data = &sysctl_timer_migration,
351 .maxlen = sizeof(unsigned int),
352 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800353 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530354 .extra1 = &zero,
355 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530356 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200357#endif /* CONFIG_SMP */
358#ifdef CONFIG_NUMA_BALANCING
359 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200360 .procname = "numa_balancing_scan_delay_ms",
361 .data = &sysctl_numa_balancing_scan_delay,
362 .maxlen = sizeof(unsigned int),
363 .mode = 0644,
364 .proc_handler = proc_dointvec,
365 },
366 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200367 .procname = "numa_balancing_scan_period_min_ms",
368 .data = &sysctl_numa_balancing_scan_period_min,
369 .maxlen = sizeof(unsigned int),
370 .mode = 0644,
371 .proc_handler = proc_dointvec,
372 },
373 {
Mel Gormanb8593bf2012-11-21 01:18:23 +0000374 .procname = "numa_balancing_scan_period_reset",
375 .data = &sysctl_numa_balancing_scan_period_reset,
376 .maxlen = sizeof(unsigned int),
377 .mode = 0644,
378 .proc_handler = proc_dointvec,
379 },
380 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200381 .procname = "numa_balancing_scan_period_max_ms",
382 .data = &sysctl_numa_balancing_scan_period_max,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
385 .proc_handler = proc_dointvec,
386 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200387 {
388 .procname = "numa_balancing_scan_size_mb",
389 .data = &sysctl_numa_balancing_scan_size,
390 .maxlen = sizeof(unsigned int),
391 .mode = 0644,
392 .proc_handler = proc_dointvec,
393 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200394#endif /* CONFIG_NUMA_BALANCING */
395#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200396 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100397 .procname = "sched_rt_period_us",
398 .data = &sysctl_sched_rt_period,
399 .maxlen = sizeof(unsigned int),
400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100402 },
403 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100404 .procname = "sched_rt_runtime_us",
405 .data = &sysctl_sched_rt_runtime,
406 .maxlen = sizeof(int),
407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100409 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600410 {
411 .procname = "sched_rr_timeslice_ms",
412 .data = &sched_rr_timeslice,
413 .maxlen = sizeof(int),
414 .mode = 0644,
415 .proc_handler = sched_rr_handler,
416 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100417#ifdef CONFIG_SCHED_AUTOGROUP
418 {
419 .procname = "sched_autogroup_enabled",
420 .data = &sysctl_sched_autogroup_enabled,
421 .maxlen = sizeof(unsigned int),
422 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800423 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100424 .extra1 = &zero,
425 .extra2 = &one,
426 },
427#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700428#ifdef CONFIG_CFS_BANDWIDTH
429 {
430 .procname = "sched_cfs_bandwidth_slice_us",
431 .data = &sysctl_sched_cfs_bandwidth_slice,
432 .maxlen = sizeof(unsigned int),
433 .mode = 0644,
434 .proc_handler = proc_dointvec_minmax,
435 .extra1 = &one,
436 },
437#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700438#ifdef CONFIG_PROVE_LOCKING
439 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700440 .procname = "prove_locking",
441 .data = &prove_locking,
442 .maxlen = sizeof(int),
443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800444 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700445 },
446#endif
447#ifdef CONFIG_LOCK_STAT
448 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700449 .procname = "lock_stat",
450 .data = &lock_stat,
451 .maxlen = sizeof(int),
452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800453 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454 },
455#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .procname = "panic",
458 .data = &panic_timeout,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 },
Alex Kelly046d6622012-10-04 17:15:23 -0700463#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 .procname = "core_uses_pid",
466 .data = &core_uses_pid,
467 .maxlen = sizeof(int),
468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800469 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 },
471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "core_pattern",
473 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700474 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700476 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
Neil Hormana2939802009-09-23 15:56:56 -0700478 {
Neil Hormana2939802009-09-23 15:56:56 -0700479 .procname = "core_pipe_limit",
480 .data = &core_pipe_limit,
481 .maxlen = sizeof(unsigned int),
482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800483 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700484 },
Alex Kelly046d6622012-10-04 17:15:23 -0700485#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800486#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700489 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800493#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100494#ifdef CONFIG_LATENCYTOP
495 {
496 .procname = "latencytop",
497 .data = &latencytop_enabled,
498 .maxlen = sizeof(int),
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100501 },
502#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503#ifdef CONFIG_BLK_DEV_INITRD
504 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 .procname = "real-root-dev",
506 .data = &real_root_dev,
507 .maxlen = sizeof(int),
508 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800509 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 },
511#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700512 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700513 .procname = "print-fatal-signals",
514 .data = &print_fatal_signals,
515 .maxlen = sizeof(int),
516 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800517 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700518 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700519#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 .procname = "reboot-cmd",
522 .data = reboot_command,
523 .maxlen = 256,
524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 },
527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "stop-a",
529 .data = &stop_a_enabled,
530 .maxlen = sizeof (int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "scons-poweroff",
536 .data = &scons_pwroff,
537 .maxlen = sizeof (int),
538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 },
541#endif
David S. Miller08714202008-11-16 23:49:24 -0800542#ifdef CONFIG_SPARC64
543 {
David S. Miller08714202008-11-16 23:49:24 -0800544 .procname = "tsb-ratio",
545 .data = &sysctl_tsb_ratio,
546 .maxlen = sizeof (int),
547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800549 },
550#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551#ifdef __hppa__
552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "soft-power",
554 .data = &pwrsw_enabled,
555 .maxlen = sizeof (int),
556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530559#endif
560#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 .procname = "unaligned-trap",
563 .data = &unaligned_enabled,
564 .maxlen = sizeof (int),
565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800566 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 },
568#endif
569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "ctrl-alt-del",
571 .data = &C_A_D,
572 .maxlen = sizeof(int),
573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400576#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200577 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200578 .procname = "ftrace_enabled",
579 .data = &ftrace_enabled,
580 .maxlen = sizeof(int),
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200583 },
584#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500585#ifdef CONFIG_STACK_TRACER
586 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500587 .procname = "stack_tracer_enabled",
588 .data = &stack_tracer_enabled,
589 .maxlen = sizeof(int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500592 },
593#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400594#ifdef CONFIG_TRACING
595 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100596 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400597 .data = &ftrace_dump_on_oops,
598 .maxlen = sizeof(int),
599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800600 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400601 },
602#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200603#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 .procname = "modprobe",
606 .data = &modprobe_path,
607 .maxlen = KMOD_PATH_LEN,
608 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800609 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 },
Kees Cook3d433212009-04-02 15:49:29 -0700611 {
Kees Cook3d433212009-04-02 15:49:29 -0700612 .procname = "modules_disabled",
613 .data = &modules_disabled,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700618 .extra1 = &one,
619 .extra2 = &one,
620 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500622
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100625 .data = &uevent_helper,
626 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800628 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500630
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631#ifdef CONFIG_CHR_DEV_SG
632 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .procname = "sg-big-buff",
634 .data = &sg_big_buff,
635 .maxlen = sizeof (int),
636 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800637 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 },
639#endif
640#ifdef CONFIG_BSD_PROCESS_ACCT
641 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .procname = "acct",
643 .data = &acct_parm,
644 .maxlen = 3*sizeof(int),
645 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 },
648#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649#ifdef CONFIG_MAGIC_SYSRQ
650 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800652 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 .maxlen = sizeof (int),
654 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700655 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 },
657#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700658#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700661 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .maxlen = sizeof (int),
663 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800664 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700666#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 .procname = "threads-max",
669 .data = &max_threads,
670 .maxlen = sizeof(int),
671 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800672 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 },
674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "random",
676 .mode = 0555,
677 .child = random_table,
678 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 {
Eric Paris17f60a72011-04-01 17:07:50 -0400680 .procname = "usermodehelper",
681 .mode = 0555,
682 .child = usermodehelper_table,
683 },
684 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .procname = "overflowuid",
686 .data = &overflowuid,
687 .maxlen = sizeof(int),
688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .extra1 = &minolduid,
691 .extra2 = &maxolduid,
692 },
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "overflowgid",
695 .data = &overflowgid,
696 .maxlen = sizeof(int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .extra1 = &minolduid,
700 .extra2 = &maxolduid,
701 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800702#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703#ifdef CONFIG_MATHEMU
704 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 .procname = "ieee_emulation_warnings",
706 .data = &sysctl_ieee_emulation_warnings,
707 .maxlen = sizeof(int),
708 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800709 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 },
711#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200714 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 .maxlen = sizeof(int),
716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 },
719#endif
720 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .procname = "pid_max",
722 .data = &pid_max,
723 .maxlen = sizeof (int),
724 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800725 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 .extra1 = &pid_max_min,
727 .extra2 = &pid_max_max,
728 },
729 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 .procname = "panic_on_oops",
731 .data = &panic_on_oops,
732 .maxlen = sizeof(int),
733 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800734 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800736#if defined CONFIG_PRINTK
737 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800738 .procname = "printk",
739 .data = &console_loglevel,
740 .maxlen = 4*sizeof(int),
741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800743 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700746 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 .maxlen = sizeof(int),
748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 },
751 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700753 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .maxlen = sizeof(int),
755 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800756 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 },
Dave Youngaf913222009-09-22 16:43:33 -0700758 {
Dave Youngaf913222009-09-22 16:43:33 -0700759 .procname = "printk_delay",
760 .data = &printk_delay_msec,
761 .maxlen = sizeof(int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700764 .extra1 = &zero,
765 .extra2 = &ten_thousand,
766 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800768 .procname = "dmesg_restrict",
769 .data = &dmesg_restrict,
770 .maxlen = sizeof(int),
771 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700772 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800773 .extra1 = &zero,
774 .extra2 = &one,
775 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800776 {
777 .procname = "kptr_restrict",
778 .data = &kptr_restrict,
779 .maxlen = sizeof(int),
780 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700781 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800782 .extra1 = &zero,
783 .extra2 = &two,
784 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800785#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800786 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 .procname = "ngroups_max",
788 .data = &ngroups_max,
789 .maxlen = sizeof (int),
790 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 },
Dan Ballard73efc032011-10-31 17:11:20 -0700793 {
794 .procname = "cap_last_cap",
795 .data = (void *)&cap_last_cap,
796 .maxlen = sizeof(int),
797 .mode = 0444,
798 .proc_handler = proc_dointvec,
799 },
Don Zickus58687ac2010-05-07 17:11:44 -0400800#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500801 {
Don Zickus58687ac2010-05-07 17:11:44 -0400802 .procname = "watchdog",
803 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500804 .maxlen = sizeof (int),
805 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700806 .proc_handler = proc_dowatchdog,
807 .extra1 = &zero,
808 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400809 },
810 {
811 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700812 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400813 .maxlen = sizeof(int),
814 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700815 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800816 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400817 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500818 },
Don Zickus2508ce12010-05-07 17:11:46 -0400819 {
820 .procname = "softlockup_panic",
821 .data = &softlockup_panic,
822 .maxlen = sizeof(int),
823 .mode = 0644,
824 .proc_handler = proc_dointvec_minmax,
825 .extra1 = &zero,
826 .extra2 = &one,
827 },
Don Zickus5dc30552010-11-29 17:07:17 -0500828 {
829 .procname = "nmi_watchdog",
830 .data = &watchdog_enabled,
831 .maxlen = sizeof (int),
832 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700833 .proc_handler = proc_dowatchdog,
834 .extra1 = &zero,
835 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500836 },
837#endif
838#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
839 {
840 .procname = "unknown_nmi_panic",
841 .data = &unknown_nmi_panic,
842 .maxlen = sizeof (int),
843 .mode = 0644,
844 .proc_handler = proc_dointvec,
845 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500846#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847#if defined(CONFIG_X86)
848 {
Don Zickus8da5add2006-09-26 10:52:27 +0200849 .procname = "panic_on_unrecovered_nmi",
850 .data = &panic_on_unrecovered_nmi,
851 .maxlen = sizeof(int),
852 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800853 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200854 },
855 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700856 .procname = "panic_on_io_nmi",
857 .data = &panic_on_io_nmi,
858 .maxlen = sizeof(int),
859 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800860 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700861 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900862#ifdef CONFIG_DEBUG_STACKOVERFLOW
863 {
864 .procname = "panic_on_stackoverflow",
865 .data = &sysctl_panic_on_stackoverflow,
866 .maxlen = sizeof(int),
867 .mode = 0644,
868 .proc_handler = proc_dointvec,
869 },
870#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700871 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 .procname = "bootloader_type",
873 .data = &bootloader_type,
874 .maxlen = sizeof (int),
875 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800876 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100878 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700879 .procname = "bootloader_version",
880 .data = &bootloader_version,
881 .maxlen = sizeof (int),
882 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800883 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700884 },
885 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100886 .procname = "kstack_depth_to_print",
887 .data = &kstack_depth_to_print,
888 .maxlen = sizeof(int),
889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100891 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100892 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100893 .procname = "io_delay_type",
894 .data = &io_delay_type,
895 .maxlen = sizeof(int),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100898 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800900#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 .procname = "randomize_va_space",
903 .data = &randomize_va_space,
904 .maxlen = sizeof(int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800908#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800909#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700910 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700911 .procname = "spin_retry",
912 .data = &spin_retry,
913 .maxlen = sizeof (int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700916 },
917#endif
Len Brown673d5b42007-07-28 03:33:16 -0400918#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800919 {
Pavel Machekc255d842006-02-20 18:27:58 -0800920 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700921 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800922 .maxlen = sizeof (unsigned long),
923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800925 },
926#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530927#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800928 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800929 .procname = "ignore-unaligned-usertrap",
930 .data = &no_unaligned_warning,
931 .maxlen = sizeof (int),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800934 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530935#endif
936#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800937 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800938 .procname = "unaligned-dump-stack",
939 .data = &unaligned_dump_stack,
940 .maxlen = sizeof (int),
941 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800942 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800943 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800944#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800945#ifdef CONFIG_DETECT_HUNG_TASK
946 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800947 .procname = "hung_task_panic",
948 .data = &sysctl_hung_task_panic,
949 .maxlen = sizeof(int),
950 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800951 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800952 .extra1 = &zero,
953 .extra2 = &one,
954 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100955 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100956 .procname = "hung_task_check_count",
957 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100958 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100961 },
962 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100963 .procname = "hung_task_timeout_secs",
964 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100965 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100966 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800967 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100968 },
969 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100970 .procname = "hung_task_warnings",
971 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100972 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100973 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800974 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100975 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700976#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200977#ifdef CONFIG_COMPAT
978 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200979 .procname = "compat-log",
980 .data = &compat_log,
981 .maxlen = sizeof (int),
982 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200984 },
985#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700986#ifdef CONFIG_RT_MUTEXES
987 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700988 .procname = "max_lock_depth",
989 .data = &max_lock_depth,
990 .maxlen = sizeof(int),
991 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800992 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700993 },
994#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700995 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700996 .procname = "poweroff_cmd",
997 .data = &poweroff_cmd,
998 .maxlen = POWEROFF_CMD_PATH_LEN,
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001001 },
David Howells0b77f5b2008-04-29 01:01:32 -07001002#ifdef CONFIG_KEYS
1003 {
David Howells0b77f5b2008-04-29 01:01:32 -07001004 .procname = "keys",
1005 .mode = 0555,
1006 .child = key_sysctls,
1007 },
1008#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001009#ifdef CONFIG_RCU_TORTURE_TEST
1010 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001011 .procname = "rcutorture_runnable",
1012 .data = &rcutorture_runnable,
1013 .maxlen = sizeof(int),
1014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001016 },
1017#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001018#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001019 /*
1020 * User-space scripts rely on the existence of this file
1021 * as a feature check for perf_events being enabled.
1022 *
1023 * So it's an ABI, do not remove!
1024 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001025 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001026 .procname = "perf_event_paranoid",
1027 .data = &sysctl_perf_event_paranoid,
1028 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001029 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001030 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001031 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001032 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001033 .procname = "perf_event_mlock_kb",
1034 .data = &sysctl_perf_event_mlock,
1035 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001036 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001037 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001038 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001039 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001040 .procname = "perf_event_max_sample_rate",
1041 .data = &sysctl_perf_event_sample_rate,
1042 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001043 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001044 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001045 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001046#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001047#ifdef CONFIG_KMEMCHECK
1048 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001049 .procname = "kmemcheck",
1050 .data = &kmemcheck_enabled,
1051 .maxlen = sizeof(int),
1052 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001053 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001054 },
1055#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001056#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001057 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001058 .procname = "blk_iopoll",
1059 .data = &blk_iopoll_enabled,
1060 .maxlen = sizeof(int),
1061 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001062 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001063 },
Jens Axboecb684b52009-09-15 21:53:11 +02001064#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001065 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066};
1067
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001068static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 .procname = "overcommit_memory",
1071 .data = &sysctl_overcommit_memory,
1072 .maxlen = sizeof(sysctl_overcommit_memory),
1073 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001074 .proc_handler = proc_dointvec_minmax,
1075 .extra1 = &zero,
1076 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 },
1078 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001079 .procname = "panic_on_oom",
1080 .data = &sysctl_panic_on_oom,
1081 .maxlen = sizeof(sysctl_panic_on_oom),
1082 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001083 .proc_handler = proc_dointvec_minmax,
1084 .extra1 = &zero,
1085 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001086 },
1087 {
David Rientjesfe071d72007-10-16 23:25:56 -07001088 .procname = "oom_kill_allocating_task",
1089 .data = &sysctl_oom_kill_allocating_task,
1090 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1091 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001092 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001093 },
1094 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001095 .procname = "oom_dump_tasks",
1096 .data = &sysctl_oom_dump_tasks,
1097 .maxlen = sizeof(sysctl_oom_dump_tasks),
1098 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001100 },
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .procname = "overcommit_ratio",
1103 .data = &sysctl_overcommit_ratio,
1104 .maxlen = sizeof(sysctl_overcommit_ratio),
1105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 },
1108 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 .procname = "page-cluster",
1110 .data = &page_cluster,
1111 .maxlen = sizeof(int),
1112 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001113 .proc_handler = proc_dointvec_minmax,
1114 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 },
1116 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 .procname = "dirty_background_ratio",
1118 .data = &dirty_background_ratio,
1119 .maxlen = sizeof(dirty_background_ratio),
1120 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001121 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 .extra1 = &zero,
1123 .extra2 = &one_hundred,
1124 },
1125 {
David Rientjes2da02992009-01-06 14:39:31 -08001126 .procname = "dirty_background_bytes",
1127 .data = &dirty_background_bytes,
1128 .maxlen = sizeof(dirty_background_bytes),
1129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001131 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001132 },
1133 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 .procname = "dirty_ratio",
1135 .data = &vm_dirty_ratio,
1136 .maxlen = sizeof(vm_dirty_ratio),
1137 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001138 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 .extra1 = &zero,
1140 .extra2 = &one_hundred,
1141 },
1142 {
David Rientjes2da02992009-01-06 14:39:31 -08001143 .procname = "dirty_bytes",
1144 .data = &vm_dirty_bytes,
1145 .maxlen = sizeof(vm_dirty_bytes),
1146 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001147 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001148 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001149 },
1150 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001152 .data = &dirty_writeback_interval,
1153 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001155 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 },
1157 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001159 .data = &dirty_expire_interval,
1160 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001162 .proc_handler = proc_dointvec_minmax,
1163 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 },
1165 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001166 .procname = "nr_pdflush_threads",
1167 .mode = 0444 /* read-only */,
1168 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 },
1170 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 .procname = "swappiness",
1172 .data = &vm_swappiness,
1173 .maxlen = sizeof(vm_swappiness),
1174 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001175 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 .extra1 = &zero,
1177 .extra2 = &one_hundred,
1178 },
1179#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001180 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001182 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .maxlen = sizeof(unsigned long),
1184 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001185 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 .extra1 = (void *)&hugetlb_zero,
1187 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001188 },
1189#ifdef CONFIG_NUMA
1190 {
1191 .procname = "nr_hugepages_mempolicy",
1192 .data = NULL,
1193 .maxlen = sizeof(unsigned long),
1194 .mode = 0644,
1195 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1196 .extra1 = (void *)&hugetlb_zero,
1197 .extra2 = (void *)&hugetlb_infinity,
1198 },
1199#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 .procname = "hugetlb_shm_group",
1202 .data = &sysctl_hugetlb_shm_group,
1203 .maxlen = sizeof(gid_t),
1204 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001205 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 },
Mel Gorman396faf02007-07-17 04:03:13 -07001207 {
Mel Gorman396faf02007-07-17 04:03:13 -07001208 .procname = "hugepages_treat_as_movable",
1209 .data = &hugepages_treat_as_movable,
1210 .maxlen = sizeof(int),
1211 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001212 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001213 },
Adam Litke54f9f802007-10-16 01:26:20 -07001214 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001215 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001216 .data = NULL,
1217 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001218 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001219 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001220 .extra1 = (void *)&hugetlb_zero,
1221 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001222 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223#endif
1224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 .procname = "lowmem_reserve_ratio",
1226 .data = &sysctl_lowmem_reserve_ratio,
1227 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1228 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001229 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 },
1231 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001232 .procname = "drop_caches",
1233 .data = &sysctl_drop_caches,
1234 .maxlen = sizeof(int),
1235 .mode = 0644,
1236 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001237 .extra1 = &one,
1238 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001239 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001240#ifdef CONFIG_COMPACTION
1241 {
1242 .procname = "compact_memory",
1243 .data = &sysctl_compact_memory,
1244 .maxlen = sizeof(int),
1245 .mode = 0200,
1246 .proc_handler = sysctl_compaction_handler,
1247 },
Mel Gorman5e771902010-05-24 14:32:31 -07001248 {
1249 .procname = "extfrag_threshold",
1250 .data = &sysctl_extfrag_threshold,
1251 .maxlen = sizeof(int),
1252 .mode = 0644,
1253 .proc_handler = sysctl_extfrag_handler,
1254 .extra1 = &min_extfrag_threshold,
1255 .extra2 = &max_extfrag_threshold,
1256 },
1257
Mel Gorman76ab0f52010-05-24 14:32:28 -07001258#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 .procname = "min_free_kbytes",
1261 .data = &min_free_kbytes,
1262 .maxlen = sizeof(min_free_kbytes),
1263 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001264 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 .extra1 = &zero,
1266 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001267 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001268 .procname = "percpu_pagelist_fraction",
1269 .data = &percpu_pagelist_fraction,
1270 .maxlen = sizeof(percpu_pagelist_fraction),
1271 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001272 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001273 .extra1 = &min_percpu_pagelist_fract,
1274 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275#ifdef CONFIG_MMU
1276 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 .procname = "max_map_count",
1278 .data = &sysctl_max_map_count,
1279 .maxlen = sizeof(sysctl_max_map_count),
1280 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001281 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001282 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001284#else
1285 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001286 .procname = "nr_trim_pages",
1287 .data = &sysctl_nr_trim_pages,
1288 .maxlen = sizeof(sysctl_nr_trim_pages),
1289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001290 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001291 .extra1 = &zero,
1292 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293#endif
1294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .procname = "laptop_mode",
1296 .data = &laptop_mode,
1297 .maxlen = sizeof(laptop_mode),
1298 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001299 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 },
1301 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 .procname = "block_dump",
1303 .data = &block_dump,
1304 .maxlen = sizeof(block_dump),
1305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001306 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 .extra1 = &zero,
1308 },
1309 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 .procname = "vfs_cache_pressure",
1311 .data = &sysctl_vfs_cache_pressure,
1312 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1313 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001314 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 .extra1 = &zero,
1316 },
1317#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1318 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 .procname = "legacy_va_layout",
1320 .data = &sysctl_legacy_va_layout,
1321 .maxlen = sizeof(sysctl_legacy_va_layout),
1322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001323 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 .extra1 = &zero,
1325 },
1326#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001327#ifdef CONFIG_NUMA
1328 {
Christoph Lameter17436602006-01-18 17:42:32 -08001329 .procname = "zone_reclaim_mode",
1330 .data = &zone_reclaim_mode,
1331 .maxlen = sizeof(zone_reclaim_mode),
1332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001333 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001334 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001335 },
Christoph Lameter96146342006-07-03 00:24:13 -07001336 {
Christoph Lameter96146342006-07-03 00:24:13 -07001337 .procname = "min_unmapped_ratio",
1338 .data = &sysctl_min_unmapped_ratio,
1339 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001342 .extra1 = &zero,
1343 .extra2 = &one_hundred,
1344 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001345 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001346 .procname = "min_slab_ratio",
1347 .data = &sysctl_min_slab_ratio,
1348 .maxlen = sizeof(sysctl_min_slab_ratio),
1349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001350 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001351 .extra1 = &zero,
1352 .extra2 = &one_hundred,
1353 },
Christoph Lameter17436602006-01-18 17:42:32 -08001354#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001355#ifdef CONFIG_SMP
1356 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001357 .procname = "stat_interval",
1358 .data = &sysctl_stat_interval,
1359 .maxlen = sizeof(sysctl_stat_interval),
1360 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001361 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001362 },
1363#endif
David Howells6e141542009-12-15 19:27:45 +00001364#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001365 {
Eric Parised032182007-06-28 15:55:21 -04001366 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001367 .data = &dac_mmap_min_addr,
1368 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001371 },
David Howells6e141542009-12-15 19:27:45 +00001372#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001373#ifdef CONFIG_NUMA
1374 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001375 .procname = "numa_zonelist_order",
1376 .data = &numa_zonelist_order,
1377 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001380 },
1381#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001382#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001383 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001384 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001385 .procname = "vdso_enabled",
1386 .data = &vdso_enabled,
1387 .maxlen = sizeof(vdso_enabled),
1388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001389 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001390 .extra1 = &zero,
1391 },
1392#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001393#ifdef CONFIG_HIGHMEM
1394 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001395 .procname = "highmem_is_dirtyable",
1396 .data = &vm_highmem_is_dirtyable,
1397 .maxlen = sizeof(vm_highmem_is_dirtyable),
1398 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001399 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001400 .extra1 = &zero,
1401 .extra2 = &one,
1402 },
1403#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001404 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001405 .procname = "scan_unevictable_pages",
1406 .data = &scan_unevictable_pages,
1407 .maxlen = sizeof(scan_unevictable_pages),
1408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001409 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001410 },
Andi Kleen6a460792009-09-16 11:50:15 +02001411#ifdef CONFIG_MEMORY_FAILURE
1412 {
Andi Kleen6a460792009-09-16 11:50:15 +02001413 .procname = "memory_failure_early_kill",
1414 .data = &sysctl_memory_failure_early_kill,
1415 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001417 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001418 .extra1 = &zero,
1419 .extra2 = &one,
1420 },
1421 {
Andi Kleen6a460792009-09-16 11:50:15 +02001422 .procname = "memory_failure_recovery",
1423 .data = &sysctl_memory_failure_recovery,
1424 .maxlen = sizeof(sysctl_memory_failure_recovery),
1425 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001426 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001427 .extra1 = &zero,
1428 .extra2 = &one,
1429 },
1430#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001431 {
1432 .procname = "user_reserve_kbytes",
1433 .data = &sysctl_user_reserve_kbytes,
1434 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1435 .mode = 0644,
1436 .proc_handler = proc_doulongvec_minmax,
1437 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001438 {
1439 .procname = "admin_reserve_kbytes",
1440 .data = &sysctl_admin_reserve_kbytes,
1441 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1442 .mode = 0644,
1443 .proc_handler = proc_doulongvec_minmax,
1444 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001445 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446};
1447
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001448#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001449static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001450 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001451};
1452#endif
1453
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001454static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .procname = "inode-nr",
1457 .data = &inodes_stat,
1458 .maxlen = 2*sizeof(int),
1459 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001460 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 },
1462 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 .procname = "inode-state",
1464 .data = &inodes_stat,
1465 .maxlen = 7*sizeof(int),
1466 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001467 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 },
1469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 .procname = "file-nr",
1471 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001472 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 },
1476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "file-max",
1478 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001479 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001481 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 },
1483 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001484 .procname = "nr_open",
1485 .data = &sysctl_nr_open,
1486 .maxlen = sizeof(int),
1487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001488 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001489 .extra1 = &sysctl_nr_open_min,
1490 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001491 },
1492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 .procname = "dentry-state",
1494 .data = &dentry_stat,
1495 .maxlen = 6*sizeof(int),
1496 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001497 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 },
1499 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 .procname = "overflowuid",
1501 .data = &fs_overflowuid,
1502 .maxlen = sizeof(int),
1503 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001504 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 .extra1 = &minolduid,
1506 .extra2 = &maxolduid,
1507 },
1508 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 .procname = "overflowgid",
1510 .data = &fs_overflowgid,
1511 .maxlen = sizeof(int),
1512 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001513 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .extra1 = &minolduid,
1515 .extra2 = &maxolduid,
1516 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001517#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 .procname = "leases-enable",
1520 .data = &leases_enable,
1521 .maxlen = sizeof(int),
1522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001525#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526#ifdef CONFIG_DNOTIFY
1527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .procname = "dir-notify-enable",
1529 .data = &dir_notify_enable,
1530 .maxlen = sizeof(int),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 },
1534#endif
1535#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001536#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 .procname = "lease-break-time",
1539 .data = &lease_break_time,
1540 .maxlen = sizeof(int),
1541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001542 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001543 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001544#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001545#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 .procname = "aio-nr",
1548 .data = &aio_nr,
1549 .maxlen = sizeof(aio_nr),
1550 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001551 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 },
1553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 .procname = "aio-max-nr",
1555 .data = &aio_max_nr,
1556 .maxlen = sizeof(aio_max_nr),
1557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001558 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001560#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001561#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001562 {
Robert Love0399cb02005-07-13 12:38:18 -04001563 .procname = "inotify",
1564 .mode = 0555,
1565 .child = inotify_table,
1566 },
1567#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001568#ifdef CONFIG_EPOLL
1569 {
1570 .procname = "epoll",
1571 .mode = 0555,
1572 .child = epoll_table,
1573 },
1574#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001576 {
Kees Cook800179c2012-07-25 17:29:07 -07001577 .procname = "protected_symlinks",
1578 .data = &sysctl_protected_symlinks,
1579 .maxlen = sizeof(int),
1580 .mode = 0600,
1581 .proc_handler = proc_dointvec_minmax,
1582 .extra1 = &zero,
1583 .extra2 = &one,
1584 },
1585 {
1586 .procname = "protected_hardlinks",
1587 .data = &sysctl_protected_hardlinks,
1588 .maxlen = sizeof(int),
1589 .mode = 0600,
1590 .proc_handler = proc_dointvec_minmax,
1591 .extra1 = &zero,
1592 .extra2 = &one,
1593 },
1594 {
Alan Coxd6e71142005-06-23 00:09:43 -07001595 .procname = "suid_dumpable",
1596 .data = &suid_dumpable,
1597 .maxlen = sizeof(int),
1598 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001599 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001600 .extra1 = &zero,
1601 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001602 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001603#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1604 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001605 .procname = "binfmt_misc",
1606 .mode = 0555,
1607 .child = binfmt_misc_table,
1608 },
1609#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001610 {
Jens Axboeff9da692010-06-03 14:54:39 +02001611 .procname = "pipe-max-size",
1612 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001613 .maxlen = sizeof(int),
1614 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001615 .proc_handler = &pipe_proc_fn,
1616 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001617 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001618 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619};
1620
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001621static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001622#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001623 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001624 .procname = "exception-trace",
1625 .data = &show_unhandled_signals,
1626 .maxlen = sizeof(int),
1627 .mode = 0644,
1628 .proc_handler = proc_dointvec
1629 },
1630#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001631#if defined(CONFIG_OPTPROBES)
1632 {
1633 .procname = "kprobes-optimization",
1634 .data = &sysctl_kprobes_optimization,
1635 .maxlen = sizeof(int),
1636 .mode = 0644,
1637 .proc_handler = proc_kprobes_optimization_handler,
1638 .extra1 = &zero,
1639 .extra2 = &one,
1640 },
1641#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001642 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001643};
1644
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001645static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001646 { }
Robert Love0eeca282005-07-12 17:06:03 -04001647};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001649int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001650{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001651 struct ctl_table_header *hdr;
1652
1653 hdr = register_sysctl_table(sysctl_base_table);
1654 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001655 return 0;
1656}
1657
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001658#endif /* CONFIG_SYSCTL */
1659
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660/*
1661 * /proc/sys support
1662 */
1663
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001664#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001666static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001667 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001668 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001669{
1670 size_t len;
1671 char __user *p;
1672 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001673
1674 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001675 *lenp = 0;
1676 return 0;
1677 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001678
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001679 if (write) {
1680 len = 0;
1681 p = buffer;
1682 while (len < *lenp) {
1683 if (get_user(c, p++))
1684 return -EFAULT;
1685 if (c == 0 || c == '\n')
1686 break;
1687 len++;
1688 }
1689 if (len >= maxlen)
1690 len = maxlen-1;
1691 if(copy_from_user(data, buffer, len))
1692 return -EFAULT;
1693 ((char *) data)[len] = 0;
1694 *ppos += *lenp;
1695 } else {
1696 len = strlen(data);
1697 if (len > maxlen)
1698 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001699
1700 if (*ppos > len) {
1701 *lenp = 0;
1702 return 0;
1703 }
1704
1705 data += *ppos;
1706 len -= *ppos;
1707
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001708 if (len > *lenp)
1709 len = *lenp;
1710 if (len)
1711 if(copy_to_user(buffer, data, len))
1712 return -EFAULT;
1713 if (len < *lenp) {
1714 if(put_user('\n', ((char __user *) buffer) + len))
1715 return -EFAULT;
1716 len++;
1717 }
1718 *lenp = len;
1719 *ppos += len;
1720 }
1721 return 0;
1722}
1723
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724/**
1725 * proc_dostring - read a string sysctl
1726 * @table: the sysctl table
1727 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 * @buffer: the user buffer
1729 * @lenp: the size of the user buffer
1730 * @ppos: file position
1731 *
1732 * Reads/writes a string from/to the user buffer. If the kernel
1733 * buffer provided is not large enough to hold the string, the
1734 * string is truncated. The copied string is %NULL-terminated.
1735 * If the string is being read by the user process, it is copied
1736 * and a newline '\n' is added. It is truncated if the buffer is
1737 * not large enough.
1738 *
1739 * Returns 0 on success.
1740 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001741int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742 void __user *buffer, size_t *lenp, loff_t *ppos)
1743{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001744 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001745 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746}
1747
Amerigo Wang00b7c332010-05-05 00:26:45 +00001748static size_t proc_skip_spaces(char **buf)
1749{
1750 size_t ret;
1751 char *tmp = skip_spaces(*buf);
1752 ret = tmp - *buf;
1753 *buf = tmp;
1754 return ret;
1755}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001757static void proc_skip_char(char **buf, size_t *size, const char v)
1758{
1759 while (*size) {
1760 if (**buf != v)
1761 break;
1762 (*size)--;
1763 (*buf)++;
1764 }
1765}
1766
Amerigo Wang00b7c332010-05-05 00:26:45 +00001767#define TMPBUFLEN 22
1768/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001769 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001770 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001771 * @buf: a kernel buffer
1772 * @size: size of the kernel buffer
1773 * @val: this is where the number will be stored
1774 * @neg: set to %TRUE if number is negative
1775 * @perm_tr: a vector which contains the allowed trailers
1776 * @perm_tr_len: size of the perm_tr vector
1777 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001778 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001779 * In case of success %0 is returned and @buf and @size are updated with
1780 * the amount of bytes read. If @tr is non-NULL and a trailing
1781 * character exists (size is non-zero after returning from this
1782 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001783 */
1784static int proc_get_long(char **buf, size_t *size,
1785 unsigned long *val, bool *neg,
1786 const char *perm_tr, unsigned perm_tr_len, char *tr)
1787{
1788 int len;
1789 char *p, tmp[TMPBUFLEN];
1790
1791 if (!*size)
1792 return -EINVAL;
1793
1794 len = *size;
1795 if (len > TMPBUFLEN - 1)
1796 len = TMPBUFLEN - 1;
1797
1798 memcpy(tmp, *buf, len);
1799
1800 tmp[len] = 0;
1801 p = tmp;
1802 if (*p == '-' && *size > 1) {
1803 *neg = true;
1804 p++;
1805 } else
1806 *neg = false;
1807 if (!isdigit(*p))
1808 return -EINVAL;
1809
1810 *val = simple_strtoul(p, &p, 0);
1811
1812 len = p - tmp;
1813
1814 /* We don't know if the next char is whitespace thus we may accept
1815 * invalid integers (e.g. 1234...a) or two integers instead of one
1816 * (e.g. 123...1). So lets not allow such large numbers. */
1817 if (len == TMPBUFLEN - 1)
1818 return -EINVAL;
1819
1820 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1821 return -EINVAL;
1822
1823 if (tr && (len < *size))
1824 *tr = *p;
1825
1826 *buf += len;
1827 *size -= len;
1828
1829 return 0;
1830}
1831
1832/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001833 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001834 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001835 * @buf: the user buffer
1836 * @size: the size of the user buffer
1837 * @val: the integer to be converted
1838 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001839 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001840 * In case of success %0 is returned and @buf and @size are updated with
1841 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001842 */
1843static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1844 bool neg)
1845{
1846 int len;
1847 char tmp[TMPBUFLEN], *p = tmp;
1848
1849 sprintf(p, "%s%lu", neg ? "-" : "", val);
1850 len = strlen(tmp);
1851 if (len > *size)
1852 len = *size;
1853 if (copy_to_user(*buf, tmp, len))
1854 return -EFAULT;
1855 *size -= len;
1856 *buf += len;
1857 return 0;
1858}
1859#undef TMPBUFLEN
1860
1861static int proc_put_char(void __user **buf, size_t *size, char c)
1862{
1863 if (*size) {
1864 char __user **buffer = (char __user **)buf;
1865 if (put_user(c, *buffer))
1866 return -EFAULT;
1867 (*size)--, (*buffer)++;
1868 *buf = *buffer;
1869 }
1870 return 0;
1871}
1872
1873static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 int *valp,
1875 int write, void *data)
1876{
1877 if (write) {
1878 *valp = *negp ? -*lvalp : *lvalp;
1879 } else {
1880 int val = *valp;
1881 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001882 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883 *lvalp = (unsigned long)-val;
1884 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001885 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 *lvalp = (unsigned long)val;
1887 }
1888 }
1889 return 0;
1890}
1891
Amerigo Wang00b7c332010-05-05 00:26:45 +00001892static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1893
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001894static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001895 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001896 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001897 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898 int write, void *data),
1899 void *data)
1900{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001901 int *i, vleft, first = 1, err = 0;
1902 unsigned long page = 0;
1903 size_t left;
1904 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001905
Amerigo Wang00b7c332010-05-05 00:26:45 +00001906 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 *lenp = 0;
1908 return 0;
1909 }
1910
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001911 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912 vleft = table->maxlen / sizeof(*i);
1913 left = *lenp;
1914
1915 if (!conv)
1916 conv = do_proc_dointvec_conv;
1917
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001919 if (left > PAGE_SIZE - 1)
1920 left = PAGE_SIZE - 1;
1921 page = __get_free_page(GFP_TEMPORARY);
1922 kbuf = (char *) page;
1923 if (!kbuf)
1924 return -ENOMEM;
1925 if (copy_from_user(kbuf, buffer, left)) {
1926 err = -EFAULT;
1927 goto free;
1928 }
1929 kbuf[left] = 0;
1930 }
1931
1932 for (; left && vleft--; i++, first=0) {
1933 unsigned long lval;
1934 bool neg;
1935
1936 if (write) {
1937 left -= proc_skip_spaces(&kbuf);
1938
J. R. Okajima563b0462010-05-25 16:10:14 -07001939 if (!left)
1940 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001941 err = proc_get_long(&kbuf, &left, &lval, &neg,
1942 proc_wspace_sep,
1943 sizeof(proc_wspace_sep), NULL);
1944 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001945 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001946 if (conv(&neg, &lval, i, 1, data)) {
1947 err = -EINVAL;
1948 break;
1949 }
1950 } else {
1951 if (conv(&neg, &lval, i, 0, data)) {
1952 err = -EINVAL;
1953 break;
1954 }
1955 if (!first)
1956 err = proc_put_char(&buffer, &left, '\t');
1957 if (err)
1958 break;
1959 err = proc_put_long(&buffer, &left, lval, neg);
1960 if (err)
1961 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962 }
1963 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001964
1965 if (!write && !first && left && !err)
1966 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001967 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001968 left -= proc_skip_spaces(&kbuf);
1969free:
1970 if (write) {
1971 free_page(page);
1972 if (first)
1973 return err ? : -EINVAL;
1974 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975 *lenp -= left;
1976 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001977 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001978}
1979
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001980static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001981 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001982 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001983 int write, void *data),
1984 void *data)
1985{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001986 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001987 buffer, lenp, ppos, conv, data);
1988}
1989
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990/**
1991 * proc_dointvec - read a vector of integers
1992 * @table: the sysctl table
1993 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994 * @buffer: the user buffer
1995 * @lenp: the size of the user buffer
1996 * @ppos: file position
1997 *
1998 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1999 * values from/to the user buffer, treated as an ASCII string.
2000 *
2001 * Returns 0 on success.
2002 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002003int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 void __user *buffer, size_t *lenp, loff_t *ppos)
2005{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002006 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 NULL,NULL);
2008}
2009
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002010/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002011 * Taint values can only be increased
2012 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002013 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002014static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002015 void __user *buffer, size_t *lenp, loff_t *ppos)
2016{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002017 struct ctl_table t;
2018 unsigned long tmptaint = get_taint();
2019 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002020
Bastian Blank91fcd412007-04-23 14:41:14 -07002021 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002022 return -EPERM;
2023
Andi Kleen25ddbb12008-10-15 22:01:41 -07002024 t = *table;
2025 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002026 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002027 if (err < 0)
2028 return err;
2029
2030 if (write) {
2031 /*
2032 * Poor man's atomic or. Not worth adding a primitive
2033 * to everyone's atomic.h for this
2034 */
2035 int i;
2036 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2037 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302038 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002039 }
2040 }
2041
2042 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002043}
2044
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002045#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002046static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002047 void __user *buffer, size_t *lenp, loff_t *ppos)
2048{
2049 if (write && !capable(CAP_SYS_ADMIN))
2050 return -EPERM;
2051
2052 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2053}
2054#endif
2055
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056struct do_proc_dointvec_minmax_conv_param {
2057 int *min;
2058 int *max;
2059};
2060
Amerigo Wang00b7c332010-05-05 00:26:45 +00002061static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2062 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002063 int write, void *data)
2064{
2065 struct do_proc_dointvec_minmax_conv_param *param = data;
2066 if (write) {
2067 int val = *negp ? -*lvalp : *lvalp;
2068 if ((param->min && *param->min > val) ||
2069 (param->max && *param->max < val))
2070 return -EINVAL;
2071 *valp = val;
2072 } else {
2073 int val = *valp;
2074 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002075 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076 *lvalp = (unsigned long)-val;
2077 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002078 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 *lvalp = (unsigned long)val;
2080 }
2081 }
2082 return 0;
2083}
2084
2085/**
2086 * proc_dointvec_minmax - read a vector of integers with min/max values
2087 * @table: the sysctl table
2088 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 * @buffer: the user buffer
2090 * @lenp: the size of the user buffer
2091 * @ppos: file position
2092 *
2093 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2094 * values from/to the user buffer, treated as an ASCII string.
2095 *
2096 * This routine will ensure the values are within the range specified by
2097 * table->extra1 (min) and table->extra2 (max).
2098 *
2099 * Returns 0 on success.
2100 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002101int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102 void __user *buffer, size_t *lenp, loff_t *ppos)
2103{
2104 struct do_proc_dointvec_minmax_conv_param param = {
2105 .min = (int *) table->extra1,
2106 .max = (int *) table->extra2,
2107 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002108 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109 do_proc_dointvec_minmax_conv, &param);
2110}
2111
Kees Cook54b50192012-07-30 14:39:18 -07002112static void validate_coredump_safety(void)
2113{
Alex Kelly046d6622012-10-04 17:15:23 -07002114#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002115 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002116 core_pattern[0] != '/' && core_pattern[0] != '|') {
2117 printk(KERN_WARNING "Unsafe core_pattern used with "\
2118 "suid_dumpable=2. Pipe handler or fully qualified "\
2119 "core dump path required.\n");
2120 }
Alex Kelly046d6622012-10-04 17:15:23 -07002121#endif
Kees Cook54b50192012-07-30 14:39:18 -07002122}
2123
2124static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2125 void __user *buffer, size_t *lenp, loff_t *ppos)
2126{
2127 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2128 if (!error)
2129 validate_coredump_safety();
2130 return error;
2131}
2132
Alex Kelly046d6622012-10-04 17:15:23 -07002133#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002134static int proc_dostring_coredump(struct ctl_table *table, int write,
2135 void __user *buffer, size_t *lenp, loff_t *ppos)
2136{
2137 int error = proc_dostring(table, write, buffer, lenp, ppos);
2138 if (!error)
2139 validate_coredump_safety();
2140 return error;
2141}
Alex Kelly046d6622012-10-04 17:15:23 -07002142#endif
Kees Cook54b50192012-07-30 14:39:18 -07002143
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002144static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145 void __user *buffer,
2146 size_t *lenp, loff_t *ppos,
2147 unsigned long convmul,
2148 unsigned long convdiv)
2149{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002150 unsigned long *i, *min, *max;
2151 int vleft, first = 1, err = 0;
2152 unsigned long page = 0;
2153 size_t left;
2154 char *kbuf;
2155
2156 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 *lenp = 0;
2158 return 0;
2159 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002160
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002161 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002162 min = (unsigned long *) table->extra1;
2163 max = (unsigned long *) table->extra2;
2164 vleft = table->maxlen / sizeof(unsigned long);
2165 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002166
2167 if (write) {
2168 if (left > PAGE_SIZE - 1)
2169 left = PAGE_SIZE - 1;
2170 page = __get_free_page(GFP_TEMPORARY);
2171 kbuf = (char *) page;
2172 if (!kbuf)
2173 return -ENOMEM;
2174 if (copy_from_user(kbuf, buffer, left)) {
2175 err = -EFAULT;
2176 goto free;
2177 }
2178 kbuf[left] = 0;
2179 }
2180
Eric Dumazet27b3d802010-10-07 12:59:29 -07002181 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002182 unsigned long val;
2183
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 bool neg;
2186
2187 left -= proc_skip_spaces(&kbuf);
2188
2189 err = proc_get_long(&kbuf, &left, &val, &neg,
2190 proc_wspace_sep,
2191 sizeof(proc_wspace_sep), NULL);
2192 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193 break;
2194 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 continue;
2196 if ((min && val < *min) || (max && val > *max))
2197 continue;
2198 *i = val;
2199 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002200 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002202 err = proc_put_char(&buffer, &left, '\t');
2203 err = proc_put_long(&buffer, &left, val, false);
2204 if (err)
2205 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 }
2207 }
2208
Amerigo Wang00b7c332010-05-05 00:26:45 +00002209 if (!write && !first && left && !err)
2210 err = proc_put_char(&buffer, &left, '\n');
2211 if (write && !err)
2212 left -= proc_skip_spaces(&kbuf);
2213free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002215 free_page(page);
2216 if (first)
2217 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 *lenp -= left;
2220 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002221 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222}
2223
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002224static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002225 void __user *buffer,
2226 size_t *lenp, loff_t *ppos,
2227 unsigned long convmul,
2228 unsigned long convdiv)
2229{
2230 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002231 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002232}
2233
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234/**
2235 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2236 * @table: the sysctl table
2237 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 * @buffer: the user buffer
2239 * @lenp: the size of the user buffer
2240 * @ppos: file position
2241 *
2242 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2243 * values from/to the user buffer, treated as an ASCII string.
2244 *
2245 * This routine will ensure the values are within the range specified by
2246 * table->extra1 (min) and table->extra2 (max).
2247 *
2248 * Returns 0 on success.
2249 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002250int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 void __user *buffer, size_t *lenp, loff_t *ppos)
2252{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002253 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254}
2255
2256/**
2257 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2258 * @table: the sysctl table
2259 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 * @buffer: the user buffer
2261 * @lenp: the size of the user buffer
2262 * @ppos: file position
2263 *
2264 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2265 * values from/to the user buffer, treated as an ASCII string. The values
2266 * are treated as milliseconds, and converted to jiffies when they are stored.
2267 *
2268 * This routine will ensure the values are within the range specified by
2269 * table->extra1 (min) and table->extra2 (max).
2270 *
2271 * Returns 0 on success.
2272 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002273int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 void __user *buffer,
2275 size_t *lenp, loff_t *ppos)
2276{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002277 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 lenp, ppos, HZ, 1000l);
2279}
2280
2281
Amerigo Wang00b7c332010-05-05 00:26:45 +00002282static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 int *valp,
2284 int write, void *data)
2285{
2286 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002287 if (*lvalp > LONG_MAX / HZ)
2288 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2290 } else {
2291 int val = *valp;
2292 unsigned long lval;
2293 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002294 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 lval = (unsigned long)-val;
2296 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002297 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 lval = (unsigned long)val;
2299 }
2300 *lvalp = lval / HZ;
2301 }
2302 return 0;
2303}
2304
Amerigo Wang00b7c332010-05-05 00:26:45 +00002305static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 int *valp,
2307 int write, void *data)
2308{
2309 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002310 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2311 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2313 } else {
2314 int val = *valp;
2315 unsigned long lval;
2316 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002317 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 lval = (unsigned long)-val;
2319 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002320 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 lval = (unsigned long)val;
2322 }
2323 *lvalp = jiffies_to_clock_t(lval);
2324 }
2325 return 0;
2326}
2327
Amerigo Wang00b7c332010-05-05 00:26:45 +00002328static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 int *valp,
2330 int write, void *data)
2331{
2332 if (write) {
2333 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2334 } else {
2335 int val = *valp;
2336 unsigned long lval;
2337 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002338 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 lval = (unsigned long)-val;
2340 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002341 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 lval = (unsigned long)val;
2343 }
2344 *lvalp = jiffies_to_msecs(lval);
2345 }
2346 return 0;
2347}
2348
2349/**
2350 * proc_dointvec_jiffies - read a vector of integers as seconds
2351 * @table: the sysctl table
2352 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 * @buffer: the user buffer
2354 * @lenp: the size of the user buffer
2355 * @ppos: file position
2356 *
2357 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2358 * values from/to the user buffer, treated as an ASCII string.
2359 * The values read are assumed to be in seconds, and are converted into
2360 * jiffies.
2361 *
2362 * Returns 0 on success.
2363 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002364int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365 void __user *buffer, size_t *lenp, loff_t *ppos)
2366{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002367 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368 do_proc_dointvec_jiffies_conv,NULL);
2369}
2370
2371/**
2372 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2373 * @table: the sysctl table
2374 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375 * @buffer: the user buffer
2376 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002377 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 *
2379 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2380 * values from/to the user buffer, treated as an ASCII string.
2381 * The values read are assumed to be in 1/USER_HZ seconds, and
2382 * are converted into jiffies.
2383 *
2384 * Returns 0 on success.
2385 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002386int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002387 void __user *buffer, size_t *lenp, loff_t *ppos)
2388{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002389 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 do_proc_dointvec_userhz_jiffies_conv,NULL);
2391}
2392
2393/**
2394 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2395 * @table: the sysctl table
2396 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 * @buffer: the user buffer
2398 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002399 * @ppos: file position
2400 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 *
2402 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2403 * values from/to the user buffer, treated as an ASCII string.
2404 * The values read are assumed to be in 1/1000 seconds, and
2405 * are converted into jiffies.
2406 *
2407 * Returns 0 on success.
2408 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002409int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410 void __user *buffer, size_t *lenp, loff_t *ppos)
2411{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002412 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 do_proc_dointvec_ms_jiffies_conv, NULL);
2414}
2415
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002416static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002417 void __user *buffer, size_t *lenp, loff_t *ppos)
2418{
2419 struct pid *new_pid;
2420 pid_t tmp;
2421 int r;
2422
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002423 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002424
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002425 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002426 lenp, ppos, NULL, NULL);
2427 if (r || !write)
2428 return r;
2429
2430 new_pid = find_get_pid(tmp);
2431 if (!new_pid)
2432 return -ESRCH;
2433
2434 put_pid(xchg(&cad_pid, new_pid));
2435 return 0;
2436}
2437
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002438/**
2439 * proc_do_large_bitmap - read/write from/to a large bitmap
2440 * @table: the sysctl table
2441 * @write: %TRUE if this is a write to the sysctl file
2442 * @buffer: the user buffer
2443 * @lenp: the size of the user buffer
2444 * @ppos: file position
2445 *
2446 * The bitmap is stored at table->data and the bitmap length (in bits)
2447 * in table->maxlen.
2448 *
2449 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2450 * large bitmaps may be represented in a compact manner. Writing into
2451 * the file will clear the bitmap then update it with the given input.
2452 *
2453 * Returns 0 on success.
2454 */
2455int proc_do_large_bitmap(struct ctl_table *table, int write,
2456 void __user *buffer, size_t *lenp, loff_t *ppos)
2457{
2458 int err = 0;
2459 bool first = 1;
2460 size_t left = *lenp;
2461 unsigned long bitmap_len = table->maxlen;
2462 unsigned long *bitmap = (unsigned long *) table->data;
2463 unsigned long *tmp_bitmap = NULL;
2464 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2465
2466 if (!bitmap_len || !left || (*ppos && !write)) {
2467 *lenp = 0;
2468 return 0;
2469 }
2470
2471 if (write) {
2472 unsigned long page = 0;
2473 char *kbuf;
2474
2475 if (left > PAGE_SIZE - 1)
2476 left = PAGE_SIZE - 1;
2477
2478 page = __get_free_page(GFP_TEMPORARY);
2479 kbuf = (char *) page;
2480 if (!kbuf)
2481 return -ENOMEM;
2482 if (copy_from_user(kbuf, buffer, left)) {
2483 free_page(page);
2484 return -EFAULT;
2485 }
2486 kbuf[left] = 0;
2487
2488 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2489 GFP_KERNEL);
2490 if (!tmp_bitmap) {
2491 free_page(page);
2492 return -ENOMEM;
2493 }
2494 proc_skip_char(&kbuf, &left, '\n');
2495 while (!err && left) {
2496 unsigned long val_a, val_b;
2497 bool neg;
2498
2499 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2500 sizeof(tr_a), &c);
2501 if (err)
2502 break;
2503 if (val_a >= bitmap_len || neg) {
2504 err = -EINVAL;
2505 break;
2506 }
2507
2508 val_b = val_a;
2509 if (left) {
2510 kbuf++;
2511 left--;
2512 }
2513
2514 if (c == '-') {
2515 err = proc_get_long(&kbuf, &left, &val_b,
2516 &neg, tr_b, sizeof(tr_b),
2517 &c);
2518 if (err)
2519 break;
2520 if (val_b >= bitmap_len || neg ||
2521 val_a > val_b) {
2522 err = -EINVAL;
2523 break;
2524 }
2525 if (left) {
2526 kbuf++;
2527 left--;
2528 }
2529 }
2530
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002531 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002532 first = 0;
2533 proc_skip_char(&kbuf, &left, '\n');
2534 }
2535 free_page(page);
2536 } else {
2537 unsigned long bit_a, bit_b = 0;
2538
2539 while (left) {
2540 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2541 if (bit_a >= bitmap_len)
2542 break;
2543 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2544 bit_a + 1) - 1;
2545
2546 if (!first) {
2547 err = proc_put_char(&buffer, &left, ',');
2548 if (err)
2549 break;
2550 }
2551 err = proc_put_long(&buffer, &left, bit_a, false);
2552 if (err)
2553 break;
2554 if (bit_a != bit_b) {
2555 err = proc_put_char(&buffer, &left, '-');
2556 if (err)
2557 break;
2558 err = proc_put_long(&buffer, &left, bit_b, false);
2559 if (err)
2560 break;
2561 }
2562
2563 first = 0; bit_b++;
2564 }
2565 if (!err)
2566 err = proc_put_char(&buffer, &left, '\n');
2567 }
2568
2569 if (!err) {
2570 if (write) {
2571 if (*ppos)
2572 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2573 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002574 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002575 }
2576 kfree(tmp_bitmap);
2577 *lenp -= left;
2578 *ppos += *lenp;
2579 return 0;
2580 } else {
2581 kfree(tmp_bitmap);
2582 return err;
2583 }
2584}
2585
Jovi Zhang55610502011-01-12 17:00:45 -08002586#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002588int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589 void __user *buffer, size_t *lenp, loff_t *ppos)
2590{
2591 return -ENOSYS;
2592}
2593
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002594int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 void __user *buffer, size_t *lenp, loff_t *ppos)
2596{
2597 return -ENOSYS;
2598}
2599
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002600int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 void __user *buffer, size_t *lenp, loff_t *ppos)
2602{
2603 return -ENOSYS;
2604}
2605
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002606int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 void __user *buffer, size_t *lenp, loff_t *ppos)
2608{
2609 return -ENOSYS;
2610}
2611
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002612int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 void __user *buffer, size_t *lenp, loff_t *ppos)
2614{
2615 return -ENOSYS;
2616}
2617
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002618int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 void __user *buffer, size_t *lenp, loff_t *ppos)
2620{
2621 return -ENOSYS;
2622}
2623
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002624int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 void __user *buffer, size_t *lenp, loff_t *ppos)
2626{
2627 return -ENOSYS;
2628}
2629
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002630int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 void __user *buffer,
2632 size_t *lenp, loff_t *ppos)
2633{
2634 return -ENOSYS;
2635}
2636
2637
Jovi Zhang55610502011-01-12 17:00:45 -08002638#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640/*
2641 * No sense putting this after each symbol definition, twice,
2642 * exception granted :-)
2643 */
2644EXPORT_SYMBOL(proc_dointvec);
2645EXPORT_SYMBOL(proc_dointvec_jiffies);
2646EXPORT_SYMBOL(proc_dointvec_minmax);
2647EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2648EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2649EXPORT_SYMBOL(proc_dostring);
2650EXPORT_SYMBOL(proc_doulongvec_minmax);
2651EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);