blob: ce724a0dd0bbbaa34d53584e6c1ae1bbdf6151ab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Dave Youngd33ed522010-03-10 15:23:59 -080026#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070028#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020030#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070031#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/init.h>
33#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010034#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030035#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020039#include <linux/ratelimit.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070042#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/times.h>
44#include <linux/limits.h>
45#include <linux/dcache.h>
46#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070047#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080048#include <linux/nfs_fs.h>
49#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070050#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020051#include <linux/ftrace.h>
David Howells12e22c52009-04-03 16:42:35 +010052#include <linux/slow-work.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020053#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050054#include <linux/kprobes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56#include <asm/uaccess.h>
57#include <asm/processor.h>
58
Andi Kleen29cbc782006-09-30 01:47:55 +020059#ifdef CONFIG_X86
60#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010061#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010062#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020063#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080064#ifdef CONFIG_BSD_PROCESS_ACCT
65#include <linux/acct.h>
66#endif
Dave Young4f0e0562010-03-10 15:24:09 -080067#ifdef CONFIG_RT_MUTEXES
68#include <linux/rtmutex.h>
69#endif
Dave Young2edf5e42010-03-10 15:24:10 -080070#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
71#include <linux/lockdep.h>
72#endif
Dave Young15485a42010-03-10 15:24:07 -080073#ifdef CONFIG_CHR_DEV_SG
74#include <scsi/sg.h>
75#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020076
Eric W. Biederman7058cb02007-10-18 03:05:58 -070077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#if defined(CONFIG_SYSCTL)
79
80/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern int sysctl_overcommit_memory;
82extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070083extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070084extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080085extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070088extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070090extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091extern int pid_max;
92extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080094extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080095extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020096extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010097extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040098extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000099#ifndef CONFIG_MMU
100extern int sysctl_nr_trim_pages;
101#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200102#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200103extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200104#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700106/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -0800107#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700108static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200109static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700110#endif
111
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700112static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700113static int __maybe_unused one = 1;
114static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800115static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700117#ifdef CONFIG_PRINTK
118static int ten_thousand = 10000;
119#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700121/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
122static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
125static int maxolduid = 65535;
126static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800127static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129static int ngroups_max = NGROUPS_MAX;
130
David S. Miller72c57ed2008-09-11 23:29:54 -0700131#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700132#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133#endif
134
David S. Miller08714202008-11-16 23:49:24 -0800135#ifdef CONFIG_SPARC64
136extern int sysctl_tsb_ratio;
137#endif
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#ifdef __hppa__
140extern int pwrsw_enabled;
141extern int unaligned_enabled;
142#endif
143
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800144#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#ifdef CONFIG_MATHEMU
146extern int sysctl_ieee_emulation_warnings;
147#endif
148extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700149extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#endif
151
Jes Sorensend2b176e2006-02-28 09:42:23 -0800152#ifdef CONFIG_IA64
153extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800154extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800155#endif
156
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200157extern struct ratelimit_state printk_ratelimit_state;
158
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700159#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700160static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700161 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700162static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800163 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700164#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700166#ifdef CONFIG_MAGIC_SYSRQ
167static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */
168
169static int sysrq_sysctl_handler(ctl_table *table, int write,
170 void __user *buffer, size_t *lenp,
171 loff_t *ppos)
172{
173 int error;
174
175 error = proc_dointvec(table, write, buffer, lenp, ppos);
176 if (error)
177 return error;
178
179 if (write)
180 sysrq_toggle_support(__sysrq_enabled);
181
182 return 0;
183}
184
185#endif
186
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700187static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100188static struct ctl_table_root sysctl_table_root;
189static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100190 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100191 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400192 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100193 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400194 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100195};
196static struct ctl_table_root sysctl_table_root = {
197 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400198 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100199};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700201static struct ctl_table kern_table[];
202static struct ctl_table vm_table[];
203static struct ctl_table fs_table[];
204static struct ctl_table debug_table[];
205static struct ctl_table dev_table[];
206extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700207#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700208extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400209#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800210#ifdef CONFIG_EPOLL
211extern struct ctl_table epoll_table[];
212#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
215int sysctl_legacy_va_layout;
216#endif
217
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218/* The default sysctl tables: */
219
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700220static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 .procname = "kernel",
223 .mode = 0555,
224 .child = kern_table,
225 },
226 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 .procname = "vm",
228 .mode = 0555,
229 .child = vm_table,
230 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 .procname = "fs",
233 .mode = 0555,
234 .child = fs_table,
235 },
236 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 .procname = "debug",
238 .mode = 0555,
239 .child = debug_table,
240 },
241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .procname = "dev",
243 .mode = 0555,
244 .child = dev_table,
245 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700246/*
247 * NOTE: do not add new entries to this table unless you have read
248 * Documentation/sysctl/ctl_unnumbered.txt
249 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700250 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251};
252
Ingo Molnar77e54a12007-07-09 18:52:00 +0200253#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100254static int min_sched_granularity_ns = 100000; /* 100 usecs */
255static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
256static int min_wakeup_granularity_ns; /* 0 usecs */
257static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100258static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
259static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100260static int min_sched_shares_ratelimit = 100000; /* 100 usec */
261static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200262#endif
263
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700264static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200265 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200266 .procname = "sched_child_runs_first",
267 .data = &sysctl_sched_child_runs_first,
268 .maxlen = sizeof(unsigned int),
269 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800270 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200271 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200272#ifdef CONFIG_SCHED_DEBUG
273 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100274 .procname = "sched_min_granularity_ns",
275 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800278 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100279 .extra1 = &min_sched_granularity_ns,
280 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281 },
282 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200283 .procname = "sched_latency_ns",
284 .data = &sysctl_sched_latency,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800287 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200288 .extra1 = &min_sched_granularity_ns,
289 .extra2 = &max_sched_granularity_ns,
290 },
291 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200292 .procname = "sched_wakeup_granularity_ns",
293 .data = &sysctl_sched_wakeup_granularity,
294 .maxlen = sizeof(unsigned int),
295 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800296 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200297 .extra1 = &min_wakeup_granularity_ns,
298 .extra2 = &max_wakeup_granularity_ns,
299 },
300 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200301 .procname = "sched_shares_ratelimit",
302 .data = &sysctl_sched_shares_ratelimit,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800305 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100306 .extra1 = &min_sched_shares_ratelimit,
307 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200308 },
309 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100310 .procname = "sched_tunable_scaling",
311 .data = &sysctl_sched_tunable_scaling,
312 .maxlen = sizeof(enum sched_tunable_scaling),
313 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800314 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100315 .extra1 = &min_sched_tunable_scaling,
316 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200317 },
318 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200319 .procname = "sched_shares_thresh",
320 .data = &sysctl_sched_shares_thresh,
321 .maxlen = sizeof(unsigned int),
322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800323 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200324 .extra1 = &zero,
325 },
326 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200327 .procname = "sched_migration_cost",
328 .data = &sysctl_sched_migration_cost,
329 .maxlen = sizeof(unsigned int),
330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200332 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100333 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100334 .procname = "sched_nr_migrate",
335 .data = &sysctl_sched_nr_migrate,
336 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100339 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530340 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200341 .procname = "sched_time_avg",
342 .data = &sysctl_sched_time_avg,
343 .maxlen = sizeof(unsigned int),
344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800345 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200346 },
347 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530348 .procname = "timer_migration",
349 .data = &sysctl_timer_migration,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800352 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530353 .extra1 = &zero,
354 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530355 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200356#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200357 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100358 .procname = "sched_rt_period_us",
359 .data = &sysctl_sched_rt_period,
360 .maxlen = sizeof(unsigned int),
361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800362 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100363 },
364 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100365 .procname = "sched_rt_runtime_us",
366 .data = &sysctl_sched_rt_runtime,
367 .maxlen = sizeof(int),
368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800369 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100370 },
371 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200372 .procname = "sched_compat_yield",
373 .data = &sysctl_sched_compat_yield,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800376 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200377 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700378#ifdef CONFIG_PROVE_LOCKING
379 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700380 .procname = "prove_locking",
381 .data = &prove_locking,
382 .maxlen = sizeof(int),
383 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800384 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700385 },
386#endif
387#ifdef CONFIG_LOCK_STAT
388 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700389 .procname = "lock_stat",
390 .data = &lock_stat,
391 .maxlen = sizeof(int),
392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800393 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700394 },
395#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 .procname = "panic",
398 .data = &panic_timeout,
399 .maxlen = sizeof(int),
400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 },
403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .procname = "core_uses_pid",
405 .data = &core_uses_pid,
406 .maxlen = sizeof(int),
407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 },
410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 .procname = "core_pattern",
412 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700413 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800415 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 },
Neil Hormana2939802009-09-23 15:56:56 -0700417 {
Neil Hormana2939802009-09-23 15:56:56 -0700418 .procname = "core_pipe_limit",
419 .data = &core_pipe_limit,
420 .maxlen = sizeof(unsigned int),
421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800422 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700423 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800424#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700427 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800429 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800431#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100432#ifdef CONFIG_LATENCYTOP
433 {
434 .procname = "latencytop",
435 .data = &latencytop_enabled,
436 .maxlen = sizeof(int),
437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800438 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100439 },
440#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441#ifdef CONFIG_BLK_DEV_INITRD
442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 .procname = "real-root-dev",
444 .data = &real_root_dev,
445 .maxlen = sizeof(int),
446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800447 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 },
449#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700450 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700451 .procname = "print-fatal-signals",
452 .data = &print_fatal_signals,
453 .maxlen = sizeof(int),
454 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800455 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700456 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700457#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 .procname = "reboot-cmd",
460 .data = reboot_command,
461 .maxlen = 256,
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 },
465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 .procname = "stop-a",
467 .data = &stop_a_enabled,
468 .maxlen = sizeof (int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 },
472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "scons-poweroff",
474 .data = &scons_pwroff,
475 .maxlen = sizeof (int),
476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800477 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
479#endif
David S. Miller08714202008-11-16 23:49:24 -0800480#ifdef CONFIG_SPARC64
481 {
David S. Miller08714202008-11-16 23:49:24 -0800482 .procname = "tsb-ratio",
483 .data = &sysctl_tsb_ratio,
484 .maxlen = sizeof (int),
485 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800486 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800487 },
488#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489#ifdef __hppa__
490 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 .procname = "soft-power",
492 .data = &pwrsw_enabled,
493 .maxlen = sizeof (int),
494 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800495 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 },
497 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 .procname = "unaligned-trap",
499 .data = &unaligned_enabled,
500 .maxlen = sizeof (int),
501 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800502 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 },
504#endif
505 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 .procname = "ctrl-alt-del",
507 .data = &C_A_D,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400512#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200513 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200514 .procname = "ftrace_enabled",
515 .data = &ftrace_enabled,
516 .maxlen = sizeof(int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200519 },
520#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500521#ifdef CONFIG_STACK_TRACER
522 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500523 .procname = "stack_tracer_enabled",
524 .data = &stack_tracer_enabled,
525 .maxlen = sizeof(int),
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500528 },
529#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400530#ifdef CONFIG_TRACING
531 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100532 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400533 .data = &ftrace_dump_on_oops,
534 .maxlen = sizeof(int),
535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800536 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400537 },
538#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200539#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 .procname = "modprobe",
542 .data = &modprobe_path,
543 .maxlen = KMOD_PATH_LEN,
544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800545 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 },
Kees Cook3d433212009-04-02 15:49:29 -0700547 {
Kees Cook3d433212009-04-02 15:49:29 -0700548 .procname = "modules_disabled",
549 .data = &modules_disabled,
550 .maxlen = sizeof(int),
551 .mode = 0644,
552 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800553 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700554 .extra1 = &one,
555 .extra2 = &one,
556 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700558#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100561 .data = &uevent_helper,
562 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
566#endif
567#ifdef CONFIG_CHR_DEV_SG
568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "sg-big-buff",
570 .data = &sg_big_buff,
571 .maxlen = sizeof (int),
572 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
575#endif
576#ifdef CONFIG_BSD_PROCESS_ACCT
577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "acct",
579 .data = &acct_parm,
580 .maxlen = 3*sizeof(int),
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
584#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585#ifdef CONFIG_MAGIC_SYSRQ
586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800588 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 .maxlen = sizeof (int),
590 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700591 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
593#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700594#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700597 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 .maxlen = sizeof (int),
599 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800600 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700602#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 .procname = "threads-max",
605 .data = &max_threads,
606 .maxlen = sizeof(int),
607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 },
610 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 .procname = "random",
612 .mode = 0555,
613 .child = random_table,
614 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "overflowuid",
617 .data = &overflowuid,
618 .maxlen = sizeof(int),
619 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800620 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .extra1 = &minolduid,
622 .extra2 = &maxolduid,
623 },
624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "overflowgid",
626 .data = &overflowgid,
627 .maxlen = sizeof(int),
628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .extra1 = &minolduid,
631 .extra2 = &maxolduid,
632 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800633#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634#ifdef CONFIG_MATHEMU
635 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 .procname = "ieee_emulation_warnings",
637 .data = &sysctl_ieee_emulation_warnings,
638 .maxlen = sizeof(int),
639 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800640 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 },
642#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 .procname = "userprocess_debug",
645 .data = &sysctl_userprocess_debug,
646 .maxlen = sizeof(int),
647 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800648 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 },
650#endif
651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 .procname = "pid_max",
653 .data = &pid_max,
654 .maxlen = sizeof (int),
655 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800656 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .extra1 = &pid_max_min,
658 .extra2 = &pid_max_max,
659 },
660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "panic_on_oops",
662 .data = &panic_on_oops,
663 .maxlen = sizeof(int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800667#if defined CONFIG_PRINTK
668 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800669 .procname = "printk",
670 .data = &console_loglevel,
671 .maxlen = 4*sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800674 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700677 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .maxlen = sizeof(int),
679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700684 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .maxlen = sizeof(int),
686 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 },
Dave Youngaf913222009-09-22 16:43:33 -0700689 {
Dave Youngaf913222009-09-22 16:43:33 -0700690 .procname = "printk_delay",
691 .data = &printk_delay_msec,
692 .maxlen = sizeof(int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700695 .extra1 = &zero,
696 .extra2 = &ten_thousand,
697 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800698#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .procname = "ngroups_max",
701 .data = &ngroups_max,
702 .maxlen = sizeof (int),
703 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800704 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 },
706#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
707 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 .procname = "unknown_nmi_panic",
709 .data = &unknown_nmi_panic,
710 .maxlen = sizeof (int),
711 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800712 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 },
Don Zickus407984f2006-09-26 10:52:27 +0200714 {
Don Zickus407984f2006-09-26 10:52:27 +0200715 .procname = "nmi_watchdog",
716 .data = &nmi_watchdog_enabled,
717 .maxlen = sizeof (int),
718 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800719 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 },
721#endif
722#if defined(CONFIG_X86)
723 {
Don Zickus8da5add2006-09-26 10:52:27 +0200724 .procname = "panic_on_unrecovered_nmi",
725 .data = &panic_on_unrecovered_nmi,
726 .maxlen = sizeof(int),
727 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800728 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200729 },
730 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700731 .procname = "panic_on_io_nmi",
732 .data = &panic_on_io_nmi,
733 .maxlen = sizeof(int),
734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700736 },
737 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 .procname = "bootloader_type",
739 .data = &bootloader_type,
740 .maxlen = sizeof (int),
741 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100744 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700745 .procname = "bootloader_version",
746 .data = &bootloader_version,
747 .maxlen = sizeof (int),
748 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700750 },
751 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100752 .procname = "kstack_depth_to_print",
753 .data = &kstack_depth_to_print,
754 .maxlen = sizeof(int),
755 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800756 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100757 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100758 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100759 .procname = "io_delay_type",
760 .data = &io_delay_type,
761 .maxlen = sizeof(int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100764 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800766#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 .procname = "randomize_va_space",
769 .data = &randomize_va_space,
770 .maxlen = sizeof(int),
771 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800772 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800774#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800775#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700776 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700777 .procname = "spin_retry",
778 .data = &spin_retry,
779 .maxlen = sizeof (int),
780 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800781 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700782 },
783#endif
Len Brown673d5b42007-07-28 03:33:16 -0400784#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800785 {
Pavel Machekc255d842006-02-20 18:27:58 -0800786 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700787 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800788 .maxlen = sizeof (unsigned long),
789 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800790 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800791 },
792#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800793#ifdef CONFIG_IA64
794 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800795 .procname = "ignore-unaligned-usertrap",
796 .data = &no_unaligned_warning,
797 .maxlen = sizeof (int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800800 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800801 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800802 .procname = "unaligned-dump-stack",
803 .data = &unaligned_dump_stack,
804 .maxlen = sizeof (int),
805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800807 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800808#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700809#ifdef CONFIG_DETECT_SOFTLOCKUP
810 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200811 .procname = "softlockup_panic",
812 .data = &softlockup_panic,
813 .maxlen = sizeof(int),
814 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800815 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200816 .extra1 = &zero,
817 .extra2 = &one,
818 },
819 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700820 .procname = "softlockup_thresh",
821 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200822 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700823 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800824 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200825 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700826 .extra2 = &sixty,
827 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800828#endif
829#ifdef CONFIG_DETECT_HUNG_TASK
830 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800831 .procname = "hung_task_panic",
832 .data = &sysctl_hung_task_panic,
833 .maxlen = sizeof(int),
834 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800835 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800836 .extra1 = &zero,
837 .extra2 = &one,
838 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100839 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100840 .procname = "hung_task_check_count",
841 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100842 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100843 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800844 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100845 },
846 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100847 .procname = "hung_task_timeout_secs",
848 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100849 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100850 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800851 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100852 },
853 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100854 .procname = "hung_task_warnings",
855 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100856 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100857 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800858 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100859 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700860#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200861#ifdef CONFIG_COMPAT
862 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200863 .procname = "compat-log",
864 .data = &compat_log,
865 .maxlen = sizeof (int),
866 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800867 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200868 },
869#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700870#ifdef CONFIG_RT_MUTEXES
871 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700872 .procname = "max_lock_depth",
873 .data = &max_lock_depth,
874 .maxlen = sizeof(int),
875 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800876 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700877 },
878#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700879 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700880 .procname = "poweroff_cmd",
881 .data = &poweroff_cmd,
882 .maxlen = POWEROFF_CMD_PATH_LEN,
883 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800884 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700885 },
David Howells0b77f5b2008-04-29 01:01:32 -0700886#ifdef CONFIG_KEYS
887 {
David Howells0b77f5b2008-04-29 01:01:32 -0700888 .procname = "keys",
889 .mode = 0555,
890 .child = key_sysctls,
891 },
892#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700893#ifdef CONFIG_RCU_TORTURE_TEST
894 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700895 .procname = "rcutorture_runnable",
896 .data = &rcutorture_runnable,
897 .maxlen = sizeof(int),
898 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800899 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700900 },
901#endif
David Howells12e22c52009-04-03 16:42:35 +0100902#ifdef CONFIG_SLOW_WORK
903 {
David Howells12e22c52009-04-03 16:42:35 +0100904 .procname = "slow-work",
905 .mode = 0555,
906 .child = slow_work_sysctls,
907 },
908#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200909#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200910 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200911 .procname = "perf_event_paranoid",
912 .data = &sysctl_perf_event_paranoid,
913 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200916 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200917 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200918 .procname = "perf_event_mlock_kb",
919 .data = &sysctl_perf_event_mlock,
920 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200921 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800922 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200923 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200924 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200925 .procname = "perf_event_max_sample_rate",
926 .data = &sysctl_perf_event_sample_rate,
927 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200930 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200931#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200932#ifdef CONFIG_KMEMCHECK
933 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200934 .procname = "kmemcheck",
935 .data = &kmemcheck_enabled,
936 .maxlen = sizeof(int),
937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200939 },
940#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200941#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200942 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200943 .procname = "blk_iopoll",
944 .data = &blk_iopoll_enabled,
945 .maxlen = sizeof(int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200948 },
Jens Axboecb684b52009-09-15 21:53:11 +0200949#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700950/*
951 * NOTE: do not add new entries to this table unless you have read
952 * Documentation/sysctl/ctl_unnumbered.txt
953 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700954 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955};
956
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700957static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 .procname = "overcommit_memory",
960 .data = &sysctl_overcommit_memory,
961 .maxlen = sizeof(sysctl_overcommit_memory),
962 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 },
965 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700966 .procname = "panic_on_oom",
967 .data = &sysctl_panic_on_oom,
968 .maxlen = sizeof(sysctl_panic_on_oom),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700971 },
972 {
David Rientjesfe071d72007-10-16 23:25:56 -0700973 .procname = "oom_kill_allocating_task",
974 .data = &sysctl_oom_kill_allocating_task,
975 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
976 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700978 },
979 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800980 .procname = "oom_dump_tasks",
981 .data = &sysctl_oom_dump_tasks,
982 .maxlen = sizeof(sysctl_oom_dump_tasks),
983 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800985 },
986 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 .procname = "overcommit_ratio",
988 .data = &sysctl_overcommit_ratio,
989 .maxlen = sizeof(sysctl_overcommit_ratio),
990 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 },
993 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 .procname = "page-cluster",
995 .data = &page_cluster,
996 .maxlen = sizeof(int),
997 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800998 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 },
1000 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 .procname = "dirty_background_ratio",
1002 .data = &dirty_background_ratio,
1003 .maxlen = sizeof(dirty_background_ratio),
1004 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001005 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 .extra1 = &zero,
1007 .extra2 = &one_hundred,
1008 },
1009 {
David Rientjes2da02992009-01-06 14:39:31 -08001010 .procname = "dirty_background_bytes",
1011 .data = &dirty_background_bytes,
1012 .maxlen = sizeof(dirty_background_bytes),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001015 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001016 },
1017 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 .procname = "dirty_ratio",
1019 .data = &vm_dirty_ratio,
1020 .maxlen = sizeof(vm_dirty_ratio),
1021 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001022 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 .extra1 = &zero,
1024 .extra2 = &one_hundred,
1025 },
1026 {
David Rientjes2da02992009-01-06 14:39:31 -08001027 .procname = "dirty_bytes",
1028 .data = &vm_dirty_bytes,
1029 .maxlen = sizeof(vm_dirty_bytes),
1030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001032 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001033 },
1034 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001036 .data = &dirty_writeback_interval,
1037 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001039 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 },
1041 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001043 .data = &dirty_expire_interval,
1044 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001046 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 },
1048 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 .procname = "nr_pdflush_threads",
1050 .data = &nr_pdflush_threads,
1051 .maxlen = sizeof nr_pdflush_threads,
1052 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001053 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 },
1055 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 .procname = "swappiness",
1057 .data = &vm_swappiness,
1058 .maxlen = sizeof(vm_swappiness),
1059 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001060 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 .extra1 = &zero,
1062 .extra2 = &one_hundred,
1063 },
1064#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001065 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001067 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 .maxlen = sizeof(unsigned long),
1069 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001070 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 .extra1 = (void *)&hugetlb_zero,
1072 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001073 },
1074#ifdef CONFIG_NUMA
1075 {
1076 .procname = "nr_hugepages_mempolicy",
1077 .data = NULL,
1078 .maxlen = sizeof(unsigned long),
1079 .mode = 0644,
1080 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1081 .extra1 = (void *)&hugetlb_zero,
1082 .extra2 = (void *)&hugetlb_infinity,
1083 },
1084#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 .procname = "hugetlb_shm_group",
1087 .data = &sysctl_hugetlb_shm_group,
1088 .maxlen = sizeof(gid_t),
1089 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001090 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 },
Mel Gorman396faf02007-07-17 04:03:13 -07001092 {
Mel Gorman396faf02007-07-17 04:03:13 -07001093 .procname = "hugepages_treat_as_movable",
1094 .data = &hugepages_treat_as_movable,
1095 .maxlen = sizeof(int),
1096 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001097 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001098 },
Adam Litke54f9f802007-10-16 01:26:20 -07001099 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001100 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001101 .data = NULL,
1102 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001103 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001104 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001105 .extra1 = (void *)&hugetlb_zero,
1106 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001107 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108#endif
1109 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .procname = "lowmem_reserve_ratio",
1111 .data = &sysctl_lowmem_reserve_ratio,
1112 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1113 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001114 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 },
1116 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001117 .procname = "drop_caches",
1118 .data = &sysctl_drop_caches,
1119 .maxlen = sizeof(int),
1120 .mode = 0644,
1121 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001122 },
1123 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 .procname = "min_free_kbytes",
1125 .data = &min_free_kbytes,
1126 .maxlen = sizeof(min_free_kbytes),
1127 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001128 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .extra1 = &zero,
1130 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001131 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001132 .procname = "percpu_pagelist_fraction",
1133 .data = &percpu_pagelist_fraction,
1134 .maxlen = sizeof(percpu_pagelist_fraction),
1135 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001136 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001137 .extra1 = &min_percpu_pagelist_fract,
1138 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139#ifdef CONFIG_MMU
1140 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 .procname = "max_map_count",
1142 .data = &sysctl_max_map_count,
1143 .maxlen = sizeof(sysctl_max_map_count),
1144 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001145 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001146 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001148#else
1149 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001150 .procname = "nr_trim_pages",
1151 .data = &sysctl_nr_trim_pages,
1152 .maxlen = sizeof(sysctl_nr_trim_pages),
1153 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001154 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001155 .extra1 = &zero,
1156 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157#endif
1158 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 .procname = "laptop_mode",
1160 .data = &laptop_mode,
1161 .maxlen = sizeof(laptop_mode),
1162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 },
1165 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 .procname = "block_dump",
1167 .data = &block_dump,
1168 .maxlen = sizeof(block_dump),
1169 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001170 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 .extra1 = &zero,
1172 },
1173 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 .procname = "vfs_cache_pressure",
1175 .data = &sysctl_vfs_cache_pressure,
1176 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1177 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001178 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .extra1 = &zero,
1180 },
1181#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1182 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .procname = "legacy_va_layout",
1184 .data = &sysctl_legacy_va_layout,
1185 .maxlen = sizeof(sysctl_legacy_va_layout),
1186 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001187 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 .extra1 = &zero,
1189 },
1190#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001191#ifdef CONFIG_NUMA
1192 {
Christoph Lameter17436602006-01-18 17:42:32 -08001193 .procname = "zone_reclaim_mode",
1194 .data = &zone_reclaim_mode,
1195 .maxlen = sizeof(zone_reclaim_mode),
1196 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001197 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001198 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001199 },
Christoph Lameter96146342006-07-03 00:24:13 -07001200 {
Christoph Lameter96146342006-07-03 00:24:13 -07001201 .procname = "min_unmapped_ratio",
1202 .data = &sysctl_min_unmapped_ratio,
1203 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1204 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001205 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001206 .extra1 = &zero,
1207 .extra2 = &one_hundred,
1208 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001209 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001210 .procname = "min_slab_ratio",
1211 .data = &sysctl_min_slab_ratio,
1212 .maxlen = sizeof(sysctl_min_slab_ratio),
1213 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001214 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001215 .extra1 = &zero,
1216 .extra2 = &one_hundred,
1217 },
Christoph Lameter17436602006-01-18 17:42:32 -08001218#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001219#ifdef CONFIG_SMP
1220 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001221 .procname = "stat_interval",
1222 .data = &sysctl_stat_interval,
1223 .maxlen = sizeof(sysctl_stat_interval),
1224 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001225 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001226 },
1227#endif
David Howells6e141542009-12-15 19:27:45 +00001228#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001229 {
Eric Parised032182007-06-28 15:55:21 -04001230 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001231 .data = &dac_mmap_min_addr,
1232 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001233 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001234 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001235 },
David Howells6e141542009-12-15 19:27:45 +00001236#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001237#ifdef CONFIG_NUMA
1238 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001239 .procname = "numa_zonelist_order",
1240 .data = &numa_zonelist_order,
1241 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1242 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001243 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001244 },
1245#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001246#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001247 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001248 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001249 .procname = "vdso_enabled",
1250 .data = &vdso_enabled,
1251 .maxlen = sizeof(vdso_enabled),
1252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001253 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001254 .extra1 = &zero,
1255 },
1256#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001257#ifdef CONFIG_HIGHMEM
1258 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001259 .procname = "highmem_is_dirtyable",
1260 .data = &vm_highmem_is_dirtyable,
1261 .maxlen = sizeof(vm_highmem_is_dirtyable),
1262 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001263 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001264 .extra1 = &zero,
1265 .extra2 = &one,
1266 },
1267#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001268 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001269 .procname = "scan_unevictable_pages",
1270 .data = &scan_unevictable_pages,
1271 .maxlen = sizeof(scan_unevictable_pages),
1272 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001273 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001274 },
Andi Kleen6a460792009-09-16 11:50:15 +02001275#ifdef CONFIG_MEMORY_FAILURE
1276 {
Andi Kleen6a460792009-09-16 11:50:15 +02001277 .procname = "memory_failure_early_kill",
1278 .data = &sysctl_memory_failure_early_kill,
1279 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001282 .extra1 = &zero,
1283 .extra2 = &one,
1284 },
1285 {
Andi Kleen6a460792009-09-16 11:50:15 +02001286 .procname = "memory_failure_recovery",
1287 .data = &sysctl_memory_failure_recovery,
1288 .maxlen = sizeof(sysctl_memory_failure_recovery),
1289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001290 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001291 .extra1 = &zero,
1292 .extra2 = &one,
1293 },
1294#endif
1295
Andrew Morton2be7fe02007-07-15 23:41:21 -07001296/*
1297 * NOTE: do not add new entries to this table unless you have read
1298 * Documentation/sysctl/ctl_unnumbered.txt
1299 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001300 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301};
1302
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001303#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001304static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001305 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001306};
1307#endif
1308
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001309static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 .procname = "inode-nr",
1312 .data = &inodes_stat,
1313 .maxlen = 2*sizeof(int),
1314 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 },
1317 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 .procname = "inode-state",
1319 .data = &inodes_stat,
1320 .maxlen = 7*sizeof(int),
1321 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001322 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 },
1324 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .procname = "file-nr",
1326 .data = &files_stat,
1327 .maxlen = 3*sizeof(int),
1328 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001329 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330 },
1331 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 .procname = "file-max",
1333 .data = &files_stat.max_files,
1334 .maxlen = sizeof(int),
1335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001336 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 },
1338 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001339 .procname = "nr_open",
1340 .data = &sysctl_nr_open,
1341 .maxlen = sizeof(int),
1342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001343 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001344 .extra1 = &sysctl_nr_open_min,
1345 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001346 },
1347 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 .procname = "dentry-state",
1349 .data = &dentry_stat,
1350 .maxlen = 6*sizeof(int),
1351 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001352 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 },
1354 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .procname = "overflowuid",
1356 .data = &fs_overflowuid,
1357 .maxlen = sizeof(int),
1358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001359 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 .extra1 = &minolduid,
1361 .extra2 = &maxolduid,
1362 },
1363 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364 .procname = "overflowgid",
1365 .data = &fs_overflowgid,
1366 .maxlen = sizeof(int),
1367 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001368 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369 .extra1 = &minolduid,
1370 .extra2 = &maxolduid,
1371 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001372#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 .procname = "leases-enable",
1375 .data = &leases_enable,
1376 .maxlen = sizeof(int),
1377 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001378 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001380#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381#ifdef CONFIG_DNOTIFY
1382 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 .procname = "dir-notify-enable",
1384 .data = &dir_notify_enable,
1385 .maxlen = sizeof(int),
1386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001387 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 },
1389#endif
1390#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001391#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 .procname = "lease-break-time",
1394 .data = &lease_break_time,
1395 .maxlen = sizeof(int),
1396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001397 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001399#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001400#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .procname = "aio-nr",
1403 .data = &aio_nr,
1404 .maxlen = sizeof(aio_nr),
1405 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001406 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 },
1408 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 .procname = "aio-max-nr",
1410 .data = &aio_max_nr,
1411 .maxlen = sizeof(aio_max_nr),
1412 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001413 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001415#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001416#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001417 {
Robert Love0399cb02005-07-13 12:38:18 -04001418 .procname = "inotify",
1419 .mode = 0555,
1420 .child = inotify_table,
1421 },
1422#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001423#ifdef CONFIG_EPOLL
1424 {
1425 .procname = "epoll",
1426 .mode = 0555,
1427 .child = epoll_table,
1428 },
1429#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001431 {
Alan Coxd6e71142005-06-23 00:09:43 -07001432 .procname = "suid_dumpable",
1433 .data = &suid_dumpable,
1434 .maxlen = sizeof(int),
1435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001436 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001437 .extra1 = &zero,
1438 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001439 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001440#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1441 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001442 .procname = "binfmt_misc",
1443 .mode = 0555,
1444 .child = binfmt_misc_table,
1445 },
1446#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001447/*
1448 * NOTE: do not add new entries to this table unless you have read
1449 * Documentation/sysctl/ctl_unnumbered.txt
1450 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001451 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452};
1453
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001454static struct ctl_table debug_table[] = {
David S. Miller4b177642010-03-01 00:02:23 -08001455#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001456 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001457 .procname = "exception-trace",
1458 .data = &show_unhandled_signals,
1459 .maxlen = sizeof(int),
1460 .mode = 0644,
1461 .proc_handler = proc_dointvec
1462 },
1463#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001464#if defined(CONFIG_OPTPROBES)
1465 {
1466 .procname = "kprobes-optimization",
1467 .data = &sysctl_kprobes_optimization,
1468 .maxlen = sizeof(int),
1469 .mode = 0644,
1470 .proc_handler = proc_kprobes_optimization_handler,
1471 .extra1 = &zero,
1472 .extra2 = &one,
1473 },
1474#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001475 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476};
1477
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001478static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001479 { }
Robert Love0eeca282005-07-12 17:06:03 -04001480};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481
Al Viro330d57f2005-11-04 10:18:40 +00001482static DEFINE_SPINLOCK(sysctl_lock);
1483
1484/* called under sysctl_lock */
1485static int use_table(struct ctl_table_header *p)
1486{
1487 if (unlikely(p->unregistering))
1488 return 0;
1489 p->used++;
1490 return 1;
1491}
1492
1493/* called under sysctl_lock */
1494static void unuse_table(struct ctl_table_header *p)
1495{
1496 if (!--p->used)
1497 if (unlikely(p->unregistering))
1498 complete(p->unregistering);
1499}
1500
1501/* called under sysctl_lock, will reacquire if has to wait */
1502static void start_unregistering(struct ctl_table_header *p)
1503{
1504 /*
1505 * if p->used is 0, nobody will ever touch that entry again;
1506 * we'll eliminate all paths to it before dropping sysctl_lock
1507 */
1508 if (unlikely(p->used)) {
1509 struct completion wait;
1510 init_completion(&wait);
1511 p->unregistering = &wait;
1512 spin_unlock(&sysctl_lock);
1513 wait_for_completion(&wait);
1514 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001515 } else {
1516 /* anything non-NULL; we'll never dereference it */
1517 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001518 }
1519 /*
1520 * do not remove from the list until nobody holds it; walking the
1521 * list in do_sysctl() relies on that.
1522 */
1523 list_del_init(&p->ctl_entry);
1524}
1525
Al Virof7e6ced2008-07-15 01:44:23 -04001526void sysctl_head_get(struct ctl_table_header *head)
1527{
1528 spin_lock(&sysctl_lock);
1529 head->count++;
1530 spin_unlock(&sysctl_lock);
1531}
1532
1533void sysctl_head_put(struct ctl_table_header *head)
1534{
1535 spin_lock(&sysctl_lock);
1536 if (!--head->count)
1537 kfree(head);
1538 spin_unlock(&sysctl_lock);
1539}
1540
1541struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1542{
1543 if (!head)
1544 BUG();
1545 spin_lock(&sysctl_lock);
1546 if (!use_table(head))
1547 head = ERR_PTR(-ENOENT);
1548 spin_unlock(&sysctl_lock);
1549 return head;
1550}
1551
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001552void sysctl_head_finish(struct ctl_table_header *head)
1553{
1554 if (!head)
1555 return;
1556 spin_lock(&sysctl_lock);
1557 unuse_table(head);
1558 spin_unlock(&sysctl_lock);
1559}
1560
Al Viro73455092008-07-14 21:22:20 -04001561static struct ctl_table_set *
1562lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1563{
1564 struct ctl_table_set *set = &root->default_set;
1565 if (root->lookup)
1566 set = root->lookup(root, namespaces);
1567 return set;
1568}
1569
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001570static struct list_head *
1571lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001572{
Al Viro73455092008-07-14 21:22:20 -04001573 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1574 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001575}
1576
1577struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1578 struct ctl_table_header *prev)
1579{
1580 struct ctl_table_root *root;
1581 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001582 struct ctl_table_header *head;
1583 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001584
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001585 spin_lock(&sysctl_lock);
1586 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001587 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001588 tmp = &prev->ctl_entry;
1589 unuse_table(prev);
1590 goto next;
1591 }
1592 tmp = &root_table_header.ctl_entry;
1593 for (;;) {
1594 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1595
1596 if (!use_table(head))
1597 goto next;
1598 spin_unlock(&sysctl_lock);
1599 return head;
1600 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001601 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001602 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001603 header_list = lookup_header_list(root, namespaces);
1604 if (tmp != header_list)
1605 continue;
1606
1607 do {
1608 root = list_entry(root->root_list.next,
1609 struct ctl_table_root, root_list);
1610 if (root == &sysctl_table_root)
1611 goto out;
1612 header_list = lookup_header_list(root, namespaces);
1613 } while (list_empty(header_list));
1614 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001615 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001616out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001617 spin_unlock(&sysctl_lock);
1618 return NULL;
1619}
1620
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001621struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1622{
1623 return __sysctl_head_next(current->nsproxy, prev);
1624}
1625
1626void register_sysctl_root(struct ctl_table_root *root)
1627{
1628 spin_lock(&sysctl_lock);
1629 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1630 spin_unlock(&sysctl_lock);
1631}
1632
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001634 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635 * some sysctl variables are readonly even to root.
1636 */
1637
1638static int test_perm(int mode, int op)
1639{
David Howells76aac0e2008-11-14 10:39:12 +11001640 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641 mode >>= 6;
1642 else if (in_egroup_p(0))
1643 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001644 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645 return 0;
1646 return -EACCES;
1647}
1648
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001649int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650{
1651 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001652 int mode;
1653
Al Viroe6305c42008-07-15 21:03:57 -04001654 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 if (error)
1656 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001657
1658 if (root->permissions)
1659 mode = root->permissions(root, current->nsproxy, table);
1660 else
1661 mode = table->mode;
1662
1663 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664}
1665
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001666static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1667{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001668 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001669 table->parent = parent;
1670 if (table->child)
1671 sysctl_set_parent(table, table->child);
1672 }
1673}
1674
1675static __init int sysctl_init(void)
1676{
1677 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001678#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1679 {
1680 int err;
1681 err = sysctl_check_table(current->nsproxy, root_table);
1682 }
1683#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001684 return 0;
1685}
1686
1687core_initcall(sysctl_init);
1688
Al Virobfbcf032008-07-27 06:31:22 +01001689static struct ctl_table *is_branch_in(struct ctl_table *branch,
1690 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001691{
1692 struct ctl_table *p;
1693 const char *s = branch->procname;
1694
1695 /* branch should have named subdirectory as its first element */
1696 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001697 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001698
1699 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001700 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001701 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001702
1703 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001704 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001705 if (!p->child)
1706 continue;
1707 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001708 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001709 }
Al Virobfbcf032008-07-27 06:31:22 +01001710 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001711}
1712
1713/* see if attaching q to p would be an improvement */
1714static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1715{
1716 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001717 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001718 int is_better = 0;
1719 int not_in_parent = !p->attached_by;
1720
Al Virobfbcf032008-07-27 06:31:22 +01001721 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001722 if (by == q->attached_by)
1723 is_better = 1;
1724 if (to == p->attached_by)
1725 not_in_parent = 1;
1726 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001727 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001728 }
1729
1730 if (is_better && not_in_parent) {
1731 q->attached_by = by;
1732 q->attached_to = to;
1733 q->parent = p;
1734 }
1735}
1736
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001738 * __register_sysctl_paths - register a sysctl hierarchy
1739 * @root: List of sysctl headers to register on
1740 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001741 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 *
1744 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001745 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001747 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1750 * enter a sysctl file
1751 *
1752 * data - a pointer to data for use by proc_handler
1753 *
1754 * maxlen - the maximum size in bytes of the data
1755 *
1756 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1757 *
1758 * child - a pointer to the child sysctl table if this entry is a directory, or
1759 * %NULL.
1760 *
1761 * proc_handler - the text handler routine (described below)
1762 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763 * de - for internal use by the sysctl routines
1764 *
1765 * extra1, extra2 - extra pointers usable by the proc handler routines
1766 *
1767 * Leaf nodes in the sysctl tree will be represented by a single file
1768 * under /proc; non-leaf nodes will be represented by directories.
1769 *
1770 * sysctl(2) can automatically manage read and write requests through
1771 * the sysctl table. The data and maxlen fields of the ctl_table
1772 * struct enable minimal validation of the values being written to be
1773 * performed, and the mode field allows minimal authentication.
1774 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775 * There must be a proc_handler routine for any terminal nodes
1776 * mirrored under /proc/sys (non-terminals are handled by a built-in
1777 * directory handler). Several default handlers are available to
1778 * cover common cases -
1779 *
1780 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1781 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1782 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1783 *
1784 * It is the handler's job to read the input buffer from user memory
1785 * and process it. The handler should return 0 on success.
1786 *
1787 * This routine returns %NULL on a failure to register, and a pointer
1788 * to the table header on success.
1789 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001790struct ctl_table_header *__register_sysctl_paths(
1791 struct ctl_table_root *root,
1792 struct nsproxy *namespaces,
1793 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001795 struct ctl_table_header *header;
1796 struct ctl_table *new, **prevp;
1797 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001798 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001799
1800 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001801 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001802 ;
1803
1804 /*
1805 * For each path component, allocate a 2-element ctl_table array.
1806 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001807 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001808 *
1809 * We allocate everything in one go so that we don't have to
1810 * worry about freeing additional memory in unregister_sysctl_table.
1811 */
1812 header = kzalloc(sizeof(struct ctl_table_header) +
1813 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1814 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001816
1817 new = (struct ctl_table *) (header + 1);
1818
1819 /* Now connect the dots */
1820 prevp = &header->ctl_table;
1821 for (n = 0; n < npath; ++n, ++path) {
1822 /* Copy the procname */
1823 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001824 new->mode = 0555;
1825
1826 *prevp = new;
1827 prevp = &new->child;
1828
1829 new += 2;
1830 }
1831 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001832 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001833
1834 INIT_LIST_HEAD(&header->ctl_entry);
1835 header->used = 0;
1836 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001837 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001838 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001839 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001840#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001841 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001842 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001843 return NULL;
1844 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001845#endif
Al Viro330d57f2005-11-04 10:18:40 +00001846 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001847 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001848 header->attached_by = header->ctl_table;
1849 header->attached_to = root_table;
1850 header->parent = &root_table_header;
1851 for (set = header->set; set; set = set->parent) {
1852 struct ctl_table_header *p;
1853 list_for_each_entry(p, &set->list, ctl_entry) {
1854 if (p->unregistering)
1855 continue;
1856 try_attach(p, header);
1857 }
1858 }
1859 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001860 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001861 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001862
1863 return header;
1864}
1865
1866/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001867 * register_sysctl_table_path - register a sysctl table hierarchy
1868 * @path: The path to the directory the sysctl table is in.
1869 * @table: the top-level table structure
1870 *
1871 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1872 * array. A completely 0 filled entry terminates the table.
1873 *
1874 * See __register_sysctl_paths for more details.
1875 */
1876struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1877 struct ctl_table *table)
1878{
1879 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1880 path, table);
1881}
1882
1883/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001884 * register_sysctl_table - register a sysctl table hierarchy
1885 * @table: the top-level table structure
1886 *
1887 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1888 * array. A completely 0 filled entry terminates the table.
1889 *
1890 * See register_sysctl_paths for more details.
1891 */
1892struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1893{
1894 static const struct ctl_path null_path[] = { {} };
1895
1896 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001897}
1898
1899/**
1900 * unregister_sysctl_table - unregister a sysctl table hierarchy
1901 * @header: the header returned from register_sysctl_table
1902 *
1903 * Unregisters the sysctl table and all children. proc entries may not
1904 * actually be removed until they are no longer used by anyone.
1905 */
1906void unregister_sysctl_table(struct ctl_table_header * header)
1907{
Al Viro330d57f2005-11-04 10:18:40 +00001908 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001909
1910 if (header == NULL)
1911 return;
1912
Al Viro330d57f2005-11-04 10:18:40 +00001913 spin_lock(&sysctl_lock);
1914 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001915 if (!--header->parent->count) {
1916 WARN_ON(1);
1917 kfree(header->parent);
1918 }
Al Virof7e6ced2008-07-15 01:44:23 -04001919 if (!--header->count)
1920 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001921 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922}
1923
Al Viro9043476f2008-07-15 08:54:06 -04001924int sysctl_is_seen(struct ctl_table_header *p)
1925{
1926 struct ctl_table_set *set = p->set;
1927 int res;
1928 spin_lock(&sysctl_lock);
1929 if (p->unregistering)
1930 res = 0;
1931 else if (!set->is_seen)
1932 res = 1;
1933 else
1934 res = set->is_seen(set);
1935 spin_unlock(&sysctl_lock);
1936 return res;
1937}
1938
Al Viro73455092008-07-14 21:22:20 -04001939void setup_sysctl_set(struct ctl_table_set *p,
1940 struct ctl_table_set *parent,
1941 int (*is_seen)(struct ctl_table_set *))
1942{
1943 INIT_LIST_HEAD(&p->list);
1944 p->parent = parent ? parent : &sysctl_table_root.default_set;
1945 p->is_seen = is_seen;
1946}
1947
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001948#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001949struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001950{
1951 return NULL;
1952}
1953
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001954struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1955 struct ctl_table *table)
1956{
1957 return NULL;
1958}
1959
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001960void unregister_sysctl_table(struct ctl_table_header * table)
1961{
1962}
1963
Al Viro73455092008-07-14 21:22:20 -04001964void setup_sysctl_set(struct ctl_table_set *p,
1965 struct ctl_table_set *parent,
1966 int (*is_seen)(struct ctl_table_set *))
1967{
1968}
1969
Al Virof7e6ced2008-07-15 01:44:23 -04001970void sysctl_head_put(struct ctl_table_header *head)
1971{
1972}
1973
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001974#endif /* CONFIG_SYSCTL */
1975
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976/*
1977 * /proc/sys support
1978 */
1979
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001980#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001982static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001983 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001984 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001985{
1986 size_t len;
1987 char __user *p;
1988 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001989
1990 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001991 *lenp = 0;
1992 return 0;
1993 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001994
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001995 if (write) {
1996 len = 0;
1997 p = buffer;
1998 while (len < *lenp) {
1999 if (get_user(c, p++))
2000 return -EFAULT;
2001 if (c == 0 || c == '\n')
2002 break;
2003 len++;
2004 }
2005 if (len >= maxlen)
2006 len = maxlen-1;
2007 if(copy_from_user(data, buffer, len))
2008 return -EFAULT;
2009 ((char *) data)[len] = 0;
2010 *ppos += *lenp;
2011 } else {
2012 len = strlen(data);
2013 if (len > maxlen)
2014 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002015
2016 if (*ppos > len) {
2017 *lenp = 0;
2018 return 0;
2019 }
2020
2021 data += *ppos;
2022 len -= *ppos;
2023
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002024 if (len > *lenp)
2025 len = *lenp;
2026 if (len)
2027 if(copy_to_user(buffer, data, len))
2028 return -EFAULT;
2029 if (len < *lenp) {
2030 if(put_user('\n', ((char __user *) buffer) + len))
2031 return -EFAULT;
2032 len++;
2033 }
2034 *lenp = len;
2035 *ppos += len;
2036 }
2037 return 0;
2038}
2039
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040/**
2041 * proc_dostring - read a string sysctl
2042 * @table: the sysctl table
2043 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044 * @buffer: the user buffer
2045 * @lenp: the size of the user buffer
2046 * @ppos: file position
2047 *
2048 * Reads/writes a string from/to the user buffer. If the kernel
2049 * buffer provided is not large enough to hold the string, the
2050 * string is truncated. The copied string is %NULL-terminated.
2051 * If the string is being read by the user process, it is copied
2052 * and a newline '\n' is added. It is truncated if the buffer is
2053 * not large enough.
2054 *
2055 * Returns 0 on success.
2056 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002057int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058 void __user *buffer, size_t *lenp, loff_t *ppos)
2059{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002060 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002061 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062}
2063
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064
2065static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2066 int *valp,
2067 int write, void *data)
2068{
2069 if (write) {
2070 *valp = *negp ? -*lvalp : *lvalp;
2071 } else {
2072 int val = *valp;
2073 if (val < 0) {
2074 *negp = -1;
2075 *lvalp = (unsigned long)-val;
2076 } else {
2077 *negp = 0;
2078 *lvalp = (unsigned long)val;
2079 }
2080 }
2081 return 0;
2082}
2083
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002084static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002085 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002086 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2088 int write, void *data),
2089 void *data)
2090{
2091#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002092 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 unsigned long lval;
2094 size_t left, len;
2095
2096 char buf[TMPBUFLEN], *p;
2097 char __user *s = buffer;
2098
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002099 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002100 (*ppos && !write)) {
2101 *lenp = 0;
2102 return 0;
2103 }
2104
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002105 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002106 vleft = table->maxlen / sizeof(*i);
2107 left = *lenp;
2108
2109 if (!conv)
2110 conv = do_proc_dointvec_conv;
2111
2112 for (; left && vleft--; i++, first=0) {
2113 if (write) {
2114 while (left) {
2115 char c;
2116 if (get_user(c, s))
2117 return -EFAULT;
2118 if (!isspace(c))
2119 break;
2120 left--;
2121 s++;
2122 }
2123 if (!left)
2124 break;
2125 neg = 0;
2126 len = left;
2127 if (len > sizeof(buf) - 1)
2128 len = sizeof(buf) - 1;
2129 if (copy_from_user(buf, s, len))
2130 return -EFAULT;
2131 buf[len] = 0;
2132 p = buf;
2133 if (*p == '-' && left > 1) {
2134 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002135 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 }
2137 if (*p < '0' || *p > '9')
2138 break;
2139
2140 lval = simple_strtoul(p, &p, 0);
2141
2142 len = p-buf;
2143 if ((len < left) && *p && !isspace(*p))
2144 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002145 s += len;
2146 left -= len;
2147
2148 if (conv(&neg, &lval, i, 1, data))
2149 break;
2150 } else {
2151 p = buf;
2152 if (!first)
2153 *p++ = '\t';
2154
2155 if (conv(&neg, &lval, i, 0, data))
2156 break;
2157
2158 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2159 len = strlen(buf);
2160 if (len > left)
2161 len = left;
2162 if(copy_to_user(s, buf, len))
2163 return -EFAULT;
2164 left -= len;
2165 s += len;
2166 }
2167 }
2168
2169 if (!write && !first && left) {
2170 if(put_user('\n', s))
2171 return -EFAULT;
2172 left--, s++;
2173 }
2174 if (write) {
2175 while (left) {
2176 char c;
2177 if (get_user(c, s++))
2178 return -EFAULT;
2179 if (!isspace(c))
2180 break;
2181 left--;
2182 }
2183 }
2184 if (write && first)
2185 return -EINVAL;
2186 *lenp -= left;
2187 *ppos += *lenp;
2188 return 0;
2189#undef TMPBUFLEN
2190}
2191
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002192static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002193 void __user *buffer, size_t *lenp, loff_t *ppos,
2194 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2195 int write, void *data),
2196 void *data)
2197{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002198 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002199 buffer, lenp, ppos, conv, data);
2200}
2201
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202/**
2203 * proc_dointvec - read a vector of integers
2204 * @table: the sysctl table
2205 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 * @buffer: the user buffer
2207 * @lenp: the size of the user buffer
2208 * @ppos: file position
2209 *
2210 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2211 * values from/to the user buffer, treated as an ASCII string.
2212 *
2213 * Returns 0 on success.
2214 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002215int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 void __user *buffer, size_t *lenp, loff_t *ppos)
2217{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002218 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219 NULL,NULL);
2220}
2221
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002222/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002223 * Taint values can only be increased
2224 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002225 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002226static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002227 void __user *buffer, size_t *lenp, loff_t *ppos)
2228{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002229 struct ctl_table t;
2230 unsigned long tmptaint = get_taint();
2231 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002232
Bastian Blank91fcd412007-04-23 14:41:14 -07002233 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002234 return -EPERM;
2235
Andi Kleen25ddbb12008-10-15 22:01:41 -07002236 t = *table;
2237 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002238 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002239 if (err < 0)
2240 return err;
2241
2242 if (write) {
2243 /*
2244 * Poor man's atomic or. Not worth adding a primitive
2245 * to everyone's atomic.h for this
2246 */
2247 int i;
2248 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2249 if ((tmptaint >> i) & 1)
2250 add_taint(i);
2251 }
2252 }
2253
2254 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002255}
2256
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257struct do_proc_dointvec_minmax_conv_param {
2258 int *min;
2259 int *max;
2260};
2261
2262static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2263 int *valp,
2264 int write, void *data)
2265{
2266 struct do_proc_dointvec_minmax_conv_param *param = data;
2267 if (write) {
2268 int val = *negp ? -*lvalp : *lvalp;
2269 if ((param->min && *param->min > val) ||
2270 (param->max && *param->max < val))
2271 return -EINVAL;
2272 *valp = val;
2273 } else {
2274 int val = *valp;
2275 if (val < 0) {
2276 *negp = -1;
2277 *lvalp = (unsigned long)-val;
2278 } else {
2279 *negp = 0;
2280 *lvalp = (unsigned long)val;
2281 }
2282 }
2283 return 0;
2284}
2285
2286/**
2287 * proc_dointvec_minmax - read a vector of integers with min/max values
2288 * @table: the sysctl table
2289 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 * @buffer: the user buffer
2291 * @lenp: the size of the user buffer
2292 * @ppos: file position
2293 *
2294 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2295 * values from/to the user buffer, treated as an ASCII string.
2296 *
2297 * This routine will ensure the values are within the range specified by
2298 * table->extra1 (min) and table->extra2 (max).
2299 *
2300 * Returns 0 on success.
2301 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002302int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 void __user *buffer, size_t *lenp, loff_t *ppos)
2304{
2305 struct do_proc_dointvec_minmax_conv_param param = {
2306 .min = (int *) table->extra1,
2307 .max = (int *) table->extra2,
2308 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002309 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 do_proc_dointvec_minmax_conv, &param);
2311}
2312
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002313static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 void __user *buffer,
2315 size_t *lenp, loff_t *ppos,
2316 unsigned long convmul,
2317 unsigned long convdiv)
2318{
2319#define TMPBUFLEN 21
2320 unsigned long *i, *min, *max, val;
2321 int vleft, first=1, neg;
2322 size_t len, left;
2323 char buf[TMPBUFLEN], *p;
2324 char __user *s = buffer;
2325
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002326 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 (*ppos && !write)) {
2328 *lenp = 0;
2329 return 0;
2330 }
2331
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002332 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333 min = (unsigned long *) table->extra1;
2334 max = (unsigned long *) table->extra2;
2335 vleft = table->maxlen / sizeof(unsigned long);
2336 left = *lenp;
2337
2338 for (; left && vleft--; i++, min++, max++, first=0) {
2339 if (write) {
2340 while (left) {
2341 char c;
2342 if (get_user(c, s))
2343 return -EFAULT;
2344 if (!isspace(c))
2345 break;
2346 left--;
2347 s++;
2348 }
2349 if (!left)
2350 break;
2351 neg = 0;
2352 len = left;
2353 if (len > TMPBUFLEN-1)
2354 len = TMPBUFLEN-1;
2355 if (copy_from_user(buf, s, len))
2356 return -EFAULT;
2357 buf[len] = 0;
2358 p = buf;
2359 if (*p == '-' && left > 1) {
2360 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002361 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 }
2363 if (*p < '0' || *p > '9')
2364 break;
2365 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2366 len = p-buf;
2367 if ((len < left) && *p && !isspace(*p))
2368 break;
2369 if (neg)
2370 val = -val;
2371 s += len;
2372 left -= len;
2373
2374 if(neg)
2375 continue;
2376 if ((min && val < *min) || (max && val > *max))
2377 continue;
2378 *i = val;
2379 } else {
2380 p = buf;
2381 if (!first)
2382 *p++ = '\t';
2383 sprintf(p, "%lu", convdiv * (*i) / convmul);
2384 len = strlen(buf);
2385 if (len > left)
2386 len = left;
2387 if(copy_to_user(s, buf, len))
2388 return -EFAULT;
2389 left -= len;
2390 s += len;
2391 }
2392 }
2393
2394 if (!write && !first && left) {
2395 if(put_user('\n', s))
2396 return -EFAULT;
2397 left--, s++;
2398 }
2399 if (write) {
2400 while (left) {
2401 char c;
2402 if (get_user(c, s++))
2403 return -EFAULT;
2404 if (!isspace(c))
2405 break;
2406 left--;
2407 }
2408 }
2409 if (write && first)
2410 return -EINVAL;
2411 *lenp -= left;
2412 *ppos += *lenp;
2413 return 0;
2414#undef TMPBUFLEN
2415}
2416
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002417static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002418 void __user *buffer,
2419 size_t *lenp, loff_t *ppos,
2420 unsigned long convmul,
2421 unsigned long convdiv)
2422{
2423 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002424 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002425}
2426
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427/**
2428 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2429 * @table: the sysctl table
2430 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002431 * @buffer: the user buffer
2432 * @lenp: the size of the user buffer
2433 * @ppos: file position
2434 *
2435 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2436 * values from/to the user buffer, treated as an ASCII string.
2437 *
2438 * This routine will ensure the values are within the range specified by
2439 * table->extra1 (min) and table->extra2 (max).
2440 *
2441 * Returns 0 on success.
2442 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002443int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 void __user *buffer, size_t *lenp, loff_t *ppos)
2445{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002446 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447}
2448
2449/**
2450 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2451 * @table: the sysctl table
2452 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 * @buffer: the user buffer
2454 * @lenp: the size of the user buffer
2455 * @ppos: file position
2456 *
2457 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2458 * values from/to the user buffer, treated as an ASCII string. The values
2459 * are treated as milliseconds, and converted to jiffies when they are stored.
2460 *
2461 * This routine will ensure the values are within the range specified by
2462 * table->extra1 (min) and table->extra2 (max).
2463 *
2464 * Returns 0 on success.
2465 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002466int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 void __user *buffer,
2468 size_t *lenp, loff_t *ppos)
2469{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002470 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 lenp, ppos, HZ, 1000l);
2472}
2473
2474
2475static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2476 int *valp,
2477 int write, void *data)
2478{
2479 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002480 if (*lvalp > LONG_MAX / HZ)
2481 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2483 } else {
2484 int val = *valp;
2485 unsigned long lval;
2486 if (val < 0) {
2487 *negp = -1;
2488 lval = (unsigned long)-val;
2489 } else {
2490 *negp = 0;
2491 lval = (unsigned long)val;
2492 }
2493 *lvalp = lval / HZ;
2494 }
2495 return 0;
2496}
2497
2498static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2499 int *valp,
2500 int write, void *data)
2501{
2502 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002503 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2504 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2506 } else {
2507 int val = *valp;
2508 unsigned long lval;
2509 if (val < 0) {
2510 *negp = -1;
2511 lval = (unsigned long)-val;
2512 } else {
2513 *negp = 0;
2514 lval = (unsigned long)val;
2515 }
2516 *lvalp = jiffies_to_clock_t(lval);
2517 }
2518 return 0;
2519}
2520
2521static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2522 int *valp,
2523 int write, void *data)
2524{
2525 if (write) {
2526 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2527 } else {
2528 int val = *valp;
2529 unsigned long lval;
2530 if (val < 0) {
2531 *negp = -1;
2532 lval = (unsigned long)-val;
2533 } else {
2534 *negp = 0;
2535 lval = (unsigned long)val;
2536 }
2537 *lvalp = jiffies_to_msecs(lval);
2538 }
2539 return 0;
2540}
2541
2542/**
2543 * proc_dointvec_jiffies - read a vector of integers as seconds
2544 * @table: the sysctl table
2545 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 * @buffer: the user buffer
2547 * @lenp: the size of the user buffer
2548 * @ppos: file position
2549 *
2550 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2551 * values from/to the user buffer, treated as an ASCII string.
2552 * The values read are assumed to be in seconds, and are converted into
2553 * jiffies.
2554 *
2555 * Returns 0 on success.
2556 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002557int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558 void __user *buffer, size_t *lenp, loff_t *ppos)
2559{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002560 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 do_proc_dointvec_jiffies_conv,NULL);
2562}
2563
2564/**
2565 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2566 * @table: the sysctl table
2567 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 * @buffer: the user buffer
2569 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002570 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 *
2572 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2573 * values from/to the user buffer, treated as an ASCII string.
2574 * The values read are assumed to be in 1/USER_HZ seconds, and
2575 * are converted into jiffies.
2576 *
2577 * Returns 0 on success.
2578 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002579int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580 void __user *buffer, size_t *lenp, loff_t *ppos)
2581{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002582 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 do_proc_dointvec_userhz_jiffies_conv,NULL);
2584}
2585
2586/**
2587 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2588 * @table: the sysctl table
2589 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 * @buffer: the user buffer
2591 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002592 * @ppos: file position
2593 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 *
2595 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2596 * values from/to the user buffer, treated as an ASCII string.
2597 * The values read are assumed to be in 1/1000 seconds, and
2598 * are converted into jiffies.
2599 *
2600 * Returns 0 on success.
2601 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002602int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603 void __user *buffer, size_t *lenp, loff_t *ppos)
2604{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002605 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 do_proc_dointvec_ms_jiffies_conv, NULL);
2607}
2608
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002609static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002610 void __user *buffer, size_t *lenp, loff_t *ppos)
2611{
2612 struct pid *new_pid;
2613 pid_t tmp;
2614 int r;
2615
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002616 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002617
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002618 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002619 lenp, ppos, NULL, NULL);
2620 if (r || !write)
2621 return r;
2622
2623 new_pid = find_get_pid(tmp);
2624 if (!new_pid)
2625 return -ESRCH;
2626
2627 put_pid(xchg(&cad_pid, new_pid));
2628 return 0;
2629}
2630
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631#else /* CONFIG_PROC_FS */
2632
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002633int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 void __user *buffer, size_t *lenp, loff_t *ppos)
2635{
2636 return -ENOSYS;
2637}
2638
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002639int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 void __user *buffer, size_t *lenp, loff_t *ppos)
2641{
2642 return -ENOSYS;
2643}
2644
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002645int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 void __user *buffer, size_t *lenp, loff_t *ppos)
2647{
2648 return -ENOSYS;
2649}
2650
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002651int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 void __user *buffer, size_t *lenp, loff_t *ppos)
2653{
2654 return -ENOSYS;
2655}
2656
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002657int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 void __user *buffer, size_t *lenp, loff_t *ppos)
2659{
2660 return -ENOSYS;
2661}
2662
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002663int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664 void __user *buffer, size_t *lenp, loff_t *ppos)
2665{
2666 return -ENOSYS;
2667}
2668
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002669int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 void __user *buffer, size_t *lenp, loff_t *ppos)
2671{
2672 return -ENOSYS;
2673}
2674
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002675int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 void __user *buffer,
2677 size_t *lenp, loff_t *ppos)
2678{
2679 return -ENOSYS;
2680}
2681
2682
2683#endif /* CONFIG_PROC_FS */
2684
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685/*
2686 * No sense putting this after each symbol definition, twice,
2687 * exception granted :-)
2688 */
2689EXPORT_SYMBOL(proc_dointvec);
2690EXPORT_SYMBOL(proc_dointvec_jiffies);
2691EXPORT_SYMBOL(proc_dointvec_minmax);
2692EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2693EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2694EXPORT_SYMBOL(proc_dostring);
2695EXPORT_SYMBOL(proc_doulongvec_minmax);
2696EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2697EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002698EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002699EXPORT_SYMBOL(unregister_sysctl_table);