blob: 5c93d0a41b4c3018f51715a9db7b220a1872ad83 [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>
Adrian Bunk62239ac2007-07-17 04:03:45 -070033#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/init.h>
35#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010036#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030037#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <linux/sysrq.h>
39#include <linux/highuid.h>
40#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020041#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070042#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070045#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/times.h>
47#include <linux/limits.h>
48#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020049#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070051#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080052#include <linux/nfs_fs.h>
53#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070054#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020055#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020056#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050057#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020058#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070059#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040060#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070061#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000062#include <linux/binfmts.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64#include <asm/uaccess.h>
65#include <asm/processor.h>
66
Andi Kleen29cbc782006-09-30 01:47:55 +020067#ifdef CONFIG_X86
68#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010069#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010070#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020071#endif
David Howellsd550bbd2012-03-28 18:30:03 +010072#ifdef CONFIG_SPARC
73#include <asm/setup.h>
74#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080075#ifdef CONFIG_BSD_PROCESS_ACCT
76#include <linux/acct.h>
77#endif
Dave Young4f0e0562010-03-10 15:24:09 -080078#ifdef CONFIG_RT_MUTEXES
79#include <linux/rtmutex.h>
80#endif
Dave Young2edf5e42010-03-10 15:24:10 -080081#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
82#include <linux/lockdep.h>
83#endif
Dave Young15485a42010-03-10 15:24:07 -080084#ifdef CONFIG_CHR_DEV_SG
85#include <scsi/sg.h>
86#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020087
Don Zickus58687ac2010-05-07 17:11:44 -040088#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050089#include <linux/nmi.h>
90#endif
91
Eric W. Biederman7058cb02007-10-18 03:05:58 -070092
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#if defined(CONFIG_SYSCTL)
94
95/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070096extern int sysctl_overcommit_memory;
97extern int sysctl_overcommit_ratio;
98extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -0700100extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700102extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103extern int pid_max;
104extern int min_free_kbytes;
Rik van Riele13c80f2011-09-01 15:26:50 -0400105extern int extra_free_kbytes;
Arve Hjønnevågcde89492009-02-17 14:51:02 -0800106extern int min_free_order_shift;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800108extern int sysctl_drop_caches;
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;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200123static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124#endif
125
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700126static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700127static int __maybe_unused one = 1;
128static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700129static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800130static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700132#ifdef CONFIG_PRINTK
133static int ten_thousand = 10000;
134#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700135
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700136/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
137static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
140static int maxolduid = 65535;
141static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800142static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Liu Hua96f6aea2014-04-07 15:38:57 -0700147/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148#ifdef CONFIG_DETECT_HUNG_TASK
149static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150#endif
151
Dave Youngd14f1722010-02-25 20:28:57 -0500152#ifdef CONFIG_INOTIFY_USER
153#include <linux/inotify.h>
154#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700155#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#endif
157
David S. Miller08714202008-11-16 23:49:24 -0800158#ifdef CONFIG_SPARC64
159extern int sysctl_tsb_ratio;
160#endif
161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162#ifdef __hppa__
163extern int pwrsw_enabled;
164extern int unaligned_enabled;
165#endif
166
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#ifdef CONFIG_IA64
168extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800169extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800170#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
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700184#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800185/* Note: sysrq code uses it's own private copy */
186static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700187
188static int sysrq_sysctl_handler(ctl_table *table, int write,
189 void __user *buffer, size_t *lenp,
190 loff_t *ppos)
191{
192 int error;
193
194 error = proc_dointvec(table, write, buffer, lenp, ppos);
195 if (error)
196 return error;
197
198 if (write)
199 sysrq_toggle_support(__sysrq_enabled);
200
201 return 0;
202}
203
204#endif
205
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700206static struct ctl_table kern_table[];
207static struct ctl_table vm_table[];
208static struct ctl_table fs_table[];
209static struct ctl_table debug_table[];
210static struct ctl_table dev_table[];
211extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800212#ifdef CONFIG_EPOLL
213extern struct ctl_table epoll_table[];
214#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
217int sysctl_legacy_va_layout;
218#endif
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220/* The default sysctl tables: */
221
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800222static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 .procname = "kernel",
225 .mode = 0555,
226 .child = kern_table,
227 },
228 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 .procname = "vm",
230 .mode = 0555,
231 .child = vm_table,
232 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "fs",
235 .mode = 0555,
236 .child = fs_table,
237 },
238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .procname = "debug",
240 .mode = 0555,
241 .child = debug_table,
242 },
243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .procname = "dev",
245 .mode = 0555,
246 .child = dev_table,
247 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700248 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249};
250
Ingo Molnar77e54a12007-07-09 18:52:00 +0200251#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100252static int min_sched_granularity_ns = 100000; /* 100 usecs */
253static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
254static int min_wakeup_granularity_ns; /* 0 usecs */
255static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100256static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
257static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200258#endif
259
Mel Gorman5e771902010-05-24 14:32:31 -0700260#ifdef CONFIG_COMPACTION
261static int min_extfrag_threshold;
262static int max_extfrag_threshold = 1000;
263#endif
264
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700265static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200266 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200267 .procname = "sched_child_runs_first",
268 .data = &sysctl_sched_child_runs_first,
269 .maxlen = sizeof(unsigned int),
270 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800271 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200272 },
Steve Muckled448aba2012-10-24 15:00:20 -0700273 {
274 .procname = "sched_wake_to_idle",
275 .data = &sysctl_sched_wake_to_idle,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
278 .proc_handler = proc_dointvec,
279 },
Srivatsa Vaddagiriaa14be32014-03-29 16:56:45 -0700280#ifdef CONFIG_SCHED_FREQ_INPUT
Srivatsa Vaddagiri889de8f2014-01-06 16:24:48 -0800281 {
Srivatsa Vaddagirif906ba02014-03-29 11:40:16 -0700282 .procname = "sched_window_stats_policy",
283 .data = &sysctl_sched_window_stats_policy,
284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
286 .proc_handler = proc_dointvec,
287 },
288 {
Rohit Gupta1bd9e1f2014-03-13 20:54:47 -0700289 .procname = "sched_wakeup_load_threshold",
290 .data = &sysctl_sched_wakeup_load_threshold,
291 .maxlen = sizeof(unsigned int),
292 .mode = 0644,
293 .proc_handler = proc_dointvec,
294 },
Srivatsa Vaddagiriaa14be32014-03-29 16:56:45 -0700295#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200296#ifdef CONFIG_SCHED_DEBUG
297 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100298 .procname = "sched_min_granularity_ns",
299 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800302 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100303 .extra1 = &min_sched_granularity_ns,
304 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200305 },
306 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200307 .procname = "sched_latency_ns",
308 .data = &sysctl_sched_latency,
309 .maxlen = sizeof(unsigned int),
310 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800311 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200312 .extra1 = &min_sched_granularity_ns,
313 .extra2 = &max_sched_granularity_ns,
314 },
315 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200316 .procname = "sched_wakeup_granularity_ns",
317 .data = &sysctl_sched_wakeup_granularity,
318 .maxlen = sizeof(unsigned int),
319 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800320 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200321 .extra1 = &min_wakeup_granularity_ns,
322 .extra2 = &max_wakeup_granularity_ns,
323 },
324 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100325 .procname = "sched_tunable_scaling",
326 .data = &sysctl_sched_tunable_scaling,
327 .maxlen = sizeof(enum sched_tunable_scaling),
328 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800329 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100330 .extra1 = &min_sched_tunable_scaling,
331 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200332 },
333 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200334 .procname = "sched_migration_cost",
335 .data = &sysctl_sched_migration_cost,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200339 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100340 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100341 .procname = "sched_nr_migrate",
342 .data = &sysctl_sched_nr_migrate,
343 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800345 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100346 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530347 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200348 .procname = "sched_time_avg",
349 .data = &sysctl_sched_time_avg,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800352 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200353 },
354 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800355 .procname = "sched_shares_window",
356 .data = &sysctl_sched_shares_window,
357 .maxlen = sizeof(unsigned int),
358 .mode = 0644,
359 .proc_handler = proc_dointvec,
360 },
361 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530362 .procname = "timer_migration",
363 .data = &sysctl_timer_migration,
364 .maxlen = sizeof(unsigned int),
365 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800366 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530367 .extra1 = &zero,
368 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530369 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200370#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200371 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100372 .procname = "sched_rt_period_us",
373 .data = &sysctl_sched_rt_period,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800376 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100377 },
378 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100379 .procname = "sched_rt_runtime_us",
380 .data = &sysctl_sched_rt_runtime,
381 .maxlen = sizeof(int),
382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800383 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100384 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100385#ifdef CONFIG_SCHED_AUTOGROUP
386 {
387 .procname = "sched_autogroup_enabled",
388 .data = &sysctl_sched_autogroup_enabled,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800391 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100392 .extra1 = &zero,
393 .extra2 = &one,
394 },
395#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700396#ifdef CONFIG_CFS_BANDWIDTH
397 {
398 .procname = "sched_cfs_bandwidth_slice_us",
399 .data = &sysctl_sched_cfs_bandwidth_slice,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
402 .proc_handler = proc_dointvec_minmax,
403 .extra1 = &one,
404 },
405#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700406#ifdef CONFIG_PROVE_LOCKING
407 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700408 .procname = "prove_locking",
409 .data = &prove_locking,
410 .maxlen = sizeof(int),
411 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800412 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700413 },
414#endif
415#ifdef CONFIG_LOCK_STAT
416 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700417 .procname = "lock_stat",
418 .data = &lock_stat,
419 .maxlen = sizeof(int),
420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800421 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700422 },
423#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 .procname = "panic",
426 .data = &panic_timeout,
427 .maxlen = sizeof(int),
428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800429 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 },
431 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 .procname = "core_uses_pid",
433 .data = &core_uses_pid,
434 .maxlen = sizeof(int),
435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800436 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 },
438 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 .procname = "core_pattern",
440 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700441 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 },
Neil Hormana2939802009-09-23 15:56:56 -0700445 {
Neil Hormana2939802009-09-23 15:56:56 -0700446 .procname = "core_pipe_limit",
447 .data = &core_pipe_limit,
448 .maxlen = sizeof(unsigned int),
449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800450 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700451 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800452#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700455 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800456 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800457 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800459#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100460#ifdef CONFIG_LATENCYTOP
461 {
462 .procname = "latencytop",
463 .data = &latencytop_enabled,
464 .maxlen = sizeof(int),
465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100467 },
468#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469#ifdef CONFIG_BLK_DEV_INITRD
470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "real-root-dev",
472 .data = &real_root_dev,
473 .maxlen = sizeof(int),
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
477#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700478 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700479 .procname = "print-fatal-signals",
480 .data = &print_fatal_signals,
481 .maxlen = sizeof(int),
482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800483 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700484 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700485#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "reboot-cmd",
488 .data = reboot_command,
489 .maxlen = 256,
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 .procname = "stop-a",
495 .data = &stop_a_enabled,
496 .maxlen = sizeof (int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 },
500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 .procname = "scons-poweroff",
502 .data = &scons_pwroff,
503 .maxlen = sizeof (int),
504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 },
507#endif
David S. Miller08714202008-11-16 23:49:24 -0800508#ifdef CONFIG_SPARC64
509 {
David S. Miller08714202008-11-16 23:49:24 -0800510 .procname = "tsb-ratio",
511 .data = &sysctl_tsb_ratio,
512 .maxlen = sizeof (int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800515 },
516#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517#ifdef __hppa__
518 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 .procname = "soft-power",
520 .data = &pwrsw_enabled,
521 .maxlen = sizeof (int),
522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800523 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 },
525 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 .procname = "unaligned-trap",
527 .data = &unaligned_enabled,
528 .maxlen = sizeof (int),
529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800530 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 },
532#endif
533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 .procname = "ctrl-alt-del",
535 .data = &C_A_D,
536 .maxlen = sizeof(int),
537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800538 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400540#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200541 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200542 .procname = "ftrace_enabled",
543 .data = &ftrace_enabled,
544 .maxlen = sizeof(int),
545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200547 },
548#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500549#ifdef CONFIG_STACK_TRACER
550 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500551 .procname = "stack_tracer_enabled",
552 .data = &stack_tracer_enabled,
553 .maxlen = sizeof(int),
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500556 },
557#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400558#ifdef CONFIG_TRACING
559 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100560 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400561 .data = &ftrace_dump_on_oops,
562 .maxlen = sizeof(int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400565 },
566#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200567#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "modprobe",
570 .data = &modprobe_path,
571 .maxlen = KMOD_PATH_LEN,
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
Kees Cook3d433212009-04-02 15:49:29 -0700575 {
Kees Cook3d433212009-04-02 15:49:29 -0700576 .procname = "modules_disabled",
577 .data = &modules_disabled,
578 .maxlen = sizeof(int),
579 .mode = 0644,
580 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700582 .extra1 = &one,
583 .extra2 = &one,
584 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100586#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100589 .data = &uevent_helper,
590 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 },
594#endif
595#ifdef CONFIG_CHR_DEV_SG
596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 .procname = "sg-big-buff",
598 .data = &sg_big_buff,
599 .maxlen = sizeof (int),
600 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 },
603#endif
604#ifdef CONFIG_BSD_PROCESS_ACCT
605 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 .procname = "acct",
607 .data = &acct_parm,
608 .maxlen = 3*sizeof(int),
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 },
612#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613#ifdef CONFIG_MAGIC_SYSRQ
614 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800616 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 .maxlen = sizeof (int),
618 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700619 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
621#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700622#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700625 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 .maxlen = sizeof (int),
627 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800628 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700630#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 .procname = "threads-max",
633 .data = &max_threads,
634 .maxlen = sizeof(int),
635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800636 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 },
638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "random",
640 .mode = 0555,
641 .child = random_table,
642 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 {
Eric Paris17f60a72011-04-01 17:07:50 -0400644 .procname = "usermodehelper",
645 .mode = 0555,
646 .child = usermodehelper_table,
647 },
648 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 .procname = "overflowuid",
650 .data = &overflowuid,
651 .maxlen = sizeof(int),
652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .extra1 = &minolduid,
655 .extra2 = &maxolduid,
656 },
657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "overflowgid",
659 .data = &overflowgid,
660 .maxlen = sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .extra1 = &minolduid,
664 .extra2 = &maxolduid,
665 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800666#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667#ifdef CONFIG_MATHEMU
668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "ieee_emulation_warnings",
670 .data = &sysctl_ieee_emulation_warnings,
671 .maxlen = sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200678 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .maxlen = sizeof(int),
680 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800681 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 },
683#endif
684 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .procname = "pid_max",
686 .data = &pid_max,
687 .maxlen = sizeof (int),
688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .extra1 = &pid_max_min,
691 .extra2 = &pid_max_max,
692 },
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "panic_on_oops",
695 .data = &panic_on_oops,
696 .maxlen = sizeof(int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800700#if defined CONFIG_PRINTK
701 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800702 .procname = "printk",
703 .data = &console_loglevel,
704 .maxlen = 4*sizeof(int),
705 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800707 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700710 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .maxlen = sizeof(int),
712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 },
715 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700717 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .maxlen = sizeof(int),
719 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800720 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 },
Dave Youngaf913222009-09-22 16:43:33 -0700722 {
Dave Youngaf913222009-09-22 16:43:33 -0700723 .procname = "printk_delay",
724 .data = &printk_delay_msec,
725 .maxlen = sizeof(int),
726 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800727 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700728 .extra1 = &zero,
729 .extra2 = &ten_thousand,
730 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800732 .procname = "dmesg_restrict",
733 .data = &dmesg_restrict,
734 .maxlen = sizeof(int),
735 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700736 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800737 .extra1 = &zero,
738 .extra2 = &one,
739 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800740 {
741 .procname = "kptr_restrict",
742 .data = &kptr_restrict,
743 .maxlen = sizeof(int),
744 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700745 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800746 .extra1 = &zero,
747 .extra2 = &two,
748 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800749#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800750 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 .procname = "ngroups_max",
752 .data = &ngroups_max,
753 .maxlen = sizeof (int),
754 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800755 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 },
Dan Ballard73efc032011-10-31 17:11:20 -0700757 {
758 .procname = "cap_last_cap",
759 .data = (void *)&cap_last_cap,
760 .maxlen = sizeof(int),
761 .mode = 0444,
762 .proc_handler = proc_dointvec,
763 },
Don Zickus58687ac2010-05-07 17:11:44 -0400764#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500765 {
Don Zickus58687ac2010-05-07 17:11:44 -0400766 .procname = "watchdog",
767 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500768 .maxlen = sizeof (int),
769 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700770 .proc_handler = proc_dowatchdog,
771 .extra1 = &zero,
772 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400773 },
774 {
775 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700776 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400777 .maxlen = sizeof(int),
778 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700779 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400780 .extra1 = &neg_one,
781 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500782 },
Don Zickus2508ce12010-05-07 17:11:46 -0400783 {
784 .procname = "softlockup_panic",
785 .data = &softlockup_panic,
786 .maxlen = sizeof(int),
787 .mode = 0644,
788 .proc_handler = proc_dointvec_minmax,
789 .extra1 = &zero,
790 .extra2 = &one,
791 },
Don Zickus5dc30552010-11-29 17:07:17 -0500792 {
793 .procname = "nmi_watchdog",
794 .data = &watchdog_enabled,
795 .maxlen = sizeof (int),
796 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700797 .proc_handler = proc_dowatchdog,
798 .extra1 = &zero,
799 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500800 },
801#endif
802#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
803 {
804 .procname = "unknown_nmi_panic",
805 .data = &unknown_nmi_panic,
806 .maxlen = sizeof (int),
807 .mode = 0644,
808 .proc_handler = proc_dointvec,
809 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500810#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811#if defined(CONFIG_X86)
812 {
Don Zickus8da5add2006-09-26 10:52:27 +0200813 .procname = "panic_on_unrecovered_nmi",
814 .data = &panic_on_unrecovered_nmi,
815 .maxlen = sizeof(int),
816 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800817 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200818 },
819 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700820 .procname = "panic_on_io_nmi",
821 .data = &panic_on_io_nmi,
822 .maxlen = sizeof(int),
823 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800824 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700825 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900826#ifdef CONFIG_DEBUG_STACKOVERFLOW
827 {
828 .procname = "panic_on_stackoverflow",
829 .data = &sysctl_panic_on_stackoverflow,
830 .maxlen = sizeof(int),
831 .mode = 0644,
832 .proc_handler = proc_dointvec,
833 },
834#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700835 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 .procname = "bootloader_type",
837 .data = &bootloader_type,
838 .maxlen = sizeof (int),
839 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800840 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100842 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700843 .procname = "bootloader_version",
844 .data = &bootloader_version,
845 .maxlen = sizeof (int),
846 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800847 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700848 },
849 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100850 .procname = "kstack_depth_to_print",
851 .data = &kstack_depth_to_print,
852 .maxlen = sizeof(int),
853 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800854 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100855 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100856 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100857 .procname = "io_delay_type",
858 .data = &io_delay_type,
859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100862 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800864#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 .procname = "randomize_va_space",
867 .data = &randomize_va_space,
868 .maxlen = sizeof(int),
869 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800870 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800872#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800873#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700874 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700875 .procname = "spin_retry",
876 .data = &spin_retry,
877 .maxlen = sizeof (int),
878 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800879 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700880 },
881#endif
Len Brown673d5b42007-07-28 03:33:16 -0400882#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800883 {
Pavel Machekc255d842006-02-20 18:27:58 -0800884 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700885 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800886 .maxlen = sizeof (unsigned long),
887 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800888 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800889 },
890#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800891#ifdef CONFIG_IA64
892 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800893 .procname = "ignore-unaligned-usertrap",
894 .data = &no_unaligned_warning,
895 .maxlen = sizeof (int),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800898 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800899 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800900 .procname = "unaligned-dump-stack",
901 .data = &unaligned_dump_stack,
902 .maxlen = sizeof (int),
903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800905 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800906#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800907#ifdef CONFIG_DETECT_HUNG_TASK
908 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800909 .procname = "hung_task_panic",
910 .data = &sysctl_hung_task_panic,
911 .maxlen = sizeof(int),
912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800914 .extra1 = &zero,
915 .extra2 = &one,
916 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100917 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100918 .procname = "hung_task_check_count",
919 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100920 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800922 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100923 },
924 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100925 .procname = "hung_task_timeout_secs",
926 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100927 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua96f6aea2014-04-07 15:38:57 -0700930 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100931 },
932 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100933 .procname = "hung_task_warnings",
934 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100935 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100936 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800937 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100938 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700939#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200940#ifdef CONFIG_COMPAT
941 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200942 .procname = "compat-log",
943 .data = &compat_log,
944 .maxlen = sizeof (int),
945 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800946 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200947 },
948#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700949#ifdef CONFIG_RT_MUTEXES
950 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700951 .procname = "max_lock_depth",
952 .data = &max_lock_depth,
953 .maxlen = sizeof(int),
954 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800955 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700956 },
957#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700958 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700959 .procname = "poweroff_cmd",
960 .data = &poweroff_cmd,
961 .maxlen = POWEROFF_CMD_PATH_LEN,
962 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700964 },
David Howells0b77f5b2008-04-29 01:01:32 -0700965#ifdef CONFIG_KEYS
966 {
David Howells0b77f5b2008-04-29 01:01:32 -0700967 .procname = "keys",
968 .mode = 0555,
969 .child = key_sysctls,
970 },
971#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700972#ifdef CONFIG_RCU_TORTURE_TEST
973 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700974 .procname = "rcutorture_runnable",
975 .data = &rcutorture_runnable,
976 .maxlen = sizeof(int),
977 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800978 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700979 },
980#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200981#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400982 /*
983 * User-space scripts rely on the existence of this file
984 * as a feature check for perf_events being enabled.
985 *
986 * So it's an ABI, do not remove!
987 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200988 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200989 .procname = "perf_event_paranoid",
990 .data = &sysctl_perf_event_paranoid,
991 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200994 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200995 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200996 .procname = "perf_event_mlock_kb",
997 .data = &sysctl_perf_event_mlock,
998 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001001 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001002 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001003 .procname = "perf_event_max_sample_rate",
1004 .data = &sysctl_perf_event_sample_rate,
1005 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001006 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001007 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001008 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001009#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001010#ifdef CONFIG_KMEMCHECK
1011 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001012 .procname = "kmemcheck",
1013 .data = &kmemcheck_enabled,
1014 .maxlen = sizeof(int),
1015 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001016 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001017 },
1018#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001019#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001020 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001021 .procname = "blk_iopoll",
1022 .data = &blk_iopoll_enabled,
1023 .maxlen = sizeof(int),
1024 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001025 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001026 },
Jens Axboecb684b52009-09-15 21:53:11 +02001027#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001028#ifdef CONFIG_ARM
1029 {
1030 .procname = "boot_reason",
1031 .data = &boot_reason,
1032 .maxlen = sizeof(int),
1033 .mode = 0444,
1034 .proc_handler = proc_dointvec,
1035},
1036#endif
1037/*
1038 * NOTE: do not add new entries to this table unless you have read
1039 * Documentation/sysctl/ctl_unnumbered.txt
1040 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001041 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042};
1043
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001044static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 .procname = "overcommit_memory",
1047 .data = &sysctl_overcommit_memory,
1048 .maxlen = sizeof(sysctl_overcommit_memory),
1049 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001050 .proc_handler = proc_dointvec_minmax,
1051 .extra1 = &zero,
1052 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 },
1054 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001055 .procname = "panic_on_oom",
1056 .data = &sysctl_panic_on_oom,
1057 .maxlen = sizeof(sysctl_panic_on_oom),
1058 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001059 .proc_handler = proc_dointvec_minmax,
1060 .extra1 = &zero,
1061 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001062 },
1063 {
David Rientjesfe071d72007-10-16 23:25:56 -07001064 .procname = "oom_kill_allocating_task",
1065 .data = &sysctl_oom_kill_allocating_task,
1066 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1067 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001068 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001069 },
1070 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001071 .procname = "oom_dump_tasks",
1072 .data = &sysctl_oom_dump_tasks,
1073 .maxlen = sizeof(sysctl_oom_dump_tasks),
1074 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001075 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001076 },
1077 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 .procname = "overcommit_ratio",
1079 .data = &sysctl_overcommit_ratio,
1080 .maxlen = sizeof(sysctl_overcommit_ratio),
1081 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001082 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 },
1084 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 .procname = "page-cluster",
1086 .data = &page_cluster,
1087 .maxlen = sizeof(int),
1088 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001089 .proc_handler = proc_dointvec_minmax,
1090 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 },
1092 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 .procname = "dirty_background_ratio",
1094 .data = &dirty_background_ratio,
1095 .maxlen = sizeof(dirty_background_ratio),
1096 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001097 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 .extra1 = &zero,
1099 .extra2 = &one_hundred,
1100 },
1101 {
David Rientjes2da02992009-01-06 14:39:31 -08001102 .procname = "dirty_background_bytes",
1103 .data = &dirty_background_bytes,
1104 .maxlen = sizeof(dirty_background_bytes),
1105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001107 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001108 },
1109 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .procname = "dirty_ratio",
1111 .data = &vm_dirty_ratio,
1112 .maxlen = sizeof(vm_dirty_ratio),
1113 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001114 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .extra1 = &zero,
1116 .extra2 = &one_hundred,
1117 },
1118 {
David Rientjes2da02992009-01-06 14:39:31 -08001119 .procname = "dirty_bytes",
1120 .data = &vm_dirty_bytes,
1121 .maxlen = sizeof(vm_dirty_bytes),
1122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001124 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001125 },
1126 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001128 .data = &dirty_writeback_interval,
1129 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001131 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 },
1133 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001135 .data = &dirty_expire_interval,
1136 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001138 .proc_handler = proc_dointvec_minmax,
1139 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 },
1141 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 .procname = "nr_pdflush_threads",
1143 .data = &nr_pdflush_threads,
1144 .maxlen = sizeof nr_pdflush_threads,
1145 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001146 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 },
1148 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 .procname = "swappiness",
1150 .data = &vm_swappiness,
1151 .maxlen = sizeof(vm_swappiness),
1152 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001153 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .extra1 = &zero,
1155 .extra2 = &one_hundred,
1156 },
1157#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001158 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001160 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .maxlen = sizeof(unsigned long),
1162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 .extra1 = (void *)&hugetlb_zero,
1165 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001166 },
1167#ifdef CONFIG_NUMA
1168 {
1169 .procname = "nr_hugepages_mempolicy",
1170 .data = NULL,
1171 .maxlen = sizeof(unsigned long),
1172 .mode = 0644,
1173 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1174 .extra1 = (void *)&hugetlb_zero,
1175 .extra2 = (void *)&hugetlb_infinity,
1176 },
1177#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .procname = "hugetlb_shm_group",
1180 .data = &sysctl_hugetlb_shm_group,
1181 .maxlen = sizeof(gid_t),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 },
Mel Gorman396faf02007-07-17 04:03:13 -07001185 {
Mel Gorman396faf02007-07-17 04:03:13 -07001186 .procname = "hugepages_treat_as_movable",
1187 .data = &hugepages_treat_as_movable,
1188 .maxlen = sizeof(int),
1189 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001190 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001191 },
Adam Litke54f9f802007-10-16 01:26:20 -07001192 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001193 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001194 .data = NULL,
1195 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001196 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001197 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001198 .extra1 = (void *)&hugetlb_zero,
1199 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001200 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201#endif
1202 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .procname = "lowmem_reserve_ratio",
1204 .data = &sysctl_lowmem_reserve_ratio,
1205 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 },
1209 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001210 .procname = "drop_caches",
1211 .data = &sysctl_drop_caches,
1212 .maxlen = sizeof(int),
1213 .mode = 0644,
1214 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001215 .extra1 = &one,
1216 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001217 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001218#ifdef CONFIG_COMPACTION
1219 {
1220 .procname = "compact_memory",
1221 .data = &sysctl_compact_memory,
1222 .maxlen = sizeof(int),
1223 .mode = 0200,
1224 .proc_handler = sysctl_compaction_handler,
1225 },
Mel Gorman5e771902010-05-24 14:32:31 -07001226 {
1227 .procname = "extfrag_threshold",
1228 .data = &sysctl_extfrag_threshold,
1229 .maxlen = sizeof(int),
1230 .mode = 0644,
1231 .proc_handler = sysctl_extfrag_handler,
1232 .extra1 = &min_extfrag_threshold,
1233 .extra2 = &max_extfrag_threshold,
1234 },
1235
Mel Gorman76ab0f52010-05-24 14:32:28 -07001236#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 .procname = "min_free_kbytes",
1239 .data = &min_free_kbytes,
1240 .maxlen = sizeof(min_free_kbytes),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .extra1 = &zero,
1244 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001245 {
Rik van Riele13c80f2011-09-01 15:26:50 -04001246 .procname = "extra_free_kbytes",
1247 .data = &extra_free_kbytes,
1248 .maxlen = sizeof(extra_free_kbytes),
1249 .mode = 0644,
1250 .proc_handler = min_free_kbytes_sysctl_handler,
1251 .extra1 = &zero,
1252 },
1253 {
Arve Hjønnevågcde89492009-02-17 14:51:02 -08001254 .procname = "min_free_order_shift",
1255 .data = &min_free_order_shift,
1256 .maxlen = sizeof(min_free_order_shift),
1257 .mode = 0644,
1258 .proc_handler = &proc_dointvec
1259 },
1260 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001261 .procname = "percpu_pagelist_fraction",
1262 .data = &percpu_pagelist_fraction,
1263 .maxlen = sizeof(percpu_pagelist_fraction),
1264 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001265 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001266 .extra1 = &min_percpu_pagelist_fract,
1267 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268#ifdef CONFIG_MMU
1269 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 .procname = "max_map_count",
1271 .data = &sysctl_max_map_count,
1272 .maxlen = sizeof(sysctl_max_map_count),
1273 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001274 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001275 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001277#else
1278 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001279 .procname = "nr_trim_pages",
1280 .data = &sysctl_nr_trim_pages,
1281 .maxlen = sizeof(sysctl_nr_trim_pages),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001284 .extra1 = &zero,
1285 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286#endif
1287 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288 .procname = "laptop_mode",
1289 .data = &laptop_mode,
1290 .maxlen = sizeof(laptop_mode),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 },
1294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .procname = "block_dump",
1296 .data = &block_dump,
1297 .maxlen = sizeof(block_dump),
1298 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001299 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .extra1 = &zero,
1301 },
1302 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 .procname = "vfs_cache_pressure",
1304 .data = &sysctl_vfs_cache_pressure,
1305 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1306 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 .extra1 = &zero,
1309 },
1310#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .procname = "legacy_va_layout",
1313 .data = &sysctl_legacy_va_layout,
1314 .maxlen = sizeof(sysctl_legacy_va_layout),
1315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001316 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .extra1 = &zero,
1318 },
1319#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001320#ifdef CONFIG_NUMA
1321 {
Christoph Lameter17436602006-01-18 17:42:32 -08001322 .procname = "zone_reclaim_mode",
1323 .data = &zone_reclaim_mode,
1324 .maxlen = sizeof(zone_reclaim_mode),
1325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001326 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001327 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001328 },
Christoph Lameter96146342006-07-03 00:24:13 -07001329 {
Christoph Lameter96146342006-07-03 00:24:13 -07001330 .procname = "min_unmapped_ratio",
1331 .data = &sysctl_min_unmapped_ratio,
1332 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001335 .extra1 = &zero,
1336 .extra2 = &one_hundred,
1337 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001338 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001339 .procname = "min_slab_ratio",
1340 .data = &sysctl_min_slab_ratio,
1341 .maxlen = sizeof(sysctl_min_slab_ratio),
1342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001344 .extra1 = &zero,
1345 .extra2 = &one_hundred,
1346 },
Christoph Lameter17436602006-01-18 17:42:32 -08001347#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001348#ifdef CONFIG_SMP
1349 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001350 .procname = "stat_interval",
1351 .data = &sysctl_stat_interval,
1352 .maxlen = sizeof(sysctl_stat_interval),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001355 },
1356#endif
David Howells6e141542009-12-15 19:27:45 +00001357#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001358 {
Eric Parised032182007-06-28 15:55:21 -04001359 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001360 .data = &dac_mmap_min_addr,
1361 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001362 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001363 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001364 },
David Howells6e141542009-12-15 19:27:45 +00001365#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001366#ifdef CONFIG_NUMA
1367 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001368 .procname = "numa_zonelist_order",
1369 .data = &numa_zonelist_order,
1370 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1371 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001372 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001373 },
1374#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001375#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001376 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001377 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001378 .procname = "vdso_enabled",
1379 .data = &vdso_enabled,
1380 .maxlen = sizeof(vdso_enabled),
1381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001382 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001383 .extra1 = &zero,
1384 },
1385#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001386#ifdef CONFIG_HIGHMEM
1387 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001388 .procname = "highmem_is_dirtyable",
1389 .data = &vm_highmem_is_dirtyable,
1390 .maxlen = sizeof(vm_highmem_is_dirtyable),
1391 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001392 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001393 .extra1 = &zero,
1394 .extra2 = &one,
1395 },
1396#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001397 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001398 .procname = "scan_unevictable_pages",
1399 .data = &scan_unevictable_pages,
1400 .maxlen = sizeof(scan_unevictable_pages),
1401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001402 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001403 },
Andi Kleen6a460792009-09-16 11:50:15 +02001404#ifdef CONFIG_MEMORY_FAILURE
1405 {
Andi Kleen6a460792009-09-16 11:50:15 +02001406 .procname = "memory_failure_early_kill",
1407 .data = &sysctl_memory_failure_early_kill,
1408 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001410 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001411 .extra1 = &zero,
1412 .extra2 = &one,
1413 },
1414 {
Andi Kleen6a460792009-09-16 11:50:15 +02001415 .procname = "memory_failure_recovery",
1416 .data = &sysctl_memory_failure_recovery,
1417 .maxlen = sizeof(sysctl_memory_failure_recovery),
1418 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001419 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001420 .extra1 = &zero,
1421 .extra2 = &one,
1422 },
1423#endif
dcashmanbd188f92015-12-29 14:24:39 -08001424#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1425 {
1426 .procname = "mmap_rnd_bits",
1427 .data = &mmap_rnd_bits,
1428 .maxlen = sizeof(mmap_rnd_bits),
1429 .mode = 0600,
1430 .proc_handler = proc_dointvec_minmax,
1431 .extra1 = (void *)&mmap_rnd_bits_min,
1432 .extra2 = (void *)&mmap_rnd_bits_max,
1433 },
1434#endif
1435#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1436 {
1437 .procname = "mmap_rnd_compat_bits",
1438 .data = &mmap_rnd_compat_bits,
1439 .maxlen = sizeof(mmap_rnd_compat_bits),
1440 .mode = 0600,
1441 .proc_handler = proc_dointvec_minmax,
1442 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1443 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1444 },
1445#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001446 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447};
1448
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001449#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001450static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001451 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001452};
1453#endif
1454
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001455static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 .procname = "inode-nr",
1458 .data = &inodes_stat,
1459 .maxlen = 2*sizeof(int),
1460 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001461 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "inode-state",
1465 .data = &inodes_stat,
1466 .maxlen = 7*sizeof(int),
1467 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001468 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 },
1470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 .procname = "file-nr",
1472 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001473 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001475 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 },
1477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "file-max",
1479 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001480 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001482 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 },
1484 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001485 .procname = "nr_open",
1486 .data = &sysctl_nr_open,
1487 .maxlen = sizeof(int),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001490 .extra1 = &sysctl_nr_open_min,
1491 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001492 },
1493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .procname = "dentry-state",
1495 .data = &dentry_stat,
1496 .maxlen = 6*sizeof(int),
1497 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001498 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499 },
1500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .procname = "overflowuid",
1502 .data = &fs_overflowuid,
1503 .maxlen = sizeof(int),
1504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001505 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .extra1 = &minolduid,
1507 .extra2 = &maxolduid,
1508 },
1509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 .procname = "overflowgid",
1511 .data = &fs_overflowgid,
1512 .maxlen = sizeof(int),
1513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001514 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 .extra1 = &minolduid,
1516 .extra2 = &maxolduid,
1517 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001518#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520 .procname = "leases-enable",
1521 .data = &leases_enable,
1522 .maxlen = sizeof(int),
1523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001524 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001526#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527#ifdef CONFIG_DNOTIFY
1528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 .procname = "dir-notify-enable",
1530 .data = &dir_notify_enable,
1531 .maxlen = sizeof(int),
1532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 },
1535#endif
1536#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001537#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 .procname = "lease-break-time",
1540 .data = &lease_break_time,
1541 .maxlen = sizeof(int),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001545#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001546#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 .procname = "aio-nr",
1549 .data = &aio_nr,
1550 .maxlen = sizeof(aio_nr),
1551 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 },
1554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 .procname = "aio-max-nr",
1556 .data = &aio_max_nr,
1557 .maxlen = sizeof(aio_max_nr),
1558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001559 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001561#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001562#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001563 {
Robert Love0399cb02005-07-13 12:38:18 -04001564 .procname = "inotify",
1565 .mode = 0555,
1566 .child = inotify_table,
1567 },
1568#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001569#ifdef CONFIG_EPOLL
1570 {
1571 .procname = "epoll",
1572 .mode = 0555,
1573 .child = epoll_table,
1574 },
1575#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001577 {
Alan Coxd6e71142005-06-23 00:09:43 -07001578 .procname = "suid_dumpable",
1579 .data = &suid_dumpable,
1580 .maxlen = sizeof(int),
1581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001582 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001583 .extra1 = &zero,
1584 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001585 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001586#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1587 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001588 .procname = "binfmt_misc",
1589 .mode = 0555,
1590 .child = binfmt_misc_table,
1591 },
1592#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001593 {
Jens Axboeff9da692010-06-03 14:54:39 +02001594 .procname = "pipe-max-size",
1595 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001596 .maxlen = sizeof(int),
1597 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001598 .proc_handler = &pipe_proc_fn,
1599 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001600 },
Willy Tarreau53b4f1f2016-01-18 16:36:09 +01001601 {
1602 .procname = "pipe-user-pages-hard",
1603 .data = &pipe_user_pages_hard,
1604 .maxlen = sizeof(pipe_user_pages_hard),
1605 .mode = 0644,
1606 .proc_handler = proc_doulongvec_minmax,
1607 },
1608 {
1609 .procname = "pipe-user-pages-soft",
1610 .data = &pipe_user_pages_soft,
1611 .maxlen = sizeof(pipe_user_pages_soft),
1612 .mode = 0644,
1613 .proc_handler = proc_doulongvec_minmax,
1614 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001615 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001616};
1617
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001618static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001619#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001620 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001621 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001622 .procname = "exception-trace",
1623 .data = &show_unhandled_signals,
1624 .maxlen = sizeof(int),
1625 .mode = 0644,
1626 .proc_handler = proc_dointvec
1627 },
1628#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001629#if defined(CONFIG_OPTPROBES)
1630 {
1631 .procname = "kprobes-optimization",
1632 .data = &sysctl_kprobes_optimization,
1633 .maxlen = sizeof(int),
1634 .mode = 0644,
1635 .proc_handler = proc_kprobes_optimization_handler,
1636 .extra1 = &zero,
1637 .extra2 = &one,
1638 },
1639#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001640 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641};
1642
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001643static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001644 { }
Robert Love0eeca282005-07-12 17:06:03 -04001645};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001647int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001648{
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001649 register_sysctl_table(sysctl_base_table);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001650 return 0;
1651}
1652
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001653#endif /* CONFIG_SYSCTL */
1654
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655/*
1656 * /proc/sys support
1657 */
1658
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001659#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001661static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001662 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001663 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001664{
1665 size_t len;
1666 char __user *p;
1667 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001668
1669 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001670 *lenp = 0;
1671 return 0;
1672 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001673
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001674 if (write) {
1675 len = 0;
1676 p = buffer;
1677 while (len < *lenp) {
1678 if (get_user(c, p++))
1679 return -EFAULT;
1680 if (c == 0 || c == '\n')
1681 break;
1682 len++;
1683 }
1684 if (len >= maxlen)
1685 len = maxlen-1;
1686 if(copy_from_user(data, buffer, len))
1687 return -EFAULT;
1688 ((char *) data)[len] = 0;
1689 *ppos += *lenp;
1690 } else {
1691 len = strlen(data);
1692 if (len > maxlen)
1693 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001694
1695 if (*ppos > len) {
1696 *lenp = 0;
1697 return 0;
1698 }
1699
1700 data += *ppos;
1701 len -= *ppos;
1702
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001703 if (len > *lenp)
1704 len = *lenp;
1705 if (len)
1706 if(copy_to_user(buffer, data, len))
1707 return -EFAULT;
1708 if (len < *lenp) {
1709 if(put_user('\n', ((char __user *) buffer) + len))
1710 return -EFAULT;
1711 len++;
1712 }
1713 *lenp = len;
1714 *ppos += len;
1715 }
1716 return 0;
1717}
1718
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719/**
1720 * proc_dostring - read a string sysctl
1721 * @table: the sysctl table
1722 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001723 * @buffer: the user buffer
1724 * @lenp: the size of the user buffer
1725 * @ppos: file position
1726 *
1727 * Reads/writes a string from/to the user buffer. If the kernel
1728 * buffer provided is not large enough to hold the string, the
1729 * string is truncated. The copied string is %NULL-terminated.
1730 * If the string is being read by the user process, it is copied
1731 * and a newline '\n' is added. It is truncated if the buffer is
1732 * not large enough.
1733 *
1734 * Returns 0 on success.
1735 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001736int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 void __user *buffer, size_t *lenp, loff_t *ppos)
1738{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001739 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001740 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741}
1742
Amerigo Wang00b7c332010-05-05 00:26:45 +00001743static size_t proc_skip_spaces(char **buf)
1744{
1745 size_t ret;
1746 char *tmp = skip_spaces(*buf);
1747 ret = tmp - *buf;
1748 *buf = tmp;
1749 return ret;
1750}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001752static void proc_skip_char(char **buf, size_t *size, const char v)
1753{
1754 while (*size) {
1755 if (**buf != v)
1756 break;
1757 (*size)--;
1758 (*buf)++;
1759 }
1760}
1761
Amerigo Wang00b7c332010-05-05 00:26:45 +00001762#define TMPBUFLEN 22
1763/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001764 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001765 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001766 * @buf: a kernel buffer
1767 * @size: size of the kernel buffer
1768 * @val: this is where the number will be stored
1769 * @neg: set to %TRUE if number is negative
1770 * @perm_tr: a vector which contains the allowed trailers
1771 * @perm_tr_len: size of the perm_tr vector
1772 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001773 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001774 * In case of success %0 is returned and @buf and @size are updated with
1775 * the amount of bytes read. If @tr is non-NULL and a trailing
1776 * character exists (size is non-zero after returning from this
1777 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001778 */
1779static int proc_get_long(char **buf, size_t *size,
1780 unsigned long *val, bool *neg,
1781 const char *perm_tr, unsigned perm_tr_len, char *tr)
1782{
1783 int len;
1784 char *p, tmp[TMPBUFLEN];
1785
1786 if (!*size)
1787 return -EINVAL;
1788
1789 len = *size;
1790 if (len > TMPBUFLEN - 1)
1791 len = TMPBUFLEN - 1;
1792
1793 memcpy(tmp, *buf, len);
1794
1795 tmp[len] = 0;
1796 p = tmp;
1797 if (*p == '-' && *size > 1) {
1798 *neg = true;
1799 p++;
1800 } else
1801 *neg = false;
1802 if (!isdigit(*p))
1803 return -EINVAL;
1804
1805 *val = simple_strtoul(p, &p, 0);
1806
1807 len = p - tmp;
1808
1809 /* We don't know if the next char is whitespace thus we may accept
1810 * invalid integers (e.g. 1234...a) or two integers instead of one
1811 * (e.g. 123...1). So lets not allow such large numbers. */
1812 if (len == TMPBUFLEN - 1)
1813 return -EINVAL;
1814
1815 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1816 return -EINVAL;
1817
1818 if (tr && (len < *size))
1819 *tr = *p;
1820
1821 *buf += len;
1822 *size -= len;
1823
1824 return 0;
1825}
1826
1827/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001828 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001829 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001830 * @buf: the user buffer
1831 * @size: the size of the user buffer
1832 * @val: the integer to be converted
1833 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001834 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001835 * In case of success %0 is returned and @buf and @size are updated with
1836 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001837 */
1838static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1839 bool neg)
1840{
1841 int len;
1842 char tmp[TMPBUFLEN], *p = tmp;
1843
1844 sprintf(p, "%s%lu", neg ? "-" : "", val);
1845 len = strlen(tmp);
1846 if (len > *size)
1847 len = *size;
1848 if (copy_to_user(*buf, tmp, len))
1849 return -EFAULT;
1850 *size -= len;
1851 *buf += len;
1852 return 0;
1853}
1854#undef TMPBUFLEN
1855
1856static int proc_put_char(void __user **buf, size_t *size, char c)
1857{
1858 if (*size) {
1859 char __user **buffer = (char __user **)buf;
1860 if (put_user(c, *buffer))
1861 return -EFAULT;
1862 (*size)--, (*buffer)++;
1863 *buf = *buffer;
1864 }
1865 return 0;
1866}
1867
1868static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 int *valp,
1870 int write, void *data)
1871{
1872 if (write) {
1873 *valp = *negp ? -*lvalp : *lvalp;
1874 } else {
1875 int val = *valp;
1876 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001877 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 *lvalp = (unsigned long)-val;
1879 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001880 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881 *lvalp = (unsigned long)val;
1882 }
1883 }
1884 return 0;
1885}
1886
Amerigo Wang00b7c332010-05-05 00:26:45 +00001887static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1888
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001889static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001890 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001891 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001892 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 int write, void *data),
1894 void *data)
1895{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001896 int *i, vleft, first = 1, err = 0;
1897 unsigned long page = 0;
1898 size_t left;
1899 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900
Amerigo Wang00b7c332010-05-05 00:26:45 +00001901 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902 *lenp = 0;
1903 return 0;
1904 }
1905
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001906 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 vleft = table->maxlen / sizeof(*i);
1908 left = *lenp;
1909
1910 if (!conv)
1911 conv = do_proc_dointvec_conv;
1912
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001914 if (left > PAGE_SIZE - 1)
1915 left = PAGE_SIZE - 1;
1916 page = __get_free_page(GFP_TEMPORARY);
1917 kbuf = (char *) page;
1918 if (!kbuf)
1919 return -ENOMEM;
1920 if (copy_from_user(kbuf, buffer, left)) {
1921 err = -EFAULT;
1922 goto free;
1923 }
1924 kbuf[left] = 0;
1925 }
1926
1927 for (; left && vleft--; i++, first=0) {
1928 unsigned long lval;
1929 bool neg;
1930
1931 if (write) {
1932 left -= proc_skip_spaces(&kbuf);
1933
J. R. Okajima563b0462010-05-25 16:10:14 -07001934 if (!left)
1935 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001936 err = proc_get_long(&kbuf, &left, &lval, &neg,
1937 proc_wspace_sep,
1938 sizeof(proc_wspace_sep), NULL);
1939 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001941 if (conv(&neg, &lval, i, 1, data)) {
1942 err = -EINVAL;
1943 break;
1944 }
1945 } else {
1946 if (conv(&neg, &lval, i, 0, data)) {
1947 err = -EINVAL;
1948 break;
1949 }
1950 if (!first)
1951 err = proc_put_char(&buffer, &left, '\t');
1952 if (err)
1953 break;
1954 err = proc_put_long(&buffer, &left, lval, neg);
1955 if (err)
1956 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 }
1958 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00001959
1960 if (!write && !first && left && !err)
1961 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07001962 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00001963 left -= proc_skip_spaces(&kbuf);
1964free:
1965 if (write) {
1966 free_page(page);
1967 if (first)
1968 return err ? : -EINVAL;
1969 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970 *lenp -= left;
1971 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00001972 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973}
1974
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001975static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001976 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001977 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001978 int write, void *data),
1979 void *data)
1980{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001981 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001982 buffer, lenp, ppos, conv, data);
1983}
1984
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985/**
1986 * proc_dointvec - read a vector of integers
1987 * @table: the sysctl table
1988 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001989 * @buffer: the user buffer
1990 * @lenp: the size of the user buffer
1991 * @ppos: file position
1992 *
1993 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1994 * values from/to the user buffer, treated as an ASCII string.
1995 *
1996 * Returns 0 on success.
1997 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001998int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 void __user *buffer, size_t *lenp, loff_t *ppos)
2000{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002001 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 NULL,NULL);
2003}
2004
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002005/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002006 * Taint values can only be increased
2007 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002008 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002009static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002010 void __user *buffer, size_t *lenp, loff_t *ppos)
2011{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002012 struct ctl_table t;
2013 unsigned long tmptaint = get_taint();
2014 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002015
Bastian Blank91fcd412007-04-23 14:41:14 -07002016 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002017 return -EPERM;
2018
Andi Kleen25ddbb12008-10-15 22:01:41 -07002019 t = *table;
2020 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002021 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002022 if (err < 0)
2023 return err;
2024
2025 if (write) {
2026 /*
2027 * Poor man's atomic or. Not worth adding a primitive
2028 * to everyone's atomic.h for this
2029 */
2030 int i;
2031 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2032 if ((tmptaint >> i) & 1)
2033 add_taint(i);
2034 }
2035 }
2036
2037 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002038}
2039
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002040#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002041static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002042 void __user *buffer, size_t *lenp, loff_t *ppos)
2043{
2044 if (write && !capable(CAP_SYS_ADMIN))
2045 return -EPERM;
2046
2047 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2048}
2049#endif
2050
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051struct do_proc_dointvec_minmax_conv_param {
2052 int *min;
2053 int *max;
2054};
2055
Amerigo Wang00b7c332010-05-05 00:26:45 +00002056static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2057 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058 int write, void *data)
2059{
2060 struct do_proc_dointvec_minmax_conv_param *param = data;
2061 if (write) {
2062 int val = *negp ? -*lvalp : *lvalp;
2063 if ((param->min && *param->min > val) ||
2064 (param->max && *param->max < val))
2065 return -EINVAL;
2066 *valp = val;
2067 } else {
2068 int val = *valp;
2069 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002070 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071 *lvalp = (unsigned long)-val;
2072 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002073 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 *lvalp = (unsigned long)val;
2075 }
2076 }
2077 return 0;
2078}
2079
2080/**
2081 * proc_dointvec_minmax - read a vector of integers with min/max values
2082 * @table: the sysctl table
2083 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 * @buffer: the user buffer
2085 * @lenp: the size of the user buffer
2086 * @ppos: file position
2087 *
2088 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2089 * values from/to the user buffer, treated as an ASCII string.
2090 *
2091 * This routine will ensure the values are within the range specified by
2092 * table->extra1 (min) and table->extra2 (max).
2093 *
2094 * Returns 0 on success.
2095 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002096int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 void __user *buffer, size_t *lenp, loff_t *ppos)
2098{
2099 struct do_proc_dointvec_minmax_conv_param param = {
2100 .min = (int *) table->extra1,
2101 .max = (int *) table->extra2,
2102 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002103 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104 do_proc_dointvec_minmax_conv, &param);
2105}
2106
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002107static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 void __user *buffer,
2109 size_t *lenp, loff_t *ppos,
2110 unsigned long convmul,
2111 unsigned long convdiv)
2112{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002113 unsigned long *i, *min, *max;
2114 int vleft, first = 1, err = 0;
2115 unsigned long page = 0;
2116 size_t left;
2117 char *kbuf;
2118
2119 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120 *lenp = 0;
2121 return 0;
2122 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002123
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002124 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 min = (unsigned long *) table->extra1;
2126 max = (unsigned long *) table->extra2;
2127 vleft = table->maxlen / sizeof(unsigned long);
2128 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002129
2130 if (write) {
2131 if (left > PAGE_SIZE - 1)
2132 left = PAGE_SIZE - 1;
2133 page = __get_free_page(GFP_TEMPORARY);
2134 kbuf = (char *) page;
2135 if (!kbuf)
2136 return -ENOMEM;
2137 if (copy_from_user(kbuf, buffer, left)) {
2138 err = -EFAULT;
2139 goto free;
2140 }
2141 kbuf[left] = 0;
2142 }
2143
Eric Dumazet27b3d802010-10-07 12:59:29 -07002144 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002145 unsigned long val;
2146
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002148 bool neg;
2149
2150 left -= proc_skip_spaces(&kbuf);
2151
2152 err = proc_get_long(&kbuf, &left, &val, &neg,
2153 proc_wspace_sep,
2154 sizeof(proc_wspace_sep), NULL);
2155 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002156 break;
2157 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 continue;
2159 if ((min && val < *min) || (max && val > *max))
2160 continue;
2161 *i = val;
2162 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002163 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002165 err = proc_put_char(&buffer, &left, '\t');
2166 err = proc_put_long(&buffer, &left, val, false);
2167 if (err)
2168 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169 }
2170 }
2171
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 if (!write && !first && left && !err)
2173 err = proc_put_char(&buffer, &left, '\n');
2174 if (write && !err)
2175 left -= proc_skip_spaces(&kbuf);
2176free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002178 free_page(page);
2179 if (first)
2180 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 *lenp -= left;
2183 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002184 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185}
2186
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002187static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002188 void __user *buffer,
2189 size_t *lenp, loff_t *ppos,
2190 unsigned long convmul,
2191 unsigned long convdiv)
2192{
2193 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002194 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002195}
2196
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197/**
2198 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2199 * @table: the sysctl table
2200 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 * @buffer: the user buffer
2202 * @lenp: the size of the user buffer
2203 * @ppos: file position
2204 *
2205 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2206 * values from/to the user buffer, treated as an ASCII string.
2207 *
2208 * This routine will ensure the values are within the range specified by
2209 * table->extra1 (min) and table->extra2 (max).
2210 *
2211 * Returns 0 on success.
2212 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002213int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214 void __user *buffer, size_t *lenp, loff_t *ppos)
2215{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002216 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217}
2218
2219/**
2220 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2221 * @table: the sysctl table
2222 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223 * @buffer: the user buffer
2224 * @lenp: the size of the user buffer
2225 * @ppos: file position
2226 *
2227 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2228 * values from/to the user buffer, treated as an ASCII string. The values
2229 * are treated as milliseconds, and converted to jiffies when they are stored.
2230 *
2231 * This routine will ensure the values are within the range specified by
2232 * table->extra1 (min) and table->extra2 (max).
2233 *
2234 * Returns 0 on success.
2235 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002236int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002237 void __user *buffer,
2238 size_t *lenp, loff_t *ppos)
2239{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002240 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241 lenp, ppos, HZ, 1000l);
2242}
2243
2244
Amerigo Wang00b7c332010-05-05 00:26:45 +00002245static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 int *valp,
2247 int write, void *data)
2248{
2249 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002250 if (*lvalp > LONG_MAX / HZ)
2251 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2253 } else {
2254 int val = *valp;
2255 unsigned long lval;
2256 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002257 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258 lval = (unsigned long)-val;
2259 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002260 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 lval = (unsigned long)val;
2262 }
2263 *lvalp = lval / HZ;
2264 }
2265 return 0;
2266}
2267
Amerigo Wang00b7c332010-05-05 00:26:45 +00002268static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269 int *valp,
2270 int write, void *data)
2271{
2272 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002273 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2274 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2276 } else {
2277 int val = *valp;
2278 unsigned long lval;
2279 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002280 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 lval = (unsigned long)-val;
2282 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002283 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284 lval = (unsigned long)val;
2285 }
2286 *lvalp = jiffies_to_clock_t(lval);
2287 }
2288 return 0;
2289}
2290
Amerigo Wang00b7c332010-05-05 00:26:45 +00002291static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 int *valp,
2293 int write, void *data)
2294{
2295 if (write) {
2296 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2297 } else {
2298 int val = *valp;
2299 unsigned long lval;
2300 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002301 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 lval = (unsigned long)-val;
2303 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002304 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 lval = (unsigned long)val;
2306 }
2307 *lvalp = jiffies_to_msecs(lval);
2308 }
2309 return 0;
2310}
2311
2312/**
2313 * proc_dointvec_jiffies - read a vector of integers as seconds
2314 * @table: the sysctl table
2315 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 * @buffer: the user buffer
2317 * @lenp: the size of the user buffer
2318 * @ppos: file position
2319 *
2320 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2321 * values from/to the user buffer, treated as an ASCII string.
2322 * The values read are assumed to be in seconds, and are converted into
2323 * jiffies.
2324 *
2325 * Returns 0 on success.
2326 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002327int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 void __user *buffer, size_t *lenp, loff_t *ppos)
2329{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002330 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 do_proc_dointvec_jiffies_conv,NULL);
2332}
2333
2334/**
2335 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2336 * @table: the sysctl table
2337 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 * @buffer: the user buffer
2339 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002340 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 *
2342 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2343 * values from/to the user buffer, treated as an ASCII string.
2344 * The values read are assumed to be in 1/USER_HZ seconds, and
2345 * are converted into jiffies.
2346 *
2347 * Returns 0 on success.
2348 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002349int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 void __user *buffer, size_t *lenp, loff_t *ppos)
2351{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002352 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 do_proc_dointvec_userhz_jiffies_conv,NULL);
2354}
2355
2356/**
2357 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2358 * @table: the sysctl table
2359 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 * @buffer: the user buffer
2361 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002362 * @ppos: file position
2363 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 *
2365 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2366 * values from/to the user buffer, treated as an ASCII string.
2367 * The values read are assumed to be in 1/1000 seconds, and
2368 * are converted into jiffies.
2369 *
2370 * Returns 0 on success.
2371 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002372int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373 void __user *buffer, size_t *lenp, loff_t *ppos)
2374{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002375 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 do_proc_dointvec_ms_jiffies_conv, NULL);
2377}
2378
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002379static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002380 void __user *buffer, size_t *lenp, loff_t *ppos)
2381{
2382 struct pid *new_pid;
2383 pid_t tmp;
2384 int r;
2385
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002386 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002387
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002388 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002389 lenp, ppos, NULL, NULL);
2390 if (r || !write)
2391 return r;
2392
2393 new_pid = find_get_pid(tmp);
2394 if (!new_pid)
2395 return -ESRCH;
2396
2397 put_pid(xchg(&cad_pid, new_pid));
2398 return 0;
2399}
2400
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002401/**
2402 * proc_do_large_bitmap - read/write from/to a large bitmap
2403 * @table: the sysctl table
2404 * @write: %TRUE if this is a write to the sysctl file
2405 * @buffer: the user buffer
2406 * @lenp: the size of the user buffer
2407 * @ppos: file position
2408 *
2409 * The bitmap is stored at table->data and the bitmap length (in bits)
2410 * in table->maxlen.
2411 *
2412 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2413 * large bitmaps may be represented in a compact manner. Writing into
2414 * the file will clear the bitmap then update it with the given input.
2415 *
2416 * Returns 0 on success.
2417 */
2418int proc_do_large_bitmap(struct ctl_table *table, int write,
2419 void __user *buffer, size_t *lenp, loff_t *ppos)
2420{
2421 int err = 0;
2422 bool first = 1;
2423 size_t left = *lenp;
2424 unsigned long bitmap_len = table->maxlen;
2425 unsigned long *bitmap = (unsigned long *) table->data;
2426 unsigned long *tmp_bitmap = NULL;
2427 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2428
2429 if (!bitmap_len || !left || (*ppos && !write)) {
2430 *lenp = 0;
2431 return 0;
2432 }
2433
2434 if (write) {
2435 unsigned long page = 0;
2436 char *kbuf;
2437
2438 if (left > PAGE_SIZE - 1)
2439 left = PAGE_SIZE - 1;
2440
2441 page = __get_free_page(GFP_TEMPORARY);
2442 kbuf = (char *) page;
2443 if (!kbuf)
2444 return -ENOMEM;
2445 if (copy_from_user(kbuf, buffer, left)) {
2446 free_page(page);
2447 return -EFAULT;
2448 }
2449 kbuf[left] = 0;
2450
2451 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2452 GFP_KERNEL);
2453 if (!tmp_bitmap) {
2454 free_page(page);
2455 return -ENOMEM;
2456 }
2457 proc_skip_char(&kbuf, &left, '\n');
2458 while (!err && left) {
2459 unsigned long val_a, val_b;
2460 bool neg;
2461
2462 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2463 sizeof(tr_a), &c);
2464 if (err)
2465 break;
2466 if (val_a >= bitmap_len || neg) {
2467 err = -EINVAL;
2468 break;
2469 }
2470
2471 val_b = val_a;
2472 if (left) {
2473 kbuf++;
2474 left--;
2475 }
2476
2477 if (c == '-') {
2478 err = proc_get_long(&kbuf, &left, &val_b,
2479 &neg, tr_b, sizeof(tr_b),
2480 &c);
2481 if (err)
2482 break;
2483 if (val_b >= bitmap_len || neg ||
2484 val_a > val_b) {
2485 err = -EINVAL;
2486 break;
2487 }
2488 if (left) {
2489 kbuf++;
2490 left--;
2491 }
2492 }
2493
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002494 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002495 first = 0;
2496 proc_skip_char(&kbuf, &left, '\n');
2497 }
2498 free_page(page);
2499 } else {
2500 unsigned long bit_a, bit_b = 0;
2501
2502 while (left) {
2503 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2504 if (bit_a >= bitmap_len)
2505 break;
2506 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2507 bit_a + 1) - 1;
2508
2509 if (!first) {
2510 err = proc_put_char(&buffer, &left, ',');
2511 if (err)
2512 break;
2513 }
2514 err = proc_put_long(&buffer, &left, bit_a, false);
2515 if (err)
2516 break;
2517 if (bit_a != bit_b) {
2518 err = proc_put_char(&buffer, &left, '-');
2519 if (err)
2520 break;
2521 err = proc_put_long(&buffer, &left, bit_b, false);
2522 if (err)
2523 break;
2524 }
2525
2526 first = 0; bit_b++;
2527 }
2528 if (!err)
2529 err = proc_put_char(&buffer, &left, '\n');
2530 }
2531
2532 if (!err) {
2533 if (write) {
2534 if (*ppos)
2535 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2536 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002537 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002538 }
2539 kfree(tmp_bitmap);
2540 *lenp -= left;
2541 *ppos += *lenp;
2542 return 0;
2543 } else {
2544 kfree(tmp_bitmap);
2545 return err;
2546 }
2547}
2548
Jovi Zhang55610502011-01-12 17:00:45 -08002549#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002551int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 void __user *buffer, size_t *lenp, loff_t *ppos)
2553{
2554 return -ENOSYS;
2555}
2556
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002557int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558 void __user *buffer, size_t *lenp, loff_t *ppos)
2559{
2560 return -ENOSYS;
2561}
2562
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002563int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 void __user *buffer, size_t *lenp, loff_t *ppos)
2565{
2566 return -ENOSYS;
2567}
2568
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002569int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 void __user *buffer, size_t *lenp, loff_t *ppos)
2571{
2572 return -ENOSYS;
2573}
2574
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002575int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 void __user *buffer, size_t *lenp, loff_t *ppos)
2577{
2578 return -ENOSYS;
2579}
2580
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002581int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 void __user *buffer, size_t *lenp, loff_t *ppos)
2583{
2584 return -ENOSYS;
2585}
2586
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002587int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 void __user *buffer, size_t *lenp, loff_t *ppos)
2589{
2590 return -ENOSYS;
2591}
2592
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002593int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 void __user *buffer,
2595 size_t *lenp, loff_t *ppos)
2596{
2597 return -ENOSYS;
2598}
2599
2600
Jovi Zhang55610502011-01-12 17:00:45 -08002601#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603/*
2604 * No sense putting this after each symbol definition, twice,
2605 * exception granted :-)
2606 */
2607EXPORT_SYMBOL(proc_dointvec);
2608EXPORT_SYMBOL(proc_dointvec_jiffies);
2609EXPORT_SYMBOL(proc_dointvec_minmax);
2610EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2611EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2612EXPORT_SYMBOL(proc_dostring);
2613EXPORT_SYMBOL(proc_doulongvec_minmax);
2614EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);