blob: 11d53046b9052f05a3dbef149ac1608be2a03d9c [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>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080027#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070029#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020031#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070032#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/init.h>
34#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010035#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030036#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/sysrq.h>
38#include <linux/highuid.h>
39#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020040#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070041#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070044#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/times.h>
46#include <linux/limits.h>
47#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020048#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070050#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080051#include <linux/nfs_fs.h>
52#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070053#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020054#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020055#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050056#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020057#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070058#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040059#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070060#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000061#include <linux/binfmts.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63#include <asm/uaccess.h>
64#include <asm/processor.h>
65
Andi Kleen29cbc782006-09-30 01:47:55 +020066#ifdef CONFIG_X86
67#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010068#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010069#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020070#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080071#ifdef CONFIG_BSD_PROCESS_ACCT
72#include <linux/acct.h>
73#endif
Dave Young4f0e0562010-03-10 15:24:09 -080074#ifdef CONFIG_RT_MUTEXES
75#include <linux/rtmutex.h>
76#endif
Dave Young2edf5e42010-03-10 15:24:10 -080077#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
78#include <linux/lockdep.h>
79#endif
Dave Young15485a42010-03-10 15:24:07 -080080#ifdef CONFIG_CHR_DEV_SG
81#include <scsi/sg.h>
82#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020083
Don Zickus58687ac2010-05-07 17:11:44 -040084#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050085#include <linux/nmi.h>
86#endif
87
Eric W. Biederman7058cb02007-10-18 03:05:58 -070088
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#if defined(CONFIG_SYSCTL)
90
91/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092extern int sysctl_overcommit_memory;
93extern int sysctl_overcommit_ratio;
94extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070096extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070098extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern int pid_max;
100extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800102extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800103extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200104extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100105extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400106extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000107#ifndef CONFIG_MMU
108extern int sysctl_nr_trim_pages;
109#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200110#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200111extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700114/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400115#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200117static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118#endif
119
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700121static int __maybe_unused one = 1;
122static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700123static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800124static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700126#ifdef CONFIG_PRINTK
127static int ten_thousand = 10000;
128#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700130/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
131static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
134static int maxolduid = 65535;
135static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800136static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700139static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Dave Youngd14f1722010-02-25 20:28:57 -0500141#ifdef CONFIG_INOTIFY_USER
142#include <linux/inotify.h>
143#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700144#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700145#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif
147
David S. Miller08714202008-11-16 23:49:24 -0800148#ifdef CONFIG_SPARC64
149extern int sysctl_tsb_ratio;
150#endif
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#ifdef __hppa__
153extern int pwrsw_enabled;
154extern int unaligned_enabled;
155#endif
156
Jes Sorensend2b176e2006-02-28 09:42:23 -0800157#ifdef CONFIG_IA64
158extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800159extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800160#endif
161
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700162#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700163static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700164 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700165static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800166 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700167#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700168
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700169#ifdef CONFIG_PRINTK
170static int proc_dmesg_restrict(struct ctl_table *table, int write,
171 void __user *buffer, size_t *lenp, loff_t *ppos);
172#endif
173
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700174#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800175/* Note: sysrq code uses it's own private copy */
176static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700177
178static int sysrq_sysctl_handler(ctl_table *table, int write,
179 void __user *buffer, size_t *lenp,
180 loff_t *ppos)
181{
182 int error;
183
184 error = proc_dointvec(table, write, buffer, lenp, ppos);
185 if (error)
186 return error;
187
188 if (write)
189 sysrq_toggle_support(__sysrq_enabled);
190
191 return 0;
192}
193
194#endif
195
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700196static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100197static struct ctl_table_root sysctl_table_root;
198static struct ctl_table_header root_table_header = {
Al Virodfef6dc2011-03-08 01:25:28 -0500199 {{.count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100200 .ctl_table = root_table,
Al Virodfef6dc2011-03-08 01:25:28 -0500201 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100202 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400203 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100204};
205static struct ctl_table_root sysctl_table_root = {
206 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400207 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100208};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700210static struct ctl_table kern_table[];
211static struct ctl_table vm_table[];
212static struct ctl_table fs_table[];
213static struct ctl_table debug_table[];
214static struct ctl_table dev_table[];
215extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800216#ifdef CONFIG_EPOLL
217extern struct ctl_table epoll_table[];
218#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
220#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
221int sysctl_legacy_va_layout;
222#endif
223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224/* The default sysctl tables: */
225
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700226static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 .procname = "kernel",
229 .mode = 0555,
230 .child = kern_table,
231 },
232 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 .procname = "vm",
234 .mode = 0555,
235 .child = vm_table,
236 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 .procname = "fs",
239 .mode = 0555,
240 .child = fs_table,
241 },
242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "debug",
244 .mode = 0555,
245 .child = debug_table,
246 },
247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "dev",
249 .mode = 0555,
250 .child = dev_table,
251 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700252 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253};
254
Ingo Molnar77e54a12007-07-09 18:52:00 +0200255#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100256static int min_sched_granularity_ns = 100000; /* 100 usecs */
257static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
258static int min_wakeup_granularity_ns; /* 0 usecs */
259static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100260static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
261static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200262#endif
263
Mel Gorman5e771902010-05-24 14:32:31 -0700264#ifdef CONFIG_COMPACTION
265static int min_extfrag_threshold;
266static int max_extfrag_threshold = 1000;
267#endif
268
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700269static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200270 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200271 .procname = "sched_child_runs_first",
272 .data = &sysctl_sched_child_runs_first,
273 .maxlen = sizeof(unsigned int),
274 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800275 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200276 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200277#ifdef CONFIG_SCHED_DEBUG
278 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100279 .procname = "sched_min_granularity_ns",
280 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281 .maxlen = sizeof(unsigned int),
282 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800283 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100284 .extra1 = &min_sched_granularity_ns,
285 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200286 },
287 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200288 .procname = "sched_latency_ns",
289 .data = &sysctl_sched_latency,
290 .maxlen = sizeof(unsigned int),
291 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800292 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200293 .extra1 = &min_sched_granularity_ns,
294 .extra2 = &max_sched_granularity_ns,
295 },
296 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200297 .procname = "sched_wakeup_granularity_ns",
298 .data = &sysctl_sched_wakeup_granularity,
299 .maxlen = sizeof(unsigned int),
300 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800301 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200302 .extra1 = &min_wakeup_granularity_ns,
303 .extra2 = &max_wakeup_granularity_ns,
304 },
305 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100306 .procname = "sched_tunable_scaling",
307 .data = &sysctl_sched_tunable_scaling,
308 .maxlen = sizeof(enum sched_tunable_scaling),
309 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800310 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100311 .extra1 = &min_sched_tunable_scaling,
312 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200313 },
314 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200315 .procname = "sched_migration_cost",
316 .data = &sysctl_sched_migration_cost,
317 .maxlen = sizeof(unsigned int),
318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800319 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200320 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100321 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100322 .procname = "sched_nr_migrate",
323 .data = &sysctl_sched_nr_migrate,
324 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800326 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100327 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530328 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200329 .procname = "sched_time_avg",
330 .data = &sysctl_sched_time_avg,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800333 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200334 },
335 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800336 .procname = "sched_shares_window",
337 .data = &sysctl_sched_shares_window,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
340 .proc_handler = proc_dointvec,
341 },
342 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530343 .procname = "timer_migration",
344 .data = &sysctl_timer_migration,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800347 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530348 .extra1 = &zero,
349 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530350 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200351#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200352 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100353 .procname = "sched_rt_period_us",
354 .data = &sysctl_sched_rt_period,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800357 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100358 },
359 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100360 .procname = "sched_rt_runtime_us",
361 .data = &sysctl_sched_rt_runtime,
362 .maxlen = sizeof(int),
363 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800364 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100365 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100366#ifdef CONFIG_SCHED_AUTOGROUP
367 {
368 .procname = "sched_autogroup_enabled",
369 .data = &sysctl_sched_autogroup_enabled,
370 .maxlen = sizeof(unsigned int),
371 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800372 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100373 .extra1 = &zero,
374 .extra2 = &one,
375 },
376#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700377#ifdef CONFIG_CFS_BANDWIDTH
378 {
379 .procname = "sched_cfs_bandwidth_slice_us",
380 .data = &sysctl_sched_cfs_bandwidth_slice,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec_minmax,
384 .extra1 = &one,
385 },
386#endif
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 {
Eric Paris17f60a72011-04-01 17:07:50 -0400625 .procname = "usermodehelper",
626 .mode = 0555,
627 .child = usermodehelper_table,
628 },
629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .procname = "overflowuid",
631 .data = &overflowuid,
632 .maxlen = sizeof(int),
633 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800634 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .extra1 = &minolduid,
636 .extra2 = &maxolduid,
637 },
638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "overflowgid",
640 .data = &overflowgid,
641 .maxlen = sizeof(int),
642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800643 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 .extra1 = &minolduid,
645 .extra2 = &maxolduid,
646 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800647#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648#ifdef CONFIG_MATHEMU
649 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .procname = "ieee_emulation_warnings",
651 .data = &sysctl_ieee_emulation_warnings,
652 .maxlen = sizeof(int),
653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 },
656#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200659 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .maxlen = sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 },
664#endif
665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 .procname = "pid_max",
667 .data = &pid_max,
668 .maxlen = sizeof (int),
669 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800670 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .extra1 = &pid_max_min,
672 .extra2 = &pid_max_max,
673 },
674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "panic_on_oops",
676 .data = &panic_on_oops,
677 .maxlen = sizeof(int),
678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800679 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800681#if defined CONFIG_PRINTK
682 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800683 .procname = "printk",
684 .data = &console_loglevel,
685 .maxlen = 4*sizeof(int),
686 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800688 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700691 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .maxlen = sizeof(int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 },
696 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700698 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 .maxlen = sizeof(int),
700 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800701 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 },
Dave Youngaf913222009-09-22 16:43:33 -0700703 {
Dave Youngaf913222009-09-22 16:43:33 -0700704 .procname = "printk_delay",
705 .data = &printk_delay_msec,
706 .maxlen = sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700709 .extra1 = &zero,
710 .extra2 = &ten_thousand,
711 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800713 .procname = "dmesg_restrict",
714 .data = &dmesg_restrict,
715 .maxlen = sizeof(int),
716 .mode = 0644,
717 .proc_handler = proc_dointvec_minmax,
718 .extra1 = &zero,
719 .extra2 = &one,
720 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800721 {
722 .procname = "kptr_restrict",
723 .data = &kptr_restrict,
724 .maxlen = sizeof(int),
725 .mode = 0644,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700726 .proc_handler = proc_dmesg_restrict,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800727 .extra1 = &zero,
728 .extra2 = &two,
729 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800730#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800731 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 .procname = "ngroups_max",
733 .data = &ngroups_max,
734 .maxlen = sizeof (int),
735 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800736 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 },
Dan Ballard73efc032011-10-31 17:11:20 -0700738 {
739 .procname = "cap_last_cap",
740 .data = (void *)&cap_last_cap,
741 .maxlen = sizeof(int),
742 .mode = 0444,
743 .proc_handler = proc_dointvec,
744 },
Don Zickus58687ac2010-05-07 17:11:44 -0400745#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500746 {
Don Zickus58687ac2010-05-07 17:11:44 -0400747 .procname = "watchdog",
748 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500749 .maxlen = sizeof (int),
750 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700751 .proc_handler = proc_dowatchdog,
752 .extra1 = &zero,
753 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400754 },
755 {
756 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700757 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400758 .maxlen = sizeof(int),
759 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700760 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400761 .extra1 = &neg_one,
762 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500763 },
Don Zickus2508ce12010-05-07 17:11:46 -0400764 {
765 .procname = "softlockup_panic",
766 .data = &softlockup_panic,
767 .maxlen = sizeof(int),
768 .mode = 0644,
769 .proc_handler = proc_dointvec_minmax,
770 .extra1 = &zero,
771 .extra2 = &one,
772 },
Don Zickus5dc30552010-11-29 17:07:17 -0500773 {
774 .procname = "nmi_watchdog",
775 .data = &watchdog_enabled,
776 .maxlen = sizeof (int),
777 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700778 .proc_handler = proc_dowatchdog,
779 .extra1 = &zero,
780 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500781 },
782#endif
783#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
784 {
785 .procname = "unknown_nmi_panic",
786 .data = &unknown_nmi_panic,
787 .maxlen = sizeof (int),
788 .mode = 0644,
789 .proc_handler = proc_dointvec,
790 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500791#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792#if defined(CONFIG_X86)
793 {
Don Zickus8da5add2006-09-26 10:52:27 +0200794 .procname = "panic_on_unrecovered_nmi",
795 .data = &panic_on_unrecovered_nmi,
796 .maxlen = sizeof(int),
797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200799 },
800 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700801 .procname = "panic_on_io_nmi",
802 .data = &panic_on_io_nmi,
803 .maxlen = sizeof(int),
804 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800805 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700806 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900807#ifdef CONFIG_DEBUG_STACKOVERFLOW
808 {
809 .procname = "panic_on_stackoverflow",
810 .data = &sysctl_panic_on_stackoverflow,
811 .maxlen = sizeof(int),
812 .mode = 0644,
813 .proc_handler = proc_dointvec,
814 },
815#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700816 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 .procname = "bootloader_type",
818 .data = &bootloader_type,
819 .maxlen = sizeof (int),
820 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800821 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100823 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700824 .procname = "bootloader_version",
825 .data = &bootloader_version,
826 .maxlen = sizeof (int),
827 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800828 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700829 },
830 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100831 .procname = "kstack_depth_to_print",
832 .data = &kstack_depth_to_print,
833 .maxlen = sizeof(int),
834 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800835 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100836 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100837 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100838 .procname = "io_delay_type",
839 .data = &io_delay_type,
840 .maxlen = sizeof(int),
841 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800842 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100843 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800845#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 .procname = "randomize_va_space",
848 .data = &randomize_va_space,
849 .maxlen = sizeof(int),
850 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800851 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800853#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800854#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700855 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700856 .procname = "spin_retry",
857 .data = &spin_retry,
858 .maxlen = sizeof (int),
859 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800860 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700861 },
862#endif
Len Brown673d5b42007-07-28 03:33:16 -0400863#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800864 {
Pavel Machekc255d842006-02-20 18:27:58 -0800865 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700866 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800867 .maxlen = sizeof (unsigned long),
868 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800869 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800870 },
871#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800872#ifdef CONFIG_IA64
873 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800874 .procname = "ignore-unaligned-usertrap",
875 .data = &no_unaligned_warning,
876 .maxlen = sizeof (int),
877 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800878 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800879 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800880 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800881 .procname = "unaligned-dump-stack",
882 .data = &unaligned_dump_stack,
883 .maxlen = sizeof (int),
884 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800885 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800886 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800887#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800888#ifdef CONFIG_DETECT_HUNG_TASK
889 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800890 .procname = "hung_task_panic",
891 .data = &sysctl_hung_task_panic,
892 .maxlen = sizeof(int),
893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800894 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800895 .extra1 = &zero,
896 .extra2 = &one,
897 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100898 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100899 .procname = "hung_task_check_count",
900 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100901 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100902 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800903 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100904 },
905 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100906 .procname = "hung_task_timeout_secs",
907 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100908 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100909 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800910 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100911 },
912 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100913 .procname = "hung_task_warnings",
914 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100915 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100916 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800917 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100918 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700919#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200920#ifdef CONFIG_COMPAT
921 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200922 .procname = "compat-log",
923 .data = &compat_log,
924 .maxlen = sizeof (int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200927 },
928#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700929#ifdef CONFIG_RT_MUTEXES
930 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700931 .procname = "max_lock_depth",
932 .data = &max_lock_depth,
933 .maxlen = sizeof(int),
934 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800935 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700936 },
937#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700938 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700939 .procname = "poweroff_cmd",
940 .data = &poweroff_cmd,
941 .maxlen = POWEROFF_CMD_PATH_LEN,
942 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800943 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700944 },
David Howells0b77f5b2008-04-29 01:01:32 -0700945#ifdef CONFIG_KEYS
946 {
David Howells0b77f5b2008-04-29 01:01:32 -0700947 .procname = "keys",
948 .mode = 0555,
949 .child = key_sysctls,
950 },
951#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700952#ifdef CONFIG_RCU_TORTURE_TEST
953 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700954 .procname = "rcutorture_runnable",
955 .data = &rcutorture_runnable,
956 .maxlen = sizeof(int),
957 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800958 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700959 },
960#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200961#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400962 /*
963 * User-space scripts rely on the existence of this file
964 * as a feature check for perf_events being enabled.
965 *
966 * So it's an ABI, do not remove!
967 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200968 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200969 .procname = "perf_event_paranoid",
970 .data = &sysctl_perf_event_paranoid,
971 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200972 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800973 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200974 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200975 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200976 .procname = "perf_event_mlock_kb",
977 .data = &sysctl_perf_event_mlock,
978 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200979 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800980 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200981 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200982 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200983 .procname = "perf_event_max_sample_rate",
984 .data = &sysctl_perf_event_sample_rate,
985 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200986 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100987 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200988 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200989#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200990#ifdef CONFIG_KMEMCHECK
991 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200992 .procname = "kmemcheck",
993 .data = &kmemcheck_enabled,
994 .maxlen = sizeof(int),
995 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800996 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200997 },
998#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200999#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001000 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001001 .procname = "blk_iopoll",
1002 .data = &blk_iopoll_enabled,
1003 .maxlen = sizeof(int),
1004 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001005 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001006 },
Jens Axboecb684b52009-09-15 21:53:11 +02001007#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001008 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009};
1010
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001011static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 .procname = "overcommit_memory",
1014 .data = &sysctl_overcommit_memory,
1015 .maxlen = sizeof(sysctl_overcommit_memory),
1016 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001017 .proc_handler = proc_dointvec_minmax,
1018 .extra1 = &zero,
1019 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 },
1021 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001022 .procname = "panic_on_oom",
1023 .data = &sysctl_panic_on_oom,
1024 .maxlen = sizeof(sysctl_panic_on_oom),
1025 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001026 .proc_handler = proc_dointvec_minmax,
1027 .extra1 = &zero,
1028 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001029 },
1030 {
David Rientjesfe071d72007-10-16 23:25:56 -07001031 .procname = "oom_kill_allocating_task",
1032 .data = &sysctl_oom_kill_allocating_task,
1033 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1034 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001035 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001036 },
1037 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001038 .procname = "oom_dump_tasks",
1039 .data = &sysctl_oom_dump_tasks,
1040 .maxlen = sizeof(sysctl_oom_dump_tasks),
1041 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001043 },
1044 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 .procname = "overcommit_ratio",
1046 .data = &sysctl_overcommit_ratio,
1047 .maxlen = sizeof(sysctl_overcommit_ratio),
1048 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001049 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 },
1051 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052 .procname = "page-cluster",
1053 .data = &page_cluster,
1054 .maxlen = sizeof(int),
1055 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001056 .proc_handler = proc_dointvec_minmax,
1057 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 },
1059 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 .procname = "dirty_background_ratio",
1061 .data = &dirty_background_ratio,
1062 .maxlen = sizeof(dirty_background_ratio),
1063 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001064 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 .extra1 = &zero,
1066 .extra2 = &one_hundred,
1067 },
1068 {
David Rientjes2da02992009-01-06 14:39:31 -08001069 .procname = "dirty_background_bytes",
1070 .data = &dirty_background_bytes,
1071 .maxlen = sizeof(dirty_background_bytes),
1072 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001073 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001074 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001075 },
1076 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 .procname = "dirty_ratio",
1078 .data = &vm_dirty_ratio,
1079 .maxlen = sizeof(vm_dirty_ratio),
1080 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001081 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 .extra1 = &zero,
1083 .extra2 = &one_hundred,
1084 },
1085 {
David Rientjes2da02992009-01-06 14:39:31 -08001086 .procname = "dirty_bytes",
1087 .data = &vm_dirty_bytes,
1088 .maxlen = sizeof(vm_dirty_bytes),
1089 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001090 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001091 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001092 },
1093 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001095 .data = &dirty_writeback_interval,
1096 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001098 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 },
1100 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001102 .data = &dirty_expire_interval,
1103 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001105 .proc_handler = proc_dointvec_minmax,
1106 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 },
1108 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 .procname = "nr_pdflush_threads",
1110 .data = &nr_pdflush_threads,
1111 .maxlen = sizeof nr_pdflush_threads,
1112 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001113 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 },
1115 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 .procname = "swappiness",
1117 .data = &vm_swappiness,
1118 .maxlen = sizeof(vm_swappiness),
1119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001120 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 .extra1 = &zero,
1122 .extra2 = &one_hundred,
1123 },
1124#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001125 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001127 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 .maxlen = sizeof(unsigned long),
1129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 .extra1 = (void *)&hugetlb_zero,
1132 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001133 },
1134#ifdef CONFIG_NUMA
1135 {
1136 .procname = "nr_hugepages_mempolicy",
1137 .data = NULL,
1138 .maxlen = sizeof(unsigned long),
1139 .mode = 0644,
1140 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1141 .extra1 = (void *)&hugetlb_zero,
1142 .extra2 = (void *)&hugetlb_infinity,
1143 },
1144#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 .procname = "hugetlb_shm_group",
1147 .data = &sysctl_hugetlb_shm_group,
1148 .maxlen = sizeof(gid_t),
1149 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001150 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 },
Mel Gorman396faf02007-07-17 04:03:13 -07001152 {
Mel Gorman396faf02007-07-17 04:03:13 -07001153 .procname = "hugepages_treat_as_movable",
1154 .data = &hugepages_treat_as_movable,
1155 .maxlen = sizeof(int),
1156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001157 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001158 },
Adam Litke54f9f802007-10-16 01:26:20 -07001159 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001160 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001161 .data = NULL,
1162 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001163 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001164 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001165 .extra1 = (void *)&hugetlb_zero,
1166 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001167 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168#endif
1169 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 .procname = "lowmem_reserve_ratio",
1171 .data = &sysctl_lowmem_reserve_ratio,
1172 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 },
1176 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001177 .procname = "drop_caches",
1178 .data = &sysctl_drop_caches,
1179 .maxlen = sizeof(int),
1180 .mode = 0644,
1181 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001182 .extra1 = &one,
1183 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001184 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001185#ifdef CONFIG_COMPACTION
1186 {
1187 .procname = "compact_memory",
1188 .data = &sysctl_compact_memory,
1189 .maxlen = sizeof(int),
1190 .mode = 0200,
1191 .proc_handler = sysctl_compaction_handler,
1192 },
Mel Gorman5e771902010-05-24 14:32:31 -07001193 {
1194 .procname = "extfrag_threshold",
1195 .data = &sysctl_extfrag_threshold,
1196 .maxlen = sizeof(int),
1197 .mode = 0644,
1198 .proc_handler = sysctl_extfrag_handler,
1199 .extra1 = &min_extfrag_threshold,
1200 .extra2 = &max_extfrag_threshold,
1201 },
1202
Mel Gorman76ab0f52010-05-24 14:32:28 -07001203#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001204 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 .procname = "min_free_kbytes",
1206 .data = &min_free_kbytes,
1207 .maxlen = sizeof(min_free_kbytes),
1208 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001209 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210 .extra1 = &zero,
1211 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001212 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001213 .procname = "percpu_pagelist_fraction",
1214 .data = &percpu_pagelist_fraction,
1215 .maxlen = sizeof(percpu_pagelist_fraction),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001218 .extra1 = &min_percpu_pagelist_fract,
1219 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220#ifdef CONFIG_MMU
1221 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 .procname = "max_map_count",
1223 .data = &sysctl_max_map_count,
1224 .maxlen = sizeof(sysctl_max_map_count),
1225 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001226 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001227 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001229#else
1230 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001231 .procname = "nr_trim_pages",
1232 .data = &sysctl_nr_trim_pages,
1233 .maxlen = sizeof(sysctl_nr_trim_pages),
1234 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001235 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001236 .extra1 = &zero,
1237 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238#endif
1239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 .procname = "laptop_mode",
1241 .data = &laptop_mode,
1242 .maxlen = sizeof(laptop_mode),
1243 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001244 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 },
1246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 .procname = "block_dump",
1248 .data = &block_dump,
1249 .maxlen = sizeof(block_dump),
1250 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001251 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252 .extra1 = &zero,
1253 },
1254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .procname = "vfs_cache_pressure",
1256 .data = &sysctl_vfs_cache_pressure,
1257 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1258 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001259 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 .extra1 = &zero,
1261 },
1262#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1263 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 .procname = "legacy_va_layout",
1265 .data = &sysctl_legacy_va_layout,
1266 .maxlen = sizeof(sysctl_legacy_va_layout),
1267 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001268 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 .extra1 = &zero,
1270 },
1271#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001272#ifdef CONFIG_NUMA
1273 {
Christoph Lameter17436602006-01-18 17:42:32 -08001274 .procname = "zone_reclaim_mode",
1275 .data = &zone_reclaim_mode,
1276 .maxlen = sizeof(zone_reclaim_mode),
1277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001278 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001279 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001280 },
Christoph Lameter96146342006-07-03 00:24:13 -07001281 {
Christoph Lameter96146342006-07-03 00:24:13 -07001282 .procname = "min_unmapped_ratio",
1283 .data = &sysctl_min_unmapped_ratio,
1284 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1285 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001286 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001287 .extra1 = &zero,
1288 .extra2 = &one_hundred,
1289 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001290 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001291 .procname = "min_slab_ratio",
1292 .data = &sysctl_min_slab_ratio,
1293 .maxlen = sizeof(sysctl_min_slab_ratio),
1294 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001295 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001296 .extra1 = &zero,
1297 .extra2 = &one_hundred,
1298 },
Christoph Lameter17436602006-01-18 17:42:32 -08001299#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001300#ifdef CONFIG_SMP
1301 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001302 .procname = "stat_interval",
1303 .data = &sysctl_stat_interval,
1304 .maxlen = sizeof(sysctl_stat_interval),
1305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001306 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001307 },
1308#endif
David Howells6e141542009-12-15 19:27:45 +00001309#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001310 {
Eric Parised032182007-06-28 15:55:21 -04001311 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001312 .data = &dac_mmap_min_addr,
1313 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001314 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001316 },
David Howells6e141542009-12-15 19:27:45 +00001317#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001318#ifdef CONFIG_NUMA
1319 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001320 .procname = "numa_zonelist_order",
1321 .data = &numa_zonelist_order,
1322 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001325 },
1326#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001327#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001328 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001329 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001330 .procname = "vdso_enabled",
1331 .data = &vdso_enabled,
1332 .maxlen = sizeof(vdso_enabled),
1333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001335 .extra1 = &zero,
1336 },
1337#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001338#ifdef CONFIG_HIGHMEM
1339 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001340 .procname = "highmem_is_dirtyable",
1341 .data = &vm_highmem_is_dirtyable,
1342 .maxlen = sizeof(vm_highmem_is_dirtyable),
1343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001344 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001345 .extra1 = &zero,
1346 .extra2 = &one,
1347 },
1348#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001349 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001350 .procname = "scan_unevictable_pages",
1351 .data = &scan_unevictable_pages,
1352 .maxlen = sizeof(scan_unevictable_pages),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001355 },
Andi Kleen6a460792009-09-16 11:50:15 +02001356#ifdef CONFIG_MEMORY_FAILURE
1357 {
Andi Kleen6a460792009-09-16 11:50:15 +02001358 .procname = "memory_failure_early_kill",
1359 .data = &sysctl_memory_failure_early_kill,
1360 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001363 .extra1 = &zero,
1364 .extra2 = &one,
1365 },
1366 {
Andi Kleen6a460792009-09-16 11:50:15 +02001367 .procname = "memory_failure_recovery",
1368 .data = &sysctl_memory_failure_recovery,
1369 .maxlen = sizeof(sysctl_memory_failure_recovery),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001372 .extra1 = &zero,
1373 .extra2 = &one,
1374 },
1375#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001376 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377};
1378
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001379#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001380static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001381 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001382};
1383#endif
1384
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001385static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 .procname = "inode-nr",
1388 .data = &inodes_stat,
1389 .maxlen = 2*sizeof(int),
1390 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001391 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 },
1393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 .procname = "inode-state",
1395 .data = &inodes_stat,
1396 .maxlen = 7*sizeof(int),
1397 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001398 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 },
1400 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 .procname = "file-nr",
1402 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001403 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 },
1407 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 .procname = "file-max",
1409 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001410 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001412 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 },
1414 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001415 .procname = "nr_open",
1416 .data = &sysctl_nr_open,
1417 .maxlen = sizeof(int),
1418 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001419 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001420 .extra1 = &sysctl_nr_open_min,
1421 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001422 },
1423 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 .procname = "dentry-state",
1425 .data = &dentry_stat,
1426 .maxlen = 6*sizeof(int),
1427 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001428 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 },
1430 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 .procname = "overflowuid",
1432 .data = &fs_overflowuid,
1433 .maxlen = sizeof(int),
1434 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001435 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 .extra1 = &minolduid,
1437 .extra2 = &maxolduid,
1438 },
1439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 .procname = "overflowgid",
1441 .data = &fs_overflowgid,
1442 .maxlen = sizeof(int),
1443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001444 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 .extra1 = &minolduid,
1446 .extra2 = &maxolduid,
1447 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001448#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "leases-enable",
1451 .data = &leases_enable,
1452 .maxlen = sizeof(int),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001456#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457#ifdef CONFIG_DNOTIFY
1458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .procname = "dir-notify-enable",
1460 .data = &dir_notify_enable,
1461 .maxlen = sizeof(int),
1462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001463 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 },
1465#endif
1466#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001467#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .procname = "lease-break-time",
1470 .data = &lease_break_time,
1471 .maxlen = sizeof(int),
1472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001473 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001475#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001476#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "aio-nr",
1479 .data = &aio_nr,
1480 .maxlen = sizeof(aio_nr),
1481 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 },
1484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "aio-max-nr",
1486 .data = &aio_max_nr,
1487 .maxlen = sizeof(aio_max_nr),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001491#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001492#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001493 {
Robert Love0399cb02005-07-13 12:38:18 -04001494 .procname = "inotify",
1495 .mode = 0555,
1496 .child = inotify_table,
1497 },
1498#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001499#ifdef CONFIG_EPOLL
1500 {
1501 .procname = "epoll",
1502 .mode = 0555,
1503 .child = epoll_table,
1504 },
1505#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001507 {
Alan Coxd6e71142005-06-23 00:09:43 -07001508 .procname = "suid_dumpable",
1509 .data = &suid_dumpable,
1510 .maxlen = sizeof(int),
1511 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001512 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001513 .extra1 = &zero,
1514 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001515 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001516#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1517 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001518 .procname = "binfmt_misc",
1519 .mode = 0555,
1520 .child = binfmt_misc_table,
1521 },
1522#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001523 {
Jens Axboeff9da692010-06-03 14:54:39 +02001524 .procname = "pipe-max-size",
1525 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001526 .maxlen = sizeof(int),
1527 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001528 .proc_handler = &pipe_proc_fn,
1529 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001530 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001531 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532};
1533
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001534static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001535#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001536 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001537 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001538 .procname = "exception-trace",
1539 .data = &show_unhandled_signals,
1540 .maxlen = sizeof(int),
1541 .mode = 0644,
1542 .proc_handler = proc_dointvec
1543 },
1544#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001545#if defined(CONFIG_OPTPROBES)
1546 {
1547 .procname = "kprobes-optimization",
1548 .data = &sysctl_kprobes_optimization,
1549 .maxlen = sizeof(int),
1550 .mode = 0644,
1551 .proc_handler = proc_kprobes_optimization_handler,
1552 .extra1 = &zero,
1553 .extra2 = &one,
1554 },
1555#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001556 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557};
1558
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001559static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001560 { }
Robert Love0eeca282005-07-12 17:06:03 -04001561};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562
Al Viro330d57f2005-11-04 10:18:40 +00001563static DEFINE_SPINLOCK(sysctl_lock);
1564
1565/* called under sysctl_lock */
1566static int use_table(struct ctl_table_header *p)
1567{
1568 if (unlikely(p->unregistering))
1569 return 0;
1570 p->used++;
1571 return 1;
1572}
1573
1574/* called under sysctl_lock */
1575static void unuse_table(struct ctl_table_header *p)
1576{
1577 if (!--p->used)
1578 if (unlikely(p->unregistering))
1579 complete(p->unregistering);
1580}
1581
1582/* called under sysctl_lock, will reacquire if has to wait */
1583static void start_unregistering(struct ctl_table_header *p)
1584{
1585 /*
1586 * if p->used is 0, nobody will ever touch that entry again;
1587 * we'll eliminate all paths to it before dropping sysctl_lock
1588 */
1589 if (unlikely(p->used)) {
1590 struct completion wait;
1591 init_completion(&wait);
1592 p->unregistering = &wait;
1593 spin_unlock(&sysctl_lock);
1594 wait_for_completion(&wait);
1595 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001596 } else {
1597 /* anything non-NULL; we'll never dereference it */
1598 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001599 }
1600 /*
1601 * do not remove from the list until nobody holds it; walking the
1602 * list in do_sysctl() relies on that.
1603 */
1604 list_del_init(&p->ctl_entry);
1605}
1606
Al Virof7e6ced2008-07-15 01:44:23 -04001607void sysctl_head_get(struct ctl_table_header *head)
1608{
1609 spin_lock(&sysctl_lock);
1610 head->count++;
1611 spin_unlock(&sysctl_lock);
1612}
1613
1614void sysctl_head_put(struct ctl_table_header *head)
1615{
1616 spin_lock(&sysctl_lock);
1617 if (!--head->count)
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001618 kfree_rcu(head, rcu);
Al Virof7e6ced2008-07-15 01:44:23 -04001619 spin_unlock(&sysctl_lock);
1620}
1621
1622struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1623{
1624 if (!head)
1625 BUG();
1626 spin_lock(&sysctl_lock);
1627 if (!use_table(head))
1628 head = ERR_PTR(-ENOENT);
1629 spin_unlock(&sysctl_lock);
1630 return head;
1631}
1632
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001633void sysctl_head_finish(struct ctl_table_header *head)
1634{
1635 if (!head)
1636 return;
1637 spin_lock(&sysctl_lock);
1638 unuse_table(head);
1639 spin_unlock(&sysctl_lock);
1640}
1641
Al Viro73455092008-07-14 21:22:20 -04001642static struct ctl_table_set *
1643lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1644{
1645 struct ctl_table_set *set = &root->default_set;
1646 if (root->lookup)
1647 set = root->lookup(root, namespaces);
1648 return set;
1649}
1650
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001651static struct list_head *
1652lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001653{
Al Viro73455092008-07-14 21:22:20 -04001654 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1655 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001656}
1657
1658struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1659 struct ctl_table_header *prev)
1660{
1661 struct ctl_table_root *root;
1662 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001663 struct ctl_table_header *head;
1664 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001665
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001666 spin_lock(&sysctl_lock);
1667 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001668 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001669 tmp = &prev->ctl_entry;
1670 unuse_table(prev);
1671 goto next;
1672 }
1673 tmp = &root_table_header.ctl_entry;
1674 for (;;) {
1675 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1676
1677 if (!use_table(head))
1678 goto next;
1679 spin_unlock(&sysctl_lock);
1680 return head;
1681 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001682 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001683 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001684 header_list = lookup_header_list(root, namespaces);
1685 if (tmp != header_list)
1686 continue;
1687
1688 do {
1689 root = list_entry(root->root_list.next,
1690 struct ctl_table_root, root_list);
1691 if (root == &sysctl_table_root)
1692 goto out;
1693 header_list = lookup_header_list(root, namespaces);
1694 } while (list_empty(header_list));
1695 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001696 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001697out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001698 spin_unlock(&sysctl_lock);
1699 return NULL;
1700}
1701
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001702struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1703{
1704 return __sysctl_head_next(current->nsproxy, prev);
1705}
1706
1707void register_sysctl_root(struct ctl_table_root *root)
1708{
1709 spin_lock(&sysctl_lock);
1710 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1711 spin_unlock(&sysctl_lock);
1712}
1713
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714/*
Eric W. Biederman1ff007eb2007-02-14 00:34:11 -08001715 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716 * some sysctl variables are readonly even to root.
1717 */
1718
1719static int test_perm(int mode, int op)
1720{
David Howells76aac0e2008-11-14 10:39:12 +11001721 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 mode >>= 6;
1723 else if (in_egroup_p(0))
1724 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001725 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 return 0;
1727 return -EACCES;
1728}
1729
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001730int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731{
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001732 int mode;
1733
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001734 if (root->permissions)
1735 mode = root->permissions(root, current->nsproxy, table);
1736 else
1737 mode = table->mode;
1738
1739 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740}
1741
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001742static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1743{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001744 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001745 table->parent = parent;
1746 if (table->child)
1747 sysctl_set_parent(table, table->child);
1748 }
1749}
1750
1751static __init int sysctl_init(void)
1752{
1753 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001754#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Andi Kleenb3bd3de2010-08-10 14:17:51 -07001755 sysctl_check_table(current->nsproxy, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001756#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001757 return 0;
1758}
1759
1760core_initcall(sysctl_init);
1761
Al Virobfbcf032008-07-27 06:31:22 +01001762static struct ctl_table *is_branch_in(struct ctl_table *branch,
1763 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001764{
1765 struct ctl_table *p;
1766 const char *s = branch->procname;
1767
1768 /* branch should have named subdirectory as its first element */
1769 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001770 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001771
1772 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001773 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001774 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001775
1776 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001777 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001778 if (!p->child)
1779 continue;
1780 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001781 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001782 }
Al Virobfbcf032008-07-27 06:31:22 +01001783 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001784}
1785
1786/* see if attaching q to p would be an improvement */
1787static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1788{
1789 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001790 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001791 int is_better = 0;
1792 int not_in_parent = !p->attached_by;
1793
Al Virobfbcf032008-07-27 06:31:22 +01001794 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001795 if (by == q->attached_by)
1796 is_better = 1;
1797 if (to == p->attached_by)
1798 not_in_parent = 1;
1799 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001800 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001801 }
1802
1803 if (is_better && not_in_parent) {
1804 q->attached_by = by;
1805 q->attached_to = to;
1806 q->parent = p;
1807 }
1808}
1809
Linus Torvalds1da177e2005-04-16 15:20:36 -07001810/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001811 * __register_sysctl_paths - register a sysctl hierarchy
1812 * @root: List of sysctl headers to register on
1813 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001814 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816 *
1817 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001818 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001820 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001821 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1823 * enter a sysctl file
1824 *
1825 * data - a pointer to data for use by proc_handler
1826 *
1827 * maxlen - the maximum size in bytes of the data
1828 *
1829 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1830 *
1831 * child - a pointer to the child sysctl table if this entry is a directory, or
1832 * %NULL.
1833 *
1834 * proc_handler - the text handler routine (described below)
1835 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836 * de - for internal use by the sysctl routines
1837 *
1838 * extra1, extra2 - extra pointers usable by the proc handler routines
1839 *
1840 * Leaf nodes in the sysctl tree will be represented by a single file
1841 * under /proc; non-leaf nodes will be represented by directories.
1842 *
1843 * sysctl(2) can automatically manage read and write requests through
1844 * the sysctl table. The data and maxlen fields of the ctl_table
1845 * struct enable minimal validation of the values being written to be
1846 * performed, and the mode field allows minimal authentication.
1847 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 * There must be a proc_handler routine for any terminal nodes
1849 * mirrored under /proc/sys (non-terminals are handled by a built-in
1850 * directory handler). Several default handlers are available to
1851 * cover common cases -
1852 *
1853 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1854 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1855 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1856 *
1857 * It is the handler's job to read the input buffer from user memory
1858 * and process it. The handler should return 0 on success.
1859 *
1860 * This routine returns %NULL on a failure to register, and a pointer
1861 * to the table header on success.
1862 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001863struct ctl_table_header *__register_sysctl_paths(
1864 struct ctl_table_root *root,
1865 struct nsproxy *namespaces,
1866 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001868 struct ctl_table_header *header;
1869 struct ctl_table *new, **prevp;
1870 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001871 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001872
1873 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001874 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001875 ;
1876
1877 /*
1878 * For each path component, allocate a 2-element ctl_table array.
1879 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001880 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001881 *
1882 * We allocate everything in one go so that we don't have to
1883 * worry about freeing additional memory in unregister_sysctl_table.
1884 */
1885 header = kzalloc(sizeof(struct ctl_table_header) +
1886 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1887 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001889
1890 new = (struct ctl_table *) (header + 1);
1891
1892 /* Now connect the dots */
1893 prevp = &header->ctl_table;
1894 for (n = 0; n < npath; ++n, ++path) {
1895 /* Copy the procname */
1896 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001897 new->mode = 0555;
1898
1899 *prevp = new;
1900 prevp = &new->child;
1901
1902 new += 2;
1903 }
1904 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001905 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001906
1907 INIT_LIST_HEAD(&header->ctl_entry);
1908 header->used = 0;
1909 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001910 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001911 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001912 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001913#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001914 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001915 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001916 return NULL;
1917 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001918#endif
Al Viro330d57f2005-11-04 10:18:40 +00001919 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001920 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001921 header->attached_by = header->ctl_table;
1922 header->attached_to = root_table;
1923 header->parent = &root_table_header;
1924 for (set = header->set; set; set = set->parent) {
1925 struct ctl_table_header *p;
1926 list_for_each_entry(p, &set->list, ctl_entry) {
1927 if (p->unregistering)
1928 continue;
1929 try_attach(p, header);
1930 }
1931 }
1932 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001933 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001934 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001935
1936 return header;
1937}
1938
1939/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001940 * register_sysctl_table_path - register a sysctl table hierarchy
1941 * @path: The path to the directory the sysctl table is in.
1942 * @table: the top-level table structure
1943 *
1944 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1945 * array. A completely 0 filled entry terminates the table.
1946 *
1947 * See __register_sysctl_paths for more details.
1948 */
1949struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1950 struct ctl_table *table)
1951{
1952 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1953 path, table);
1954}
1955
1956/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001957 * register_sysctl_table - register a sysctl table hierarchy
1958 * @table: the top-level table structure
1959 *
1960 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1961 * array. A completely 0 filled entry terminates the table.
1962 *
1963 * See register_sysctl_paths for more details.
1964 */
1965struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1966{
1967 static const struct ctl_path null_path[] = { {} };
1968
1969 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970}
1971
1972/**
1973 * unregister_sysctl_table - unregister a sysctl table hierarchy
1974 * @header: the header returned from register_sysctl_table
1975 *
1976 * Unregisters the sysctl table and all children. proc entries may not
1977 * actually be removed until they are no longer used by anyone.
1978 */
1979void unregister_sysctl_table(struct ctl_table_header * header)
1980{
Al Viro330d57f2005-11-04 10:18:40 +00001981 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001982
1983 if (header == NULL)
1984 return;
1985
Al Viro330d57f2005-11-04 10:18:40 +00001986 spin_lock(&sysctl_lock);
1987 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001988 if (!--header->parent->count) {
1989 WARN_ON(1);
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001990 kfree_rcu(header->parent, rcu);
Al Viroae7edec2008-07-15 06:33:31 -04001991 }
Al Virof7e6ced2008-07-15 01:44:23 -04001992 if (!--header->count)
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001993 kfree_rcu(header, rcu);
Al Viro330d57f2005-11-04 10:18:40 +00001994 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995}
1996
Al Viro90434762008-07-15 08:54:06 -04001997int sysctl_is_seen(struct ctl_table_header *p)
1998{
1999 struct ctl_table_set *set = p->set;
2000 int res;
2001 spin_lock(&sysctl_lock);
2002 if (p->unregistering)
2003 res = 0;
2004 else if (!set->is_seen)
2005 res = 1;
2006 else
2007 res = set->is_seen(set);
2008 spin_unlock(&sysctl_lock);
2009 return res;
2010}
2011
Al Viro73455092008-07-14 21:22:20 -04002012void setup_sysctl_set(struct ctl_table_set *p,
2013 struct ctl_table_set *parent,
2014 int (*is_seen)(struct ctl_table_set *))
2015{
2016 INIT_LIST_HEAD(&p->list);
2017 p->parent = parent ? parent : &sysctl_table_root.default_set;
2018 p->is_seen = is_seen;
2019}
2020
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002021#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002022struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002023{
2024 return NULL;
2025}
2026
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002027struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2028 struct ctl_table *table)
2029{
2030 return NULL;
2031}
2032
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002033void unregister_sysctl_table(struct ctl_table_header * table)
2034{
2035}
2036
Al Viro73455092008-07-14 21:22:20 -04002037void setup_sysctl_set(struct ctl_table_set *p,
2038 struct ctl_table_set *parent,
2039 int (*is_seen)(struct ctl_table_set *))
2040{
2041}
2042
Al Virof7e6ced2008-07-15 01:44:23 -04002043void sysctl_head_put(struct ctl_table_header *head)
2044{
2045}
2046
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002047#endif /* CONFIG_SYSCTL */
2048
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049/*
2050 * /proc/sys support
2051 */
2052
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002053#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002055static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002056 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002057 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002058{
2059 size_t len;
2060 char __user *p;
2061 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002062
2063 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002064 *lenp = 0;
2065 return 0;
2066 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002067
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002068 if (write) {
2069 len = 0;
2070 p = buffer;
2071 while (len < *lenp) {
2072 if (get_user(c, p++))
2073 return -EFAULT;
2074 if (c == 0 || c == '\n')
2075 break;
2076 len++;
2077 }
2078 if (len >= maxlen)
2079 len = maxlen-1;
2080 if(copy_from_user(data, buffer, len))
2081 return -EFAULT;
2082 ((char *) data)[len] = 0;
2083 *ppos += *lenp;
2084 } else {
2085 len = strlen(data);
2086 if (len > maxlen)
2087 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002088
2089 if (*ppos > len) {
2090 *lenp = 0;
2091 return 0;
2092 }
2093
2094 data += *ppos;
2095 len -= *ppos;
2096
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002097 if (len > *lenp)
2098 len = *lenp;
2099 if (len)
2100 if(copy_to_user(buffer, data, len))
2101 return -EFAULT;
2102 if (len < *lenp) {
2103 if(put_user('\n', ((char __user *) buffer) + len))
2104 return -EFAULT;
2105 len++;
2106 }
2107 *lenp = len;
2108 *ppos += len;
2109 }
2110 return 0;
2111}
2112
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113/**
2114 * proc_dostring - read a string sysctl
2115 * @table: the sysctl table
2116 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117 * @buffer: the user buffer
2118 * @lenp: the size of the user buffer
2119 * @ppos: file position
2120 *
2121 * Reads/writes a string from/to the user buffer. If the kernel
2122 * buffer provided is not large enough to hold the string, the
2123 * string is truncated. The copied string is %NULL-terminated.
2124 * If the string is being read by the user process, it is copied
2125 * and a newline '\n' is added. It is truncated if the buffer is
2126 * not large enough.
2127 *
2128 * Returns 0 on success.
2129 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002130int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131 void __user *buffer, size_t *lenp, loff_t *ppos)
2132{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002133 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002134 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135}
2136
Amerigo Wang00b7c332010-05-05 00:26:45 +00002137static size_t proc_skip_spaces(char **buf)
2138{
2139 size_t ret;
2140 char *tmp = skip_spaces(*buf);
2141 ret = tmp - *buf;
2142 *buf = tmp;
2143 return ret;
2144}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002146static void proc_skip_char(char **buf, size_t *size, const char v)
2147{
2148 while (*size) {
2149 if (**buf != v)
2150 break;
2151 (*size)--;
2152 (*buf)++;
2153 }
2154}
2155
Amerigo Wang00b7c332010-05-05 00:26:45 +00002156#define TMPBUFLEN 22
2157/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002158 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002160 * @buf: a kernel buffer
2161 * @size: size of the kernel buffer
2162 * @val: this is where the number will be stored
2163 * @neg: set to %TRUE if number is negative
2164 * @perm_tr: a vector which contains the allowed trailers
2165 * @perm_tr_len: size of the perm_tr vector
2166 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002167 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002168 * In case of success %0 is returned and @buf and @size are updated with
2169 * the amount of bytes read. If @tr is non-NULL and a trailing
2170 * character exists (size is non-zero after returning from this
2171 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 */
2173static int proc_get_long(char **buf, size_t *size,
2174 unsigned long *val, bool *neg,
2175 const char *perm_tr, unsigned perm_tr_len, char *tr)
2176{
2177 int len;
2178 char *p, tmp[TMPBUFLEN];
2179
2180 if (!*size)
2181 return -EINVAL;
2182
2183 len = *size;
2184 if (len > TMPBUFLEN - 1)
2185 len = TMPBUFLEN - 1;
2186
2187 memcpy(tmp, *buf, len);
2188
2189 tmp[len] = 0;
2190 p = tmp;
2191 if (*p == '-' && *size > 1) {
2192 *neg = true;
2193 p++;
2194 } else
2195 *neg = false;
2196 if (!isdigit(*p))
2197 return -EINVAL;
2198
2199 *val = simple_strtoul(p, &p, 0);
2200
2201 len = p - tmp;
2202
2203 /* We don't know if the next char is whitespace thus we may accept
2204 * invalid integers (e.g. 1234...a) or two integers instead of one
2205 * (e.g. 123...1). So lets not allow such large numbers. */
2206 if (len == TMPBUFLEN - 1)
2207 return -EINVAL;
2208
2209 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2210 return -EINVAL;
2211
2212 if (tr && (len < *size))
2213 *tr = *p;
2214
2215 *buf += len;
2216 *size -= len;
2217
2218 return 0;
2219}
2220
2221/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002222 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002223 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002224 * @buf: the user buffer
2225 * @size: the size of the user buffer
2226 * @val: the integer to be converted
2227 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002228 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002229 * In case of success %0 is returned and @buf and @size are updated with
2230 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002231 */
2232static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2233 bool neg)
2234{
2235 int len;
2236 char tmp[TMPBUFLEN], *p = tmp;
2237
2238 sprintf(p, "%s%lu", neg ? "-" : "", val);
2239 len = strlen(tmp);
2240 if (len > *size)
2241 len = *size;
2242 if (copy_to_user(*buf, tmp, len))
2243 return -EFAULT;
2244 *size -= len;
2245 *buf += len;
2246 return 0;
2247}
2248#undef TMPBUFLEN
2249
2250static int proc_put_char(void __user **buf, size_t *size, char c)
2251{
2252 if (*size) {
2253 char __user **buffer = (char __user **)buf;
2254 if (put_user(c, *buffer))
2255 return -EFAULT;
2256 (*size)--, (*buffer)++;
2257 *buf = *buffer;
2258 }
2259 return 0;
2260}
2261
2262static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 int *valp,
2264 int write, void *data)
2265{
2266 if (write) {
2267 *valp = *negp ? -*lvalp : *lvalp;
2268 } else {
2269 int val = *valp;
2270 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002271 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 *lvalp = (unsigned long)-val;
2273 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002274 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 *lvalp = (unsigned long)val;
2276 }
2277 }
2278 return 0;
2279}
2280
Amerigo Wang00b7c332010-05-05 00:26:45 +00002281static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2282
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002283static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002284 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002285 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002286 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287 int write, void *data),
2288 void *data)
2289{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002290 int *i, vleft, first = 1, err = 0;
2291 unsigned long page = 0;
2292 size_t left;
2293 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294
Amerigo Wang00b7c332010-05-05 00:26:45 +00002295 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 *lenp = 0;
2297 return 0;
2298 }
2299
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002300 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 vleft = table->maxlen / sizeof(*i);
2302 left = *lenp;
2303
2304 if (!conv)
2305 conv = do_proc_dointvec_conv;
2306
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002308 if (left > PAGE_SIZE - 1)
2309 left = PAGE_SIZE - 1;
2310 page = __get_free_page(GFP_TEMPORARY);
2311 kbuf = (char *) page;
2312 if (!kbuf)
2313 return -ENOMEM;
2314 if (copy_from_user(kbuf, buffer, left)) {
2315 err = -EFAULT;
2316 goto free;
2317 }
2318 kbuf[left] = 0;
2319 }
2320
2321 for (; left && vleft--; i++, first=0) {
2322 unsigned long lval;
2323 bool neg;
2324
2325 if (write) {
2326 left -= proc_skip_spaces(&kbuf);
2327
J. R. Okajima563b0462010-05-25 16:10:14 -07002328 if (!left)
2329 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002330 err = proc_get_long(&kbuf, &left, &lval, &neg,
2331 proc_wspace_sep,
2332 sizeof(proc_wspace_sep), NULL);
2333 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 if (conv(&neg, &lval, i, 1, data)) {
2336 err = -EINVAL;
2337 break;
2338 }
2339 } else {
2340 if (conv(&neg, &lval, i, 0, data)) {
2341 err = -EINVAL;
2342 break;
2343 }
2344 if (!first)
2345 err = proc_put_char(&buffer, &left, '\t');
2346 if (err)
2347 break;
2348 err = proc_put_long(&buffer, &left, lval, neg);
2349 if (err)
2350 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 }
2352 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002353
2354 if (!write && !first && left && !err)
2355 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002356 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002357 left -= proc_skip_spaces(&kbuf);
2358free:
2359 if (write) {
2360 free_page(page);
2361 if (first)
2362 return err ? : -EINVAL;
2363 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364 *lenp -= left;
2365 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002366 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367}
2368
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002369static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002370 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002371 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002372 int write, void *data),
2373 void *data)
2374{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002375 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002376 buffer, lenp, ppos, conv, data);
2377}
2378
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379/**
2380 * proc_dointvec - read a vector of integers
2381 * @table: the sysctl table
2382 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 * @buffer: the user buffer
2384 * @lenp: the size of the user buffer
2385 * @ppos: file position
2386 *
2387 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2388 * values from/to the user buffer, treated as an ASCII string.
2389 *
2390 * Returns 0 on success.
2391 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002392int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 void __user *buffer, size_t *lenp, loff_t *ppos)
2394{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002395 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 NULL,NULL);
2397}
2398
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002399/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002400 * Taint values can only be increased
2401 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002402 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002404 void __user *buffer, size_t *lenp, loff_t *ppos)
2405{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002406 struct ctl_table t;
2407 unsigned long tmptaint = get_taint();
2408 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002409
Bastian Blank91fcd412007-04-23 14:41:14 -07002410 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002411 return -EPERM;
2412
Andi Kleen25ddbb12008-10-15 22:01:41 -07002413 t = *table;
2414 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002415 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002416 if (err < 0)
2417 return err;
2418
2419 if (write) {
2420 /*
2421 * Poor man's atomic or. Not worth adding a primitive
2422 * to everyone's atomic.h for this
2423 */
2424 int i;
2425 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2426 if ((tmptaint >> i) & 1)
2427 add_taint(i);
2428 }
2429 }
2430
2431 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002432}
2433
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002434#ifdef CONFIG_PRINTK
2435static int proc_dmesg_restrict(struct ctl_table *table, int write,
2436 void __user *buffer, size_t *lenp, loff_t *ppos)
2437{
2438 if (write && !capable(CAP_SYS_ADMIN))
2439 return -EPERM;
2440
2441 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2442}
2443#endif
2444
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445struct do_proc_dointvec_minmax_conv_param {
2446 int *min;
2447 int *max;
2448};
2449
Amerigo Wang00b7c332010-05-05 00:26:45 +00002450static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2451 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 int write, void *data)
2453{
2454 struct do_proc_dointvec_minmax_conv_param *param = data;
2455 if (write) {
2456 int val = *negp ? -*lvalp : *lvalp;
2457 if ((param->min && *param->min > val) ||
2458 (param->max && *param->max < val))
2459 return -EINVAL;
2460 *valp = val;
2461 } else {
2462 int val = *valp;
2463 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002464 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002465 *lvalp = (unsigned long)-val;
2466 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002467 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 *lvalp = (unsigned long)val;
2469 }
2470 }
2471 return 0;
2472}
2473
2474/**
2475 * proc_dointvec_minmax - read a vector of integers with min/max values
2476 * @table: the sysctl table
2477 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 * @buffer: the user buffer
2479 * @lenp: the size of the user buffer
2480 * @ppos: file position
2481 *
2482 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2483 * values from/to the user buffer, treated as an ASCII string.
2484 *
2485 * This routine will ensure the values are within the range specified by
2486 * table->extra1 (min) and table->extra2 (max).
2487 *
2488 * Returns 0 on success.
2489 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002490int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 void __user *buffer, size_t *lenp, loff_t *ppos)
2492{
2493 struct do_proc_dointvec_minmax_conv_param param = {
2494 .min = (int *) table->extra1,
2495 .max = (int *) table->extra2,
2496 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002497 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 do_proc_dointvec_minmax_conv, &param);
2499}
2500
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002501static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502 void __user *buffer,
2503 size_t *lenp, loff_t *ppos,
2504 unsigned long convmul,
2505 unsigned long convdiv)
2506{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002507 unsigned long *i, *min, *max;
2508 int vleft, first = 1, err = 0;
2509 unsigned long page = 0;
2510 size_t left;
2511 char *kbuf;
2512
2513 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 *lenp = 0;
2515 return 0;
2516 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002517
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002518 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 min = (unsigned long *) table->extra1;
2520 max = (unsigned long *) table->extra2;
2521 vleft = table->maxlen / sizeof(unsigned long);
2522 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002523
2524 if (write) {
2525 if (left > PAGE_SIZE - 1)
2526 left = PAGE_SIZE - 1;
2527 page = __get_free_page(GFP_TEMPORARY);
2528 kbuf = (char *) page;
2529 if (!kbuf)
2530 return -ENOMEM;
2531 if (copy_from_user(kbuf, buffer, left)) {
2532 err = -EFAULT;
2533 goto free;
2534 }
2535 kbuf[left] = 0;
2536 }
2537
Eric Dumazet27b3d802010-10-07 12:59:29 -07002538 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002539 unsigned long val;
2540
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002542 bool neg;
2543
2544 left -= proc_skip_spaces(&kbuf);
2545
2546 err = proc_get_long(&kbuf, &left, &val, &neg,
2547 proc_wspace_sep,
2548 sizeof(proc_wspace_sep), NULL);
2549 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 break;
2551 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 continue;
2553 if ((min && val < *min) || (max && val > *max))
2554 continue;
2555 *i = val;
2556 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002557 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002559 err = proc_put_char(&buffer, &left, '\t');
2560 err = proc_put_long(&buffer, &left, val, false);
2561 if (err)
2562 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 }
2564 }
2565
Amerigo Wang00b7c332010-05-05 00:26:45 +00002566 if (!write && !first && left && !err)
2567 err = proc_put_char(&buffer, &left, '\n');
2568 if (write && !err)
2569 left -= proc_skip_spaces(&kbuf);
2570free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002572 free_page(page);
2573 if (first)
2574 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 *lenp -= left;
2577 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002578 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579}
2580
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002581static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002582 void __user *buffer,
2583 size_t *lenp, loff_t *ppos,
2584 unsigned long convmul,
2585 unsigned long convdiv)
2586{
2587 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002588 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002589}
2590
Linus Torvalds1da177e2005-04-16 15:20:36 -07002591/**
2592 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2593 * @table: the sysctl table
2594 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 * @buffer: the user buffer
2596 * @lenp: the size of the user buffer
2597 * @ppos: file position
2598 *
2599 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2600 * values from/to the user buffer, treated as an ASCII string.
2601 *
2602 * This routine will ensure the values are within the range specified by
2603 * table->extra1 (min) and table->extra2 (max).
2604 *
2605 * Returns 0 on success.
2606 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002607int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 void __user *buffer, size_t *lenp, loff_t *ppos)
2609{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002610 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611}
2612
2613/**
2614 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2615 * @table: the sysctl table
2616 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 * @buffer: the user buffer
2618 * @lenp: the size of the user buffer
2619 * @ppos: file position
2620 *
2621 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2622 * values from/to the user buffer, treated as an ASCII string. The values
2623 * are treated as milliseconds, and converted to jiffies when they are stored.
2624 *
2625 * This routine will ensure the values are within the range specified by
2626 * table->extra1 (min) and table->extra2 (max).
2627 *
2628 * Returns 0 on success.
2629 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002630int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 void __user *buffer,
2632 size_t *lenp, loff_t *ppos)
2633{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002634 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 lenp, ppos, HZ, 1000l);
2636}
2637
2638
Amerigo Wang00b7c332010-05-05 00:26:45 +00002639static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 int *valp,
2641 int write, void *data)
2642{
2643 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002644 if (*lvalp > LONG_MAX / HZ)
2645 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2647 } else {
2648 int val = *valp;
2649 unsigned long lval;
2650 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002651 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 lval = (unsigned long)-val;
2653 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002654 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 lval = (unsigned long)val;
2656 }
2657 *lvalp = lval / HZ;
2658 }
2659 return 0;
2660}
2661
Amerigo Wang00b7c332010-05-05 00:26:45 +00002662static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663 int *valp,
2664 int write, void *data)
2665{
2666 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002667 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2668 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2670 } else {
2671 int val = *valp;
2672 unsigned long lval;
2673 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002674 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 lval = (unsigned long)-val;
2676 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002677 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 lval = (unsigned long)val;
2679 }
2680 *lvalp = jiffies_to_clock_t(lval);
2681 }
2682 return 0;
2683}
2684
Amerigo Wang00b7c332010-05-05 00:26:45 +00002685static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 int *valp,
2687 int write, void *data)
2688{
2689 if (write) {
2690 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2691 } else {
2692 int val = *valp;
2693 unsigned long lval;
2694 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002695 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696 lval = (unsigned long)-val;
2697 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002698 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002699 lval = (unsigned long)val;
2700 }
2701 *lvalp = jiffies_to_msecs(lval);
2702 }
2703 return 0;
2704}
2705
2706/**
2707 * proc_dointvec_jiffies - read a vector of integers as seconds
2708 * @table: the sysctl table
2709 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002710 * @buffer: the user buffer
2711 * @lenp: the size of the user buffer
2712 * @ppos: file position
2713 *
2714 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2715 * values from/to the user buffer, treated as an ASCII string.
2716 * The values read are assumed to be in seconds, and are converted into
2717 * jiffies.
2718 *
2719 * Returns 0 on success.
2720 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002721int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002722 void __user *buffer, size_t *lenp, loff_t *ppos)
2723{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002724 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002725 do_proc_dointvec_jiffies_conv,NULL);
2726}
2727
2728/**
2729 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2730 * @table: the sysctl table
2731 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732 * @buffer: the user buffer
2733 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002734 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002735 *
2736 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2737 * values from/to the user buffer, treated as an ASCII string.
2738 * The values read are assumed to be in 1/USER_HZ seconds, and
2739 * are converted into jiffies.
2740 *
2741 * Returns 0 on success.
2742 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002743int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002744 void __user *buffer, size_t *lenp, loff_t *ppos)
2745{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002746 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002747 do_proc_dointvec_userhz_jiffies_conv,NULL);
2748}
2749
2750/**
2751 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2752 * @table: the sysctl table
2753 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002754 * @buffer: the user buffer
2755 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002756 * @ppos: file position
2757 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758 *
2759 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2760 * values from/to the user buffer, treated as an ASCII string.
2761 * The values read are assumed to be in 1/1000 seconds, and
2762 * are converted into jiffies.
2763 *
2764 * Returns 0 on success.
2765 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002766int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 void __user *buffer, size_t *lenp, loff_t *ppos)
2768{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002769 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002770 do_proc_dointvec_ms_jiffies_conv, NULL);
2771}
2772
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002773static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002774 void __user *buffer, size_t *lenp, loff_t *ppos)
2775{
2776 struct pid *new_pid;
2777 pid_t tmp;
2778 int r;
2779
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002780 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002781
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002782 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002783 lenp, ppos, NULL, NULL);
2784 if (r || !write)
2785 return r;
2786
2787 new_pid = find_get_pid(tmp);
2788 if (!new_pid)
2789 return -ESRCH;
2790
2791 put_pid(xchg(&cad_pid, new_pid));
2792 return 0;
2793}
2794
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002795/**
2796 * proc_do_large_bitmap - read/write from/to a large bitmap
2797 * @table: the sysctl table
2798 * @write: %TRUE if this is a write to the sysctl file
2799 * @buffer: the user buffer
2800 * @lenp: the size of the user buffer
2801 * @ppos: file position
2802 *
2803 * The bitmap is stored at table->data and the bitmap length (in bits)
2804 * in table->maxlen.
2805 *
2806 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2807 * large bitmaps may be represented in a compact manner. Writing into
2808 * the file will clear the bitmap then update it with the given input.
2809 *
2810 * Returns 0 on success.
2811 */
2812int proc_do_large_bitmap(struct ctl_table *table, int write,
2813 void __user *buffer, size_t *lenp, loff_t *ppos)
2814{
2815 int err = 0;
2816 bool first = 1;
2817 size_t left = *lenp;
2818 unsigned long bitmap_len = table->maxlen;
2819 unsigned long *bitmap = (unsigned long *) table->data;
2820 unsigned long *tmp_bitmap = NULL;
2821 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2822
2823 if (!bitmap_len || !left || (*ppos && !write)) {
2824 *lenp = 0;
2825 return 0;
2826 }
2827
2828 if (write) {
2829 unsigned long page = 0;
2830 char *kbuf;
2831
2832 if (left > PAGE_SIZE - 1)
2833 left = PAGE_SIZE - 1;
2834
2835 page = __get_free_page(GFP_TEMPORARY);
2836 kbuf = (char *) page;
2837 if (!kbuf)
2838 return -ENOMEM;
2839 if (copy_from_user(kbuf, buffer, left)) {
2840 free_page(page);
2841 return -EFAULT;
2842 }
2843 kbuf[left] = 0;
2844
2845 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2846 GFP_KERNEL);
2847 if (!tmp_bitmap) {
2848 free_page(page);
2849 return -ENOMEM;
2850 }
2851 proc_skip_char(&kbuf, &left, '\n');
2852 while (!err && left) {
2853 unsigned long val_a, val_b;
2854 bool neg;
2855
2856 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2857 sizeof(tr_a), &c);
2858 if (err)
2859 break;
2860 if (val_a >= bitmap_len || neg) {
2861 err = -EINVAL;
2862 break;
2863 }
2864
2865 val_b = val_a;
2866 if (left) {
2867 kbuf++;
2868 left--;
2869 }
2870
2871 if (c == '-') {
2872 err = proc_get_long(&kbuf, &left, &val_b,
2873 &neg, tr_b, sizeof(tr_b),
2874 &c);
2875 if (err)
2876 break;
2877 if (val_b >= bitmap_len || neg ||
2878 val_a > val_b) {
2879 err = -EINVAL;
2880 break;
2881 }
2882 if (left) {
2883 kbuf++;
2884 left--;
2885 }
2886 }
2887
2888 while (val_a <= val_b)
2889 set_bit(val_a++, tmp_bitmap);
2890
2891 first = 0;
2892 proc_skip_char(&kbuf, &left, '\n');
2893 }
2894 free_page(page);
2895 } else {
2896 unsigned long bit_a, bit_b = 0;
2897
2898 while (left) {
2899 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2900 if (bit_a >= bitmap_len)
2901 break;
2902 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2903 bit_a + 1) - 1;
2904
2905 if (!first) {
2906 err = proc_put_char(&buffer, &left, ',');
2907 if (err)
2908 break;
2909 }
2910 err = proc_put_long(&buffer, &left, bit_a, false);
2911 if (err)
2912 break;
2913 if (bit_a != bit_b) {
2914 err = proc_put_char(&buffer, &left, '-');
2915 if (err)
2916 break;
2917 err = proc_put_long(&buffer, &left, bit_b, false);
2918 if (err)
2919 break;
2920 }
2921
2922 first = 0; bit_b++;
2923 }
2924 if (!err)
2925 err = proc_put_char(&buffer, &left, '\n');
2926 }
2927
2928 if (!err) {
2929 if (write) {
2930 if (*ppos)
2931 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2932 else
2933 memcpy(bitmap, tmp_bitmap,
2934 BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
2935 }
2936 kfree(tmp_bitmap);
2937 *lenp -= left;
2938 *ppos += *lenp;
2939 return 0;
2940 } else {
2941 kfree(tmp_bitmap);
2942 return err;
2943 }
2944}
2945
Jovi Zhang55610502011-01-12 17:00:45 -08002946#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002948int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002949 void __user *buffer, size_t *lenp, loff_t *ppos)
2950{
2951 return -ENOSYS;
2952}
2953
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002954int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 void __user *buffer, size_t *lenp, loff_t *ppos)
2956{
2957 return -ENOSYS;
2958}
2959
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002960int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002961 void __user *buffer, size_t *lenp, loff_t *ppos)
2962{
2963 return -ENOSYS;
2964}
2965
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002966int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967 void __user *buffer, size_t *lenp, loff_t *ppos)
2968{
2969 return -ENOSYS;
2970}
2971
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002972int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973 void __user *buffer, size_t *lenp, loff_t *ppos)
2974{
2975 return -ENOSYS;
2976}
2977
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002978int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979 void __user *buffer, size_t *lenp, loff_t *ppos)
2980{
2981 return -ENOSYS;
2982}
2983
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002984int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985 void __user *buffer, size_t *lenp, loff_t *ppos)
2986{
2987 return -ENOSYS;
2988}
2989
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002990int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991 void __user *buffer,
2992 size_t *lenp, loff_t *ppos)
2993{
2994 return -ENOSYS;
2995}
2996
2997
Jovi Zhang55610502011-01-12 17:00:45 -08002998#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002999
Linus Torvalds1da177e2005-04-16 15:20:36 -07003000/*
3001 * No sense putting this after each symbol definition, twice,
3002 * exception granted :-)
3003 */
3004EXPORT_SYMBOL(proc_dointvec);
3005EXPORT_SYMBOL(proc_dointvec_jiffies);
3006EXPORT_SYMBOL(proc_dointvec_minmax);
3007EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3008EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3009EXPORT_SYMBOL(proc_dostring);
3010EXPORT_SYMBOL(proc_doulongvec_minmax);
3011EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3012EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003013EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003014EXPORT_SYMBOL(unregister_sysctl_table);