blob: ca38e8e3e907557f74faaad7ddb57d330bd43d2d [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>
Dave Youngd33ed522010-03-10 15:23:59 -080026#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070028#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020030#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070031#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/init.h>
33#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010034#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030035#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020039#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070040#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070043#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/times.h>
45#include <linux/limits.h>
46#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020047#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070049#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080050#include <linux/nfs_fs.h>
51#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070052#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020053#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020054#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050055#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020056#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070057#include <linux/oom.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59#include <asm/uaccess.h>
60#include <asm/processor.h>
61
Andi Kleen29cbc782006-09-30 01:47:55 +020062#ifdef CONFIG_X86
63#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010064#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010065#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020066#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080067#ifdef CONFIG_BSD_PROCESS_ACCT
68#include <linux/acct.h>
69#endif
Dave Young4f0e0562010-03-10 15:24:09 -080070#ifdef CONFIG_RT_MUTEXES
71#include <linux/rtmutex.h>
72#endif
Dave Young2edf5e42010-03-10 15:24:10 -080073#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
74#include <linux/lockdep.h>
75#endif
Dave Young15485a42010-03-10 15:24:07 -080076#ifdef CONFIG_CHR_DEV_SG
77#include <scsi/sg.h>
78#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020079
Don Zickus58687ac2010-05-07 17:11:44 -040080#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050081#include <linux/nmi.h>
82#endif
83
Eric W. Biederman7058cb02007-10-18 03:05:58 -070084
Linus Torvalds1da177e2005-04-16 15:20:36 -070085#if defined(CONFIG_SYSCTL)
86
87/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088extern int sysctl_overcommit_memory;
89extern int sysctl_overcommit_ratio;
90extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070092extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070094extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern int pid_max;
96extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080098extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080099extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200100extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100101extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400102extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000103#ifndef CONFIG_MMU
104extern int sysctl_nr_trim_pages;
105#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200106#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200107extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200108#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700110/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400111#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700112static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200113static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700114#endif
115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700117static int __maybe_unused one = 1;
118static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800119static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700121#ifdef CONFIG_PRINTK
122static int ten_thousand = 10000;
123#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700125/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
126static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
129static int maxolduid = 65535;
130static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800131static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133static int ngroups_max = NGROUPS_MAX;
134
Dave Youngd14f1722010-02-25 20:28:57 -0500135#ifdef CONFIG_INOTIFY_USER
136#include <linux/inotify.h>
137#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700138#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700139#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140#endif
141
David S. Miller08714202008-11-16 23:49:24 -0800142#ifdef CONFIG_SPARC64
143extern int sysctl_tsb_ratio;
144#endif
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#ifdef __hppa__
147extern int pwrsw_enabled;
148extern int unaligned_enabled;
149#endif
150
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800151#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#ifdef CONFIG_MATHEMU
153extern int sysctl_ieee_emulation_warnings;
154#endif
155extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700156extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#endif
158
Jes Sorensend2b176e2006-02-28 09:42:23 -0800159#ifdef CONFIG_IA64
160extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800161extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800162#endif
163
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200164extern struct ratelimit_state printk_ratelimit_state;
165
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700166#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700167static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700168 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700169static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800170 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700171#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700172
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700173#ifdef CONFIG_MAGIC_SYSRQ
174static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */
175
176static int sysrq_sysctl_handler(ctl_table *table, int write,
177 void __user *buffer, size_t *lenp,
178 loff_t *ppos)
179{
180 int error;
181
182 error = proc_dointvec(table, write, buffer, lenp, ppos);
183 if (error)
184 return error;
185
186 if (write)
187 sysrq_toggle_support(__sysrq_enabled);
188
189 return 0;
190}
191
192#endif
193
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700194static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100195static struct ctl_table_root sysctl_table_root;
196static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100197 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100198 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400199 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100200 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400201 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100202};
203static struct ctl_table_root sysctl_table_root = {
204 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400205 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100206};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700208static struct ctl_table kern_table[];
209static struct ctl_table vm_table[];
210static struct ctl_table fs_table[];
211static struct ctl_table debug_table[];
212static struct ctl_table dev_table[];
213extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800214#ifdef CONFIG_EPOLL
215extern struct ctl_table epoll_table[];
216#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
219int sysctl_legacy_va_layout;
220#endif
221
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222/* The default sysctl tables: */
223
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700224static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 .procname = "kernel",
227 .mode = 0555,
228 .child = kern_table,
229 },
230 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 .procname = "vm",
232 .mode = 0555,
233 .child = vm_table,
234 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 .procname = "fs",
237 .mode = 0555,
238 .child = fs_table,
239 },
240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "debug",
242 .mode = 0555,
243 .child = debug_table,
244 },
245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "dev",
247 .mode = 0555,
248 .child = dev_table,
249 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700250/*
251 * NOTE: do not add new entries to this table unless you have read
252 * Documentation/sysctl/ctl_unnumbered.txt
253 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700254 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255};
256
Ingo Molnar77e54a12007-07-09 18:52:00 +0200257#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100258static int min_sched_granularity_ns = 100000; /* 100 usecs */
259static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
260static int min_wakeup_granularity_ns; /* 0 usecs */
261static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100262static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
263static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100264static int min_sched_shares_ratelimit = 100000; /* 100 usec */
265static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200266#endif
267
Mel Gorman5e771902010-05-24 14:32:31 -0700268#ifdef CONFIG_COMPACTION
269static int min_extfrag_threshold;
270static int max_extfrag_threshold = 1000;
271#endif
272
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700273static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200274 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200275 .procname = "sched_child_runs_first",
276 .data = &sysctl_sched_child_runs_first,
277 .maxlen = sizeof(unsigned int),
278 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800279 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200280 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281#ifdef CONFIG_SCHED_DEBUG
282 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100283 .procname = "sched_min_granularity_ns",
284 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800287 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100288 .extra1 = &min_sched_granularity_ns,
289 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200290 },
291 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200292 .procname = "sched_latency_ns",
293 .data = &sysctl_sched_latency,
294 .maxlen = sizeof(unsigned int),
295 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800296 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200297 .extra1 = &min_sched_granularity_ns,
298 .extra2 = &max_sched_granularity_ns,
299 },
300 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200301 .procname = "sched_wakeup_granularity_ns",
302 .data = &sysctl_sched_wakeup_granularity,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800305 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200306 .extra1 = &min_wakeup_granularity_ns,
307 .extra2 = &max_wakeup_granularity_ns,
308 },
309 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200310 .procname = "sched_shares_ratelimit",
311 .data = &sysctl_sched_shares_ratelimit,
312 .maxlen = sizeof(unsigned int),
313 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800314 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100315 .extra1 = &min_sched_shares_ratelimit,
316 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200317 },
318 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100319 .procname = "sched_tunable_scaling",
320 .data = &sysctl_sched_tunable_scaling,
321 .maxlen = sizeof(enum sched_tunable_scaling),
322 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800323 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100324 .extra1 = &min_sched_tunable_scaling,
325 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200326 },
327 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200328 .procname = "sched_shares_thresh",
329 .data = &sysctl_sched_shares_thresh,
330 .maxlen = sizeof(unsigned int),
331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800332 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200333 .extra1 = &zero,
334 },
335 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200336 .procname = "sched_migration_cost",
337 .data = &sysctl_sched_migration_cost,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800340 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200341 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100342 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100343 .procname = "sched_nr_migrate",
344 .data = &sysctl_sched_nr_migrate,
345 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800347 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100348 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530349 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200350 .procname = "sched_time_avg",
351 .data = &sysctl_sched_time_avg,
352 .maxlen = sizeof(unsigned int),
353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800354 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200355 },
356 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530357 .procname = "timer_migration",
358 .data = &sysctl_timer_migration,
359 .maxlen = sizeof(unsigned int),
360 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800361 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530362 .extra1 = &zero,
363 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530364 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200365#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200366 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100367 .procname = "sched_rt_period_us",
368 .data = &sysctl_sched_rt_period,
369 .maxlen = sizeof(unsigned int),
370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800371 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100372 },
373 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100374 .procname = "sched_rt_runtime_us",
375 .data = &sysctl_sched_rt_runtime,
376 .maxlen = sizeof(int),
377 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800378 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100379 },
380 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200381 .procname = "sched_compat_yield",
382 .data = &sysctl_sched_compat_yield,
383 .maxlen = sizeof(unsigned int),
384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800385 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200386 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700387#ifdef CONFIG_PROVE_LOCKING
388 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700389 .procname = "prove_locking",
390 .data = &prove_locking,
391 .maxlen = sizeof(int),
392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800393 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700394 },
395#endif
396#ifdef CONFIG_LOCK_STAT
397 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700398 .procname = "lock_stat",
399 .data = &lock_stat,
400 .maxlen = sizeof(int),
401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800402 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700403 },
404#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200405 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 .procname = "panic",
407 .data = &panic_timeout,
408 .maxlen = sizeof(int),
409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800410 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 },
412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 .procname = "core_uses_pid",
414 .data = &core_uses_pid,
415 .maxlen = sizeof(int),
416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800417 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 },
419 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 .procname = "core_pattern",
421 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700422 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800424 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 },
Neil Hormana2939802009-09-23 15:56:56 -0700426 {
Neil Hormana2939802009-09-23 15:56:56 -0700427 .procname = "core_pipe_limit",
428 .data = &core_pipe_limit,
429 .maxlen = sizeof(unsigned int),
430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800431 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700432 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800433#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700436 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800438 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800440#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100441#ifdef CONFIG_LATENCYTOP
442 {
443 .procname = "latencytop",
444 .data = &latencytop_enabled,
445 .maxlen = sizeof(int),
446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800447 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100448 },
449#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450#ifdef CONFIG_BLK_DEV_INITRD
451 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 .procname = "real-root-dev",
453 .data = &real_root_dev,
454 .maxlen = sizeof(int),
455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800456 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 },
458#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700459 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700460 .procname = "print-fatal-signals",
461 .data = &print_fatal_signals,
462 .maxlen = sizeof(int),
463 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800464 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700465 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700466#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 .procname = "reboot-cmd",
469 .data = reboot_command,
470 .maxlen = 256,
471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800472 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 },
474 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 .procname = "stop-a",
476 .data = &stop_a_enabled,
477 .maxlen = sizeof (int),
478 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800479 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 },
481 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .procname = "scons-poweroff",
483 .data = &scons_pwroff,
484 .maxlen = sizeof (int),
485 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800486 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 },
488#endif
David S. Miller08714202008-11-16 23:49:24 -0800489#ifdef CONFIG_SPARC64
490 {
David S. Miller08714202008-11-16 23:49:24 -0800491 .procname = "tsb-ratio",
492 .data = &sysctl_tsb_ratio,
493 .maxlen = sizeof (int),
494 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800495 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800496 },
497#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498#ifdef __hppa__
499 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 .procname = "soft-power",
501 .data = &pwrsw_enabled,
502 .maxlen = sizeof (int),
503 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800504 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 },
506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 .procname = "unaligned-trap",
508 .data = &unaligned_enabled,
509 .maxlen = sizeof (int),
510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800511 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 },
513#endif
514 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 .procname = "ctrl-alt-del",
516 .data = &C_A_D,
517 .maxlen = sizeof(int),
518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800519 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400521#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200522 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200523 .procname = "ftrace_enabled",
524 .data = &ftrace_enabled,
525 .maxlen = sizeof(int),
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200528 },
529#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500530#ifdef CONFIG_STACK_TRACER
531 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500532 .procname = "stack_tracer_enabled",
533 .data = &stack_tracer_enabled,
534 .maxlen = sizeof(int),
535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800536 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500537 },
538#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400539#ifdef CONFIG_TRACING
540 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100541 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400542 .data = &ftrace_dump_on_oops,
543 .maxlen = sizeof(int),
544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800545 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400546 },
547#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200548#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 .procname = "modprobe",
551 .data = &modprobe_path,
552 .maxlen = KMOD_PATH_LEN,
553 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800554 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 },
Kees Cook3d433212009-04-02 15:49:29 -0700556 {
Kees Cook3d433212009-04-02 15:49:29 -0700557 .procname = "modules_disabled",
558 .data = &modules_disabled,
559 .maxlen = sizeof(int),
560 .mode = 0644,
561 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700563 .extra1 = &one,
564 .extra2 = &one,
565 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100567#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100570 .data = &uevent_helper,
571 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
575#endif
576#ifdef CONFIG_CHR_DEV_SG
577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "sg-big-buff",
579 .data = &sg_big_buff,
580 .maxlen = sizeof (int),
581 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
584#endif
585#ifdef CONFIG_BSD_PROCESS_ACCT
586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "acct",
588 .data = &acct_parm,
589 .maxlen = 3*sizeof(int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
593#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594#ifdef CONFIG_MAGIC_SYSRQ
595 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800597 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 .maxlen = sizeof (int),
599 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700600 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 },
602#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700603#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700606 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .maxlen = sizeof (int),
608 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800609 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700611#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 .procname = "threads-max",
614 .data = &max_threads,
615 .maxlen = sizeof(int),
616 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 },
619 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 .procname = "random",
621 .mode = 0555,
622 .child = random_table,
623 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "overflowuid",
626 .data = &overflowuid,
627 .maxlen = sizeof(int),
628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .extra1 = &minolduid,
631 .extra2 = &maxolduid,
632 },
633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "overflowgid",
635 .data = &overflowgid,
636 .maxlen = sizeof(int),
637 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800638 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .extra1 = &minolduid,
640 .extra2 = &maxolduid,
641 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800642#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643#ifdef CONFIG_MATHEMU
644 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 .procname = "ieee_emulation_warnings",
646 .data = &sysctl_ieee_emulation_warnings,
647 .maxlen = sizeof(int),
648 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800649 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 },
651#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200654 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .maxlen = sizeof(int),
656 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800657 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 },
659#endif
660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "pid_max",
662 .data = &pid_max,
663 .maxlen = sizeof (int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 .extra1 = &pid_max_min,
667 .extra2 = &pid_max_max,
668 },
669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .procname = "panic_on_oops",
671 .data = &panic_on_oops,
672 .maxlen = sizeof(int),
673 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800674 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800676#if defined CONFIG_PRINTK
677 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800678 .procname = "printk",
679 .data = &console_loglevel,
680 .maxlen = 4*sizeof(int),
681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800682 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800683 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700686 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .maxlen = sizeof(int),
688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 },
691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700693 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .maxlen = sizeof(int),
695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800696 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 },
Dave Youngaf913222009-09-22 16:43:33 -0700698 {
Dave Youngaf913222009-09-22 16:43:33 -0700699 .procname = "printk_delay",
700 .data = &printk_delay_msec,
701 .maxlen = sizeof(int),
702 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800703 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700704 .extra1 = &zero,
705 .extra2 = &ten_thousand,
706 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800707#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "ngroups_max",
710 .data = &ngroups_max,
711 .maxlen = sizeof (int),
712 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 },
Don Zickus58687ac2010-05-07 17:11:44 -0400715#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500716 {
Don Zickus58687ac2010-05-07 17:11:44 -0400717 .procname = "watchdog",
718 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500719 .maxlen = sizeof (int),
720 .mode = 0644,
Don Zickus58687ac2010-05-07 17:11:44 -0400721 .proc_handler = proc_dowatchdog_enabled,
722 },
723 {
724 .procname = "watchdog_thresh",
725 .data = &softlockup_thresh,
726 .maxlen = sizeof(int),
727 .mode = 0644,
728 .proc_handler = proc_dowatchdog_thresh,
729 .extra1 = &neg_one,
730 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500731 },
Don Zickus2508ce12010-05-07 17:11:46 -0400732 {
733 .procname = "softlockup_panic",
734 .data = &softlockup_panic,
735 .maxlen = sizeof(int),
736 .mode = 0644,
737 .proc_handler = proc_dointvec_minmax,
738 .extra1 = &zero,
739 .extra2 = &one,
740 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500741#endif
Don Zickus58687ac2010-05-07 17:11:44 -0400742#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) && !defined(CONFIG_LOCKUP_DETECTOR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .procname = "unknown_nmi_panic",
745 .data = &unknown_nmi_panic,
746 .maxlen = sizeof (int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 },
Don Zickus407984f2006-09-26 10:52:27 +0200750 {
Don Zickus407984f2006-09-26 10:52:27 +0200751 .procname = "nmi_watchdog",
752 .data = &nmi_watchdog_enabled,
753 .maxlen = sizeof (int),
754 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800755 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 },
757#endif
758#if defined(CONFIG_X86)
759 {
Don Zickus8da5add2006-09-26 10:52:27 +0200760 .procname = "panic_on_unrecovered_nmi",
761 .data = &panic_on_unrecovered_nmi,
762 .maxlen = sizeof(int),
763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200765 },
766 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700767 .procname = "panic_on_io_nmi",
768 .data = &panic_on_io_nmi,
769 .maxlen = sizeof(int),
770 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800771 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700772 },
773 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 .procname = "bootloader_type",
775 .data = &bootloader_type,
776 .maxlen = sizeof (int),
777 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800778 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100780 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700781 .procname = "bootloader_version",
782 .data = &bootloader_version,
783 .maxlen = sizeof (int),
784 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700786 },
787 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100788 .procname = "kstack_depth_to_print",
789 .data = &kstack_depth_to_print,
790 .maxlen = sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100793 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100794 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100795 .procname = "io_delay_type",
796 .data = &io_delay_type,
797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100800 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800802#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 .procname = "randomize_va_space",
805 .data = &randomize_va_space,
806 .maxlen = sizeof(int),
807 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800808 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800810#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800811#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700812 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700813 .procname = "spin_retry",
814 .data = &spin_retry,
815 .maxlen = sizeof (int),
816 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800817 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700818 },
819#endif
Len Brown673d5b42007-07-28 03:33:16 -0400820#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800821 {
Pavel Machekc255d842006-02-20 18:27:58 -0800822 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700823 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800824 .maxlen = sizeof (unsigned long),
825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800827 },
828#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800829#ifdef CONFIG_IA64
830 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800831 .procname = "ignore-unaligned-usertrap",
832 .data = &no_unaligned_warning,
833 .maxlen = sizeof (int),
834 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800835 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800836 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800837 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800838 .procname = "unaligned-dump-stack",
839 .data = &unaligned_dump_stack,
840 .maxlen = sizeof (int),
841 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800842 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800843 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800844#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800845#ifdef CONFIG_DETECT_HUNG_TASK
846 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800847 .procname = "hung_task_panic",
848 .data = &sysctl_hung_task_panic,
849 .maxlen = sizeof(int),
850 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800851 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800852 .extra1 = &zero,
853 .extra2 = &one,
854 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100855 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100856 .procname = "hung_task_check_count",
857 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100858 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100859 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800860 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100861 },
862 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100863 .procname = "hung_task_timeout_secs",
864 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100865 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100866 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800867 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100868 },
869 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100870 .procname = "hung_task_warnings",
871 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100872 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100873 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800874 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100875 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700876#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200877#ifdef CONFIG_COMPAT
878 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200879 .procname = "compat-log",
880 .data = &compat_log,
881 .maxlen = sizeof (int),
882 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800883 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200884 },
885#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700886#ifdef CONFIG_RT_MUTEXES
887 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700888 .procname = "max_lock_depth",
889 .data = &max_lock_depth,
890 .maxlen = sizeof(int),
891 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800892 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700893 },
894#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700895 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700896 .procname = "poweroff_cmd",
897 .data = &poweroff_cmd,
898 .maxlen = POWEROFF_CMD_PATH_LEN,
899 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800900 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700901 },
David Howells0b77f5b2008-04-29 01:01:32 -0700902#ifdef CONFIG_KEYS
903 {
David Howells0b77f5b2008-04-29 01:01:32 -0700904 .procname = "keys",
905 .mode = 0555,
906 .child = key_sysctls,
907 },
908#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700909#ifdef CONFIG_RCU_TORTURE_TEST
910 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700911 .procname = "rcutorture_runnable",
912 .data = &rcutorture_runnable,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700916 },
917#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200918#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200919 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200920 .procname = "perf_event_paranoid",
921 .data = &sysctl_perf_event_paranoid,
922 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200925 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200926 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200927 .procname = "perf_event_mlock_kb",
928 .data = &sysctl_perf_event_mlock,
929 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200930 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800931 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200932 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200933 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200934 .procname = "perf_event_max_sample_rate",
935 .data = &sysctl_perf_event_sample_rate,
936 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200939 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200940#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200941#ifdef CONFIG_KMEMCHECK
942 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200943 .procname = "kmemcheck",
944 .data = &kmemcheck_enabled,
945 .maxlen = sizeof(int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200948 },
949#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200950#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200951 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200952 .procname = "blk_iopoll",
953 .data = &blk_iopoll_enabled,
954 .maxlen = sizeof(int),
955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800956 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200957 },
Jens Axboecb684b52009-09-15 21:53:11 +0200958#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700959/*
960 * NOTE: do not add new entries to this table unless you have read
961 * Documentation/sysctl/ctl_unnumbered.txt
962 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700963 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964};
965
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700966static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 .procname = "overcommit_memory",
969 .data = &sysctl_overcommit_memory,
970 .maxlen = sizeof(sysctl_overcommit_memory),
971 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800972 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 },
974 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700975 .procname = "panic_on_oom",
976 .data = &sysctl_panic_on_oom,
977 .maxlen = sizeof(sysctl_panic_on_oom),
978 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800979 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700980 },
981 {
David Rientjesfe071d72007-10-16 23:25:56 -0700982 .procname = "oom_kill_allocating_task",
983 .data = &sysctl_oom_kill_allocating_task,
984 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
985 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800986 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700987 },
988 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800989 .procname = "oom_dump_tasks",
990 .data = &sysctl_oom_dump_tasks,
991 .maxlen = sizeof(sysctl_oom_dump_tasks),
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800994 },
995 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 .procname = "overcommit_ratio",
997 .data = &sysctl_overcommit_ratio,
998 .maxlen = sizeof(sysctl_overcommit_ratio),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 },
1002 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 .procname = "page-cluster",
1004 .data = &page_cluster,
1005 .maxlen = sizeof(int),
1006 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001007 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 },
1009 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 .procname = "dirty_background_ratio",
1011 .data = &dirty_background_ratio,
1012 .maxlen = sizeof(dirty_background_ratio),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 .extra1 = &zero,
1016 .extra2 = &one_hundred,
1017 },
1018 {
David Rientjes2da02992009-01-06 14:39:31 -08001019 .procname = "dirty_background_bytes",
1020 .data = &dirty_background_bytes,
1021 .maxlen = sizeof(dirty_background_bytes),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001024 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001025 },
1026 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 .procname = "dirty_ratio",
1028 .data = &vm_dirty_ratio,
1029 .maxlen = sizeof(vm_dirty_ratio),
1030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 .extra1 = &zero,
1033 .extra2 = &one_hundred,
1034 },
1035 {
David Rientjes2da02992009-01-06 14:39:31 -08001036 .procname = "dirty_bytes",
1037 .data = &vm_dirty_bytes,
1038 .maxlen = sizeof(vm_dirty_bytes),
1039 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001040 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001041 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001042 },
1043 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001045 .data = &dirty_writeback_interval,
1046 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001048 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 },
1050 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001052 .data = &dirty_expire_interval,
1053 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001055 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 },
1057 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 .procname = "nr_pdflush_threads",
1059 .data = &nr_pdflush_threads,
1060 .maxlen = sizeof nr_pdflush_threads,
1061 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001062 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 },
1064 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 .procname = "swappiness",
1066 .data = &vm_swappiness,
1067 .maxlen = sizeof(vm_swappiness),
1068 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001069 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 .extra1 = &zero,
1071 .extra2 = &one_hundred,
1072 },
1073#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001074 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001076 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 .maxlen = sizeof(unsigned long),
1078 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001079 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 .extra1 = (void *)&hugetlb_zero,
1081 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001082 },
1083#ifdef CONFIG_NUMA
1084 {
1085 .procname = "nr_hugepages_mempolicy",
1086 .data = NULL,
1087 .maxlen = sizeof(unsigned long),
1088 .mode = 0644,
1089 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1090 .extra1 = (void *)&hugetlb_zero,
1091 .extra2 = (void *)&hugetlb_infinity,
1092 },
1093#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .procname = "hugetlb_shm_group",
1096 .data = &sysctl_hugetlb_shm_group,
1097 .maxlen = sizeof(gid_t),
1098 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 },
Mel Gorman396faf02007-07-17 04:03:13 -07001101 {
Mel Gorman396faf02007-07-17 04:03:13 -07001102 .procname = "hugepages_treat_as_movable",
1103 .data = &hugepages_treat_as_movable,
1104 .maxlen = sizeof(int),
1105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001107 },
Adam Litke54f9f802007-10-16 01:26:20 -07001108 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001109 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001110 .data = NULL,
1111 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001112 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001113 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001114 .extra1 = (void *)&hugetlb_zero,
1115 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001116 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117#endif
1118 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 .procname = "lowmem_reserve_ratio",
1120 .data = &sysctl_lowmem_reserve_ratio,
1121 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 },
1125 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001126 .procname = "drop_caches",
1127 .data = &sysctl_drop_caches,
1128 .maxlen = sizeof(int),
1129 .mode = 0644,
1130 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001131 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001132#ifdef CONFIG_COMPACTION
1133 {
1134 .procname = "compact_memory",
1135 .data = &sysctl_compact_memory,
1136 .maxlen = sizeof(int),
1137 .mode = 0200,
1138 .proc_handler = sysctl_compaction_handler,
1139 },
Mel Gorman5e771902010-05-24 14:32:31 -07001140 {
1141 .procname = "extfrag_threshold",
1142 .data = &sysctl_extfrag_threshold,
1143 .maxlen = sizeof(int),
1144 .mode = 0644,
1145 .proc_handler = sysctl_extfrag_handler,
1146 .extra1 = &min_extfrag_threshold,
1147 .extra2 = &max_extfrag_threshold,
1148 },
1149
Mel Gorman76ab0f52010-05-24 14:32:28 -07001150#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "min_free_kbytes",
1153 .data = &min_free_kbytes,
1154 .maxlen = sizeof(min_free_kbytes),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .extra1 = &zero,
1158 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001159 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001160 .procname = "percpu_pagelist_fraction",
1161 .data = &percpu_pagelist_fraction,
1162 .maxlen = sizeof(percpu_pagelist_fraction),
1163 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001164 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001165 .extra1 = &min_percpu_pagelist_fract,
1166 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167#ifdef CONFIG_MMU
1168 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .procname = "max_map_count",
1170 .data = &sysctl_max_map_count,
1171 .maxlen = sizeof(sysctl_max_map_count),
1172 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001173 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001174 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001176#else
1177 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001178 .procname = "nr_trim_pages",
1179 .data = &sysctl_nr_trim_pages,
1180 .maxlen = sizeof(sysctl_nr_trim_pages),
1181 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001182 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001183 .extra1 = &zero,
1184 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185#endif
1186 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 .procname = "laptop_mode",
1188 .data = &laptop_mode,
1189 .maxlen = sizeof(laptop_mode),
1190 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001191 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 },
1193 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 .procname = "block_dump",
1195 .data = &block_dump,
1196 .maxlen = sizeof(block_dump),
1197 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001198 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 .extra1 = &zero,
1200 },
1201 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 .procname = "vfs_cache_pressure",
1203 .data = &sysctl_vfs_cache_pressure,
1204 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1205 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001206 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 .extra1 = &zero,
1208 },
1209#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1210 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 .procname = "legacy_va_layout",
1212 .data = &sysctl_legacy_va_layout,
1213 .maxlen = sizeof(sysctl_legacy_va_layout),
1214 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001215 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 .extra1 = &zero,
1217 },
1218#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001219#ifdef CONFIG_NUMA
1220 {
Christoph Lameter17436602006-01-18 17:42:32 -08001221 .procname = "zone_reclaim_mode",
1222 .data = &zone_reclaim_mode,
1223 .maxlen = sizeof(zone_reclaim_mode),
1224 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001225 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001226 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001227 },
Christoph Lameter96146342006-07-03 00:24:13 -07001228 {
Christoph Lameter96146342006-07-03 00:24:13 -07001229 .procname = "min_unmapped_ratio",
1230 .data = &sysctl_min_unmapped_ratio,
1231 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1232 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001233 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001234 .extra1 = &zero,
1235 .extra2 = &one_hundred,
1236 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001237 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001238 .procname = "min_slab_ratio",
1239 .data = &sysctl_min_slab_ratio,
1240 .maxlen = sizeof(sysctl_min_slab_ratio),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001243 .extra1 = &zero,
1244 .extra2 = &one_hundred,
1245 },
Christoph Lameter17436602006-01-18 17:42:32 -08001246#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001247#ifdef CONFIG_SMP
1248 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001249 .procname = "stat_interval",
1250 .data = &sysctl_stat_interval,
1251 .maxlen = sizeof(sysctl_stat_interval),
1252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001253 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001254 },
1255#endif
David Howells6e141542009-12-15 19:27:45 +00001256#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001257 {
Eric Parised032182007-06-28 15:55:21 -04001258 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001259 .data = &dac_mmap_min_addr,
1260 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001261 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001262 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001263 },
David Howells6e141542009-12-15 19:27:45 +00001264#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001265#ifdef CONFIG_NUMA
1266 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001267 .procname = "numa_zonelist_order",
1268 .data = &numa_zonelist_order,
1269 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1270 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001271 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001272 },
1273#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001274#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001275 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001276 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001277 .procname = "vdso_enabled",
1278 .data = &vdso_enabled,
1279 .maxlen = sizeof(vdso_enabled),
1280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001282 .extra1 = &zero,
1283 },
1284#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001285#ifdef CONFIG_HIGHMEM
1286 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001287 .procname = "highmem_is_dirtyable",
1288 .data = &vm_highmem_is_dirtyable,
1289 .maxlen = sizeof(vm_highmem_is_dirtyable),
1290 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001291 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001292 .extra1 = &zero,
1293 .extra2 = &one,
1294 },
1295#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001296 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001297 .procname = "scan_unevictable_pages",
1298 .data = &scan_unevictable_pages,
1299 .maxlen = sizeof(scan_unevictable_pages),
1300 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001302 },
Andi Kleen6a460792009-09-16 11:50:15 +02001303#ifdef CONFIG_MEMORY_FAILURE
1304 {
Andi Kleen6a460792009-09-16 11:50:15 +02001305 .procname = "memory_failure_early_kill",
1306 .data = &sysctl_memory_failure_early_kill,
1307 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001310 .extra1 = &zero,
1311 .extra2 = &one,
1312 },
1313 {
Andi Kleen6a460792009-09-16 11:50:15 +02001314 .procname = "memory_failure_recovery",
1315 .data = &sysctl_memory_failure_recovery,
1316 .maxlen = sizeof(sysctl_memory_failure_recovery),
1317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001319 .extra1 = &zero,
1320 .extra2 = &one,
1321 },
1322#endif
1323
Andrew Morton2be7fe02007-07-15 23:41:21 -07001324/*
1325 * NOTE: do not add new entries to this table unless you have read
1326 * Documentation/sysctl/ctl_unnumbered.txt
1327 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001328 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329};
1330
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001331#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001332static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001333 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001334};
1335#endif
1336
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001337static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 .procname = "inode-nr",
1340 .data = &inodes_stat,
1341 .maxlen = 2*sizeof(int),
1342 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 },
1345 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .procname = "inode-state",
1347 .data = &inodes_stat,
1348 .maxlen = 7*sizeof(int),
1349 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001350 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 },
1352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "file-nr",
1354 .data = &files_stat,
1355 .maxlen = 3*sizeof(int),
1356 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 },
1359 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 .procname = "file-max",
1361 .data = &files_stat.max_files,
1362 .maxlen = sizeof(int),
1363 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001364 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 },
1366 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001367 .procname = "nr_open",
1368 .data = &sysctl_nr_open,
1369 .maxlen = sizeof(int),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001372 .extra1 = &sysctl_nr_open_min,
1373 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001374 },
1375 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376 .procname = "dentry-state",
1377 .data = &dentry_stat,
1378 .maxlen = 6*sizeof(int),
1379 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001380 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 },
1382 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 .procname = "overflowuid",
1384 .data = &fs_overflowuid,
1385 .maxlen = sizeof(int),
1386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 .extra1 = &minolduid,
1389 .extra2 = &maxolduid,
1390 },
1391 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 .procname = "overflowgid",
1393 .data = &fs_overflowgid,
1394 .maxlen = sizeof(int),
1395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001396 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 .extra1 = &minolduid,
1398 .extra2 = &maxolduid,
1399 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001400#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .procname = "leases-enable",
1403 .data = &leases_enable,
1404 .maxlen = sizeof(int),
1405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001406 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001408#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409#ifdef CONFIG_DNOTIFY
1410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "dir-notify-enable",
1412 .data = &dir_notify_enable,
1413 .maxlen = sizeof(int),
1414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001415 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416 },
1417#endif
1418#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001419#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421 .procname = "lease-break-time",
1422 .data = &lease_break_time,
1423 .maxlen = sizeof(int),
1424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001425 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001426 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001427#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001428#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 .procname = "aio-nr",
1431 .data = &aio_nr,
1432 .maxlen = sizeof(aio_nr),
1433 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001434 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 },
1436 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 .procname = "aio-max-nr",
1438 .data = &aio_max_nr,
1439 .maxlen = sizeof(aio_max_nr),
1440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001441 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001443#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001444#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001445 {
Robert Love0399cb02005-07-13 12:38:18 -04001446 .procname = "inotify",
1447 .mode = 0555,
1448 .child = inotify_table,
1449 },
1450#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001451#ifdef CONFIG_EPOLL
1452 {
1453 .procname = "epoll",
1454 .mode = 0555,
1455 .child = epoll_table,
1456 },
1457#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001459 {
Alan Coxd6e71142005-06-23 00:09:43 -07001460 .procname = "suid_dumpable",
1461 .data = &suid_dumpable,
1462 .maxlen = sizeof(int),
1463 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001464 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001465 .extra1 = &zero,
1466 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001467 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001468#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1469 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001470 .procname = "binfmt_misc",
1471 .mode = 0555,
1472 .child = binfmt_misc_table,
1473 },
1474#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001475 {
Jens Axboeff9da692010-06-03 14:54:39 +02001476 .procname = "pipe-max-size",
1477 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001478 .maxlen = sizeof(int),
1479 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001480 .proc_handler = &pipe_proc_fn,
1481 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001482 },
Andrew Morton2be7fe02007-07-15 23:41:21 -07001483/*
1484 * NOTE: do not add new entries to this table unless you have read
1485 * Documentation/sysctl/ctl_unnumbered.txt
1486 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001487 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488};
1489
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001490static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001491#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
1492 defined(CONFIG_S390)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001493 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001494 .procname = "exception-trace",
1495 .data = &show_unhandled_signals,
1496 .maxlen = sizeof(int),
1497 .mode = 0644,
1498 .proc_handler = proc_dointvec
1499 },
1500#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001501#if defined(CONFIG_OPTPROBES)
1502 {
1503 .procname = "kprobes-optimization",
1504 .data = &sysctl_kprobes_optimization,
1505 .maxlen = sizeof(int),
1506 .mode = 0644,
1507 .proc_handler = proc_kprobes_optimization_handler,
1508 .extra1 = &zero,
1509 .extra2 = &one,
1510 },
1511#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001512 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513};
1514
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001515static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001516 { }
Robert Love0eeca282005-07-12 17:06:03 -04001517};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518
Al Viro330d57f2005-11-04 10:18:40 +00001519static DEFINE_SPINLOCK(sysctl_lock);
1520
1521/* called under sysctl_lock */
1522static int use_table(struct ctl_table_header *p)
1523{
1524 if (unlikely(p->unregistering))
1525 return 0;
1526 p->used++;
1527 return 1;
1528}
1529
1530/* called under sysctl_lock */
1531static void unuse_table(struct ctl_table_header *p)
1532{
1533 if (!--p->used)
1534 if (unlikely(p->unregistering))
1535 complete(p->unregistering);
1536}
1537
1538/* called under sysctl_lock, will reacquire if has to wait */
1539static void start_unregistering(struct ctl_table_header *p)
1540{
1541 /*
1542 * if p->used is 0, nobody will ever touch that entry again;
1543 * we'll eliminate all paths to it before dropping sysctl_lock
1544 */
1545 if (unlikely(p->used)) {
1546 struct completion wait;
1547 init_completion(&wait);
1548 p->unregistering = &wait;
1549 spin_unlock(&sysctl_lock);
1550 wait_for_completion(&wait);
1551 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001552 } else {
1553 /* anything non-NULL; we'll never dereference it */
1554 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001555 }
1556 /*
1557 * do not remove from the list until nobody holds it; walking the
1558 * list in do_sysctl() relies on that.
1559 */
1560 list_del_init(&p->ctl_entry);
1561}
1562
Al Virof7e6ced2008-07-15 01:44:23 -04001563void sysctl_head_get(struct ctl_table_header *head)
1564{
1565 spin_lock(&sysctl_lock);
1566 head->count++;
1567 spin_unlock(&sysctl_lock);
1568}
1569
1570void sysctl_head_put(struct ctl_table_header *head)
1571{
1572 spin_lock(&sysctl_lock);
1573 if (!--head->count)
1574 kfree(head);
1575 spin_unlock(&sysctl_lock);
1576}
1577
1578struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1579{
1580 if (!head)
1581 BUG();
1582 spin_lock(&sysctl_lock);
1583 if (!use_table(head))
1584 head = ERR_PTR(-ENOENT);
1585 spin_unlock(&sysctl_lock);
1586 return head;
1587}
1588
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001589void sysctl_head_finish(struct ctl_table_header *head)
1590{
1591 if (!head)
1592 return;
1593 spin_lock(&sysctl_lock);
1594 unuse_table(head);
1595 spin_unlock(&sysctl_lock);
1596}
1597
Al Viro73455092008-07-14 21:22:20 -04001598static struct ctl_table_set *
1599lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1600{
1601 struct ctl_table_set *set = &root->default_set;
1602 if (root->lookup)
1603 set = root->lookup(root, namespaces);
1604 return set;
1605}
1606
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001607static struct list_head *
1608lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001609{
Al Viro73455092008-07-14 21:22:20 -04001610 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1611 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001612}
1613
1614struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1615 struct ctl_table_header *prev)
1616{
1617 struct ctl_table_root *root;
1618 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001619 struct ctl_table_header *head;
1620 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001621
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001622 spin_lock(&sysctl_lock);
1623 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001624 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001625 tmp = &prev->ctl_entry;
1626 unuse_table(prev);
1627 goto next;
1628 }
1629 tmp = &root_table_header.ctl_entry;
1630 for (;;) {
1631 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1632
1633 if (!use_table(head))
1634 goto next;
1635 spin_unlock(&sysctl_lock);
1636 return head;
1637 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001638 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001639 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001640 header_list = lookup_header_list(root, namespaces);
1641 if (tmp != header_list)
1642 continue;
1643
1644 do {
1645 root = list_entry(root->root_list.next,
1646 struct ctl_table_root, root_list);
1647 if (root == &sysctl_table_root)
1648 goto out;
1649 header_list = lookup_header_list(root, namespaces);
1650 } while (list_empty(header_list));
1651 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001652 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001653out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001654 spin_unlock(&sysctl_lock);
1655 return NULL;
1656}
1657
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001658struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1659{
1660 return __sysctl_head_next(current->nsproxy, prev);
1661}
1662
1663void register_sysctl_root(struct ctl_table_root *root)
1664{
1665 spin_lock(&sysctl_lock);
1666 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1667 spin_unlock(&sysctl_lock);
1668}
1669
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001671 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001672 * some sysctl variables are readonly even to root.
1673 */
1674
1675static int test_perm(int mode, int op)
1676{
David Howells76aac0e2008-11-14 10:39:12 +11001677 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 mode >>= 6;
1679 else if (in_egroup_p(0))
1680 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001681 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 return 0;
1683 return -EACCES;
1684}
1685
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001686int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687{
1688 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001689 int mode;
1690
Al Viroe6305c42008-07-15 21:03:57 -04001691 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 if (error)
1693 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001694
1695 if (root->permissions)
1696 mode = root->permissions(root, current->nsproxy, table);
1697 else
1698 mode = table->mode;
1699
1700 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701}
1702
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001703static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1704{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001705 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001706 table->parent = parent;
1707 if (table->child)
1708 sysctl_set_parent(table, table->child);
1709 }
1710}
1711
1712static __init int sysctl_init(void)
1713{
1714 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001715#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1716 {
1717 int err;
1718 err = sysctl_check_table(current->nsproxy, root_table);
1719 }
1720#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001721 return 0;
1722}
1723
1724core_initcall(sysctl_init);
1725
Al Virobfbcf032008-07-27 06:31:22 +01001726static struct ctl_table *is_branch_in(struct ctl_table *branch,
1727 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001728{
1729 struct ctl_table *p;
1730 const char *s = branch->procname;
1731
1732 /* branch should have named subdirectory as its first element */
1733 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001734 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001735
1736 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001737 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001738 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001739
1740 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001741 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001742 if (!p->child)
1743 continue;
1744 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001745 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001746 }
Al Virobfbcf032008-07-27 06:31:22 +01001747 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001748}
1749
1750/* see if attaching q to p would be an improvement */
1751static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1752{
1753 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001754 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001755 int is_better = 0;
1756 int not_in_parent = !p->attached_by;
1757
Al Virobfbcf032008-07-27 06:31:22 +01001758 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001759 if (by == q->attached_by)
1760 is_better = 1;
1761 if (to == p->attached_by)
1762 not_in_parent = 1;
1763 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001764 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001765 }
1766
1767 if (is_better && not_in_parent) {
1768 q->attached_by = by;
1769 q->attached_to = to;
1770 q->parent = p;
1771 }
1772}
1773
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001775 * __register_sysctl_paths - register a sysctl hierarchy
1776 * @root: List of sysctl headers to register on
1777 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001778 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780 *
1781 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001782 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001784 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1787 * enter a sysctl file
1788 *
1789 * data - a pointer to data for use by proc_handler
1790 *
1791 * maxlen - the maximum size in bytes of the data
1792 *
1793 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1794 *
1795 * child - a pointer to the child sysctl table if this entry is a directory, or
1796 * %NULL.
1797 *
1798 * proc_handler - the text handler routine (described below)
1799 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800 * de - for internal use by the sysctl routines
1801 *
1802 * extra1, extra2 - extra pointers usable by the proc handler routines
1803 *
1804 * Leaf nodes in the sysctl tree will be represented by a single file
1805 * under /proc; non-leaf nodes will be represented by directories.
1806 *
1807 * sysctl(2) can automatically manage read and write requests through
1808 * the sysctl table. The data and maxlen fields of the ctl_table
1809 * struct enable minimal validation of the values being written to be
1810 * performed, and the mode field allows minimal authentication.
1811 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812 * There must be a proc_handler routine for any terminal nodes
1813 * mirrored under /proc/sys (non-terminals are handled by a built-in
1814 * directory handler). Several default handlers are available to
1815 * cover common cases -
1816 *
1817 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1818 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1819 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1820 *
1821 * It is the handler's job to read the input buffer from user memory
1822 * and process it. The handler should return 0 on success.
1823 *
1824 * This routine returns %NULL on a failure to register, and a pointer
1825 * to the table header on success.
1826 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001827struct ctl_table_header *__register_sysctl_paths(
1828 struct ctl_table_root *root,
1829 struct nsproxy *namespaces,
1830 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001832 struct ctl_table_header *header;
1833 struct ctl_table *new, **prevp;
1834 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001835 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001836
1837 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001838 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001839 ;
1840
1841 /*
1842 * For each path component, allocate a 2-element ctl_table array.
1843 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001844 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001845 *
1846 * We allocate everything in one go so that we don't have to
1847 * worry about freeing additional memory in unregister_sysctl_table.
1848 */
1849 header = kzalloc(sizeof(struct ctl_table_header) +
1850 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1851 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001853
1854 new = (struct ctl_table *) (header + 1);
1855
1856 /* Now connect the dots */
1857 prevp = &header->ctl_table;
1858 for (n = 0; n < npath; ++n, ++path) {
1859 /* Copy the procname */
1860 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001861 new->mode = 0555;
1862
1863 *prevp = new;
1864 prevp = &new->child;
1865
1866 new += 2;
1867 }
1868 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001869 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001870
1871 INIT_LIST_HEAD(&header->ctl_entry);
1872 header->used = 0;
1873 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001874 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001875 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001876 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001877#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001878 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001879 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001880 return NULL;
1881 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001882#endif
Al Viro330d57f2005-11-04 10:18:40 +00001883 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001884 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001885 header->attached_by = header->ctl_table;
1886 header->attached_to = root_table;
1887 header->parent = &root_table_header;
1888 for (set = header->set; set; set = set->parent) {
1889 struct ctl_table_header *p;
1890 list_for_each_entry(p, &set->list, ctl_entry) {
1891 if (p->unregistering)
1892 continue;
1893 try_attach(p, header);
1894 }
1895 }
1896 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001897 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001898 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001899
1900 return header;
1901}
1902
1903/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001904 * register_sysctl_table_path - register a sysctl table hierarchy
1905 * @path: The path to the directory the sysctl table is in.
1906 * @table: the top-level table structure
1907 *
1908 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1909 * array. A completely 0 filled entry terminates the table.
1910 *
1911 * See __register_sysctl_paths for more details.
1912 */
1913struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1914 struct ctl_table *table)
1915{
1916 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1917 path, table);
1918}
1919
1920/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001921 * register_sysctl_table - register a sysctl table hierarchy
1922 * @table: the top-level table structure
1923 *
1924 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1925 * array. A completely 0 filled entry terminates the table.
1926 *
1927 * See register_sysctl_paths for more details.
1928 */
1929struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1930{
1931 static const struct ctl_path null_path[] = { {} };
1932
1933 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934}
1935
1936/**
1937 * unregister_sysctl_table - unregister a sysctl table hierarchy
1938 * @header: the header returned from register_sysctl_table
1939 *
1940 * Unregisters the sysctl table and all children. proc entries may not
1941 * actually be removed until they are no longer used by anyone.
1942 */
1943void unregister_sysctl_table(struct ctl_table_header * header)
1944{
Al Viro330d57f2005-11-04 10:18:40 +00001945 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001946
1947 if (header == NULL)
1948 return;
1949
Al Viro330d57f2005-11-04 10:18:40 +00001950 spin_lock(&sysctl_lock);
1951 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001952 if (!--header->parent->count) {
1953 WARN_ON(1);
1954 kfree(header->parent);
1955 }
Al Virof7e6ced2008-07-15 01:44:23 -04001956 if (!--header->count)
1957 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001958 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001959}
1960
Al Viro9043476f2008-07-15 08:54:06 -04001961int sysctl_is_seen(struct ctl_table_header *p)
1962{
1963 struct ctl_table_set *set = p->set;
1964 int res;
1965 spin_lock(&sysctl_lock);
1966 if (p->unregistering)
1967 res = 0;
1968 else if (!set->is_seen)
1969 res = 1;
1970 else
1971 res = set->is_seen(set);
1972 spin_unlock(&sysctl_lock);
1973 return res;
1974}
1975
Al Viro73455092008-07-14 21:22:20 -04001976void setup_sysctl_set(struct ctl_table_set *p,
1977 struct ctl_table_set *parent,
1978 int (*is_seen)(struct ctl_table_set *))
1979{
1980 INIT_LIST_HEAD(&p->list);
1981 p->parent = parent ? parent : &sysctl_table_root.default_set;
1982 p->is_seen = is_seen;
1983}
1984
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001985#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001986struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001987{
1988 return NULL;
1989}
1990
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001991struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1992 struct ctl_table *table)
1993{
1994 return NULL;
1995}
1996
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001997void unregister_sysctl_table(struct ctl_table_header * table)
1998{
1999}
2000
Al Viro73455092008-07-14 21:22:20 -04002001void setup_sysctl_set(struct ctl_table_set *p,
2002 struct ctl_table_set *parent,
2003 int (*is_seen)(struct ctl_table_set *))
2004{
2005}
2006
Al Virof7e6ced2008-07-15 01:44:23 -04002007void sysctl_head_put(struct ctl_table_header *head)
2008{
2009}
2010
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002011#endif /* CONFIG_SYSCTL */
2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013/*
2014 * /proc/sys support
2015 */
2016
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002017#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002019static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002020 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002021 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002022{
2023 size_t len;
2024 char __user *p;
2025 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002026
2027 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002028 *lenp = 0;
2029 return 0;
2030 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002031
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002032 if (write) {
2033 len = 0;
2034 p = buffer;
2035 while (len < *lenp) {
2036 if (get_user(c, p++))
2037 return -EFAULT;
2038 if (c == 0 || c == '\n')
2039 break;
2040 len++;
2041 }
2042 if (len >= maxlen)
2043 len = maxlen-1;
2044 if(copy_from_user(data, buffer, len))
2045 return -EFAULT;
2046 ((char *) data)[len] = 0;
2047 *ppos += *lenp;
2048 } else {
2049 len = strlen(data);
2050 if (len > maxlen)
2051 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002052
2053 if (*ppos > len) {
2054 *lenp = 0;
2055 return 0;
2056 }
2057
2058 data += *ppos;
2059 len -= *ppos;
2060
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002061 if (len > *lenp)
2062 len = *lenp;
2063 if (len)
2064 if(copy_to_user(buffer, data, len))
2065 return -EFAULT;
2066 if (len < *lenp) {
2067 if(put_user('\n', ((char __user *) buffer) + len))
2068 return -EFAULT;
2069 len++;
2070 }
2071 *lenp = len;
2072 *ppos += len;
2073 }
2074 return 0;
2075}
2076
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077/**
2078 * proc_dostring - read a string sysctl
2079 * @table: the sysctl table
2080 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081 * @buffer: the user buffer
2082 * @lenp: the size of the user buffer
2083 * @ppos: file position
2084 *
2085 * Reads/writes a string from/to the user buffer. If the kernel
2086 * buffer provided is not large enough to hold the string, the
2087 * string is truncated. The copied string is %NULL-terminated.
2088 * If the string is being read by the user process, it is copied
2089 * and a newline '\n' is added. It is truncated if the buffer is
2090 * not large enough.
2091 *
2092 * Returns 0 on success.
2093 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002094int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 void __user *buffer, size_t *lenp, loff_t *ppos)
2096{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002097 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002098 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099}
2100
Amerigo Wang00b7c332010-05-05 00:26:45 +00002101static size_t proc_skip_spaces(char **buf)
2102{
2103 size_t ret;
2104 char *tmp = skip_spaces(*buf);
2105 ret = tmp - *buf;
2106 *buf = tmp;
2107 return ret;
2108}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002110static void proc_skip_char(char **buf, size_t *size, const char v)
2111{
2112 while (*size) {
2113 if (**buf != v)
2114 break;
2115 (*size)--;
2116 (*buf)++;
2117 }
2118}
2119
Amerigo Wang00b7c332010-05-05 00:26:45 +00002120#define TMPBUFLEN 22
2121/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002122 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002123 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002124 * @buf: a kernel buffer
2125 * @size: size of the kernel buffer
2126 * @val: this is where the number will be stored
2127 * @neg: set to %TRUE if number is negative
2128 * @perm_tr: a vector which contains the allowed trailers
2129 * @perm_tr_len: size of the perm_tr vector
2130 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002131 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002132 * In case of success %0 is returned and @buf and @size are updated with
2133 * the amount of bytes read. If @tr is non-NULL and a trailing
2134 * character exists (size is non-zero after returning from this
2135 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002136 */
2137static int proc_get_long(char **buf, size_t *size,
2138 unsigned long *val, bool *neg,
2139 const char *perm_tr, unsigned perm_tr_len, char *tr)
2140{
2141 int len;
2142 char *p, tmp[TMPBUFLEN];
2143
2144 if (!*size)
2145 return -EINVAL;
2146
2147 len = *size;
2148 if (len > TMPBUFLEN - 1)
2149 len = TMPBUFLEN - 1;
2150
2151 memcpy(tmp, *buf, len);
2152
2153 tmp[len] = 0;
2154 p = tmp;
2155 if (*p == '-' && *size > 1) {
2156 *neg = true;
2157 p++;
2158 } else
2159 *neg = false;
2160 if (!isdigit(*p))
2161 return -EINVAL;
2162
2163 *val = simple_strtoul(p, &p, 0);
2164
2165 len = p - tmp;
2166
2167 /* We don't know if the next char is whitespace thus we may accept
2168 * invalid integers (e.g. 1234...a) or two integers instead of one
2169 * (e.g. 123...1). So lets not allow such large numbers. */
2170 if (len == TMPBUFLEN - 1)
2171 return -EINVAL;
2172
2173 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2174 return -EINVAL;
2175
2176 if (tr && (len < *size))
2177 *tr = *p;
2178
2179 *buf += len;
2180 *size -= len;
2181
2182 return 0;
2183}
2184
2185/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002186 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002188 * @buf: the user buffer
2189 * @size: the size of the user buffer
2190 * @val: the integer to be converted
2191 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002192 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002193 * In case of success %0 is returned and @buf and @size are updated with
2194 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195 */
2196static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2197 bool neg)
2198{
2199 int len;
2200 char tmp[TMPBUFLEN], *p = tmp;
2201
2202 sprintf(p, "%s%lu", neg ? "-" : "", val);
2203 len = strlen(tmp);
2204 if (len > *size)
2205 len = *size;
2206 if (copy_to_user(*buf, tmp, len))
2207 return -EFAULT;
2208 *size -= len;
2209 *buf += len;
2210 return 0;
2211}
2212#undef TMPBUFLEN
2213
2214static int proc_put_char(void __user **buf, size_t *size, char c)
2215{
2216 if (*size) {
2217 char __user **buffer = (char __user **)buf;
2218 if (put_user(c, *buffer))
2219 return -EFAULT;
2220 (*size)--, (*buffer)++;
2221 *buf = *buffer;
2222 }
2223 return 0;
2224}
2225
2226static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 int *valp,
2228 int write, void *data)
2229{
2230 if (write) {
2231 *valp = *negp ? -*lvalp : *lvalp;
2232 } else {
2233 int val = *valp;
2234 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002235 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 *lvalp = (unsigned long)-val;
2237 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002238 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 *lvalp = (unsigned long)val;
2240 }
2241 }
2242 return 0;
2243}
2244
Amerigo Wang00b7c332010-05-05 00:26:45 +00002245static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2246
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002247static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002248 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002249 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002250 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 int write, void *data),
2252 void *data)
2253{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002254 int *i, vleft, first = 1, err = 0;
2255 unsigned long page = 0;
2256 size_t left;
2257 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258
Amerigo Wang00b7c332010-05-05 00:26:45 +00002259 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 *lenp = 0;
2261 return 0;
2262 }
2263
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002264 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 vleft = table->maxlen / sizeof(*i);
2266 left = *lenp;
2267
2268 if (!conv)
2269 conv = do_proc_dointvec_conv;
2270
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002272 if (left > PAGE_SIZE - 1)
2273 left = PAGE_SIZE - 1;
2274 page = __get_free_page(GFP_TEMPORARY);
2275 kbuf = (char *) page;
2276 if (!kbuf)
2277 return -ENOMEM;
2278 if (copy_from_user(kbuf, buffer, left)) {
2279 err = -EFAULT;
2280 goto free;
2281 }
2282 kbuf[left] = 0;
2283 }
2284
2285 for (; left && vleft--; i++, first=0) {
2286 unsigned long lval;
2287 bool neg;
2288
2289 if (write) {
2290 left -= proc_skip_spaces(&kbuf);
2291
J. R. Okajima563b0462010-05-25 16:10:14 -07002292 if (!left)
2293 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002294 err = proc_get_long(&kbuf, &left, &lval, &neg,
2295 proc_wspace_sep,
2296 sizeof(proc_wspace_sep), NULL);
2297 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002299 if (conv(&neg, &lval, i, 1, data)) {
2300 err = -EINVAL;
2301 break;
2302 }
2303 } else {
2304 if (conv(&neg, &lval, i, 0, data)) {
2305 err = -EINVAL;
2306 break;
2307 }
2308 if (!first)
2309 err = proc_put_char(&buffer, &left, '\t');
2310 if (err)
2311 break;
2312 err = proc_put_long(&buffer, &left, lval, neg);
2313 if (err)
2314 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 }
2316 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002317
2318 if (!write && !first && left && !err)
2319 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002320 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002321 left -= proc_skip_spaces(&kbuf);
2322free:
2323 if (write) {
2324 free_page(page);
2325 if (first)
2326 return err ? : -EINVAL;
2327 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 *lenp -= left;
2329 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002330 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331}
2332
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002333static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002334 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002336 int write, void *data),
2337 void *data)
2338{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002339 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002340 buffer, lenp, ppos, conv, data);
2341}
2342
Linus Torvalds1da177e2005-04-16 15:20:36 -07002343/**
2344 * proc_dointvec - read a vector of integers
2345 * @table: the sysctl table
2346 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 * @buffer: the user buffer
2348 * @lenp: the size of the user buffer
2349 * @ppos: file position
2350 *
2351 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2352 * values from/to the user buffer, treated as an ASCII string.
2353 *
2354 * Returns 0 on success.
2355 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002356int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 void __user *buffer, size_t *lenp, loff_t *ppos)
2358{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002359 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 NULL,NULL);
2361}
2362
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002363/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002364 * Taint values can only be increased
2365 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002366 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002367static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002368 void __user *buffer, size_t *lenp, loff_t *ppos)
2369{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002370 struct ctl_table t;
2371 unsigned long tmptaint = get_taint();
2372 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002373
Bastian Blank91fcd412007-04-23 14:41:14 -07002374 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002375 return -EPERM;
2376
Andi Kleen25ddbb12008-10-15 22:01:41 -07002377 t = *table;
2378 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002379 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002380 if (err < 0)
2381 return err;
2382
2383 if (write) {
2384 /*
2385 * Poor man's atomic or. Not worth adding a primitive
2386 * to everyone's atomic.h for this
2387 */
2388 int i;
2389 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2390 if ((tmptaint >> i) & 1)
2391 add_taint(i);
2392 }
2393 }
2394
2395 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002396}
2397
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398struct do_proc_dointvec_minmax_conv_param {
2399 int *min;
2400 int *max;
2401};
2402
Amerigo Wang00b7c332010-05-05 00:26:45 +00002403static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2404 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 int write, void *data)
2406{
2407 struct do_proc_dointvec_minmax_conv_param *param = data;
2408 if (write) {
2409 int val = *negp ? -*lvalp : *lvalp;
2410 if ((param->min && *param->min > val) ||
2411 (param->max && *param->max < val))
2412 return -EINVAL;
2413 *valp = val;
2414 } else {
2415 int val = *valp;
2416 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002417 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418 *lvalp = (unsigned long)-val;
2419 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002420 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421 *lvalp = (unsigned long)val;
2422 }
2423 }
2424 return 0;
2425}
2426
2427/**
2428 * proc_dointvec_minmax - read a vector of integers with min/max values
2429 * @table: the sysctl table
2430 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 * @buffer: the user buffer
2432 * @lenp: the size of the user buffer
2433 * @ppos: file position
2434 *
2435 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2436 * values from/to the user buffer, treated as an ASCII string.
2437 *
2438 * This routine will ensure the values are within the range specified by
2439 * table->extra1 (min) and table->extra2 (max).
2440 *
2441 * Returns 0 on success.
2442 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002443int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 void __user *buffer, size_t *lenp, loff_t *ppos)
2445{
2446 struct do_proc_dointvec_minmax_conv_param param = {
2447 .min = (int *) table->extra1,
2448 .max = (int *) table->extra2,
2449 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002450 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 do_proc_dointvec_minmax_conv, &param);
2452}
2453
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002454static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455 void __user *buffer,
2456 size_t *lenp, loff_t *ppos,
2457 unsigned long convmul,
2458 unsigned long convdiv)
2459{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002460 unsigned long *i, *min, *max;
2461 int vleft, first = 1, err = 0;
2462 unsigned long page = 0;
2463 size_t left;
2464 char *kbuf;
2465
2466 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 *lenp = 0;
2468 return 0;
2469 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002470
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002471 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 min = (unsigned long *) table->extra1;
2473 max = (unsigned long *) table->extra2;
2474 vleft = table->maxlen / sizeof(unsigned long);
2475 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002476
2477 if (write) {
2478 if (left > PAGE_SIZE - 1)
2479 left = PAGE_SIZE - 1;
2480 page = __get_free_page(GFP_TEMPORARY);
2481 kbuf = (char *) page;
2482 if (!kbuf)
2483 return -ENOMEM;
2484 if (copy_from_user(kbuf, buffer, left)) {
2485 err = -EFAULT;
2486 goto free;
2487 }
2488 kbuf[left] = 0;
2489 }
2490
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 for (; left && vleft--; i++, min++, max++, first=0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002492 unsigned long val;
2493
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002495 bool neg;
2496
2497 left -= proc_skip_spaces(&kbuf);
2498
2499 err = proc_get_long(&kbuf, &left, &val, &neg,
2500 proc_wspace_sep,
2501 sizeof(proc_wspace_sep), NULL);
2502 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 break;
2504 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 continue;
2506 if ((min && val < *min) || (max && val > *max))
2507 continue;
2508 *i = val;
2509 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002510 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002512 err = proc_put_char(&buffer, &left, '\t');
2513 err = proc_put_long(&buffer, &left, val, false);
2514 if (err)
2515 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 }
2517 }
2518
Amerigo Wang00b7c332010-05-05 00:26:45 +00002519 if (!write && !first && left && !err)
2520 err = proc_put_char(&buffer, &left, '\n');
2521 if (write && !err)
2522 left -= proc_skip_spaces(&kbuf);
2523free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002525 free_page(page);
2526 if (first)
2527 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529 *lenp -= left;
2530 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002531 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532}
2533
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002534static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002535 void __user *buffer,
2536 size_t *lenp, loff_t *ppos,
2537 unsigned long convmul,
2538 unsigned long convdiv)
2539{
2540 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002541 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002542}
2543
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544/**
2545 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
2550 * @ppos: file position
2551 *
2552 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2553 * values from/to the user buffer, treated as an ASCII string.
2554 *
2555 * This routine will ensure the values are within the range specified by
2556 * table->extra1 (min) and table->extra2 (max).
2557 *
2558 * Returns 0 on success.
2559 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002560int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 void __user *buffer, size_t *lenp, loff_t *ppos)
2562{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002563 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564}
2565
2566/**
2567 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2568 * @table: the sysctl table
2569 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 * @buffer: the user buffer
2571 * @lenp: the size of the user buffer
2572 * @ppos: file position
2573 *
2574 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2575 * values from/to the user buffer, treated as an ASCII string. The values
2576 * are treated as milliseconds, and converted to jiffies when they are stored.
2577 *
2578 * This routine will ensure the values are within the range specified by
2579 * table->extra1 (min) and table->extra2 (max).
2580 *
2581 * Returns 0 on success.
2582 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002583int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 void __user *buffer,
2585 size_t *lenp, loff_t *ppos)
2586{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002587 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 lenp, ppos, HZ, 1000l);
2589}
2590
2591
Amerigo Wang00b7c332010-05-05 00:26:45 +00002592static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 int *valp,
2594 int write, void *data)
2595{
2596 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002597 if (*lvalp > LONG_MAX / HZ)
2598 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2600 } else {
2601 int val = *valp;
2602 unsigned long lval;
2603 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002604 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 lval = (unsigned long)-val;
2606 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002607 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 lval = (unsigned long)val;
2609 }
2610 *lvalp = lval / HZ;
2611 }
2612 return 0;
2613}
2614
Amerigo Wang00b7c332010-05-05 00:26:45 +00002615static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 int *valp,
2617 int write, void *data)
2618{
2619 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002620 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2621 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2623 } else {
2624 int val = *valp;
2625 unsigned long lval;
2626 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002627 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 lval = (unsigned long)-val;
2629 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002630 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 lval = (unsigned long)val;
2632 }
2633 *lvalp = jiffies_to_clock_t(lval);
2634 }
2635 return 0;
2636}
2637
Amerigo Wang00b7c332010-05-05 00:26:45 +00002638static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 int *valp,
2640 int write, void *data)
2641{
2642 if (write) {
2643 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2644 } else {
2645 int val = *valp;
2646 unsigned long lval;
2647 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002648 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 lval = (unsigned long)-val;
2650 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002651 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 lval = (unsigned long)val;
2653 }
2654 *lvalp = jiffies_to_msecs(lval);
2655 }
2656 return 0;
2657}
2658
2659/**
2660 * proc_dointvec_jiffies - read a vector of integers as seconds
2661 * @table: the sysctl table
2662 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663 * @buffer: the user buffer
2664 * @lenp: the size of the user buffer
2665 * @ppos: file position
2666 *
2667 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2668 * values from/to the user buffer, treated as an ASCII string.
2669 * The values read are assumed to be in seconds, and are converted into
2670 * jiffies.
2671 *
2672 * Returns 0 on success.
2673 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002674int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 void __user *buffer, size_t *lenp, loff_t *ppos)
2676{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002677 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 do_proc_dointvec_jiffies_conv,NULL);
2679}
2680
2681/**
2682 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2683 * @table: the sysctl table
2684 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 * @buffer: the user buffer
2686 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002687 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002688 *
2689 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2690 * values from/to the user buffer, treated as an ASCII string.
2691 * The values read are assumed to be in 1/USER_HZ seconds, and
2692 * are converted into jiffies.
2693 *
2694 * Returns 0 on success.
2695 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002696int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 void __user *buffer, size_t *lenp, loff_t *ppos)
2698{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002699 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002700 do_proc_dointvec_userhz_jiffies_conv,NULL);
2701}
2702
2703/**
2704 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2705 * @table: the sysctl table
2706 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002707 * @buffer: the user buffer
2708 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002709 * @ppos: file position
2710 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002711 *
2712 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2713 * values from/to the user buffer, treated as an ASCII string.
2714 * The values read are assumed to be in 1/1000 seconds, and
2715 * are converted into jiffies.
2716 *
2717 * Returns 0 on success.
2718 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002719int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002720 void __user *buffer, size_t *lenp, loff_t *ppos)
2721{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002722 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 do_proc_dointvec_ms_jiffies_conv, NULL);
2724}
2725
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002726static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002727 void __user *buffer, size_t *lenp, loff_t *ppos)
2728{
2729 struct pid *new_pid;
2730 pid_t tmp;
2731 int r;
2732
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002733 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002734
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002735 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002736 lenp, ppos, NULL, NULL);
2737 if (r || !write)
2738 return r;
2739
2740 new_pid = find_get_pid(tmp);
2741 if (!new_pid)
2742 return -ESRCH;
2743
2744 put_pid(xchg(&cad_pid, new_pid));
2745 return 0;
2746}
2747
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002748/**
2749 * proc_do_large_bitmap - read/write from/to a large bitmap
2750 * @table: the sysctl table
2751 * @write: %TRUE if this is a write to the sysctl file
2752 * @buffer: the user buffer
2753 * @lenp: the size of the user buffer
2754 * @ppos: file position
2755 *
2756 * The bitmap is stored at table->data and the bitmap length (in bits)
2757 * in table->maxlen.
2758 *
2759 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2760 * large bitmaps may be represented in a compact manner. Writing into
2761 * the file will clear the bitmap then update it with the given input.
2762 *
2763 * Returns 0 on success.
2764 */
2765int proc_do_large_bitmap(struct ctl_table *table, int write,
2766 void __user *buffer, size_t *lenp, loff_t *ppos)
2767{
2768 int err = 0;
2769 bool first = 1;
2770 size_t left = *lenp;
2771 unsigned long bitmap_len = table->maxlen;
2772 unsigned long *bitmap = (unsigned long *) table->data;
2773 unsigned long *tmp_bitmap = NULL;
2774 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2775
2776 if (!bitmap_len || !left || (*ppos && !write)) {
2777 *lenp = 0;
2778 return 0;
2779 }
2780
2781 if (write) {
2782 unsigned long page = 0;
2783 char *kbuf;
2784
2785 if (left > PAGE_SIZE - 1)
2786 left = PAGE_SIZE - 1;
2787
2788 page = __get_free_page(GFP_TEMPORARY);
2789 kbuf = (char *) page;
2790 if (!kbuf)
2791 return -ENOMEM;
2792 if (copy_from_user(kbuf, buffer, left)) {
2793 free_page(page);
2794 return -EFAULT;
2795 }
2796 kbuf[left] = 0;
2797
2798 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2799 GFP_KERNEL);
2800 if (!tmp_bitmap) {
2801 free_page(page);
2802 return -ENOMEM;
2803 }
2804 proc_skip_char(&kbuf, &left, '\n');
2805 while (!err && left) {
2806 unsigned long val_a, val_b;
2807 bool neg;
2808
2809 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2810 sizeof(tr_a), &c);
2811 if (err)
2812 break;
2813 if (val_a >= bitmap_len || neg) {
2814 err = -EINVAL;
2815 break;
2816 }
2817
2818 val_b = val_a;
2819 if (left) {
2820 kbuf++;
2821 left--;
2822 }
2823
2824 if (c == '-') {
2825 err = proc_get_long(&kbuf, &left, &val_b,
2826 &neg, tr_b, sizeof(tr_b),
2827 &c);
2828 if (err)
2829 break;
2830 if (val_b >= bitmap_len || neg ||
2831 val_a > val_b) {
2832 err = -EINVAL;
2833 break;
2834 }
2835 if (left) {
2836 kbuf++;
2837 left--;
2838 }
2839 }
2840
2841 while (val_a <= val_b)
2842 set_bit(val_a++, tmp_bitmap);
2843
2844 first = 0;
2845 proc_skip_char(&kbuf, &left, '\n');
2846 }
2847 free_page(page);
2848 } else {
2849 unsigned long bit_a, bit_b = 0;
2850
2851 while (left) {
2852 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2853 if (bit_a >= bitmap_len)
2854 break;
2855 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2856 bit_a + 1) - 1;
2857
2858 if (!first) {
2859 err = proc_put_char(&buffer, &left, ',');
2860 if (err)
2861 break;
2862 }
2863 err = proc_put_long(&buffer, &left, bit_a, false);
2864 if (err)
2865 break;
2866 if (bit_a != bit_b) {
2867 err = proc_put_char(&buffer, &left, '-');
2868 if (err)
2869 break;
2870 err = proc_put_long(&buffer, &left, bit_b, false);
2871 if (err)
2872 break;
2873 }
2874
2875 first = 0; bit_b++;
2876 }
2877 if (!err)
2878 err = proc_put_char(&buffer, &left, '\n');
2879 }
2880
2881 if (!err) {
2882 if (write) {
2883 if (*ppos)
2884 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2885 else
2886 memcpy(bitmap, tmp_bitmap,
2887 BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
2888 }
2889 kfree(tmp_bitmap);
2890 *lenp -= left;
2891 *ppos += *lenp;
2892 return 0;
2893 } else {
2894 kfree(tmp_bitmap);
2895 return err;
2896 }
2897}
2898
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899#else /* CONFIG_PROC_FS */
2900
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002901int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002902 void __user *buffer, size_t *lenp, loff_t *ppos)
2903{
2904 return -ENOSYS;
2905}
2906
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002907int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908 void __user *buffer, size_t *lenp, loff_t *ppos)
2909{
2910 return -ENOSYS;
2911}
2912
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002913int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002914 void __user *buffer, size_t *lenp, loff_t *ppos)
2915{
2916 return -ENOSYS;
2917}
2918
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002919int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920 void __user *buffer, size_t *lenp, loff_t *ppos)
2921{
2922 return -ENOSYS;
2923}
2924
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002925int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002926 void __user *buffer, size_t *lenp, loff_t *ppos)
2927{
2928 return -ENOSYS;
2929}
2930
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002931int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 void __user *buffer, size_t *lenp, loff_t *ppos)
2933{
2934 return -ENOSYS;
2935}
2936
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002937int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 void __user *buffer, size_t *lenp, loff_t *ppos)
2939{
2940 return -ENOSYS;
2941}
2942
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002943int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 void __user *buffer,
2945 size_t *lenp, loff_t *ppos)
2946{
2947 return -ENOSYS;
2948}
2949
2950
2951#endif /* CONFIG_PROC_FS */
2952
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953/*
2954 * No sense putting this after each symbol definition, twice,
2955 * exception granted :-)
2956 */
2957EXPORT_SYMBOL(proc_dointvec);
2958EXPORT_SYMBOL(proc_dointvec_jiffies);
2959EXPORT_SYMBOL(proc_dointvec_minmax);
2960EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2961EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2962EXPORT_SYMBOL(proc_dostring);
2963EXPORT_SYMBOL(proc_doulongvec_minmax);
2964EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2965EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002966EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967EXPORT_SYMBOL(unregister_sysctl_table);