blob: c49d66658ec0c97eae795ab70c65188100233aaf [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#include <asm/uaccess.h>
63#include <asm/processor.h>
64
Andi Kleen29cbc782006-09-30 01:47:55 +020065#ifdef CONFIG_X86
66#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010067#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010068#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020069#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080070#ifdef CONFIG_BSD_PROCESS_ACCT
71#include <linux/acct.h>
72#endif
Dave Young4f0e0562010-03-10 15:24:09 -080073#ifdef CONFIG_RT_MUTEXES
74#include <linux/rtmutex.h>
75#endif
Dave Young2edf5e42010-03-10 15:24:10 -080076#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
77#include <linux/lockdep.h>
78#endif
Dave Young15485a42010-03-10 15:24:07 -080079#ifdef CONFIG_CHR_DEV_SG
80#include <scsi/sg.h>
81#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020082
Don Zickus58687ac2010-05-07 17:11:44 -040083#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050084#include <linux/nmi.h>
85#endif
86
Eric W. Biederman7058cb02007-10-18 03:05:58 -070087
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#if defined(CONFIG_SYSCTL)
89
90/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091extern int sysctl_overcommit_memory;
92extern int sysctl_overcommit_ratio;
93extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070095extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070097extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern int pid_max;
99extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800101extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800102extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200103extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100104extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400105extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000106#ifndef CONFIG_MMU
107extern int sysctl_nr_trim_pages;
108#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200109#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200110extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200111#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700113/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400114#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700115static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200116static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117#endif
118
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700120static int __maybe_unused one = 1;
121static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700122static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800123static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700125#ifdef CONFIG_PRINTK
126static int ten_thousand = 10000;
127#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700129/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
130static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
133static int maxolduid = 65535;
134static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800135static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700138static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Dave Youngd14f1722010-02-25 20:28:57 -0500140#ifdef CONFIG_INOTIFY_USER
141#include <linux/inotify.h>
142#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700143#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700144#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#endif
146
David S. Miller08714202008-11-16 23:49:24 -0800147#ifdef CONFIG_SPARC64
148extern int sysctl_tsb_ratio;
149#endif
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#ifdef __hppa__
152extern int pwrsw_enabled;
153extern int unaligned_enabled;
154#endif
155
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800156#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#ifdef CONFIG_MATHEMU
158extern int sysctl_ieee_emulation_warnings;
159#endif
160extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700161extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162#endif
163
Jes Sorensend2b176e2006-02-28 09:42:23 -0800164#ifdef CONFIG_IA64
165extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800166extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#endif
168
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700169#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700170static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700171 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700172static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800173 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700175
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700176#ifdef CONFIG_PRINTK
177static int proc_dmesg_restrict(struct ctl_table *table, int write,
178 void __user *buffer, size_t *lenp, loff_t *ppos);
179#endif
180
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700181#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800182/* Note: sysrq code uses it's own private copy */
183static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700184
185static int sysrq_sysctl_handler(ctl_table *table, int write,
186 void __user *buffer, size_t *lenp,
187 loff_t *ppos)
188{
189 int error;
190
191 error = proc_dointvec(table, write, buffer, lenp, ppos);
192 if (error)
193 return error;
194
195 if (write)
196 sysrq_toggle_support(__sysrq_enabled);
197
198 return 0;
199}
200
201#endif
202
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700203static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100204static struct ctl_table_root sysctl_table_root;
205static struct ctl_table_header root_table_header = {
Al Virodfef6dcd32011-03-08 01:25:28 -0500206 {{.count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100207 .ctl_table = root_table,
Al Virodfef6dcd32011-03-08 01:25:28 -0500208 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100209 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400210 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100211};
212static struct ctl_table_root sysctl_table_root = {
213 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400214 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100215};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700217static struct ctl_table kern_table[];
218static struct ctl_table vm_table[];
219static struct ctl_table fs_table[];
220static struct ctl_table debug_table[];
221static struct ctl_table dev_table[];
222extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800223#ifdef CONFIG_EPOLL
224extern struct ctl_table epoll_table[];
225#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
227#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
228int sysctl_legacy_va_layout;
229#endif
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231/* The default sysctl tables: */
232
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700233static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .procname = "kernel",
236 .mode = 0555,
237 .child = kern_table,
238 },
239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "vm",
241 .mode = 0555,
242 .child = vm_table,
243 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "fs",
246 .mode = 0555,
247 .child = fs_table,
248 },
249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "debug",
251 .mode = 0555,
252 .child = debug_table,
253 },
254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 .procname = "dev",
256 .mode = 0555,
257 .child = dev_table,
258 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700259 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260};
261
Ingo Molnar77e54a12007-07-09 18:52:00 +0200262#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100263static int min_sched_granularity_ns = 100000; /* 100 usecs */
264static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
265static int min_wakeup_granularity_ns; /* 0 usecs */
266static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100267static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
268static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200269#endif
270
Mel Gorman5e771902010-05-24 14:32:31 -0700271#ifdef CONFIG_COMPACTION
272static int min_extfrag_threshold;
273static int max_extfrag_threshold = 1000;
274#endif
275
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700276static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200277 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200278 .procname = "sched_child_runs_first",
279 .data = &sysctl_sched_child_runs_first,
280 .maxlen = sizeof(unsigned int),
281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800282 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200283 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200284#ifdef CONFIG_SCHED_DEBUG
285 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100286 .procname = "sched_min_granularity_ns",
287 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200288 .maxlen = sizeof(unsigned int),
289 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800290 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100291 .extra1 = &min_sched_granularity_ns,
292 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200293 },
294 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200295 .procname = "sched_latency_ns",
296 .data = &sysctl_sched_latency,
297 .maxlen = sizeof(unsigned int),
298 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800299 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200300 .extra1 = &min_sched_granularity_ns,
301 .extra2 = &max_sched_granularity_ns,
302 },
303 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200304 .procname = "sched_wakeup_granularity_ns",
305 .data = &sysctl_sched_wakeup_granularity,
306 .maxlen = sizeof(unsigned int),
307 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800308 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200309 .extra1 = &min_wakeup_granularity_ns,
310 .extra2 = &max_wakeup_granularity_ns,
311 },
312 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100313 .procname = "sched_tunable_scaling",
314 .data = &sysctl_sched_tunable_scaling,
315 .maxlen = sizeof(enum sched_tunable_scaling),
316 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800317 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100318 .extra1 = &min_sched_tunable_scaling,
319 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200320 },
321 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200322 .procname = "sched_migration_cost",
323 .data = &sysctl_sched_migration_cost,
324 .maxlen = sizeof(unsigned int),
325 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800326 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200327 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100328 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100329 .procname = "sched_nr_migrate",
330 .data = &sysctl_sched_nr_migrate,
331 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800333 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100334 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530335 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200336 .procname = "sched_time_avg",
337 .data = &sysctl_sched_time_avg,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800340 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200341 },
342 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800343 .procname = "sched_shares_window",
344 .data = &sysctl_sched_shares_window,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
347 .proc_handler = proc_dointvec,
348 },
349 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530350 .procname = "timer_migration",
351 .data = &sysctl_timer_migration,
352 .maxlen = sizeof(unsigned int),
353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800354 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530355 .extra1 = &zero,
356 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530357 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200358#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200359 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100360 .procname = "sched_rt_period_us",
361 .data = &sysctl_sched_rt_period,
362 .maxlen = sizeof(unsigned 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 },
366 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100367 .procname = "sched_rt_runtime_us",
368 .data = &sysctl_sched_rt_runtime,
369 .maxlen = sizeof(int),
370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800371 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100372 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100373#ifdef CONFIG_SCHED_AUTOGROUP
374 {
375 .procname = "sched_autogroup_enabled",
376 .data = &sysctl_sched_autogroup_enabled,
377 .maxlen = sizeof(unsigned int),
378 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800379 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100380 .extra1 = &zero,
381 .extra2 = &one,
382 },
383#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700384#ifdef CONFIG_CFS_BANDWIDTH
385 {
386 .procname = "sched_cfs_bandwidth_slice_us",
387 .data = &sysctl_sched_cfs_bandwidth_slice,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
390 .proc_handler = proc_dointvec_minmax,
391 .extra1 = &one,
392 },
393#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700394#ifdef CONFIG_PROVE_LOCKING
395 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700396 .procname = "prove_locking",
397 .data = &prove_locking,
398 .maxlen = sizeof(int),
399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800400 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700401 },
402#endif
403#ifdef CONFIG_LOCK_STAT
404 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700405 .procname = "lock_stat",
406 .data = &lock_stat,
407 .maxlen = sizeof(int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700410 },
411#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 .procname = "panic",
414 .data = &panic_timeout,
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_uses_pid",
421 .data = &core_uses_pid,
422 .maxlen = sizeof(int),
423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800424 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 },
426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 .procname = "core_pattern",
428 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700429 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800431 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 },
Neil Hormana2939802009-09-23 15:56:56 -0700433 {
Neil Hormana2939802009-09-23 15:56:56 -0700434 .procname = "core_pipe_limit",
435 .data = &core_pipe_limit,
436 .maxlen = sizeof(unsigned int),
437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800438 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700439 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800440#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700443 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800445 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800447#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100448#ifdef CONFIG_LATENCYTOP
449 {
450 .procname = "latencytop",
451 .data = &latencytop_enabled,
452 .maxlen = sizeof(int),
453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800454 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100455 },
456#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457#ifdef CONFIG_BLK_DEV_INITRD
458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 .procname = "real-root-dev",
460 .data = &real_root_dev,
461 .maxlen = sizeof(int),
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 },
465#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700466 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700467 .procname = "print-fatal-signals",
468 .data = &print_fatal_signals,
469 .maxlen = sizeof(int),
470 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800471 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700472 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700473#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 .procname = "reboot-cmd",
476 .data = reboot_command,
477 .maxlen = 256,
478 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800479 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 },
481 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .procname = "stop-a",
483 .data = &stop_a_enabled,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "scons-poweroff",
490 .data = &scons_pwroff,
491 .maxlen = sizeof (int),
492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800493 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 },
495#endif
David S. Miller08714202008-11-16 23:49:24 -0800496#ifdef CONFIG_SPARC64
497 {
David S. Miller08714202008-11-16 23:49:24 -0800498 .procname = "tsb-ratio",
499 .data = &sysctl_tsb_ratio,
500 .maxlen = sizeof (int),
501 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800502 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800503 },
504#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505#ifdef __hppa__
506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 .procname = "soft-power",
508 .data = &pwrsw_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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 .procname = "unaligned-trap",
515 .data = &unaligned_enabled,
516 .maxlen = sizeof (int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 },
520#endif
521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 .procname = "ctrl-alt-del",
523 .data = &C_A_D,
524 .maxlen = sizeof(int),
525 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800526 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400528#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200529 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200530 .procname = "ftrace_enabled",
531 .data = &ftrace_enabled,
532 .maxlen = sizeof(int),
533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800534 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200535 },
536#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500537#ifdef CONFIG_STACK_TRACER
538 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500539 .procname = "stack_tracer_enabled",
540 .data = &stack_tracer_enabled,
541 .maxlen = sizeof(int),
542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800543 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500544 },
545#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400546#ifdef CONFIG_TRACING
547 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100548 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400549 .data = &ftrace_dump_on_oops,
550 .maxlen = sizeof(int),
551 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800552 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400553 },
554#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200555#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 .procname = "modprobe",
558 .data = &modprobe_path,
559 .maxlen = KMOD_PATH_LEN,
560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800561 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 },
Kees Cook3d433212009-04-02 15:49:29 -0700563 {
Kees Cook3d433212009-04-02 15:49:29 -0700564 .procname = "modules_disabled",
565 .data = &modules_disabled,
566 .maxlen = sizeof(int),
567 .mode = 0644,
568 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800569 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700570 .extra1 = &one,
571 .extra2 = &one,
572 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100574#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100577 .data = &uevent_helper,
578 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800580 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 },
582#endif
583#ifdef CONFIG_CHR_DEV_SG
584 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .procname = "sg-big-buff",
586 .data = &sg_big_buff,
587 .maxlen = sizeof (int),
588 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 },
591#endif
592#ifdef CONFIG_BSD_PROCESS_ACCT
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "acct",
595 .data = &acct_parm,
596 .maxlen = 3*sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 },
600#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601#ifdef CONFIG_MAGIC_SYSRQ
602 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800604 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 .maxlen = sizeof (int),
606 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700607 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 },
609#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700610#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700613 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .maxlen = sizeof (int),
615 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700618#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 .procname = "threads-max",
621 .data = &max_threads,
622 .maxlen = sizeof(int),
623 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800624 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 },
626 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 .procname = "random",
628 .mode = 0555,
629 .child = random_table,
630 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 {
Eric Paris17f60a72011-04-01 17:07:50 -0400632 .procname = "usermodehelper",
633 .mode = 0555,
634 .child = usermodehelper_table,
635 },
636 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 .procname = "overflowuid",
638 .data = &overflowuid,
639 .maxlen = sizeof(int),
640 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .extra1 = &minolduid,
643 .extra2 = &maxolduid,
644 },
645 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 .procname = "overflowgid",
647 .data = &overflowgid,
648 .maxlen = sizeof(int),
649 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800650 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 .extra1 = &minolduid,
652 .extra2 = &maxolduid,
653 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800654#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655#ifdef CONFIG_MATHEMU
656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .procname = "ieee_emulation_warnings",
658 .data = &sysctl_ieee_emulation_warnings,
659 .maxlen = sizeof(int),
660 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 },
663#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200666 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .maxlen = sizeof(int),
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671#endif
672 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 .procname = "pid_max",
674 .data = &pid_max,
675 .maxlen = sizeof (int),
676 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800677 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .extra1 = &pid_max_min,
679 .extra2 = &pid_max_max,
680 },
681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "panic_on_oops",
683 .data = &panic_on_oops,
684 .maxlen = sizeof(int),
685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800688#if defined CONFIG_PRINTK
689 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800690 .procname = "printk",
691 .data = &console_loglevel,
692 .maxlen = 4*sizeof(int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800695 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700698 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 },
703 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700705 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .maxlen = sizeof(int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 },
Dave Youngaf913222009-09-22 16:43:33 -0700710 {
Dave Youngaf913222009-09-22 16:43:33 -0700711 .procname = "printk_delay",
712 .data = &printk_delay_msec,
713 .maxlen = sizeof(int),
714 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800715 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700716 .extra1 = &zero,
717 .extra2 = &ten_thousand,
718 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800720 .procname = "dmesg_restrict",
721 .data = &dmesg_restrict,
722 .maxlen = sizeof(int),
723 .mode = 0644,
724 .proc_handler = proc_dointvec_minmax,
725 .extra1 = &zero,
726 .extra2 = &one,
727 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800728 {
729 .procname = "kptr_restrict",
730 .data = &kptr_restrict,
731 .maxlen = sizeof(int),
732 .mode = 0644,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700733 .proc_handler = proc_dmesg_restrict,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800734 .extra1 = &zero,
735 .extra2 = &two,
736 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800737#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800738 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .procname = "ngroups_max",
740 .data = &ngroups_max,
741 .maxlen = sizeof (int),
742 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800743 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 },
Dan Ballard73efc032011-10-31 17:11:20 -0700745 {
746 .procname = "cap_last_cap",
747 .data = (void *)&cap_last_cap,
748 .maxlen = sizeof(int),
749 .mode = 0444,
750 .proc_handler = proc_dointvec,
751 },
Don Zickus58687ac2010-05-07 17:11:44 -0400752#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500753 {
Don Zickus58687ac2010-05-07 17:11:44 -0400754 .procname = "watchdog",
755 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500756 .maxlen = sizeof (int),
757 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700758 .proc_handler = proc_dowatchdog,
759 .extra1 = &zero,
760 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400761 },
762 {
763 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700764 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400765 .maxlen = sizeof(int),
766 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700767 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400768 .extra1 = &neg_one,
769 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500770 },
Don Zickus2508ce12010-05-07 17:11:46 -0400771 {
772 .procname = "softlockup_panic",
773 .data = &softlockup_panic,
774 .maxlen = sizeof(int),
775 .mode = 0644,
776 .proc_handler = proc_dointvec_minmax,
777 .extra1 = &zero,
778 .extra2 = &one,
779 },
Don Zickus5dc30552010-11-29 17:07:17 -0500780 {
781 .procname = "nmi_watchdog",
782 .data = &watchdog_enabled,
783 .maxlen = sizeof (int),
784 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700785 .proc_handler = proc_dowatchdog,
786 .extra1 = &zero,
787 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500788 },
789#endif
790#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
791 {
792 .procname = "unknown_nmi_panic",
793 .data = &unknown_nmi_panic,
794 .maxlen = sizeof (int),
795 .mode = 0644,
796 .proc_handler = proc_dointvec,
797 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500798#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799#if defined(CONFIG_X86)
800 {
Don Zickus8da5add2006-09-26 10:52:27 +0200801 .procname = "panic_on_unrecovered_nmi",
802 .data = &panic_on_unrecovered_nmi,
803 .maxlen = sizeof(int),
804 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800805 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200806 },
807 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700808 .procname = "panic_on_io_nmi",
809 .data = &panic_on_io_nmi,
810 .maxlen = sizeof(int),
811 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800812 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700813 },
814 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 .procname = "bootloader_type",
816 .data = &bootloader_type,
817 .maxlen = sizeof (int),
818 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800819 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100821 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700822 .procname = "bootloader_version",
823 .data = &bootloader_version,
824 .maxlen = sizeof (int),
825 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700827 },
828 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100829 .procname = "kstack_depth_to_print",
830 .data = &kstack_depth_to_print,
831 .maxlen = sizeof(int),
832 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800833 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100834 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100835 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100836 .procname = "io_delay_type",
837 .data = &io_delay_type,
838 .maxlen = sizeof(int),
839 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800840 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100841 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800843#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 .procname = "randomize_va_space",
846 .data = &randomize_va_space,
847 .maxlen = sizeof(int),
848 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800849 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800851#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800852#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700853 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700854 .procname = "spin_retry",
855 .data = &spin_retry,
856 .maxlen = sizeof (int),
857 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800858 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700859 },
860#endif
Len Brown673d5b42007-07-28 03:33:16 -0400861#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800862 {
Pavel Machekc255d842006-02-20 18:27:58 -0800863 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700864 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800865 .maxlen = sizeof (unsigned long),
866 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800867 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800868 },
869#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800870#ifdef CONFIG_IA64
871 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800872 .procname = "ignore-unaligned-usertrap",
873 .data = &no_unaligned_warning,
874 .maxlen = sizeof (int),
875 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800876 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800877 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800878 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800879 .procname = "unaligned-dump-stack",
880 .data = &unaligned_dump_stack,
881 .maxlen = sizeof (int),
882 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800883 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800884 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800885#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800886#ifdef CONFIG_DETECT_HUNG_TASK
887 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800888 .procname = "hung_task_panic",
889 .data = &sysctl_hung_task_panic,
890 .maxlen = sizeof(int),
891 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800892 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800893 .extra1 = &zero,
894 .extra2 = &one,
895 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100896 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100897 .procname = "hung_task_check_count",
898 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100899 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100900 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100902 },
903 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100904 .procname = "hung_task_timeout_secs",
905 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100906 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100907 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800908 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100909 },
910 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100911 .procname = "hung_task_warnings",
912 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100913 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100916 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700917#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200918#ifdef CONFIG_COMPAT
919 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200920 .procname = "compat-log",
921 .data = &compat_log,
922 .maxlen = sizeof (int),
923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200925 },
926#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700927#ifdef CONFIG_RT_MUTEXES
928 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700929 .procname = "max_lock_depth",
930 .data = &max_lock_depth,
931 .maxlen = sizeof(int),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700934 },
935#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700936 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700937 .procname = "poweroff_cmd",
938 .data = &poweroff_cmd,
939 .maxlen = POWEROFF_CMD_PATH_LEN,
940 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800941 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700942 },
David Howells0b77f5b2008-04-29 01:01:32 -0700943#ifdef CONFIG_KEYS
944 {
David Howells0b77f5b2008-04-29 01:01:32 -0700945 .procname = "keys",
946 .mode = 0555,
947 .child = key_sysctls,
948 },
949#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700950#ifdef CONFIG_RCU_TORTURE_TEST
951 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700952 .procname = "rcutorture_runnable",
953 .data = &rcutorture_runnable,
954 .maxlen = sizeof(int),
955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800956 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700957 },
958#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200959#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400960 /*
961 * User-space scripts rely on the existence of this file
962 * as a feature check for perf_events being enabled.
963 *
964 * So it's an ABI, do not remove!
965 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200966 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200967 .procname = "perf_event_paranoid",
968 .data = &sysctl_perf_event_paranoid,
969 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200970 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800971 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200972 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200973 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200974 .procname = "perf_event_mlock_kb",
975 .data = &sysctl_perf_event_mlock,
976 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200977 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800978 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200979 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200980 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200981 .procname = "perf_event_max_sample_rate",
982 .data = &sysctl_perf_event_sample_rate,
983 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200984 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100985 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200986 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200987#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200988#ifdef CONFIG_KMEMCHECK
989 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200990 .procname = "kmemcheck",
991 .data = &kmemcheck_enabled,
992 .maxlen = sizeof(int),
993 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800994 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200995 },
996#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200997#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200998 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200999 .procname = "blk_iopoll",
1000 .data = &blk_iopoll_enabled,
1001 .maxlen = sizeof(int),
1002 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001003 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001004 },
Jens Axboecb684b52009-09-15 21:53:11 +02001005#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001006 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007};
1008
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001009static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 .procname = "overcommit_memory",
1012 .data = &sysctl_overcommit_memory,
1013 .maxlen = sizeof(sysctl_overcommit_memory),
1014 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001015 .proc_handler = proc_dointvec_minmax,
1016 .extra1 = &zero,
1017 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 },
1019 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001020 .procname = "panic_on_oom",
1021 .data = &sysctl_panic_on_oom,
1022 .maxlen = sizeof(sysctl_panic_on_oom),
1023 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001024 .proc_handler = proc_dointvec_minmax,
1025 .extra1 = &zero,
1026 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001027 },
1028 {
David Rientjesfe071d72007-10-16 23:25:56 -07001029 .procname = "oom_kill_allocating_task",
1030 .data = &sysctl_oom_kill_allocating_task,
1031 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1032 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001033 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001034 },
1035 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001036 .procname = "oom_dump_tasks",
1037 .data = &sysctl_oom_dump_tasks,
1038 .maxlen = sizeof(sysctl_oom_dump_tasks),
1039 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001040 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001041 },
1042 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 .procname = "overcommit_ratio",
1044 .data = &sysctl_overcommit_ratio,
1045 .maxlen = sizeof(sysctl_overcommit_ratio),
1046 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001047 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 },
1049 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 .procname = "page-cluster",
1051 .data = &page_cluster,
1052 .maxlen = sizeof(int),
1053 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001054 .proc_handler = proc_dointvec_minmax,
1055 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 },
1057 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 .procname = "dirty_background_ratio",
1059 .data = &dirty_background_ratio,
1060 .maxlen = sizeof(dirty_background_ratio),
1061 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001062 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 .extra1 = &zero,
1064 .extra2 = &one_hundred,
1065 },
1066 {
David Rientjes2da02992009-01-06 14:39:31 -08001067 .procname = "dirty_background_bytes",
1068 .data = &dirty_background_bytes,
1069 .maxlen = sizeof(dirty_background_bytes),
1070 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001071 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001072 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001073 },
1074 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 .procname = "dirty_ratio",
1076 .data = &vm_dirty_ratio,
1077 .maxlen = sizeof(vm_dirty_ratio),
1078 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001079 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 .extra1 = &zero,
1081 .extra2 = &one_hundred,
1082 },
1083 {
David Rientjes2da02992009-01-06 14:39:31 -08001084 .procname = "dirty_bytes",
1085 .data = &vm_dirty_bytes,
1086 .maxlen = sizeof(vm_dirty_bytes),
1087 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001088 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001089 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001090 },
1091 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001093 .data = &dirty_writeback_interval,
1094 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 },
1098 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001100 .data = &dirty_expire_interval,
1101 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001103 .proc_handler = proc_dointvec_minmax,
1104 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 },
1106 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 .procname = "nr_pdflush_threads",
1108 .data = &nr_pdflush_threads,
1109 .maxlen = sizeof nr_pdflush_threads,
1110 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 },
1113 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 .procname = "swappiness",
1115 .data = &vm_swappiness,
1116 .maxlen = sizeof(vm_swappiness),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 .extra1 = &zero,
1120 .extra2 = &one_hundred,
1121 },
1122#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001123 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001125 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 .maxlen = sizeof(unsigned long),
1127 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001128 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .extra1 = (void *)&hugetlb_zero,
1130 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001131 },
1132#ifdef CONFIG_NUMA
1133 {
1134 .procname = "nr_hugepages_mempolicy",
1135 .data = NULL,
1136 .maxlen = sizeof(unsigned long),
1137 .mode = 0644,
1138 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1139 .extra1 = (void *)&hugetlb_zero,
1140 .extra2 = (void *)&hugetlb_infinity,
1141 },
1142#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 .procname = "hugetlb_shm_group",
1145 .data = &sysctl_hugetlb_shm_group,
1146 .maxlen = sizeof(gid_t),
1147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001148 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 },
Mel Gorman396faf02007-07-17 04:03:13 -07001150 {
Mel Gorman396faf02007-07-17 04:03:13 -07001151 .procname = "hugepages_treat_as_movable",
1152 .data = &hugepages_treat_as_movable,
1153 .maxlen = sizeof(int),
1154 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001155 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001156 },
Adam Litke54f9f802007-10-16 01:26:20 -07001157 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001158 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001159 .data = NULL,
1160 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001161 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001162 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001163 .extra1 = (void *)&hugetlb_zero,
1164 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001165 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166#endif
1167 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 .procname = "lowmem_reserve_ratio",
1169 .data = &sysctl_lowmem_reserve_ratio,
1170 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1171 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001172 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 },
1174 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001175 .procname = "drop_caches",
1176 .data = &sysctl_drop_caches,
1177 .maxlen = sizeof(int),
1178 .mode = 0644,
1179 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001180 .extra1 = &one,
1181 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001182 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001183#ifdef CONFIG_COMPACTION
1184 {
1185 .procname = "compact_memory",
1186 .data = &sysctl_compact_memory,
1187 .maxlen = sizeof(int),
1188 .mode = 0200,
1189 .proc_handler = sysctl_compaction_handler,
1190 },
Mel Gorman5e771902010-05-24 14:32:31 -07001191 {
1192 .procname = "extfrag_threshold",
1193 .data = &sysctl_extfrag_threshold,
1194 .maxlen = sizeof(int),
1195 .mode = 0644,
1196 .proc_handler = sysctl_extfrag_handler,
1197 .extra1 = &min_extfrag_threshold,
1198 .extra2 = &max_extfrag_threshold,
1199 },
1200
Mel Gorman76ab0f52010-05-24 14:32:28 -07001201#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001202 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .procname = "min_free_kbytes",
1204 .data = &min_free_kbytes,
1205 .maxlen = sizeof(min_free_kbytes),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 .extra1 = &zero,
1209 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001210 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001211 .procname = "percpu_pagelist_fraction",
1212 .data = &percpu_pagelist_fraction,
1213 .maxlen = sizeof(percpu_pagelist_fraction),
1214 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001215 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001216 .extra1 = &min_percpu_pagelist_fract,
1217 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218#ifdef CONFIG_MMU
1219 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 .procname = "max_map_count",
1221 .data = &sysctl_max_map_count,
1222 .maxlen = sizeof(sysctl_max_map_count),
1223 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001224 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001225 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001227#else
1228 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001229 .procname = "nr_trim_pages",
1230 .data = &sysctl_nr_trim_pages,
1231 .maxlen = sizeof(sysctl_nr_trim_pages),
1232 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001233 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001234 .extra1 = &zero,
1235 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236#endif
1237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 .procname = "laptop_mode",
1239 .data = &laptop_mode,
1240 .maxlen = sizeof(laptop_mode),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 },
1244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 .procname = "block_dump",
1246 .data = &block_dump,
1247 .maxlen = sizeof(block_dump),
1248 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001249 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 .extra1 = &zero,
1251 },
1252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 .procname = "vfs_cache_pressure",
1254 .data = &sysctl_vfs_cache_pressure,
1255 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1256 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001257 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 .extra1 = &zero,
1259 },
1260#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1261 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 .procname = "legacy_va_layout",
1263 .data = &sysctl_legacy_va_layout,
1264 .maxlen = sizeof(sysctl_legacy_va_layout),
1265 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001266 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 .extra1 = &zero,
1268 },
1269#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001270#ifdef CONFIG_NUMA
1271 {
Christoph Lameter17436602006-01-18 17:42:32 -08001272 .procname = "zone_reclaim_mode",
1273 .data = &zone_reclaim_mode,
1274 .maxlen = sizeof(zone_reclaim_mode),
1275 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001276 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001277 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001278 },
Christoph Lameter96146342006-07-03 00:24:13 -07001279 {
Christoph Lameter96146342006-07-03 00:24:13 -07001280 .procname = "min_unmapped_ratio",
1281 .data = &sysctl_min_unmapped_ratio,
1282 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1283 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001284 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001285 .extra1 = &zero,
1286 .extra2 = &one_hundred,
1287 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001288 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001289 .procname = "min_slab_ratio",
1290 .data = &sysctl_min_slab_ratio,
1291 .maxlen = sizeof(sysctl_min_slab_ratio),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001294 .extra1 = &zero,
1295 .extra2 = &one_hundred,
1296 },
Christoph Lameter17436602006-01-18 17:42:32 -08001297#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001298#ifdef CONFIG_SMP
1299 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001300 .procname = "stat_interval",
1301 .data = &sysctl_stat_interval,
1302 .maxlen = sizeof(sysctl_stat_interval),
1303 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001304 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001305 },
1306#endif
David Howells6e141542009-12-15 19:27:45 +00001307#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001308 {
Eric Parised032182007-06-28 15:55:21 -04001309 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001310 .data = &dac_mmap_min_addr,
1311 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001312 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001313 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001314 },
David Howells6e141542009-12-15 19:27:45 +00001315#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001316#ifdef CONFIG_NUMA
1317 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001318 .procname = "numa_zonelist_order",
1319 .data = &numa_zonelist_order,
1320 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1321 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001322 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001323 },
1324#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001325#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001326 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001327 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001328 .procname = "vdso_enabled",
1329 .data = &vdso_enabled,
1330 .maxlen = sizeof(vdso_enabled),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001333 .extra1 = &zero,
1334 },
1335#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001336#ifdef CONFIG_HIGHMEM
1337 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001338 .procname = "highmem_is_dirtyable",
1339 .data = &vm_highmem_is_dirtyable,
1340 .maxlen = sizeof(vm_highmem_is_dirtyable),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001343 .extra1 = &zero,
1344 .extra2 = &one,
1345 },
1346#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001347 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001348 .procname = "scan_unevictable_pages",
1349 .data = &scan_unevictable_pages,
1350 .maxlen = sizeof(scan_unevictable_pages),
1351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001352 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001353 },
Andi Kleen6a460792009-09-16 11:50:15 +02001354#ifdef CONFIG_MEMORY_FAILURE
1355 {
Andi Kleen6a460792009-09-16 11:50:15 +02001356 .procname = "memory_failure_early_kill",
1357 .data = &sysctl_memory_failure_early_kill,
1358 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001361 .extra1 = &zero,
1362 .extra2 = &one,
1363 },
1364 {
Andi Kleen6a460792009-09-16 11:50:15 +02001365 .procname = "memory_failure_recovery",
1366 .data = &sysctl_memory_failure_recovery,
1367 .maxlen = sizeof(sysctl_memory_failure_recovery),
1368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001369 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001370 .extra1 = &zero,
1371 .extra2 = &one,
1372 },
1373#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001374 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375};
1376
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001377#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001378static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001379 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001380};
1381#endif
1382
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001383static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 .procname = "inode-nr",
1386 .data = &inodes_stat,
1387 .maxlen = 2*sizeof(int),
1388 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001389 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 },
1391 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 .procname = "inode-state",
1393 .data = &inodes_stat,
1394 .maxlen = 7*sizeof(int),
1395 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001396 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 },
1398 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 .procname = "file-nr",
1400 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001401 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001403 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 },
1405 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 .procname = "file-max",
1407 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001408 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001410 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 },
1412 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001413 .procname = "nr_open",
1414 .data = &sysctl_nr_open,
1415 .maxlen = sizeof(int),
1416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001417 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001418 .extra1 = &sysctl_nr_open_min,
1419 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001420 },
1421 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 .procname = "dentry-state",
1423 .data = &dentry_stat,
1424 .maxlen = 6*sizeof(int),
1425 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001426 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 },
1428 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 .procname = "overflowuid",
1430 .data = &fs_overflowuid,
1431 .maxlen = sizeof(int),
1432 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001433 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 .extra1 = &minolduid,
1435 .extra2 = &maxolduid,
1436 },
1437 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 .procname = "overflowgid",
1439 .data = &fs_overflowgid,
1440 .maxlen = sizeof(int),
1441 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001442 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 .extra1 = &minolduid,
1444 .extra2 = &maxolduid,
1445 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001446#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 .procname = "leases-enable",
1449 .data = &leases_enable,
1450 .maxlen = sizeof(int),
1451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001452 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001454#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455#ifdef CONFIG_DNOTIFY
1456 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 .procname = "dir-notify-enable",
1458 .data = &dir_notify_enable,
1459 .maxlen = sizeof(int),
1460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001461 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
1463#endif
1464#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001465#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 .procname = "lease-break-time",
1468 .data = &lease_break_time,
1469 .maxlen = sizeof(int),
1470 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001471 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001473#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001474#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 .procname = "aio-nr",
1477 .data = &aio_nr,
1478 .maxlen = sizeof(aio_nr),
1479 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001480 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 },
1482 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 .procname = "aio-max-nr",
1484 .data = &aio_max_nr,
1485 .maxlen = sizeof(aio_max_nr),
1486 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001487 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001489#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001490#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001491 {
Robert Love0399cb02005-07-13 12:38:18 -04001492 .procname = "inotify",
1493 .mode = 0555,
1494 .child = inotify_table,
1495 },
1496#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001497#ifdef CONFIG_EPOLL
1498 {
1499 .procname = "epoll",
1500 .mode = 0555,
1501 .child = epoll_table,
1502 },
1503#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001505 {
Alan Coxd6e71142005-06-23 00:09:43 -07001506 .procname = "suid_dumpable",
1507 .data = &suid_dumpable,
1508 .maxlen = sizeof(int),
1509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001510 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001511 .extra1 = &zero,
1512 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001513 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001514#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1515 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001516 .procname = "binfmt_misc",
1517 .mode = 0555,
1518 .child = binfmt_misc_table,
1519 },
1520#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001521 {
Jens Axboeff9da692010-06-03 14:54:39 +02001522 .procname = "pipe-max-size",
1523 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001524 .maxlen = sizeof(int),
1525 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001526 .proc_handler = &pipe_proc_fn,
1527 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001528 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001529 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530};
1531
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001532static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001533#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001534 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001535 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001536 .procname = "exception-trace",
1537 .data = &show_unhandled_signals,
1538 .maxlen = sizeof(int),
1539 .mode = 0644,
1540 .proc_handler = proc_dointvec
1541 },
1542#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001543#if defined(CONFIG_OPTPROBES)
1544 {
1545 .procname = "kprobes-optimization",
1546 .data = &sysctl_kprobes_optimization,
1547 .maxlen = sizeof(int),
1548 .mode = 0644,
1549 .proc_handler = proc_kprobes_optimization_handler,
1550 .extra1 = &zero,
1551 .extra2 = &one,
1552 },
1553#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001554 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555};
1556
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001557static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001558 { }
Robert Love0eeca282005-07-12 17:06:03 -04001559};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560
Al Viro330d57f2005-11-04 10:18:40 +00001561static DEFINE_SPINLOCK(sysctl_lock);
1562
1563/* called under sysctl_lock */
1564static int use_table(struct ctl_table_header *p)
1565{
1566 if (unlikely(p->unregistering))
1567 return 0;
1568 p->used++;
1569 return 1;
1570}
1571
1572/* called under sysctl_lock */
1573static void unuse_table(struct ctl_table_header *p)
1574{
1575 if (!--p->used)
1576 if (unlikely(p->unregistering))
1577 complete(p->unregistering);
1578}
1579
1580/* called under sysctl_lock, will reacquire if has to wait */
1581static void start_unregistering(struct ctl_table_header *p)
1582{
1583 /*
1584 * if p->used is 0, nobody will ever touch that entry again;
1585 * we'll eliminate all paths to it before dropping sysctl_lock
1586 */
1587 if (unlikely(p->used)) {
1588 struct completion wait;
1589 init_completion(&wait);
1590 p->unregistering = &wait;
1591 spin_unlock(&sysctl_lock);
1592 wait_for_completion(&wait);
1593 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001594 } else {
1595 /* anything non-NULL; we'll never dereference it */
1596 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001597 }
1598 /*
1599 * do not remove from the list until nobody holds it; walking the
1600 * list in do_sysctl() relies on that.
1601 */
1602 list_del_init(&p->ctl_entry);
1603}
1604
Al Virof7e6ced2008-07-15 01:44:23 -04001605void sysctl_head_get(struct ctl_table_header *head)
1606{
1607 spin_lock(&sysctl_lock);
1608 head->count++;
1609 spin_unlock(&sysctl_lock);
1610}
1611
1612void sysctl_head_put(struct ctl_table_header *head)
1613{
1614 spin_lock(&sysctl_lock);
1615 if (!--head->count)
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001616 kfree_rcu(head, rcu);
Al Virof7e6ced2008-07-15 01:44:23 -04001617 spin_unlock(&sysctl_lock);
1618}
1619
1620struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1621{
1622 if (!head)
1623 BUG();
1624 spin_lock(&sysctl_lock);
1625 if (!use_table(head))
1626 head = ERR_PTR(-ENOENT);
1627 spin_unlock(&sysctl_lock);
1628 return head;
1629}
1630
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001631void sysctl_head_finish(struct ctl_table_header *head)
1632{
1633 if (!head)
1634 return;
1635 spin_lock(&sysctl_lock);
1636 unuse_table(head);
1637 spin_unlock(&sysctl_lock);
1638}
1639
Al Viro73455092008-07-14 21:22:20 -04001640static struct ctl_table_set *
1641lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1642{
1643 struct ctl_table_set *set = &root->default_set;
1644 if (root->lookup)
1645 set = root->lookup(root, namespaces);
1646 return set;
1647}
1648
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001649static struct list_head *
1650lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001651{
Al Viro73455092008-07-14 21:22:20 -04001652 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1653 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001654}
1655
1656struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1657 struct ctl_table_header *prev)
1658{
1659 struct ctl_table_root *root;
1660 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001661 struct ctl_table_header *head;
1662 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001663
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001664 spin_lock(&sysctl_lock);
1665 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001666 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001667 tmp = &prev->ctl_entry;
1668 unuse_table(prev);
1669 goto next;
1670 }
1671 tmp = &root_table_header.ctl_entry;
1672 for (;;) {
1673 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1674
1675 if (!use_table(head))
1676 goto next;
1677 spin_unlock(&sysctl_lock);
1678 return head;
1679 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001680 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001681 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001682 header_list = lookup_header_list(root, namespaces);
1683 if (tmp != header_list)
1684 continue;
1685
1686 do {
1687 root = list_entry(root->root_list.next,
1688 struct ctl_table_root, root_list);
1689 if (root == &sysctl_table_root)
1690 goto out;
1691 header_list = lookup_header_list(root, namespaces);
1692 } while (list_empty(header_list));
1693 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001694 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001695out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001696 spin_unlock(&sysctl_lock);
1697 return NULL;
1698}
1699
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001700struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1701{
1702 return __sysctl_head_next(current->nsproxy, prev);
1703}
1704
1705void register_sysctl_root(struct ctl_table_root *root)
1706{
1707 spin_lock(&sysctl_lock);
1708 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1709 spin_unlock(&sysctl_lock);
1710}
1711
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001713 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714 * some sysctl variables are readonly even to root.
1715 */
1716
1717static int test_perm(int mode, int op)
1718{
David Howells76aac0e2008-11-14 10:39:12 +11001719 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720 mode >>= 6;
1721 else if (in_egroup_p(0))
1722 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001723 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 return 0;
1725 return -EACCES;
1726}
1727
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001728int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729{
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001730 int mode;
1731
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001732 if (root->permissions)
1733 mode = root->permissions(root, current->nsproxy, table);
1734 else
1735 mode = table->mode;
1736
1737 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738}
1739
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001740static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1741{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001742 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001743 table->parent = parent;
1744 if (table->child)
1745 sysctl_set_parent(table, table->child);
1746 }
1747}
1748
1749static __init int sysctl_init(void)
1750{
1751 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001752#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Andi Kleenb3bd3de2010-08-10 14:17:51 -07001753 sysctl_check_table(current->nsproxy, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001754#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001755 return 0;
1756}
1757
1758core_initcall(sysctl_init);
1759
Al Virobfbcf032008-07-27 06:31:22 +01001760static struct ctl_table *is_branch_in(struct ctl_table *branch,
1761 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001762{
1763 struct ctl_table *p;
1764 const char *s = branch->procname;
1765
1766 /* branch should have named subdirectory as its first element */
1767 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001768 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001769
1770 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001771 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001772 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001773
1774 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001775 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001776 if (!p->child)
1777 continue;
1778 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001779 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001780 }
Al Virobfbcf032008-07-27 06:31:22 +01001781 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001782}
1783
1784/* see if attaching q to p would be an improvement */
1785static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1786{
1787 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001788 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001789 int is_better = 0;
1790 int not_in_parent = !p->attached_by;
1791
Al Virobfbcf032008-07-27 06:31:22 +01001792 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001793 if (by == q->attached_by)
1794 is_better = 1;
1795 if (to == p->attached_by)
1796 not_in_parent = 1;
1797 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001798 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001799 }
1800
1801 if (is_better && not_in_parent) {
1802 q->attached_by = by;
1803 q->attached_to = to;
1804 q->parent = p;
1805 }
1806}
1807
Linus Torvalds1da177e2005-04-16 15:20:36 -07001808/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001809 * __register_sysctl_paths - register a sysctl hierarchy
1810 * @root: List of sysctl headers to register on
1811 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001812 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 *
1815 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001816 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001818 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1821 * enter a sysctl file
1822 *
1823 * data - a pointer to data for use by proc_handler
1824 *
1825 * maxlen - the maximum size in bytes of the data
1826 *
1827 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1828 *
1829 * child - a pointer to the child sysctl table if this entry is a directory, or
1830 * %NULL.
1831 *
1832 * proc_handler - the text handler routine (described below)
1833 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 * de - for internal use by the sysctl routines
1835 *
1836 * extra1, extra2 - extra pointers usable by the proc handler routines
1837 *
1838 * Leaf nodes in the sysctl tree will be represented by a single file
1839 * under /proc; non-leaf nodes will be represented by directories.
1840 *
1841 * sysctl(2) can automatically manage read and write requests through
1842 * the sysctl table. The data and maxlen fields of the ctl_table
1843 * struct enable minimal validation of the values being written to be
1844 * performed, and the mode field allows minimal authentication.
1845 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 * There must be a proc_handler routine for any terminal nodes
1847 * mirrored under /proc/sys (non-terminals are handled by a built-in
1848 * directory handler). Several default handlers are available to
1849 * cover common cases -
1850 *
1851 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1852 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1853 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1854 *
1855 * It is the handler's job to read the input buffer from user memory
1856 * and process it. The handler should return 0 on success.
1857 *
1858 * This routine returns %NULL on a failure to register, and a pointer
1859 * to the table header on success.
1860 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001861struct ctl_table_header *__register_sysctl_paths(
1862 struct ctl_table_root *root,
1863 struct nsproxy *namespaces,
1864 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001866 struct ctl_table_header *header;
1867 struct ctl_table *new, **prevp;
1868 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001869 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001870
1871 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001872 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001873 ;
1874
1875 /*
1876 * For each path component, allocate a 2-element ctl_table array.
1877 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001878 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001879 *
1880 * We allocate everything in one go so that we don't have to
1881 * worry about freeing additional memory in unregister_sysctl_table.
1882 */
1883 header = kzalloc(sizeof(struct ctl_table_header) +
1884 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1885 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001887
1888 new = (struct ctl_table *) (header + 1);
1889
1890 /* Now connect the dots */
1891 prevp = &header->ctl_table;
1892 for (n = 0; n < npath; ++n, ++path) {
1893 /* Copy the procname */
1894 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001895 new->mode = 0555;
1896
1897 *prevp = new;
1898 prevp = &new->child;
1899
1900 new += 2;
1901 }
1902 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001903 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001904
1905 INIT_LIST_HEAD(&header->ctl_entry);
1906 header->used = 0;
1907 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001908 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001909 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001910 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001911#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001912 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001913 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001914 return NULL;
1915 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001916#endif
Al Viro330d57f2005-11-04 10:18:40 +00001917 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001918 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001919 header->attached_by = header->ctl_table;
1920 header->attached_to = root_table;
1921 header->parent = &root_table_header;
1922 for (set = header->set; set; set = set->parent) {
1923 struct ctl_table_header *p;
1924 list_for_each_entry(p, &set->list, ctl_entry) {
1925 if (p->unregistering)
1926 continue;
1927 try_attach(p, header);
1928 }
1929 }
1930 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001931 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001932 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001933
1934 return header;
1935}
1936
1937/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001938 * register_sysctl_table_path - register a sysctl table hierarchy
1939 * @path: The path to the directory the sysctl table is in.
1940 * @table: the top-level table structure
1941 *
1942 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1943 * array. A completely 0 filled entry terminates the table.
1944 *
1945 * See __register_sysctl_paths for more details.
1946 */
1947struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1948 struct ctl_table *table)
1949{
1950 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1951 path, table);
1952}
1953
1954/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001955 * register_sysctl_table - register a sysctl table hierarchy
1956 * @table: the top-level table structure
1957 *
1958 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1959 * array. A completely 0 filled entry terminates the table.
1960 *
1961 * See register_sysctl_paths for more details.
1962 */
1963struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1964{
1965 static const struct ctl_path null_path[] = { {} };
1966
1967 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968}
1969
1970/**
1971 * unregister_sysctl_table - unregister a sysctl table hierarchy
1972 * @header: the header returned from register_sysctl_table
1973 *
1974 * Unregisters the sysctl table and all children. proc entries may not
1975 * actually be removed until they are no longer used by anyone.
1976 */
1977void unregister_sysctl_table(struct ctl_table_header * header)
1978{
Al Viro330d57f2005-11-04 10:18:40 +00001979 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001980
1981 if (header == NULL)
1982 return;
1983
Al Viro330d57f2005-11-04 10:18:40 +00001984 spin_lock(&sysctl_lock);
1985 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001986 if (!--header->parent->count) {
1987 WARN_ON(1);
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001988 kfree_rcu(header->parent, rcu);
Al Viroae7edec2008-07-15 06:33:31 -04001989 }
Al Virof7e6ced2008-07-15 01:44:23 -04001990 if (!--header->count)
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001991 kfree_rcu(header, rcu);
Al Viro330d57f2005-11-04 10:18:40 +00001992 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993}
1994
Al Viro9043476f2008-07-15 08:54:06 -04001995int sysctl_is_seen(struct ctl_table_header *p)
1996{
1997 struct ctl_table_set *set = p->set;
1998 int res;
1999 spin_lock(&sysctl_lock);
2000 if (p->unregistering)
2001 res = 0;
2002 else if (!set->is_seen)
2003 res = 1;
2004 else
2005 res = set->is_seen(set);
2006 spin_unlock(&sysctl_lock);
2007 return res;
2008}
2009
Al Viro73455092008-07-14 21:22:20 -04002010void setup_sysctl_set(struct ctl_table_set *p,
2011 struct ctl_table_set *parent,
2012 int (*is_seen)(struct ctl_table_set *))
2013{
2014 INIT_LIST_HEAD(&p->list);
2015 p->parent = parent ? parent : &sysctl_table_root.default_set;
2016 p->is_seen = is_seen;
2017}
2018
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002019#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002020struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002021{
2022 return NULL;
2023}
2024
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002025struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2026 struct ctl_table *table)
2027{
2028 return NULL;
2029}
2030
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002031void unregister_sysctl_table(struct ctl_table_header * table)
2032{
2033}
2034
Al Viro73455092008-07-14 21:22:20 -04002035void setup_sysctl_set(struct ctl_table_set *p,
2036 struct ctl_table_set *parent,
2037 int (*is_seen)(struct ctl_table_set *))
2038{
2039}
2040
Al Virof7e6ced2008-07-15 01:44:23 -04002041void sysctl_head_put(struct ctl_table_header *head)
2042{
2043}
2044
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002045#endif /* CONFIG_SYSCTL */
2046
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047/*
2048 * /proc/sys support
2049 */
2050
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002051#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002053static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002054 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002055 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002056{
2057 size_t len;
2058 char __user *p;
2059 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002060
2061 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002062 *lenp = 0;
2063 return 0;
2064 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002065
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002066 if (write) {
2067 len = 0;
2068 p = buffer;
2069 while (len < *lenp) {
2070 if (get_user(c, p++))
2071 return -EFAULT;
2072 if (c == 0 || c == '\n')
2073 break;
2074 len++;
2075 }
2076 if (len >= maxlen)
2077 len = maxlen-1;
2078 if(copy_from_user(data, buffer, len))
2079 return -EFAULT;
2080 ((char *) data)[len] = 0;
2081 *ppos += *lenp;
2082 } else {
2083 len = strlen(data);
2084 if (len > maxlen)
2085 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002086
2087 if (*ppos > len) {
2088 *lenp = 0;
2089 return 0;
2090 }
2091
2092 data += *ppos;
2093 len -= *ppos;
2094
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002095 if (len > *lenp)
2096 len = *lenp;
2097 if (len)
2098 if(copy_to_user(buffer, data, len))
2099 return -EFAULT;
2100 if (len < *lenp) {
2101 if(put_user('\n', ((char __user *) buffer) + len))
2102 return -EFAULT;
2103 len++;
2104 }
2105 *lenp = len;
2106 *ppos += len;
2107 }
2108 return 0;
2109}
2110
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111/**
2112 * proc_dostring - read a string sysctl
2113 * @table: the sysctl table
2114 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002115 * @buffer: the user buffer
2116 * @lenp: the size of the user buffer
2117 * @ppos: file position
2118 *
2119 * Reads/writes a string from/to the user buffer. If the kernel
2120 * buffer provided is not large enough to hold the string, the
2121 * string is truncated. The copied string is %NULL-terminated.
2122 * If the string is being read by the user process, it is copied
2123 * and a newline '\n' is added. It is truncated if the buffer is
2124 * not large enough.
2125 *
2126 * Returns 0 on success.
2127 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002128int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 void __user *buffer, size_t *lenp, loff_t *ppos)
2130{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002131 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002132 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133}
2134
Amerigo Wang00b7c332010-05-05 00:26:45 +00002135static size_t proc_skip_spaces(char **buf)
2136{
2137 size_t ret;
2138 char *tmp = skip_spaces(*buf);
2139 ret = tmp - *buf;
2140 *buf = tmp;
2141 return ret;
2142}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002143
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002144static void proc_skip_char(char **buf, size_t *size, const char v)
2145{
2146 while (*size) {
2147 if (**buf != v)
2148 break;
2149 (*size)--;
2150 (*buf)++;
2151 }
2152}
2153
Amerigo Wang00b7c332010-05-05 00:26:45 +00002154#define TMPBUFLEN 22
2155/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002156 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002157 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002158 * @buf: a kernel buffer
2159 * @size: size of the kernel buffer
2160 * @val: this is where the number will be stored
2161 * @neg: set to %TRUE if number is negative
2162 * @perm_tr: a vector which contains the allowed trailers
2163 * @perm_tr_len: size of the perm_tr vector
2164 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002165 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002166 * In case of success %0 is returned and @buf and @size are updated with
2167 * the amount of bytes read. If @tr is non-NULL and a trailing
2168 * character exists (size is non-zero after returning from this
2169 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002170 */
2171static int proc_get_long(char **buf, size_t *size,
2172 unsigned long *val, bool *neg,
2173 const char *perm_tr, unsigned perm_tr_len, char *tr)
2174{
2175 int len;
2176 char *p, tmp[TMPBUFLEN];
2177
2178 if (!*size)
2179 return -EINVAL;
2180
2181 len = *size;
2182 if (len > TMPBUFLEN - 1)
2183 len = TMPBUFLEN - 1;
2184
2185 memcpy(tmp, *buf, len);
2186
2187 tmp[len] = 0;
2188 p = tmp;
2189 if (*p == '-' && *size > 1) {
2190 *neg = true;
2191 p++;
2192 } else
2193 *neg = false;
2194 if (!isdigit(*p))
2195 return -EINVAL;
2196
2197 *val = simple_strtoul(p, &p, 0);
2198
2199 len = p - tmp;
2200
2201 /* We don't know if the next char is whitespace thus we may accept
2202 * invalid integers (e.g. 1234...a) or two integers instead of one
2203 * (e.g. 123...1). So lets not allow such large numbers. */
2204 if (len == TMPBUFLEN - 1)
2205 return -EINVAL;
2206
2207 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2208 return -EINVAL;
2209
2210 if (tr && (len < *size))
2211 *tr = *p;
2212
2213 *buf += len;
2214 *size -= len;
2215
2216 return 0;
2217}
2218
2219/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002220 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002221 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002222 * @buf: the user buffer
2223 * @size: the size of the user buffer
2224 * @val: the integer to be converted
2225 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002226 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002227 * In case of success %0 is returned and @buf and @size are updated with
2228 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002229 */
2230static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2231 bool neg)
2232{
2233 int len;
2234 char tmp[TMPBUFLEN], *p = tmp;
2235
2236 sprintf(p, "%s%lu", neg ? "-" : "", val);
2237 len = strlen(tmp);
2238 if (len > *size)
2239 len = *size;
2240 if (copy_to_user(*buf, tmp, len))
2241 return -EFAULT;
2242 *size -= len;
2243 *buf += len;
2244 return 0;
2245}
2246#undef TMPBUFLEN
2247
2248static int proc_put_char(void __user **buf, size_t *size, char c)
2249{
2250 if (*size) {
2251 char __user **buffer = (char __user **)buf;
2252 if (put_user(c, *buffer))
2253 return -EFAULT;
2254 (*size)--, (*buffer)++;
2255 *buf = *buffer;
2256 }
2257 return 0;
2258}
2259
2260static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002261 int *valp,
2262 int write, void *data)
2263{
2264 if (write) {
2265 *valp = *negp ? -*lvalp : *lvalp;
2266 } else {
2267 int val = *valp;
2268 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002269 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 *lvalp = (unsigned long)-val;
2271 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002272 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 *lvalp = (unsigned long)val;
2274 }
2275 }
2276 return 0;
2277}
2278
Amerigo Wang00b7c332010-05-05 00:26:45 +00002279static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2280
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002281static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002282 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002283 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 int write, void *data),
2286 void *data)
2287{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002288 int *i, vleft, first = 1, err = 0;
2289 unsigned long page = 0;
2290 size_t left;
2291 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292
Amerigo Wang00b7c332010-05-05 00:26:45 +00002293 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 *lenp = 0;
2295 return 0;
2296 }
2297
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002298 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 vleft = table->maxlen / sizeof(*i);
2300 left = *lenp;
2301
2302 if (!conv)
2303 conv = do_proc_dointvec_conv;
2304
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002306 if (left > PAGE_SIZE - 1)
2307 left = PAGE_SIZE - 1;
2308 page = __get_free_page(GFP_TEMPORARY);
2309 kbuf = (char *) page;
2310 if (!kbuf)
2311 return -ENOMEM;
2312 if (copy_from_user(kbuf, buffer, left)) {
2313 err = -EFAULT;
2314 goto free;
2315 }
2316 kbuf[left] = 0;
2317 }
2318
2319 for (; left && vleft--; i++, first=0) {
2320 unsigned long lval;
2321 bool neg;
2322
2323 if (write) {
2324 left -= proc_skip_spaces(&kbuf);
2325
J. R. Okajima563b0462010-05-25 16:10:14 -07002326 if (!left)
2327 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002328 err = proc_get_long(&kbuf, &left, &lval, &neg,
2329 proc_wspace_sep,
2330 sizeof(proc_wspace_sep), NULL);
2331 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002333 if (conv(&neg, &lval, i, 1, data)) {
2334 err = -EINVAL;
2335 break;
2336 }
2337 } else {
2338 if (conv(&neg, &lval, i, 0, data)) {
2339 err = -EINVAL;
2340 break;
2341 }
2342 if (!first)
2343 err = proc_put_char(&buffer, &left, '\t');
2344 if (err)
2345 break;
2346 err = proc_put_long(&buffer, &left, lval, neg);
2347 if (err)
2348 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 }
2350 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002351
2352 if (!write && !first && left && !err)
2353 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002354 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002355 left -= proc_skip_spaces(&kbuf);
2356free:
2357 if (write) {
2358 free_page(page);
2359 if (first)
2360 return err ? : -EINVAL;
2361 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 *lenp -= left;
2363 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002364 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002365}
2366
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002367static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002368 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002369 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002370 int write, void *data),
2371 void *data)
2372{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002373 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002374 buffer, lenp, ppos, conv, data);
2375}
2376
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377/**
2378 * proc_dointvec - read a vector of integers
2379 * @table: the sysctl table
2380 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 * @buffer: the user buffer
2382 * @lenp: the size of the user buffer
2383 * @ppos: file position
2384 *
2385 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2386 * values from/to the user buffer, treated as an ASCII string.
2387 *
2388 * Returns 0 on success.
2389 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002390int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391 void __user *buffer, size_t *lenp, loff_t *ppos)
2392{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002393 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 NULL,NULL);
2395}
2396
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002397/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002398 * Taint values can only be increased
2399 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002400 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002401static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002402 void __user *buffer, size_t *lenp, loff_t *ppos)
2403{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002404 struct ctl_table t;
2405 unsigned long tmptaint = get_taint();
2406 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002407
Bastian Blank91fcd412007-04-23 14:41:14 -07002408 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002409 return -EPERM;
2410
Andi Kleen25ddbb12008-10-15 22:01:41 -07002411 t = *table;
2412 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002413 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002414 if (err < 0)
2415 return err;
2416
2417 if (write) {
2418 /*
2419 * Poor man's atomic or. Not worth adding a primitive
2420 * to everyone's atomic.h for this
2421 */
2422 int i;
2423 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2424 if ((tmptaint >> i) & 1)
2425 add_taint(i);
2426 }
2427 }
2428
2429 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002430}
2431
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002432#ifdef CONFIG_PRINTK
2433static int proc_dmesg_restrict(struct ctl_table *table, int write,
2434 void __user *buffer, size_t *lenp, loff_t *ppos)
2435{
2436 if (write && !capable(CAP_SYS_ADMIN))
2437 return -EPERM;
2438
2439 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2440}
2441#endif
2442
Linus Torvalds1da177e2005-04-16 15:20:36 -07002443struct do_proc_dointvec_minmax_conv_param {
2444 int *min;
2445 int *max;
2446};
2447
Amerigo Wang00b7c332010-05-05 00:26:45 +00002448static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2449 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 int write, void *data)
2451{
2452 struct do_proc_dointvec_minmax_conv_param *param = data;
2453 if (write) {
2454 int val = *negp ? -*lvalp : *lvalp;
2455 if ((param->min && *param->min > val) ||
2456 (param->max && *param->max < val))
2457 return -EINVAL;
2458 *valp = val;
2459 } else {
2460 int val = *valp;
2461 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002462 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463 *lvalp = (unsigned long)-val;
2464 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002465 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466 *lvalp = (unsigned long)val;
2467 }
2468 }
2469 return 0;
2470}
2471
2472/**
2473 * proc_dointvec_minmax - read a vector of integers with min/max values
2474 * @table: the sysctl table
2475 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 * @buffer: the user buffer
2477 * @lenp: the size of the user buffer
2478 * @ppos: file position
2479 *
2480 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2481 * values from/to the user buffer, treated as an ASCII string.
2482 *
2483 * This routine will ensure the values are within the range specified by
2484 * table->extra1 (min) and table->extra2 (max).
2485 *
2486 * Returns 0 on success.
2487 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002488int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002489 void __user *buffer, size_t *lenp, loff_t *ppos)
2490{
2491 struct do_proc_dointvec_minmax_conv_param param = {
2492 .min = (int *) table->extra1,
2493 .max = (int *) table->extra2,
2494 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002495 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 do_proc_dointvec_minmax_conv, &param);
2497}
2498
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002499static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 void __user *buffer,
2501 size_t *lenp, loff_t *ppos,
2502 unsigned long convmul,
2503 unsigned long convdiv)
2504{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002505 unsigned long *i, *min, *max;
2506 int vleft, first = 1, err = 0;
2507 unsigned long page = 0;
2508 size_t left;
2509 char *kbuf;
2510
2511 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 *lenp = 0;
2513 return 0;
2514 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002515
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002516 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 min = (unsigned long *) table->extra1;
2518 max = (unsigned long *) table->extra2;
2519 vleft = table->maxlen / sizeof(unsigned long);
2520 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002521
2522 if (write) {
2523 if (left > PAGE_SIZE - 1)
2524 left = PAGE_SIZE - 1;
2525 page = __get_free_page(GFP_TEMPORARY);
2526 kbuf = (char *) page;
2527 if (!kbuf)
2528 return -ENOMEM;
2529 if (copy_from_user(kbuf, buffer, left)) {
2530 err = -EFAULT;
2531 goto free;
2532 }
2533 kbuf[left] = 0;
2534 }
2535
Eric Dumazet27b3d802010-10-07 12:59:29 -07002536 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002537 unsigned long val;
2538
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002540 bool neg;
2541
2542 left -= proc_skip_spaces(&kbuf);
2543
2544 err = proc_get_long(&kbuf, &left, &val, &neg,
2545 proc_wspace_sep,
2546 sizeof(proc_wspace_sep), NULL);
2547 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 break;
2549 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 continue;
2551 if ((min && val < *min) || (max && val > *max))
2552 continue;
2553 *i = val;
2554 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002555 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002557 err = proc_put_char(&buffer, &left, '\t');
2558 err = proc_put_long(&buffer, &left, val, false);
2559 if (err)
2560 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 }
2562 }
2563
Amerigo Wang00b7c332010-05-05 00:26:45 +00002564 if (!write && !first && left && !err)
2565 err = proc_put_char(&buffer, &left, '\n');
2566 if (write && !err)
2567 left -= proc_skip_spaces(&kbuf);
2568free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002570 free_page(page);
2571 if (first)
2572 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002573 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 *lenp -= left;
2575 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002576 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577}
2578
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002579static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002580 void __user *buffer,
2581 size_t *lenp, loff_t *ppos,
2582 unsigned long convmul,
2583 unsigned long convdiv)
2584{
2585 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002586 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002587}
2588
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589/**
2590 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2591 * @table: the sysctl table
2592 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 * @buffer: the user buffer
2594 * @lenp: the size of the user buffer
2595 * @ppos: file position
2596 *
2597 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2598 * values from/to the user buffer, treated as an ASCII string.
2599 *
2600 * This routine will ensure the values are within the range specified by
2601 * table->extra1 (min) and table->extra2 (max).
2602 *
2603 * Returns 0 on success.
2604 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002605int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 void __user *buffer, size_t *lenp, loff_t *ppos)
2607{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002608 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609}
2610
2611/**
2612 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2613 * @table: the sysctl table
2614 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615 * @buffer: the user buffer
2616 * @lenp: the size of the user buffer
2617 * @ppos: file position
2618 *
2619 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2620 * values from/to the user buffer, treated as an ASCII string. The values
2621 * are treated as milliseconds, and converted to jiffies when they are stored.
2622 *
2623 * This routine will ensure the values are within the range specified by
2624 * table->extra1 (min) and table->extra2 (max).
2625 *
2626 * Returns 0 on success.
2627 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002628int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 void __user *buffer,
2630 size_t *lenp, loff_t *ppos)
2631{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002632 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 lenp, ppos, HZ, 1000l);
2634}
2635
2636
Amerigo Wang00b7c332010-05-05 00:26:45 +00002637static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 int *valp,
2639 int write, void *data)
2640{
2641 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002642 if (*lvalp > LONG_MAX / HZ)
2643 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2645 } else {
2646 int val = *valp;
2647 unsigned long lval;
2648 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002649 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 lval = (unsigned long)-val;
2651 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002652 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653 lval = (unsigned long)val;
2654 }
2655 *lvalp = lval / HZ;
2656 }
2657 return 0;
2658}
2659
Amerigo Wang00b7c332010-05-05 00:26:45 +00002660static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 int *valp,
2662 int write, void *data)
2663{
2664 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002665 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2666 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2668 } else {
2669 int val = *valp;
2670 unsigned long lval;
2671 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002672 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 lval = (unsigned long)-val;
2674 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002675 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 lval = (unsigned long)val;
2677 }
2678 *lvalp = jiffies_to_clock_t(lval);
2679 }
2680 return 0;
2681}
2682
Amerigo Wang00b7c332010-05-05 00:26:45 +00002683static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684 int *valp,
2685 int write, void *data)
2686{
2687 if (write) {
2688 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2689 } else {
2690 int val = *valp;
2691 unsigned long lval;
2692 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002693 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 lval = (unsigned long)-val;
2695 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002696 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 lval = (unsigned long)val;
2698 }
2699 *lvalp = jiffies_to_msecs(lval);
2700 }
2701 return 0;
2702}
2703
2704/**
2705 * proc_dointvec_jiffies - read a vector of integers as seconds
2706 * @table: the sysctl table
2707 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708 * @buffer: the user buffer
2709 * @lenp: the size of the user buffer
2710 * @ppos: file position
2711 *
2712 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2713 * values from/to the user buffer, treated as an ASCII string.
2714 * The values read are assumed to be in seconds, and are converted into
2715 * jiffies.
2716 *
2717 * Returns 0 on success.
2718 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002719int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002720 void __user *buffer, size_t *lenp, loff_t *ppos)
2721{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002722 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 do_proc_dointvec_jiffies_conv,NULL);
2724}
2725
2726/**
2727 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2728 * @table: the sysctl table
2729 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 * @buffer: the user buffer
2731 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002732 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733 *
2734 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2735 * values from/to the user buffer, treated as an ASCII string.
2736 * The values read are assumed to be in 1/USER_HZ seconds, and
2737 * are converted into jiffies.
2738 *
2739 * Returns 0 on success.
2740 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002741int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 void __user *buffer, size_t *lenp, loff_t *ppos)
2743{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002744 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745 do_proc_dointvec_userhz_jiffies_conv,NULL);
2746}
2747
2748/**
2749 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2750 * @table: the sysctl table
2751 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002752 * @buffer: the user buffer
2753 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002754 * @ppos: file position
2755 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002756 *
2757 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2758 * values from/to the user buffer, treated as an ASCII string.
2759 * The values read are assumed to be in 1/1000 seconds, and
2760 * are converted into jiffies.
2761 *
2762 * Returns 0 on success.
2763 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002764int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002765 void __user *buffer, size_t *lenp, loff_t *ppos)
2766{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002767 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768 do_proc_dointvec_ms_jiffies_conv, NULL);
2769}
2770
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002771static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002772 void __user *buffer, size_t *lenp, loff_t *ppos)
2773{
2774 struct pid *new_pid;
2775 pid_t tmp;
2776 int r;
2777
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002778 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002779
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002780 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002781 lenp, ppos, NULL, NULL);
2782 if (r || !write)
2783 return r;
2784
2785 new_pid = find_get_pid(tmp);
2786 if (!new_pid)
2787 return -ESRCH;
2788
2789 put_pid(xchg(&cad_pid, new_pid));
2790 return 0;
2791}
2792
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002793/**
2794 * proc_do_large_bitmap - read/write from/to a large bitmap
2795 * @table: the sysctl table
2796 * @write: %TRUE if this is a write to the sysctl file
2797 * @buffer: the user buffer
2798 * @lenp: the size of the user buffer
2799 * @ppos: file position
2800 *
2801 * The bitmap is stored at table->data and the bitmap length (in bits)
2802 * in table->maxlen.
2803 *
2804 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2805 * large bitmaps may be represented in a compact manner. Writing into
2806 * the file will clear the bitmap then update it with the given input.
2807 *
2808 * Returns 0 on success.
2809 */
2810int proc_do_large_bitmap(struct ctl_table *table, int write,
2811 void __user *buffer, size_t *lenp, loff_t *ppos)
2812{
2813 int err = 0;
2814 bool first = 1;
2815 size_t left = *lenp;
2816 unsigned long bitmap_len = table->maxlen;
2817 unsigned long *bitmap = (unsigned long *) table->data;
2818 unsigned long *tmp_bitmap = NULL;
2819 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2820
2821 if (!bitmap_len || !left || (*ppos && !write)) {
2822 *lenp = 0;
2823 return 0;
2824 }
2825
2826 if (write) {
2827 unsigned long page = 0;
2828 char *kbuf;
2829
2830 if (left > PAGE_SIZE - 1)
2831 left = PAGE_SIZE - 1;
2832
2833 page = __get_free_page(GFP_TEMPORARY);
2834 kbuf = (char *) page;
2835 if (!kbuf)
2836 return -ENOMEM;
2837 if (copy_from_user(kbuf, buffer, left)) {
2838 free_page(page);
2839 return -EFAULT;
2840 }
2841 kbuf[left] = 0;
2842
2843 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2844 GFP_KERNEL);
2845 if (!tmp_bitmap) {
2846 free_page(page);
2847 return -ENOMEM;
2848 }
2849 proc_skip_char(&kbuf, &left, '\n');
2850 while (!err && left) {
2851 unsigned long val_a, val_b;
2852 bool neg;
2853
2854 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2855 sizeof(tr_a), &c);
2856 if (err)
2857 break;
2858 if (val_a >= bitmap_len || neg) {
2859 err = -EINVAL;
2860 break;
2861 }
2862
2863 val_b = val_a;
2864 if (left) {
2865 kbuf++;
2866 left--;
2867 }
2868
2869 if (c == '-') {
2870 err = proc_get_long(&kbuf, &left, &val_b,
2871 &neg, tr_b, sizeof(tr_b),
2872 &c);
2873 if (err)
2874 break;
2875 if (val_b >= bitmap_len || neg ||
2876 val_a > val_b) {
2877 err = -EINVAL;
2878 break;
2879 }
2880 if (left) {
2881 kbuf++;
2882 left--;
2883 }
2884 }
2885
2886 while (val_a <= val_b)
2887 set_bit(val_a++, tmp_bitmap);
2888
2889 first = 0;
2890 proc_skip_char(&kbuf, &left, '\n');
2891 }
2892 free_page(page);
2893 } else {
2894 unsigned long bit_a, bit_b = 0;
2895
2896 while (left) {
2897 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2898 if (bit_a >= bitmap_len)
2899 break;
2900 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2901 bit_a + 1) - 1;
2902
2903 if (!first) {
2904 err = proc_put_char(&buffer, &left, ',');
2905 if (err)
2906 break;
2907 }
2908 err = proc_put_long(&buffer, &left, bit_a, false);
2909 if (err)
2910 break;
2911 if (bit_a != bit_b) {
2912 err = proc_put_char(&buffer, &left, '-');
2913 if (err)
2914 break;
2915 err = proc_put_long(&buffer, &left, bit_b, false);
2916 if (err)
2917 break;
2918 }
2919
2920 first = 0; bit_b++;
2921 }
2922 if (!err)
2923 err = proc_put_char(&buffer, &left, '\n');
2924 }
2925
2926 if (!err) {
2927 if (write) {
2928 if (*ppos)
2929 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2930 else
2931 memcpy(bitmap, tmp_bitmap,
2932 BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
2933 }
2934 kfree(tmp_bitmap);
2935 *lenp -= left;
2936 *ppos += *lenp;
2937 return 0;
2938 } else {
2939 kfree(tmp_bitmap);
2940 return err;
2941 }
2942}
2943
Jovi Zhang55610502011-01-12 17:00:45 -08002944#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002945
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002946int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947 void __user *buffer, size_t *lenp, loff_t *ppos)
2948{
2949 return -ENOSYS;
2950}
2951
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002952int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953 void __user *buffer, size_t *lenp, loff_t *ppos)
2954{
2955 return -ENOSYS;
2956}
2957
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002958int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002959 void __user *buffer, size_t *lenp, loff_t *ppos)
2960{
2961 return -ENOSYS;
2962}
2963
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002964int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965 void __user *buffer, size_t *lenp, loff_t *ppos)
2966{
2967 return -ENOSYS;
2968}
2969
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002970int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002971 void __user *buffer, size_t *lenp, loff_t *ppos)
2972{
2973 return -ENOSYS;
2974}
2975
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002976int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002977 void __user *buffer, size_t *lenp, loff_t *ppos)
2978{
2979 return -ENOSYS;
2980}
2981
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002982int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002983 void __user *buffer, size_t *lenp, loff_t *ppos)
2984{
2985 return -ENOSYS;
2986}
2987
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002988int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002989 void __user *buffer,
2990 size_t *lenp, loff_t *ppos)
2991{
2992 return -ENOSYS;
2993}
2994
2995
Jovi Zhang55610502011-01-12 17:00:45 -08002996#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997
Linus Torvalds1da177e2005-04-16 15:20:36 -07002998/*
2999 * No sense putting this after each symbol definition, twice,
3000 * exception granted :-)
3001 */
3002EXPORT_SYMBOL(proc_dointvec);
3003EXPORT_SYMBOL(proc_dointvec_jiffies);
3004EXPORT_SYMBOL(proc_dointvec_minmax);
3005EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3006EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3007EXPORT_SYMBOL(proc_dostring);
3008EXPORT_SYMBOL(proc_doulongvec_minmax);
3009EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3010EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003011EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003012EXPORT_SYMBOL(unregister_sysctl_table);