blob: c8da99f905cf522a34dd7ff059bde584e4d8c90a [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 */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100193static int __sysrq_enabled = CONFIG_MAGIC_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 {
374 .procname = "numa_balancing_scan_period_max_ms",
375 .data = &sysctl_numa_balancing_scan_period_max,
376 .maxlen = sizeof(unsigned int),
377 .mode = 0644,
378 .proc_handler = proc_dointvec,
379 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200380 {
381 .procname = "numa_balancing_scan_size_mb",
382 .data = &sysctl_numa_balancing_scan_size,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
385 .proc_handler = proc_dointvec,
386 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100387 {
Rik van Rielde1c9ce62013-10-07 11:29:39 +0100388 .procname = "numa_balancing_migrate_deferred",
389 .data = &sysctl_numa_balancing_migrate_deferred,
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 Rostedtf38f1d2a2008-12-16 23:06:40 -0500585#ifdef CONFIG_STACK_TRACER
586 {
Steven Rostedtf38f1d2a2008-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 Rostedtf38f1d2a2008-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 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400602 {
603 .procname = "traceoff_on_warning",
604 .data = &__disable_trace_on_warning,
605 .maxlen = sizeof(__disable_trace_on_warning),
606 .mode = 0644,
607 .proc_handler = proc_dointvec,
608 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400609#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200610#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 .procname = "modprobe",
613 .data = &modprobe_path,
614 .maxlen = KMOD_PATH_LEN,
615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 },
Kees Cook3d433212009-04-02 15:49:29 -0700618 {
Kees Cook3d433212009-04-02 15:49:29 -0700619 .procname = "modules_disabled",
620 .data = &modules_disabled,
621 .maxlen = sizeof(int),
622 .mode = 0644,
623 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800624 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700625 .extra1 = &one,
626 .extra2 = &one,
627 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628#endif
Bill Pemberton3b572b52012-11-19 13:19:29 -0500629
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100632 .data = &uevent_helper,
633 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800635 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 },
Bill Pemberton3b572b52012-11-19 13:19:29 -0500637
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638#ifdef CONFIG_CHR_DEV_SG
639 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .procname = "sg-big-buff",
641 .data = &sg_big_buff,
642 .maxlen = sizeof (int),
643 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800644 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 },
646#endif
647#ifdef CONFIG_BSD_PROCESS_ACCT
648 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 .procname = "acct",
650 .data = &acct_parm,
651 .maxlen = 3*sizeof(int),
652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 },
655#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656#ifdef CONFIG_MAGIC_SYSRQ
657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800659 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .maxlen = sizeof (int),
661 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700662 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 },
664#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700665#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700668 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .maxlen = sizeof (int),
670 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800671 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700673#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "threads-max",
676 .data = &max_threads,
677 .maxlen = sizeof(int),
678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800679 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 },
681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "random",
683 .mode = 0555,
684 .child = random_table,
685 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 {
Eric Paris17f60a72011-04-01 17:07:50 -0400687 .procname = "usermodehelper",
688 .mode = 0555,
689 .child = usermodehelper_table,
690 },
691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .procname = "overflowuid",
693 .data = &overflowuid,
694 .maxlen = sizeof(int),
695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800696 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .extra1 = &minolduid,
698 .extra2 = &maxolduid,
699 },
700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "overflowgid",
702 .data = &overflowgid,
703 .maxlen = sizeof(int),
704 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800705 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .extra1 = &minolduid,
707 .extra2 = &maxolduid,
708 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800709#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710#ifdef CONFIG_MATHEMU
711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "ieee_emulation_warnings",
713 .data = &sysctl_ieee_emulation_warnings,
714 .maxlen = sizeof(int),
715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
718#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200721 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .maxlen = sizeof(int),
723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800724 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 },
726#endif
727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .procname = "pid_max",
729 .data = &pid_max,
730 .maxlen = sizeof (int),
731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800732 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 .extra1 = &pid_max_min,
734 .extra2 = &pid_max_max,
735 },
736 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 .procname = "panic_on_oops",
738 .data = &panic_on_oops,
739 .maxlen = sizeof(int),
740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800741 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800743#if defined CONFIG_PRINTK
744 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800745 .procname = "printk",
746 .data = &console_loglevel,
747 .maxlen = 4*sizeof(int),
748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800750 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700753 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 },
758 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700760 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 .maxlen = sizeof(int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 },
Dave Youngaf913222009-09-22 16:43:33 -0700765 {
Dave Youngaf913222009-09-22 16:43:33 -0700766 .procname = "printk_delay",
767 .data = &printk_delay_msec,
768 .maxlen = sizeof(int),
769 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800770 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700771 .extra1 = &zero,
772 .extra2 = &ten_thousand,
773 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800775 .procname = "dmesg_restrict",
776 .data = &dmesg_restrict,
777 .maxlen = sizeof(int),
778 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700779 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800780 .extra1 = &zero,
781 .extra2 = &one,
782 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800783 {
784 .procname = "kptr_restrict",
785 .data = &kptr_restrict,
786 .maxlen = sizeof(int),
787 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700788 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800789 .extra1 = &zero,
790 .extra2 = &two,
791 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800792#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800793 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 .procname = "ngroups_max",
795 .data = &ngroups_max,
796 .maxlen = sizeof (int),
797 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 },
Dan Ballard73efc032011-10-31 17:11:20 -0700800 {
801 .procname = "cap_last_cap",
802 .data = (void *)&cap_last_cap,
803 .maxlen = sizeof(int),
804 .mode = 0444,
805 .proc_handler = proc_dointvec,
806 },
Don Zickus58687ac2010-05-07 17:11:44 -0400807#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500808 {
Don Zickus58687ac2010-05-07 17:11:44 -0400809 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200810 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500811 .maxlen = sizeof (int),
812 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700813 .proc_handler = proc_dowatchdog,
814 .extra1 = &zero,
815 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400816 },
817 {
818 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700819 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400820 .maxlen = sizeof(int),
821 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700822 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800823 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400824 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500825 },
Don Zickus2508ce12010-05-07 17:11:46 -0400826 {
827 .procname = "softlockup_panic",
828 .data = &softlockup_panic,
829 .maxlen = sizeof(int),
830 .mode = 0644,
831 .proc_handler = proc_dointvec_minmax,
832 .extra1 = &zero,
833 .extra2 = &one,
834 },
Don Zickus5dc30552010-11-29 17:07:17 -0500835 {
836 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200837 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500838 .maxlen = sizeof (int),
839 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700840 .proc_handler = proc_dowatchdog,
841 .extra1 = &zero,
842 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500843 },
844#endif
845#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
846 {
847 .procname = "unknown_nmi_panic",
848 .data = &unknown_nmi_panic,
849 .maxlen = sizeof (int),
850 .mode = 0644,
851 .proc_handler = proc_dointvec,
852 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500853#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854#if defined(CONFIG_X86)
855 {
Don Zickus8da5add2006-09-26 10:52:27 +0200856 .procname = "panic_on_unrecovered_nmi",
857 .data = &panic_on_unrecovered_nmi,
858 .maxlen = sizeof(int),
859 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800860 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200861 },
862 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700863 .procname = "panic_on_io_nmi",
864 .data = &panic_on_io_nmi,
865 .maxlen = sizeof(int),
866 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800867 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700868 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900869#ifdef CONFIG_DEBUG_STACKOVERFLOW
870 {
871 .procname = "panic_on_stackoverflow",
872 .data = &sysctl_panic_on_stackoverflow,
873 .maxlen = sizeof(int),
874 .mode = 0644,
875 .proc_handler = proc_dointvec,
876 },
877#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700878 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 .procname = "bootloader_type",
880 .data = &bootloader_type,
881 .maxlen = sizeof (int),
882 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800883 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100885 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700886 .procname = "bootloader_version",
887 .data = &bootloader_version,
888 .maxlen = sizeof (int),
889 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700891 },
892 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100893 .procname = "kstack_depth_to_print",
894 .data = &kstack_depth_to_print,
895 .maxlen = sizeof(int),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100898 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100899 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100900 .procname = "io_delay_type",
901 .data = &io_delay_type,
902 .maxlen = sizeof(int),
903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100905 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800907#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 .procname = "randomize_va_space",
910 .data = &randomize_va_space,
911 .maxlen = sizeof(int),
912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800915#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800916#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700917 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700918 .procname = "spin_retry",
919 .data = &spin_retry,
920 .maxlen = sizeof (int),
921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800922 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700923 },
924#endif
Len Brown673d5b42007-07-28 03:33:16 -0400925#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800926 {
Pavel Machekc255d842006-02-20 18:27:58 -0800927 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700928 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800929 .maxlen = sizeof (unsigned long),
930 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800931 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800932 },
933#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530934#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800935 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800936 .procname = "ignore-unaligned-usertrap",
937 .data = &no_unaligned_warning,
938 .maxlen = sizeof (int),
939 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800940 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800941 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530942#endif
943#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800944 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800945 .procname = "unaligned-dump-stack",
946 .data = &unaligned_dump_stack,
947 .maxlen = sizeof (int),
948 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800949 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800950 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800951#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800952#ifdef CONFIG_DETECT_HUNG_TASK
953 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800954 .procname = "hung_task_panic",
955 .data = &sysctl_hung_task_panic,
956 .maxlen = sizeof(int),
957 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800958 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800959 .extra1 = &zero,
960 .extra2 = &one,
961 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100962 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100963 .procname = "hung_task_check_count",
964 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +0800965 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100966 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +0800967 .proc_handler = proc_dointvec_minmax,
968 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100969 },
970 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100971 .procname = "hung_task_timeout_secs",
972 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100973 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100974 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800975 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100976 },
977 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100978 .procname = "hung_task_warnings",
979 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100980 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100981 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800982 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100983 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700984#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200985#ifdef CONFIG_COMPAT
986 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200987 .procname = "compat-log",
988 .data = &compat_log,
989 .maxlen = sizeof (int),
990 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200992 },
993#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700994#ifdef CONFIG_RT_MUTEXES
995 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700996 .procname = "max_lock_depth",
997 .data = &max_lock_depth,
998 .maxlen = sizeof(int),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001001 },
1002#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001003 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001004 .procname = "poweroff_cmd",
1005 .data = &poweroff_cmd,
1006 .maxlen = POWEROFF_CMD_PATH_LEN,
1007 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001008 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001009 },
David Howells0b77f5b2008-04-29 01:01:32 -07001010#ifdef CONFIG_KEYS
1011 {
David Howells0b77f5b2008-04-29 01:01:32 -07001012 .procname = "keys",
1013 .mode = 0555,
1014 .child = key_sysctls,
1015 },
1016#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001017#ifdef CONFIG_RCU_TORTURE_TEST
1018 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001019 .procname = "rcutorture_runnable",
1020 .data = &rcutorture_runnable,
1021 .maxlen = sizeof(int),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -07001024 },
1025#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001026#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001027 /*
1028 * User-space scripts rely on the existence of this file
1029 * as a feature check for perf_events being enabled.
1030 *
1031 * So it's an ABI, do not remove!
1032 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001033 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001034 .procname = "perf_event_paranoid",
1035 .data = &sysctl_perf_event_paranoid,
1036 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001037 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001039 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001040 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001041 .procname = "perf_event_mlock_kb",
1042 .data = &sysctl_perf_event_mlock,
1043 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001044 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001045 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001046 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001047 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001048 .procname = "perf_event_max_sample_rate",
1049 .data = &sysctl_perf_event_sample_rate,
1050 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001051 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001052 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001053 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001054 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001055 {
1056 .procname = "perf_cpu_time_max_percent",
1057 .data = &sysctl_perf_cpu_time_max_percent,
1058 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1059 .mode = 0644,
1060 .proc_handler = perf_cpu_time_max_percent_handler,
1061 .extra1 = &zero,
1062 .extra2 = &one_hundred,
1063 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001064#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001065#ifdef CONFIG_KMEMCHECK
1066 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001067 .procname = "kmemcheck",
1068 .data = &kmemcheck_enabled,
1069 .maxlen = sizeof(int),
1070 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001071 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001072 },
1073#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001074#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001075 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001076 .procname = "blk_iopoll",
1077 .data = &blk_iopoll_enabled,
1078 .maxlen = sizeof(int),
1079 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001080 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001081 },
Jens Axboecb684b52009-09-15 21:53:11 +02001082#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001083 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084};
1085
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001086static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 .procname = "overcommit_memory",
1089 .data = &sysctl_overcommit_memory,
1090 .maxlen = sizeof(sysctl_overcommit_memory),
1091 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001092 .proc_handler = proc_dointvec_minmax,
1093 .extra1 = &zero,
1094 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 },
1096 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001097 .procname = "panic_on_oom",
1098 .data = &sysctl_panic_on_oom,
1099 .maxlen = sizeof(sysctl_panic_on_oom),
1100 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001101 .proc_handler = proc_dointvec_minmax,
1102 .extra1 = &zero,
1103 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001104 },
1105 {
David Rientjesfe071d72007-10-16 23:25:56 -07001106 .procname = "oom_kill_allocating_task",
1107 .data = &sysctl_oom_kill_allocating_task,
1108 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1109 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001110 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001111 },
1112 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001113 .procname = "oom_dump_tasks",
1114 .data = &sysctl_oom_dump_tasks,
1115 .maxlen = sizeof(sysctl_oom_dump_tasks),
1116 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001117 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001118 },
1119 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 .procname = "overcommit_ratio",
1121 .data = &sysctl_overcommit_ratio,
1122 .maxlen = sizeof(sysctl_overcommit_ratio),
1123 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001124 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 },
1126 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 .procname = "page-cluster",
1128 .data = &page_cluster,
1129 .maxlen = sizeof(int),
1130 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001131 .proc_handler = proc_dointvec_minmax,
1132 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 },
1134 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 .procname = "dirty_background_ratio",
1136 .data = &dirty_background_ratio,
1137 .maxlen = sizeof(dirty_background_ratio),
1138 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001139 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .extra1 = &zero,
1141 .extra2 = &one_hundred,
1142 },
1143 {
David Rientjes2da02992009-01-06 14:39:31 -08001144 .procname = "dirty_background_bytes",
1145 .data = &dirty_background_bytes,
1146 .maxlen = sizeof(dirty_background_bytes),
1147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001148 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001149 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001150 },
1151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "dirty_ratio",
1153 .data = &vm_dirty_ratio,
1154 .maxlen = sizeof(vm_dirty_ratio),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .extra1 = &zero,
1158 .extra2 = &one_hundred,
1159 },
1160 {
David Rientjes2da02992009-01-06 14:39:31 -08001161 .procname = "dirty_bytes",
1162 .data = &vm_dirty_bytes,
1163 .maxlen = sizeof(vm_dirty_bytes),
1164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001165 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001166 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001167 },
1168 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001170 .data = &dirty_writeback_interval,
1171 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001173 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 },
1175 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001177 .data = &dirty_expire_interval,
1178 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001180 .proc_handler = proc_dointvec_minmax,
1181 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 },
1183 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001184 .procname = "nr_pdflush_threads",
1185 .mode = 0444 /* read-only */,
1186 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 },
1188 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 .procname = "swappiness",
1190 .data = &vm_swappiness,
1191 .maxlen = sizeof(vm_swappiness),
1192 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001193 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 .extra1 = &zero,
1195 .extra2 = &one_hundred,
1196 },
1197#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001198 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001200 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 .maxlen = sizeof(unsigned long),
1202 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001203 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 .extra1 = (void *)&hugetlb_zero,
1205 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001206 },
1207#ifdef CONFIG_NUMA
1208 {
1209 .procname = "nr_hugepages_mempolicy",
1210 .data = NULL,
1211 .maxlen = sizeof(unsigned long),
1212 .mode = 0644,
1213 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1214 .extra1 = (void *)&hugetlb_zero,
1215 .extra2 = (void *)&hugetlb_infinity,
1216 },
1217#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 .procname = "hugetlb_shm_group",
1220 .data = &sysctl_hugetlb_shm_group,
1221 .maxlen = sizeof(gid_t),
1222 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001223 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 },
Mel Gorman396faf02007-07-17 04:03:13 -07001225 {
Mel Gorman396faf02007-07-17 04:03:13 -07001226 .procname = "hugepages_treat_as_movable",
1227 .data = &hugepages_treat_as_movable,
1228 .maxlen = sizeof(int),
1229 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001230 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001231 },
Adam Litke54f9f802007-10-16 01:26:20 -07001232 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001233 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001234 .data = NULL,
1235 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001236 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001237 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001238 .extra1 = (void *)&hugetlb_zero,
1239 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001240 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241#endif
1242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .procname = "lowmem_reserve_ratio",
1244 .data = &sysctl_lowmem_reserve_ratio,
1245 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1246 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001247 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 },
1249 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001250 .procname = "drop_caches",
1251 .data = &sysctl_drop_caches,
1252 .maxlen = sizeof(int),
1253 .mode = 0644,
1254 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001255 .extra1 = &one,
1256 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001257 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001258#ifdef CONFIG_COMPACTION
1259 {
1260 .procname = "compact_memory",
1261 .data = &sysctl_compact_memory,
1262 .maxlen = sizeof(int),
1263 .mode = 0200,
1264 .proc_handler = sysctl_compaction_handler,
1265 },
Mel Gorman5e771902010-05-24 14:32:31 -07001266 {
1267 .procname = "extfrag_threshold",
1268 .data = &sysctl_extfrag_threshold,
1269 .maxlen = sizeof(int),
1270 .mode = 0644,
1271 .proc_handler = sysctl_extfrag_handler,
1272 .extra1 = &min_extfrag_threshold,
1273 .extra2 = &max_extfrag_threshold,
1274 },
1275
Mel Gorman76ab0f52010-05-24 14:32:28 -07001276#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001277 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 .procname = "min_free_kbytes",
1279 .data = &min_free_kbytes,
1280 .maxlen = sizeof(min_free_kbytes),
1281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001282 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283 .extra1 = &zero,
1284 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001285 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001286 .procname = "percpu_pagelist_fraction",
1287 .data = &percpu_pagelist_fraction,
1288 .maxlen = sizeof(percpu_pagelist_fraction),
1289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001290 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001291 .extra1 = &min_percpu_pagelist_fract,
1292 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293#ifdef CONFIG_MMU
1294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .procname = "max_map_count",
1296 .data = &sysctl_max_map_count,
1297 .maxlen = sizeof(sysctl_max_map_count),
1298 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001299 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001300 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001302#else
1303 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001304 .procname = "nr_trim_pages",
1305 .data = &sysctl_nr_trim_pages,
1306 .maxlen = sizeof(sysctl_nr_trim_pages),
1307 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001308 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001309 .extra1 = &zero,
1310 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311#endif
1312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .procname = "laptop_mode",
1314 .data = &laptop_mode,
1315 .maxlen = sizeof(laptop_mode),
1316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001317 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 },
1319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "block_dump",
1321 .data = &block_dump,
1322 .maxlen = sizeof(block_dump),
1323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .extra1 = &zero,
1326 },
1327 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 .procname = "vfs_cache_pressure",
1329 .data = &sysctl_vfs_cache_pressure,
1330 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 .extra1 = &zero,
1334 },
1335#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "legacy_va_layout",
1338 .data = &sysctl_legacy_va_layout,
1339 .maxlen = sizeof(sysctl_legacy_va_layout),
1340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 .extra1 = &zero,
1343 },
1344#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001345#ifdef CONFIG_NUMA
1346 {
Christoph Lameter17436602006-01-18 17:42:32 -08001347 .procname = "zone_reclaim_mode",
1348 .data = &zone_reclaim_mode,
1349 .maxlen = sizeof(zone_reclaim_mode),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001352 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001353 },
Christoph Lameter96146342006-07-03 00:24:13 -07001354 {
Christoph Lameter96146342006-07-03 00:24:13 -07001355 .procname = "min_unmapped_ratio",
1356 .data = &sysctl_min_unmapped_ratio,
1357 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001359 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001360 .extra1 = &zero,
1361 .extra2 = &one_hundred,
1362 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001363 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001364 .procname = "min_slab_ratio",
1365 .data = &sysctl_min_slab_ratio,
1366 .maxlen = sizeof(sysctl_min_slab_ratio),
1367 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001368 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001369 .extra1 = &zero,
1370 .extra2 = &one_hundred,
1371 },
Christoph Lameter17436602006-01-18 17:42:32 -08001372#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001373#ifdef CONFIG_SMP
1374 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001375 .procname = "stat_interval",
1376 .data = &sysctl_stat_interval,
1377 .maxlen = sizeof(sysctl_stat_interval),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001380 },
1381#endif
David Howells6e141542009-12-15 19:27:45 +00001382#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001383 {
Eric Parised032182007-06-28 15:55:21 -04001384 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001385 .data = &dac_mmap_min_addr,
1386 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001387 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001388 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001389 },
David Howells6e141542009-12-15 19:27:45 +00001390#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001391#ifdef CONFIG_NUMA
1392 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001393 .procname = "numa_zonelist_order",
1394 .data = &numa_zonelist_order,
1395 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001397 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001398 },
1399#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001400#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001401 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001402 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001403 .procname = "vdso_enabled",
1404 .data = &vdso_enabled,
1405 .maxlen = sizeof(vdso_enabled),
1406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001407 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001408 .extra1 = &zero,
1409 },
1410#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001411#ifdef CONFIG_HIGHMEM
1412 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001413 .procname = "highmem_is_dirtyable",
1414 .data = &vm_highmem_is_dirtyable,
1415 .maxlen = sizeof(vm_highmem_is_dirtyable),
1416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001417 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001418 .extra1 = &zero,
1419 .extra2 = &one,
1420 },
1421#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001422 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001423 .procname = "scan_unevictable_pages",
1424 .data = &scan_unevictable_pages,
1425 .maxlen = sizeof(scan_unevictable_pages),
1426 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001427 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001428 },
Andi Kleen6a460792009-09-16 11:50:15 +02001429#ifdef CONFIG_MEMORY_FAILURE
1430 {
Andi Kleen6a460792009-09-16 11:50:15 +02001431 .procname = "memory_failure_early_kill",
1432 .data = &sysctl_memory_failure_early_kill,
1433 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1434 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001435 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001436 .extra1 = &zero,
1437 .extra2 = &one,
1438 },
1439 {
Andi Kleen6a460792009-09-16 11:50:15 +02001440 .procname = "memory_failure_recovery",
1441 .data = &sysctl_memory_failure_recovery,
1442 .maxlen = sizeof(sysctl_memory_failure_recovery),
1443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001444 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001445 .extra1 = &zero,
1446 .extra2 = &one,
1447 },
1448#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001449 {
1450 .procname = "user_reserve_kbytes",
1451 .data = &sysctl_user_reserve_kbytes,
1452 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1453 .mode = 0644,
1454 .proc_handler = proc_doulongvec_minmax,
1455 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001456 {
1457 .procname = "admin_reserve_kbytes",
1458 .data = &sysctl_admin_reserve_kbytes,
1459 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1460 .mode = 0644,
1461 .proc_handler = proc_doulongvec_minmax,
1462 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001463 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464};
1465
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001466#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001467static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001468 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001469};
1470#endif
1471
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001472static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 .procname = "inode-nr",
1475 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001476 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001478 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 },
1480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .procname = "inode-state",
1482 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001483 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001485 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 },
1487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "file-nr",
1489 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001490 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001491 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001492 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 },
1494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "file-max",
1496 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001497 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001499 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 },
1501 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001502 .procname = "nr_open",
1503 .data = &sysctl_nr_open,
1504 .maxlen = sizeof(int),
1505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001506 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001507 .extra1 = &sysctl_nr_open_min,
1508 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001509 },
1510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 .procname = "dentry-state",
1512 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001513 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001515 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516 },
1517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 .procname = "overflowuid",
1519 .data = &fs_overflowuid,
1520 .maxlen = sizeof(int),
1521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001522 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 .extra1 = &minolduid,
1524 .extra2 = &maxolduid,
1525 },
1526 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527 .procname = "overflowgid",
1528 .data = &fs_overflowgid,
1529 .maxlen = sizeof(int),
1530 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001531 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 .extra1 = &minolduid,
1533 .extra2 = &maxolduid,
1534 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001535#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001536 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537 .procname = "leases-enable",
1538 .data = &leases_enable,
1539 .maxlen = sizeof(int),
1540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001541 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001543#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544#ifdef CONFIG_DNOTIFY
1545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 .procname = "dir-notify-enable",
1547 .data = &dir_notify_enable,
1548 .maxlen = sizeof(int),
1549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001550 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 },
1552#endif
1553#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001554#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556 .procname = "lease-break-time",
1557 .data = &lease_break_time,
1558 .maxlen = sizeof(int),
1559 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001560 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001562#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001563#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 .procname = "aio-nr",
1566 .data = &aio_nr,
1567 .maxlen = sizeof(aio_nr),
1568 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001569 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001570 },
1571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 .procname = "aio-max-nr",
1573 .data = &aio_max_nr,
1574 .maxlen = sizeof(aio_max_nr),
1575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001576 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001578#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001579#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001580 {
Robert Love0399cb02005-07-13 12:38:18 -04001581 .procname = "inotify",
1582 .mode = 0555,
1583 .child = inotify_table,
1584 },
1585#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001586#ifdef CONFIG_EPOLL
1587 {
1588 .procname = "epoll",
1589 .mode = 0555,
1590 .child = epoll_table,
1591 },
1592#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001594 {
Kees Cook800179c2012-07-25 17:29:07 -07001595 .procname = "protected_symlinks",
1596 .data = &sysctl_protected_symlinks,
1597 .maxlen = sizeof(int),
1598 .mode = 0600,
1599 .proc_handler = proc_dointvec_minmax,
1600 .extra1 = &zero,
1601 .extra2 = &one,
1602 },
1603 {
1604 .procname = "protected_hardlinks",
1605 .data = &sysctl_protected_hardlinks,
1606 .maxlen = sizeof(int),
1607 .mode = 0600,
1608 .proc_handler = proc_dointvec_minmax,
1609 .extra1 = &zero,
1610 .extra2 = &one,
1611 },
1612 {
Alan Coxd6e71142005-06-23 00:09:43 -07001613 .procname = "suid_dumpable",
1614 .data = &suid_dumpable,
1615 .maxlen = sizeof(int),
1616 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001617 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001618 .extra1 = &zero,
1619 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001620 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001621#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1622 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001623 .procname = "binfmt_misc",
1624 .mode = 0555,
1625 .child = binfmt_misc_table,
1626 },
1627#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001628 {
Jens Axboeff9da692010-06-03 14:54:39 +02001629 .procname = "pipe-max-size",
1630 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001631 .maxlen = sizeof(int),
1632 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001633 .proc_handler = &pipe_proc_fn,
1634 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001635 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001636 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637};
1638
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001639static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001640#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001641 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001642 .procname = "exception-trace",
1643 .data = &show_unhandled_signals,
1644 .maxlen = sizeof(int),
1645 .mode = 0644,
1646 .proc_handler = proc_dointvec
1647 },
1648#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001649#if defined(CONFIG_OPTPROBES)
1650 {
1651 .procname = "kprobes-optimization",
1652 .data = &sysctl_kprobes_optimization,
1653 .maxlen = sizeof(int),
1654 .mode = 0644,
1655 .proc_handler = proc_kprobes_optimization_handler,
1656 .extra1 = &zero,
1657 .extra2 = &one,
1658 },
1659#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001660 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661};
1662
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001663static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001664 { }
Robert Love0eeca282005-07-12 17:06:03 -04001665};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001667int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001668{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001669 struct ctl_table_header *hdr;
1670
1671 hdr = register_sysctl_table(sysctl_base_table);
1672 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001673 return 0;
1674}
1675
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001676#endif /* CONFIG_SYSCTL */
1677
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678/*
1679 * /proc/sys support
1680 */
1681
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001682#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001684static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001685 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001686 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001687{
1688 size_t len;
1689 char __user *p;
1690 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001691
1692 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001693 *lenp = 0;
1694 return 0;
1695 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001696
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001697 if (write) {
1698 len = 0;
1699 p = buffer;
1700 while (len < *lenp) {
1701 if (get_user(c, p++))
1702 return -EFAULT;
1703 if (c == 0 || c == '\n')
1704 break;
1705 len++;
1706 }
1707 if (len >= maxlen)
1708 len = maxlen-1;
1709 if(copy_from_user(data, buffer, len))
1710 return -EFAULT;
1711 ((char *) data)[len] = 0;
1712 *ppos += *lenp;
1713 } else {
1714 len = strlen(data);
1715 if (len > maxlen)
1716 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001717
1718 if (*ppos > len) {
1719 *lenp = 0;
1720 return 0;
1721 }
1722
1723 data += *ppos;
1724 len -= *ppos;
1725
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001726 if (len > *lenp)
1727 len = *lenp;
1728 if (len)
1729 if(copy_to_user(buffer, data, len))
1730 return -EFAULT;
1731 if (len < *lenp) {
1732 if(put_user('\n', ((char __user *) buffer) + len))
1733 return -EFAULT;
1734 len++;
1735 }
1736 *lenp = len;
1737 *ppos += len;
1738 }
1739 return 0;
1740}
1741
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742/**
1743 * proc_dostring - read a string sysctl
1744 * @table: the sysctl table
1745 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 * @buffer: the user buffer
1747 * @lenp: the size of the user buffer
1748 * @ppos: file position
1749 *
1750 * Reads/writes a string from/to the user buffer. If the kernel
1751 * buffer provided is not large enough to hold the string, the
1752 * string is truncated. The copied string is %NULL-terminated.
1753 * If the string is being read by the user process, it is copied
1754 * and a newline '\n' is added. It is truncated if the buffer is
1755 * not large enough.
1756 *
1757 * Returns 0 on success.
1758 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001759int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 void __user *buffer, size_t *lenp, loff_t *ppos)
1761{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001762 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001763 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764}
1765
Amerigo Wang00b7c332010-05-05 00:26:45 +00001766static size_t proc_skip_spaces(char **buf)
1767{
1768 size_t ret;
1769 char *tmp = skip_spaces(*buf);
1770 ret = tmp - *buf;
1771 *buf = tmp;
1772 return ret;
1773}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001775static void proc_skip_char(char **buf, size_t *size, const char v)
1776{
1777 while (*size) {
1778 if (**buf != v)
1779 break;
1780 (*size)--;
1781 (*buf)++;
1782 }
1783}
1784
Amerigo Wang00b7c332010-05-05 00:26:45 +00001785#define TMPBUFLEN 22
1786/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001787 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001788 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001789 * @buf: a kernel buffer
1790 * @size: size of the kernel buffer
1791 * @val: this is where the number will be stored
1792 * @neg: set to %TRUE if number is negative
1793 * @perm_tr: a vector which contains the allowed trailers
1794 * @perm_tr_len: size of the perm_tr vector
1795 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001796 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001797 * In case of success %0 is returned and @buf and @size are updated with
1798 * the amount of bytes read. If @tr is non-NULL and a trailing
1799 * character exists (size is non-zero after returning from this
1800 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001801 */
1802static int proc_get_long(char **buf, size_t *size,
1803 unsigned long *val, bool *neg,
1804 const char *perm_tr, unsigned perm_tr_len, char *tr)
1805{
1806 int len;
1807 char *p, tmp[TMPBUFLEN];
1808
1809 if (!*size)
1810 return -EINVAL;
1811
1812 len = *size;
1813 if (len > TMPBUFLEN - 1)
1814 len = TMPBUFLEN - 1;
1815
1816 memcpy(tmp, *buf, len);
1817
1818 tmp[len] = 0;
1819 p = tmp;
1820 if (*p == '-' && *size > 1) {
1821 *neg = true;
1822 p++;
1823 } else
1824 *neg = false;
1825 if (!isdigit(*p))
1826 return -EINVAL;
1827
1828 *val = simple_strtoul(p, &p, 0);
1829
1830 len = p - tmp;
1831
1832 /* We don't know if the next char is whitespace thus we may accept
1833 * invalid integers (e.g. 1234...a) or two integers instead of one
1834 * (e.g. 123...1). So lets not allow such large numbers. */
1835 if (len == TMPBUFLEN - 1)
1836 return -EINVAL;
1837
1838 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1839 return -EINVAL;
1840
1841 if (tr && (len < *size))
1842 *tr = *p;
1843
1844 *buf += len;
1845 *size -= len;
1846
1847 return 0;
1848}
1849
1850/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001851 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001852 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001853 * @buf: the user buffer
1854 * @size: the size of the user buffer
1855 * @val: the integer to be converted
1856 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001857 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001858 * In case of success %0 is returned and @buf and @size are updated with
1859 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001860 */
1861static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1862 bool neg)
1863{
1864 int len;
1865 char tmp[TMPBUFLEN], *p = tmp;
1866
1867 sprintf(p, "%s%lu", neg ? "-" : "", val);
1868 len = strlen(tmp);
1869 if (len > *size)
1870 len = *size;
1871 if (copy_to_user(*buf, tmp, len))
1872 return -EFAULT;
1873 *size -= len;
1874 *buf += len;
1875 return 0;
1876}
1877#undef TMPBUFLEN
1878
1879static int proc_put_char(void __user **buf, size_t *size, char c)
1880{
1881 if (*size) {
1882 char __user **buffer = (char __user **)buf;
1883 if (put_user(c, *buffer))
1884 return -EFAULT;
1885 (*size)--, (*buffer)++;
1886 *buf = *buffer;
1887 }
1888 return 0;
1889}
1890
1891static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 int *valp,
1893 int write, void *data)
1894{
1895 if (write) {
1896 *valp = *negp ? -*lvalp : *lvalp;
1897 } else {
1898 int val = *valp;
1899 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001900 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901 *lvalp = (unsigned long)-val;
1902 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001903 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 *lvalp = (unsigned long)val;
1905 }
1906 }
1907 return 0;
1908}
1909
Amerigo Wang00b7c332010-05-05 00:26:45 +00001910static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1911
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001912static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001913 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001914 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001915 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 int write, void *data),
1917 void *data)
1918{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001919 int *i, vleft, first = 1, err = 0;
1920 unsigned long page = 0;
1921 size_t left;
1922 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923
Amerigo Wang00b7c332010-05-05 00:26:45 +00001924 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 *lenp = 0;
1926 return 0;
1927 }
1928
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001929 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001930 vleft = table->maxlen / sizeof(*i);
1931 left = *lenp;
1932
1933 if (!conv)
1934 conv = do_proc_dointvec_conv;
1935
Linus Torvalds1da177e2005-04-16 15:20:36 -07001936 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001937 if (left > PAGE_SIZE - 1)
1938 left = PAGE_SIZE - 1;
1939 page = __get_free_page(GFP_TEMPORARY);
1940 kbuf = (char *) page;
1941 if (!kbuf)
1942 return -ENOMEM;
1943 if (copy_from_user(kbuf, buffer, left)) {
1944 err = -EFAULT;
1945 goto free;
1946 }
1947 kbuf[left] = 0;
1948 }
1949
1950 for (; left && vleft--; i++, first=0) {
1951 unsigned long lval;
1952 bool neg;
1953
1954 if (write) {
1955 left -= proc_skip_spaces(&kbuf);
1956
J. R. Okajima563b0462010-05-25 16:10:14 -07001957 if (!left)
1958 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001959 err = proc_get_long(&kbuf, &left, &lval, &neg,
1960 proc_wspace_sep,
1961 sizeof(proc_wspace_sep), NULL);
1962 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001964 if (conv(&neg, &lval, i, 1, data)) {
1965 err = -EINVAL;
1966 break;
1967 }
1968 } else {
1969 if (conv(&neg, &lval, i, 0, data)) {
1970 err = -EINVAL;
1971 break;
1972 }
1973 if (!first)
1974 err = proc_put_char(&buffer, &left, '\t');
1975 if (err)
1976 break;
1977 err = proc_put_long(&buffer, &left, lval, neg);
1978 if (err)
1979 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001980 }
1981 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001982
1983 if (!write && !first && left && !err)
1984 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001985 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001986 left -= proc_skip_spaces(&kbuf);
1987free:
1988 if (write) {
1989 free_page(page);
1990 if (first)
1991 return err ? : -EINVAL;
1992 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993 *lenp -= left;
1994 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001995 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996}
1997
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001998static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001999 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002000 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002001 int write, void *data),
2002 void *data)
2003{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002004 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002005 buffer, lenp, ppos, conv, data);
2006}
2007
Linus Torvalds1da177e2005-04-16 15:20:36 -07002008/**
2009 * proc_dointvec - read a vector of integers
2010 * @table: the sysctl table
2011 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012 * @buffer: the user buffer
2013 * @lenp: the size of the user buffer
2014 * @ppos: file position
2015 *
2016 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2017 * values from/to the user buffer, treated as an ASCII string.
2018 *
2019 * Returns 0 on success.
2020 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002021int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022 void __user *buffer, size_t *lenp, loff_t *ppos)
2023{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002024 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025 NULL,NULL);
2026}
2027
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002028/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002029 * Taint values can only be increased
2030 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002031 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002032static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002033 void __user *buffer, size_t *lenp, loff_t *ppos)
2034{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002035 struct ctl_table t;
2036 unsigned long tmptaint = get_taint();
2037 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002038
Bastian Blank91fcd412007-04-23 14:41:14 -07002039 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002040 return -EPERM;
2041
Andi Kleen25ddbb12008-10-15 22:01:41 -07002042 t = *table;
2043 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002044 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002045 if (err < 0)
2046 return err;
2047
2048 if (write) {
2049 /*
2050 * Poor man's atomic or. Not worth adding a primitive
2051 * to everyone's atomic.h for this
2052 */
2053 int i;
2054 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2055 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302056 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002057 }
2058 }
2059
2060 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002061}
2062
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002063#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002064static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002065 void __user *buffer, size_t *lenp, loff_t *ppos)
2066{
2067 if (write && !capable(CAP_SYS_ADMIN))
2068 return -EPERM;
2069
2070 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2071}
2072#endif
2073
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074struct do_proc_dointvec_minmax_conv_param {
2075 int *min;
2076 int *max;
2077};
2078
Amerigo Wang00b7c332010-05-05 00:26:45 +00002079static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2080 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081 int write, void *data)
2082{
2083 struct do_proc_dointvec_minmax_conv_param *param = data;
2084 if (write) {
2085 int val = *negp ? -*lvalp : *lvalp;
2086 if ((param->min && *param->min > val) ||
2087 (param->max && *param->max < val))
2088 return -EINVAL;
2089 *valp = val;
2090 } else {
2091 int val = *valp;
2092 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002093 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094 *lvalp = (unsigned long)-val;
2095 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002096 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 *lvalp = (unsigned long)val;
2098 }
2099 }
2100 return 0;
2101}
2102
2103/**
2104 * proc_dointvec_minmax - read a vector of integers with min/max values
2105 * @table: the sysctl table
2106 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107 * @buffer: the user buffer
2108 * @lenp: the size of the user buffer
2109 * @ppos: file position
2110 *
2111 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2112 * values from/to the user buffer, treated as an ASCII string.
2113 *
2114 * This routine will ensure the values are within the range specified by
2115 * table->extra1 (min) and table->extra2 (max).
2116 *
2117 * Returns 0 on success.
2118 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002119int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120 void __user *buffer, size_t *lenp, loff_t *ppos)
2121{
2122 struct do_proc_dointvec_minmax_conv_param param = {
2123 .min = (int *) table->extra1,
2124 .max = (int *) table->extra2,
2125 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002126 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127 do_proc_dointvec_minmax_conv, &param);
2128}
2129
Kees Cook54b50192012-07-30 14:39:18 -07002130static void validate_coredump_safety(void)
2131{
Alex Kelly046d6622012-10-04 17:15:23 -07002132#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002133 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002134 core_pattern[0] != '/' && core_pattern[0] != '|') {
2135 printk(KERN_WARNING "Unsafe core_pattern used with "\
2136 "suid_dumpable=2. Pipe handler or fully qualified "\
2137 "core dump path required.\n");
2138 }
Alex Kelly046d6622012-10-04 17:15:23 -07002139#endif
Kees Cook54b50192012-07-30 14:39:18 -07002140}
2141
2142static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2143 void __user *buffer, size_t *lenp, loff_t *ppos)
2144{
2145 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2146 if (!error)
2147 validate_coredump_safety();
2148 return error;
2149}
2150
Alex Kelly046d6622012-10-04 17:15:23 -07002151#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002152static int proc_dostring_coredump(struct ctl_table *table, int write,
2153 void __user *buffer, size_t *lenp, loff_t *ppos)
2154{
2155 int error = proc_dostring(table, write, buffer, lenp, ppos);
2156 if (!error)
2157 validate_coredump_safety();
2158 return error;
2159}
Alex Kelly046d6622012-10-04 17:15:23 -07002160#endif
Kees Cook54b50192012-07-30 14:39:18 -07002161
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002162static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163 void __user *buffer,
2164 size_t *lenp, loff_t *ppos,
2165 unsigned long convmul,
2166 unsigned long convdiv)
2167{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002168 unsigned long *i, *min, *max;
2169 int vleft, first = 1, err = 0;
2170 unsigned long page = 0;
2171 size_t left;
2172 char *kbuf;
2173
2174 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175 *lenp = 0;
2176 return 0;
2177 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002178
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002179 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 min = (unsigned long *) table->extra1;
2181 max = (unsigned long *) table->extra2;
2182 vleft = table->maxlen / sizeof(unsigned long);
2183 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002184
2185 if (write) {
2186 if (left > PAGE_SIZE - 1)
2187 left = PAGE_SIZE - 1;
2188 page = __get_free_page(GFP_TEMPORARY);
2189 kbuf = (char *) page;
2190 if (!kbuf)
2191 return -ENOMEM;
2192 if (copy_from_user(kbuf, buffer, left)) {
2193 err = -EFAULT;
2194 goto free;
2195 }
2196 kbuf[left] = 0;
2197 }
2198
Eric Dumazet27b3d802010-10-07 12:59:29 -07002199 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002200 unsigned long val;
2201
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 bool neg;
2204
2205 left -= proc_skip_spaces(&kbuf);
2206
2207 err = proc_get_long(&kbuf, &left, &val, &neg,
2208 proc_wspace_sep,
2209 sizeof(proc_wspace_sep), NULL);
2210 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 break;
2212 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213 continue;
2214 if ((min && val < *min) || (max && val > *max))
2215 continue;
2216 *i = val;
2217 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002218 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002219 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002220 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002221 if (err)
2222 break;
2223 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002224 err = proc_put_long(&buffer, &left, val, false);
2225 if (err)
2226 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 }
2228 }
2229
Amerigo Wang00b7c332010-05-05 00:26:45 +00002230 if (!write && !first && left && !err)
2231 err = proc_put_char(&buffer, &left, '\n');
2232 if (write && !err)
2233 left -= proc_skip_spaces(&kbuf);
2234free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 free_page(page);
2237 if (first)
2238 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 *lenp -= left;
2241 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002242 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243}
2244
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002245static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002246 void __user *buffer,
2247 size_t *lenp, loff_t *ppos,
2248 unsigned long convmul,
2249 unsigned long convdiv)
2250{
2251 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002252 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002253}
2254
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255/**
2256 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2257 * @table: the sysctl table
2258 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 * @buffer: the user buffer
2260 * @lenp: the size of the user buffer
2261 * @ppos: file position
2262 *
2263 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2264 * values from/to the user buffer, treated as an ASCII string.
2265 *
2266 * This routine will ensure the values are within the range specified by
2267 * table->extra1 (min) and table->extra2 (max).
2268 *
2269 * Returns 0 on success.
2270 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002271int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 void __user *buffer, size_t *lenp, loff_t *ppos)
2273{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002274 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275}
2276
2277/**
2278 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2279 * @table: the sysctl table
2280 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 * @buffer: the user buffer
2282 * @lenp: the size of the user buffer
2283 * @ppos: file position
2284 *
2285 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2286 * values from/to the user buffer, treated as an ASCII string. The values
2287 * are treated as milliseconds, and converted to jiffies when they are stored.
2288 *
2289 * This routine will ensure the values are within the range specified by
2290 * table->extra1 (min) and table->extra2 (max).
2291 *
2292 * Returns 0 on success.
2293 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002294int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 void __user *buffer,
2296 size_t *lenp, loff_t *ppos)
2297{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002298 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 lenp, ppos, HZ, 1000l);
2300}
2301
2302
Amerigo Wang00b7c332010-05-05 00:26:45 +00002303static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304 int *valp,
2305 int write, void *data)
2306{
2307 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002308 if (*lvalp > LONG_MAX / HZ)
2309 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2311 } else {
2312 int val = *valp;
2313 unsigned long lval;
2314 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002315 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 lval = (unsigned long)-val;
2317 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002318 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 lval = (unsigned long)val;
2320 }
2321 *lvalp = lval / HZ;
2322 }
2323 return 0;
2324}
2325
Amerigo Wang00b7c332010-05-05 00:26:45 +00002326static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 int *valp,
2328 int write, void *data)
2329{
2330 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002331 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2332 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 *valp = clock_t_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_clock_t(lval);
2345 }
2346 return 0;
2347}
2348
Amerigo Wang00b7c332010-05-05 00:26:45 +00002349static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 int *valp,
2351 int write, void *data)
2352{
2353 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002354 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2355
2356 if (jif > INT_MAX)
2357 return 1;
2358 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359 } else {
2360 int val = *valp;
2361 unsigned long lval;
2362 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002363 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 lval = (unsigned long)-val;
2365 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002366 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 lval = (unsigned long)val;
2368 }
2369 *lvalp = jiffies_to_msecs(lval);
2370 }
2371 return 0;
2372}
2373
2374/**
2375 * proc_dointvec_jiffies - read a vector of integers as seconds
2376 * @table: the sysctl table
2377 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002378 * @buffer: the user buffer
2379 * @lenp: the size of the user buffer
2380 * @ppos: file position
2381 *
2382 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2383 * values from/to the user buffer, treated as an ASCII string.
2384 * The values read are assumed to be in seconds, and are converted into
2385 * jiffies.
2386 *
2387 * Returns 0 on success.
2388 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002389int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 void __user *buffer, size_t *lenp, loff_t *ppos)
2391{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002392 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 do_proc_dointvec_jiffies_conv,NULL);
2394}
2395
2396/**
2397 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2398 * @table: the sysctl table
2399 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 * @buffer: the user buffer
2401 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002402 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 *
2404 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2405 * values from/to the user buffer, treated as an ASCII string.
2406 * The values read are assumed to be in 1/USER_HZ seconds, and
2407 * are converted into jiffies.
2408 *
2409 * Returns 0 on success.
2410 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002411int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412 void __user *buffer, size_t *lenp, loff_t *ppos)
2413{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002414 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415 do_proc_dointvec_userhz_jiffies_conv,NULL);
2416}
2417
2418/**
2419 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2420 * @table: the sysctl table
2421 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 * @buffer: the user buffer
2423 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002424 * @ppos: file position
2425 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426 *
2427 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2428 * values from/to the user buffer, treated as an ASCII string.
2429 * The values read are assumed to be in 1/1000 seconds, and
2430 * are converted into jiffies.
2431 *
2432 * Returns 0 on success.
2433 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002434int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 void __user *buffer, size_t *lenp, loff_t *ppos)
2436{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002437 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 do_proc_dointvec_ms_jiffies_conv, NULL);
2439}
2440
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002441static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002442 void __user *buffer, size_t *lenp, loff_t *ppos)
2443{
2444 struct pid *new_pid;
2445 pid_t tmp;
2446 int r;
2447
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002448 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002449
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002450 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002451 lenp, ppos, NULL, NULL);
2452 if (r || !write)
2453 return r;
2454
2455 new_pid = find_get_pid(tmp);
2456 if (!new_pid)
2457 return -ESRCH;
2458
2459 put_pid(xchg(&cad_pid, new_pid));
2460 return 0;
2461}
2462
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002463/**
2464 * proc_do_large_bitmap - read/write from/to a large bitmap
2465 * @table: the sysctl table
2466 * @write: %TRUE if this is a write to the sysctl file
2467 * @buffer: the user buffer
2468 * @lenp: the size of the user buffer
2469 * @ppos: file position
2470 *
2471 * The bitmap is stored at table->data and the bitmap length (in bits)
2472 * in table->maxlen.
2473 *
2474 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2475 * large bitmaps may be represented in a compact manner. Writing into
2476 * the file will clear the bitmap then update it with the given input.
2477 *
2478 * Returns 0 on success.
2479 */
2480int proc_do_large_bitmap(struct ctl_table *table, int write,
2481 void __user *buffer, size_t *lenp, loff_t *ppos)
2482{
2483 int err = 0;
2484 bool first = 1;
2485 size_t left = *lenp;
2486 unsigned long bitmap_len = table->maxlen;
2487 unsigned long *bitmap = (unsigned long *) table->data;
2488 unsigned long *tmp_bitmap = NULL;
2489 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2490
2491 if (!bitmap_len || !left || (*ppos && !write)) {
2492 *lenp = 0;
2493 return 0;
2494 }
2495
2496 if (write) {
2497 unsigned long page = 0;
2498 char *kbuf;
2499
2500 if (left > PAGE_SIZE - 1)
2501 left = PAGE_SIZE - 1;
2502
2503 page = __get_free_page(GFP_TEMPORARY);
2504 kbuf = (char *) page;
2505 if (!kbuf)
2506 return -ENOMEM;
2507 if (copy_from_user(kbuf, buffer, left)) {
2508 free_page(page);
2509 return -EFAULT;
2510 }
2511 kbuf[left] = 0;
2512
2513 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2514 GFP_KERNEL);
2515 if (!tmp_bitmap) {
2516 free_page(page);
2517 return -ENOMEM;
2518 }
2519 proc_skip_char(&kbuf, &left, '\n');
2520 while (!err && left) {
2521 unsigned long val_a, val_b;
2522 bool neg;
2523
2524 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2525 sizeof(tr_a), &c);
2526 if (err)
2527 break;
2528 if (val_a >= bitmap_len || neg) {
2529 err = -EINVAL;
2530 break;
2531 }
2532
2533 val_b = val_a;
2534 if (left) {
2535 kbuf++;
2536 left--;
2537 }
2538
2539 if (c == '-') {
2540 err = proc_get_long(&kbuf, &left, &val_b,
2541 &neg, tr_b, sizeof(tr_b),
2542 &c);
2543 if (err)
2544 break;
2545 if (val_b >= bitmap_len || neg ||
2546 val_a > val_b) {
2547 err = -EINVAL;
2548 break;
2549 }
2550 if (left) {
2551 kbuf++;
2552 left--;
2553 }
2554 }
2555
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002556 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002557 first = 0;
2558 proc_skip_char(&kbuf, &left, '\n');
2559 }
2560 free_page(page);
2561 } else {
2562 unsigned long bit_a, bit_b = 0;
2563
2564 while (left) {
2565 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2566 if (bit_a >= bitmap_len)
2567 break;
2568 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2569 bit_a + 1) - 1;
2570
2571 if (!first) {
2572 err = proc_put_char(&buffer, &left, ',');
2573 if (err)
2574 break;
2575 }
2576 err = proc_put_long(&buffer, &left, bit_a, false);
2577 if (err)
2578 break;
2579 if (bit_a != bit_b) {
2580 err = proc_put_char(&buffer, &left, '-');
2581 if (err)
2582 break;
2583 err = proc_put_long(&buffer, &left, bit_b, false);
2584 if (err)
2585 break;
2586 }
2587
2588 first = 0; bit_b++;
2589 }
2590 if (!err)
2591 err = proc_put_char(&buffer, &left, '\n');
2592 }
2593
2594 if (!err) {
2595 if (write) {
2596 if (*ppos)
2597 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2598 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002599 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002600 }
2601 kfree(tmp_bitmap);
2602 *lenp -= left;
2603 *ppos += *lenp;
2604 return 0;
2605 } else {
2606 kfree(tmp_bitmap);
2607 return err;
2608 }
2609}
2610
Jovi Zhang55610502011-01-12 17:00:45 -08002611#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002613int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 void __user *buffer, size_t *lenp, loff_t *ppos)
2615{
2616 return -ENOSYS;
2617}
2618
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002619int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 void __user *buffer, size_t *lenp, loff_t *ppos)
2621{
2622 return -ENOSYS;
2623}
2624
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002625int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626 void __user *buffer, size_t *lenp, loff_t *ppos)
2627{
2628 return -ENOSYS;
2629}
2630
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002631int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 void __user *buffer, size_t *lenp, loff_t *ppos)
2633{
2634 return -ENOSYS;
2635}
2636
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002637int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 void __user *buffer, size_t *lenp, loff_t *ppos)
2639{
2640 return -ENOSYS;
2641}
2642
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002643int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 void __user *buffer, size_t *lenp, loff_t *ppos)
2645{
2646 return -ENOSYS;
2647}
2648
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002649int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 void __user *buffer, size_t *lenp, loff_t *ppos)
2651{
2652 return -ENOSYS;
2653}
2654
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002655int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 void __user *buffer,
2657 size_t *lenp, loff_t *ppos)
2658{
2659 return -ENOSYS;
2660}
2661
2662
Jovi Zhang55610502011-01-12 17:00:45 -08002663#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665/*
2666 * No sense putting this after each symbol definition, twice,
2667 * exception granted :-)
2668 */
2669EXPORT_SYMBOL(proc_dointvec);
2670EXPORT_SYMBOL(proc_dointvec_jiffies);
2671EXPORT_SYMBOL(proc_dointvec_minmax);
2672EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2673EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2674EXPORT_SYMBOL(proc_dostring);
2675EXPORT_SYMBOL(proc_doulongvec_minmax);
2676EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);