blob: 999bc3fccf470af2ca4d1dc54613b292b0da5d58 [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
Don Zickus58687ac2010-05-07 17:11:44 -040077#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050078#include <linux/nmi.h>
79#endif
80
Eric W. Biederman7058cb02007-10-18 03:05:58 -070081
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#if defined(CONFIG_SYSCTL)
83
84/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085extern int sysctl_overcommit_memory;
86extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070087extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070088extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080089extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070092extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070094extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern int pid_max;
96extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080098extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080099extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200100extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100101extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400102extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000103#ifndef CONFIG_MMU
104extern int sysctl_nr_trim_pages;
105#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200106#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200107extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200108#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700110/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -0800111#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700112static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200113static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700114#endif
115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700117static int __maybe_unused one = 1;
118static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800119static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700121#ifdef CONFIG_PRINTK
122static int ten_thousand = 10000;
123#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700125/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
126static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
129static int maxolduid = 65535;
130static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800131static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133static int ngroups_max = NGROUPS_MAX;
134
David S. Miller72c57ed2008-09-11 23:29:54 -0700135#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700136#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137#endif
138
David S. Miller08714202008-11-16 23:49:24 -0800139#ifdef CONFIG_SPARC64
140extern int sysctl_tsb_ratio;
141#endif
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#ifdef __hppa__
144extern int pwrsw_enabled;
145extern int unaligned_enabled;
146#endif
147
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800148#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#ifdef CONFIG_MATHEMU
150extern int sysctl_ieee_emulation_warnings;
151#endif
152extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700153extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#endif
155
Jes Sorensend2b176e2006-02-28 09:42:23 -0800156#ifdef CONFIG_IA64
157extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800158extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800159#endif
160
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200161extern struct ratelimit_state printk_ratelimit_state;
162
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700163#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700164static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700166static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800167 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700168#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700169
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700170static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100171static struct ctl_table_root sysctl_table_root;
172static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100173 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400175 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100176 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400177 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100178};
179static struct ctl_table_root sysctl_table_root = {
180 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400181 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100182};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700184static struct ctl_table kern_table[];
185static struct ctl_table vm_table[];
186static struct ctl_table fs_table[];
187static struct ctl_table debug_table[];
188static struct ctl_table dev_table[];
189extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700190#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700191extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400192#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800193#ifdef CONFIG_EPOLL
194extern struct ctl_table epoll_table[];
195#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
198int sysctl_legacy_va_layout;
199#endif
200
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201/* The default sysctl tables: */
202
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700203static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 .procname = "kernel",
206 .mode = 0555,
207 .child = kern_table,
208 },
209 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 .procname = "vm",
211 .mode = 0555,
212 .child = vm_table,
213 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 .procname = "fs",
216 .mode = 0555,
217 .child = fs_table,
218 },
219 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 .procname = "debug",
221 .mode = 0555,
222 .child = debug_table,
223 },
224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 .procname = "dev",
226 .mode = 0555,
227 .child = dev_table,
228 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700229/*
230 * NOTE: do not add new entries to this table unless you have read
231 * Documentation/sysctl/ctl_unnumbered.txt
232 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700233 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234};
235
Ingo Molnar77e54a12007-07-09 18:52:00 +0200236#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100237static int min_sched_granularity_ns = 100000; /* 100 usecs */
238static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
239static int min_wakeup_granularity_ns; /* 0 usecs */
240static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100241static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
242static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100243static int min_sched_shares_ratelimit = 100000; /* 100 usec */
244static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200245#endif
246
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700247static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200248 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200249 .procname = "sched_child_runs_first",
250 .data = &sysctl_sched_child_runs_first,
251 .maxlen = sizeof(unsigned int),
252 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800253 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200254 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200255#ifdef CONFIG_SCHED_DEBUG
256 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100257 .procname = "sched_min_granularity_ns",
258 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200259 .maxlen = sizeof(unsigned int),
260 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800261 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100262 .extra1 = &min_sched_granularity_ns,
263 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200264 },
265 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200266 .procname = "sched_latency_ns",
267 .data = &sysctl_sched_latency,
268 .maxlen = sizeof(unsigned int),
269 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800270 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200271 .extra1 = &min_sched_granularity_ns,
272 .extra2 = &max_sched_granularity_ns,
273 },
274 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200275 .procname = "sched_wakeup_granularity_ns",
276 .data = &sysctl_sched_wakeup_granularity,
277 .maxlen = sizeof(unsigned int),
278 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800279 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280 .extra1 = &min_wakeup_granularity_ns,
281 .extra2 = &max_wakeup_granularity_ns,
282 },
283 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200284 .procname = "sched_shares_ratelimit",
285 .data = &sysctl_sched_shares_ratelimit,
286 .maxlen = sizeof(unsigned int),
287 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800288 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100289 .extra1 = &min_sched_shares_ratelimit,
290 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200291 },
292 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100293 .procname = "sched_tunable_scaling",
294 .data = &sysctl_sched_tunable_scaling,
295 .maxlen = sizeof(enum sched_tunable_scaling),
296 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800297 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100298 .extra1 = &min_sched_tunable_scaling,
299 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200300 },
301 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200302 .procname = "sched_shares_thresh",
303 .data = &sysctl_sched_shares_thresh,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800306 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200307 .extra1 = &zero,
308 },
309 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200310 .procname = "sched_migration_cost",
311 .data = &sysctl_sched_migration_cost,
312 .maxlen = sizeof(unsigned int),
313 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800314 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200315 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100316 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100317 .procname = "sched_nr_migrate",
318 .data = &sysctl_sched_nr_migrate,
319 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100320 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800321 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100322 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530323 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200324 .procname = "sched_time_avg",
325 .data = &sysctl_sched_time_avg,
326 .maxlen = sizeof(unsigned int),
327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800328 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200329 },
330 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530331 .procname = "timer_migration",
332 .data = &sysctl_timer_migration,
333 .maxlen = sizeof(unsigned int),
334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800335 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530336 .extra1 = &zero,
337 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530338 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200339#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200340 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100341 .procname = "sched_rt_period_us",
342 .data = &sysctl_sched_rt_period,
343 .maxlen = sizeof(unsigned int),
344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800345 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100346 },
347 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100348 .procname = "sched_rt_runtime_us",
349 .data = &sysctl_sched_rt_runtime,
350 .maxlen = sizeof(int),
351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800352 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100353 },
354 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200355 .procname = "sched_compat_yield",
356 .data = &sysctl_sched_compat_yield,
357 .maxlen = sizeof(unsigned int),
358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800359 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200360 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700361#ifdef CONFIG_PROVE_LOCKING
362 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700363 .procname = "prove_locking",
364 .data = &prove_locking,
365 .maxlen = sizeof(int),
366 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800367 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700368 },
369#endif
370#ifdef CONFIG_LOCK_STAT
371 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700372 .procname = "lock_stat",
373 .data = &lock_stat,
374 .maxlen = sizeof(int),
375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800376 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700377 },
378#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200379 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 .procname = "panic",
381 .data = &panic_timeout,
382 .maxlen = sizeof(int),
383 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800384 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 },
386 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 .procname = "core_uses_pid",
388 .data = &core_uses_pid,
389 .maxlen = sizeof(int),
390 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800391 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 },
393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 .procname = "core_pattern",
395 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700396 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800398 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 },
Neil Hormana2939802009-09-23 15:56:56 -0700400 {
Neil Hormana2939802009-09-23 15:56:56 -0700401 .procname = "core_pipe_limit",
402 .data = &core_pipe_limit,
403 .maxlen = sizeof(unsigned int),
404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800405 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700406 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800407#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700410 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800411 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800412 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800414#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100415#ifdef CONFIG_LATENCYTOP
416 {
417 .procname = "latencytop",
418 .data = &latencytop_enabled,
419 .maxlen = sizeof(int),
420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800421 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100422 },
423#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424#ifdef CONFIG_BLK_DEV_INITRD
425 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 .procname = "real-root-dev",
427 .data = &real_root_dev,
428 .maxlen = sizeof(int),
429 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800430 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 },
432#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700433 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700434 .procname = "print-fatal-signals",
435 .data = &print_fatal_signals,
436 .maxlen = sizeof(int),
437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800438 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700439 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700440#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 .procname = "reboot-cmd",
443 .data = reboot_command,
444 .maxlen = 256,
445 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800446 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 },
448 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 .procname = "stop-a",
450 .data = &stop_a_enabled,
451 .maxlen = sizeof (int),
452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800453 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 },
455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 .procname = "scons-poweroff",
457 .data = &scons_pwroff,
458 .maxlen = sizeof (int),
459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 },
462#endif
David S. Miller08714202008-11-16 23:49:24 -0800463#ifdef CONFIG_SPARC64
464 {
David S. Miller08714202008-11-16 23:49:24 -0800465 .procname = "tsb-ratio",
466 .data = &sysctl_tsb_ratio,
467 .maxlen = sizeof (int),
468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800469 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800470 },
471#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472#ifdef __hppa__
473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 .procname = "soft-power",
475 .data = &pwrsw_enabled,
476 .maxlen = sizeof (int),
477 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800478 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 },
480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 .procname = "unaligned-trap",
482 .data = &unaligned_enabled,
483 .maxlen = sizeof (int),
484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800485 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 },
487#endif
488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "ctrl-alt-del",
490 .data = &C_A_D,
491 .maxlen = sizeof(int),
492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800493 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400495#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200496 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200497 .procname = "ftrace_enabled",
498 .data = &ftrace_enabled,
499 .maxlen = sizeof(int),
500 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800501 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200502 },
503#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500504#ifdef CONFIG_STACK_TRACER
505 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500506 .procname = "stack_tracer_enabled",
507 .data = &stack_tracer_enabled,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500511 },
512#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400513#ifdef CONFIG_TRACING
514 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100515 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400516 .data = &ftrace_dump_on_oops,
517 .maxlen = sizeof(int),
518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800519 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400520 },
521#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200522#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 .procname = "modprobe",
525 .data = &modprobe_path,
526 .maxlen = KMOD_PATH_LEN,
527 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800528 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 },
Kees Cook3d433212009-04-02 15:49:29 -0700530 {
Kees Cook3d433212009-04-02 15:49:29 -0700531 .procname = "modules_disabled",
532 .data = &modules_disabled,
533 .maxlen = sizeof(int),
534 .mode = 0644,
535 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800536 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700537 .extra1 = &one,
538 .extra2 = &one,
539 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700541#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100544 .data = &uevent_helper,
545 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800547 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 },
549#endif
550#ifdef CONFIG_CHR_DEV_SG
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "sg-big-buff",
553 .data = &sg_big_buff,
554 .maxlen = sizeof (int),
555 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558#endif
559#ifdef CONFIG_BSD_PROCESS_ACCT
560 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 .procname = "acct",
562 .data = &acct_parm,
563 .maxlen = 3*sizeof(int),
564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800565 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 },
567#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568#ifdef CONFIG_MAGIC_SYSRQ
569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800571 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 .maxlen = sizeof (int),
573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 },
576#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700577#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700580 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 .maxlen = sizeof (int),
582 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700585#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "threads-max",
588 .data = &max_threads,
589 .maxlen = sizeof(int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "random",
595 .mode = 0555,
596 .child = random_table,
597 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .procname = "overflowuid",
600 .data = &overflowuid,
601 .maxlen = sizeof(int),
602 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800603 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 .extra1 = &minolduid,
605 .extra2 = &maxolduid,
606 },
607 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 .procname = "overflowgid",
609 .data = &overflowgid,
610 .maxlen = sizeof(int),
611 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800612 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 .extra1 = &minolduid,
614 .extra2 = &maxolduid,
615 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800616#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617#ifdef CONFIG_MATHEMU
618 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 .procname = "ieee_emulation_warnings",
620 .data = &sysctl_ieee_emulation_warnings,
621 .maxlen = sizeof(int),
622 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800623 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 },
625#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 .procname = "userprocess_debug",
628 .data = &sysctl_userprocess_debug,
629 .maxlen = sizeof(int),
630 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800631 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 },
633#endif
634 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .procname = "pid_max",
636 .data = &pid_max,
637 .maxlen = sizeof (int),
638 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800639 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .extra1 = &pid_max_min,
641 .extra2 = &pid_max_max,
642 },
643 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 .procname = "panic_on_oops",
645 .data = &panic_on_oops,
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 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800650#if defined CONFIG_PRINTK
651 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800652 .procname = "printk",
653 .data = &console_loglevel,
654 .maxlen = 4*sizeof(int),
655 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800656 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800657 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700660 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .maxlen = sizeof(int),
662 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800663 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 },
665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700667 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 .maxlen = sizeof(int),
669 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800670 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 },
Dave Youngaf913222009-09-22 16:43:33 -0700672 {
Dave Youngaf913222009-09-22 16:43:33 -0700673 .procname = "printk_delay",
674 .data = &printk_delay_msec,
675 .maxlen = sizeof(int),
676 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800677 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700678 .extra1 = &zero,
679 .extra2 = &ten_thousand,
680 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800681#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "ngroups_max",
684 .data = &ngroups_max,
685 .maxlen = sizeof (int),
686 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 },
Don Zickus58687ac2010-05-07 17:11:44 -0400689#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500690 {
Don Zickus58687ac2010-05-07 17:11:44 -0400691 .procname = "watchdog",
692 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500693 .maxlen = sizeof (int),
694 .mode = 0644,
Don Zickus58687ac2010-05-07 17:11:44 -0400695 .proc_handler = proc_dowatchdog_enabled,
696 },
697 {
698 .procname = "watchdog_thresh",
699 .data = &softlockup_thresh,
700 .maxlen = sizeof(int),
701 .mode = 0644,
702 .proc_handler = proc_dowatchdog_thresh,
703 .extra1 = &neg_one,
704 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500705 },
706#endif
Don Zickus58687ac2010-05-07 17:11:44 -0400707#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) && !defined(CONFIG_LOCKUP_DETECTOR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "unknown_nmi_panic",
710 .data = &unknown_nmi_panic,
711 .maxlen = sizeof (int),
712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 },
Don Zickus407984f2006-09-26 10:52:27 +0200715 {
Don Zickus407984f2006-09-26 10:52:27 +0200716 .procname = "nmi_watchdog",
717 .data = &nmi_watchdog_enabled,
718 .maxlen = sizeof (int),
719 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800720 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 },
722#endif
723#if defined(CONFIG_X86)
724 {
Don Zickus8da5add2006-09-26 10:52:27 +0200725 .procname = "panic_on_unrecovered_nmi",
726 .data = &panic_on_unrecovered_nmi,
727 .maxlen = sizeof(int),
728 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800729 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200730 },
731 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700732 .procname = "panic_on_io_nmi",
733 .data = &panic_on_io_nmi,
734 .maxlen = sizeof(int),
735 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800736 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700737 },
738 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .procname = "bootloader_type",
740 .data = &bootloader_type,
741 .maxlen = sizeof (int),
742 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800743 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100745 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700746 .procname = "bootloader_version",
747 .data = &bootloader_version,
748 .maxlen = sizeof (int),
749 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700751 },
752 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100753 .procname = "kstack_depth_to_print",
754 .data = &kstack_depth_to_print,
755 .maxlen = sizeof(int),
756 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800757 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100758 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100759 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100760 .procname = "io_delay_type",
761 .data = &io_delay_type,
762 .maxlen = sizeof(int),
763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800764 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100765 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800767#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 .procname = "randomize_va_space",
770 .data = &randomize_va_space,
771 .maxlen = sizeof(int),
772 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800773 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800775#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800776#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700777 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700778 .procname = "spin_retry",
779 .data = &spin_retry,
780 .maxlen = sizeof (int),
781 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800782 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700783 },
784#endif
Len Brown673d5b42007-07-28 03:33:16 -0400785#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800786 {
Pavel Machekc255d842006-02-20 18:27:58 -0800787 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700788 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800789 .maxlen = sizeof (unsigned long),
790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800792 },
793#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800794#ifdef CONFIG_IA64
795 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800796 .procname = "ignore-unaligned-usertrap",
797 .data = &no_unaligned_warning,
798 .maxlen = sizeof (int),
799 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800800 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800801 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800802 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800803 .procname = "unaligned-dump-stack",
804 .data = &unaligned_dump_stack,
805 .maxlen = sizeof (int),
806 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800808 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800809#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700810#ifdef CONFIG_DETECT_SOFTLOCKUP
811 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200812 .procname = "softlockup_panic",
813 .data = &softlockup_panic,
814 .maxlen = sizeof(int),
815 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800816 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200817 .extra1 = &zero,
818 .extra2 = &one,
819 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800820#endif
821#ifdef CONFIG_DETECT_HUNG_TASK
822 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800823 .procname = "hung_task_panic",
824 .data = &sysctl_hung_task_panic,
825 .maxlen = sizeof(int),
826 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800827 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800828 .extra1 = &zero,
829 .extra2 = &one,
830 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100831 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100832 .procname = "hung_task_check_count",
833 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100834 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100835 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800836 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100837 },
838 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100839 .procname = "hung_task_timeout_secs",
840 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100841 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100842 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800843 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100844 },
845 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100846 .procname = "hung_task_warnings",
847 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100848 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100849 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800850 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100851 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700852#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200853#ifdef CONFIG_COMPAT
854 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200855 .procname = "compat-log",
856 .data = &compat_log,
857 .maxlen = sizeof (int),
858 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800859 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200860 },
861#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700862#ifdef CONFIG_RT_MUTEXES
863 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700864 .procname = "max_lock_depth",
865 .data = &max_lock_depth,
866 .maxlen = sizeof(int),
867 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800868 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700869 },
870#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700871 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700872 .procname = "poweroff_cmd",
873 .data = &poweroff_cmd,
874 .maxlen = POWEROFF_CMD_PATH_LEN,
875 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800876 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700877 },
David Howells0b77f5b2008-04-29 01:01:32 -0700878#ifdef CONFIG_KEYS
879 {
David Howells0b77f5b2008-04-29 01:01:32 -0700880 .procname = "keys",
881 .mode = 0555,
882 .child = key_sysctls,
883 },
884#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700885#ifdef CONFIG_RCU_TORTURE_TEST
886 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700887 .procname = "rcutorture_runnable",
888 .data = &rcutorture_runnable,
889 .maxlen = sizeof(int),
890 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800891 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700892 },
893#endif
David Howells12e22c52009-04-03 16:42:35 +0100894#ifdef CONFIG_SLOW_WORK
895 {
David Howells12e22c52009-04-03 16:42:35 +0100896 .procname = "slow-work",
897 .mode = 0555,
898 .child = slow_work_sysctls,
899 },
900#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200901#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200902 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200903 .procname = "perf_event_paranoid",
904 .data = &sysctl_perf_event_paranoid,
905 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200906 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800907 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200908 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200909 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200910 .procname = "perf_event_mlock_kb",
911 .data = &sysctl_perf_event_mlock,
912 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200913 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800914 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200915 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200916 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200917 .procname = "perf_event_max_sample_rate",
918 .data = &sysctl_perf_event_sample_rate,
919 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200920 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800921 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200922 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200923#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200924#ifdef CONFIG_KMEMCHECK
925 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200926 .procname = "kmemcheck",
927 .data = &kmemcheck_enabled,
928 .maxlen = sizeof(int),
929 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800930 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200931 },
932#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200933#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200934 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200935 .procname = "blk_iopoll",
936 .data = &blk_iopoll_enabled,
937 .maxlen = sizeof(int),
938 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800939 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200940 },
Jens Axboecb684b52009-09-15 21:53:11 +0200941#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700942/*
943 * NOTE: do not add new entries to this table unless you have read
944 * Documentation/sysctl/ctl_unnumbered.txt
945 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700946 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947};
948
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700949static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 .procname = "overcommit_memory",
952 .data = &sysctl_overcommit_memory,
953 .maxlen = sizeof(sysctl_overcommit_memory),
954 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800955 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 },
957 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700958 .procname = "panic_on_oom",
959 .data = &sysctl_panic_on_oom,
960 .maxlen = sizeof(sysctl_panic_on_oom),
961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800962 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700963 },
964 {
David Rientjesfe071d72007-10-16 23:25:56 -0700965 .procname = "oom_kill_allocating_task",
966 .data = &sysctl_oom_kill_allocating_task,
967 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
968 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800969 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700970 },
971 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800972 .procname = "oom_dump_tasks",
973 .data = &sysctl_oom_dump_tasks,
974 .maxlen = sizeof(sysctl_oom_dump_tasks),
975 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800976 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800977 },
978 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 .procname = "overcommit_ratio",
980 .data = &sysctl_overcommit_ratio,
981 .maxlen = sizeof(sysctl_overcommit_ratio),
982 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 },
985 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 .procname = "page-cluster",
987 .data = &page_cluster,
988 .maxlen = sizeof(int),
989 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800990 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 },
992 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 .procname = "dirty_background_ratio",
994 .data = &dirty_background_ratio,
995 .maxlen = sizeof(dirty_background_ratio),
996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 .extra1 = &zero,
999 .extra2 = &one_hundred,
1000 },
1001 {
David Rientjes2da02992009-01-06 14:39:31 -08001002 .procname = "dirty_background_bytes",
1003 .data = &dirty_background_bytes,
1004 .maxlen = sizeof(dirty_background_bytes),
1005 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001006 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001007 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001008 },
1009 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 .procname = "dirty_ratio",
1011 .data = &vm_dirty_ratio,
1012 .maxlen = sizeof(vm_dirty_ratio),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 .extra1 = &zero,
1016 .extra2 = &one_hundred,
1017 },
1018 {
David Rientjes2da02992009-01-06 14:39:31 -08001019 .procname = "dirty_bytes",
1020 .data = &vm_dirty_bytes,
1021 .maxlen = sizeof(vm_dirty_bytes),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001024 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001025 },
1026 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001028 .data = &dirty_writeback_interval,
1029 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 },
1033 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001035 .data = &dirty_expire_interval,
1036 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 },
1040 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 .procname = "nr_pdflush_threads",
1042 .data = &nr_pdflush_threads,
1043 .maxlen = sizeof nr_pdflush_threads,
1044 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001045 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 },
1047 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 .procname = "swappiness",
1049 .data = &vm_swappiness,
1050 .maxlen = sizeof(vm_swappiness),
1051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 .extra1 = &zero,
1054 .extra2 = &one_hundred,
1055 },
1056#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001057 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001059 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 .maxlen = sizeof(unsigned long),
1061 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001062 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 .extra1 = (void *)&hugetlb_zero,
1064 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001065 },
1066#ifdef CONFIG_NUMA
1067 {
1068 .procname = "nr_hugepages_mempolicy",
1069 .data = NULL,
1070 .maxlen = sizeof(unsigned long),
1071 .mode = 0644,
1072 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1073 .extra1 = (void *)&hugetlb_zero,
1074 .extra2 = (void *)&hugetlb_infinity,
1075 },
1076#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 .procname = "hugetlb_shm_group",
1079 .data = &sysctl_hugetlb_shm_group,
1080 .maxlen = sizeof(gid_t),
1081 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001082 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 },
Mel Gorman396faf02007-07-17 04:03:13 -07001084 {
Mel Gorman396faf02007-07-17 04:03:13 -07001085 .procname = "hugepages_treat_as_movable",
1086 .data = &hugepages_treat_as_movable,
1087 .maxlen = sizeof(int),
1088 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001089 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001090 },
Adam Litke54f9f802007-10-16 01:26:20 -07001091 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001092 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001093 .data = NULL,
1094 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001097 .extra1 = (void *)&hugetlb_zero,
1098 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001099 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100#endif
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .procname = "lowmem_reserve_ratio",
1103 .data = &sysctl_lowmem_reserve_ratio,
1104 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 },
1108 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001109 .procname = "drop_caches",
1110 .data = &sysctl_drop_caches,
1111 .maxlen = sizeof(int),
1112 .mode = 0644,
1113 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001114 },
1115 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 .procname = "min_free_kbytes",
1117 .data = &min_free_kbytes,
1118 .maxlen = sizeof(min_free_kbytes),
1119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001120 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 .extra1 = &zero,
1122 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001123 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001124 .procname = "percpu_pagelist_fraction",
1125 .data = &percpu_pagelist_fraction,
1126 .maxlen = sizeof(percpu_pagelist_fraction),
1127 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001128 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001129 .extra1 = &min_percpu_pagelist_fract,
1130 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131#ifdef CONFIG_MMU
1132 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 .procname = "max_map_count",
1134 .data = &sysctl_max_map_count,
1135 .maxlen = sizeof(sysctl_max_map_count),
1136 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001137 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001138 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001140#else
1141 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001142 .procname = "nr_trim_pages",
1143 .data = &sysctl_nr_trim_pages,
1144 .maxlen = sizeof(sysctl_nr_trim_pages),
1145 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001146 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001147 .extra1 = &zero,
1148 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149#endif
1150 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 .procname = "laptop_mode",
1152 .data = &laptop_mode,
1153 .maxlen = sizeof(laptop_mode),
1154 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001155 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 },
1157 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .procname = "block_dump",
1159 .data = &block_dump,
1160 .maxlen = sizeof(block_dump),
1161 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001162 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 .extra1 = &zero,
1164 },
1165 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 .procname = "vfs_cache_pressure",
1167 .data = &sysctl_vfs_cache_pressure,
1168 .maxlen = sizeof(sysctl_vfs_cache_pressure),
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#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1174 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 .procname = "legacy_va_layout",
1176 .data = &sysctl_legacy_va_layout,
1177 .maxlen = sizeof(sysctl_legacy_va_layout),
1178 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001179 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 .extra1 = &zero,
1181 },
1182#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001183#ifdef CONFIG_NUMA
1184 {
Christoph Lameter17436602006-01-18 17:42:32 -08001185 .procname = "zone_reclaim_mode",
1186 .data = &zone_reclaim_mode,
1187 .maxlen = sizeof(zone_reclaim_mode),
1188 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001189 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001190 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001191 },
Christoph Lameter96146342006-07-03 00:24:13 -07001192 {
Christoph Lameter96146342006-07-03 00:24:13 -07001193 .procname = "min_unmapped_ratio",
1194 .data = &sysctl_min_unmapped_ratio,
1195 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1196 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001197 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001198 .extra1 = &zero,
1199 .extra2 = &one_hundred,
1200 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001201 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001202 .procname = "min_slab_ratio",
1203 .data = &sysctl_min_slab_ratio,
1204 .maxlen = sizeof(sysctl_min_slab_ratio),
1205 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001206 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001207 .extra1 = &zero,
1208 .extra2 = &one_hundred,
1209 },
Christoph Lameter17436602006-01-18 17:42:32 -08001210#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001211#ifdef CONFIG_SMP
1212 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001213 .procname = "stat_interval",
1214 .data = &sysctl_stat_interval,
1215 .maxlen = sizeof(sysctl_stat_interval),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001218 },
1219#endif
David Howells6e141542009-12-15 19:27:45 +00001220#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001221 {
Eric Parised032182007-06-28 15:55:21 -04001222 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001223 .data = &dac_mmap_min_addr,
1224 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001225 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001226 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001227 },
David Howells6e141542009-12-15 19:27:45 +00001228#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001229#ifdef CONFIG_NUMA
1230 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001231 .procname = "numa_zonelist_order",
1232 .data = &numa_zonelist_order,
1233 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1234 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001235 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001236 },
1237#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001238#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001239 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001240 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001241 .procname = "vdso_enabled",
1242 .data = &vdso_enabled,
1243 .maxlen = sizeof(vdso_enabled),
1244 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001245 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001246 .extra1 = &zero,
1247 },
1248#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001249#ifdef CONFIG_HIGHMEM
1250 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001251 .procname = "highmem_is_dirtyable",
1252 .data = &vm_highmem_is_dirtyable,
1253 .maxlen = sizeof(vm_highmem_is_dirtyable),
1254 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001255 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001256 .extra1 = &zero,
1257 .extra2 = &one,
1258 },
1259#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001260 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001261 .procname = "scan_unevictable_pages",
1262 .data = &scan_unevictable_pages,
1263 .maxlen = sizeof(scan_unevictable_pages),
1264 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001265 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001266 },
Andi Kleen6a460792009-09-16 11:50:15 +02001267#ifdef CONFIG_MEMORY_FAILURE
1268 {
Andi Kleen6a460792009-09-16 11:50:15 +02001269 .procname = "memory_failure_early_kill",
1270 .data = &sysctl_memory_failure_early_kill,
1271 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1272 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001273 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001274 .extra1 = &zero,
1275 .extra2 = &one,
1276 },
1277 {
Andi Kleen6a460792009-09-16 11:50:15 +02001278 .procname = "memory_failure_recovery",
1279 .data = &sysctl_memory_failure_recovery,
1280 .maxlen = sizeof(sysctl_memory_failure_recovery),
1281 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001282 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001283 .extra1 = &zero,
1284 .extra2 = &one,
1285 },
1286#endif
1287
Andrew Morton2be7fe02007-07-15 23:41:21 -07001288/*
1289 * NOTE: do not add new entries to this table unless you have read
1290 * Documentation/sysctl/ctl_unnumbered.txt
1291 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001292 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293};
1294
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001295#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001296static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001297 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001298};
1299#endif
1300
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001301static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 .procname = "inode-nr",
1304 .data = &inodes_stat,
1305 .maxlen = 2*sizeof(int),
1306 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001308 },
1309 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 .procname = "inode-state",
1311 .data = &inodes_stat,
1312 .maxlen = 7*sizeof(int),
1313 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001314 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 },
1316 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .procname = "file-nr",
1318 .data = &files_stat,
1319 .maxlen = 3*sizeof(int),
1320 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001321 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 },
1323 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 .procname = "file-max",
1325 .data = &files_stat.max_files,
1326 .maxlen = sizeof(int),
1327 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001328 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 },
1330 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001331 .procname = "nr_open",
1332 .data = &sysctl_nr_open,
1333 .maxlen = sizeof(int),
1334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001335 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001336 .extra1 = &sysctl_nr_open_min,
1337 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001338 },
1339 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340 .procname = "dentry-state",
1341 .data = &dentry_stat,
1342 .maxlen = 6*sizeof(int),
1343 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001344 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 },
1346 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .procname = "overflowuid",
1348 .data = &fs_overflowuid,
1349 .maxlen = sizeof(int),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 .extra1 = &minolduid,
1353 .extra2 = &maxolduid,
1354 },
1355 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 .procname = "overflowgid",
1357 .data = &fs_overflowgid,
1358 .maxlen = sizeof(int),
1359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 .extra1 = &minolduid,
1362 .extra2 = &maxolduid,
1363 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001364#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 .procname = "leases-enable",
1367 .data = &leases_enable,
1368 .maxlen = sizeof(int),
1369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001372#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373#ifdef CONFIG_DNOTIFY
1374 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 .procname = "dir-notify-enable",
1376 .data = &dir_notify_enable,
1377 .maxlen = sizeof(int),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 },
1381#endif
1382#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001383#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 .procname = "lease-break-time",
1386 .data = &lease_break_time,
1387 .maxlen = sizeof(int),
1388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001389 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001391#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001392#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 .procname = "aio-nr",
1395 .data = &aio_nr,
1396 .maxlen = sizeof(aio_nr),
1397 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001398 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 },
1400 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 .procname = "aio-max-nr",
1402 .data = &aio_max_nr,
1403 .maxlen = sizeof(aio_max_nr),
1404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001407#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001408#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001409 {
Robert Love0399cb02005-07-13 12:38:18 -04001410 .procname = "inotify",
1411 .mode = 0555,
1412 .child = inotify_table,
1413 },
1414#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001415#ifdef CONFIG_EPOLL
1416 {
1417 .procname = "epoll",
1418 .mode = 0555,
1419 .child = epoll_table,
1420 },
1421#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001423 {
Alan Coxd6e71142005-06-23 00:09:43 -07001424 .procname = "suid_dumpable",
1425 .data = &suid_dumpable,
1426 .maxlen = sizeof(int),
1427 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001428 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001429 .extra1 = &zero,
1430 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001431 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001432#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1433 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001434 .procname = "binfmt_misc",
1435 .mode = 0555,
1436 .child = binfmt_misc_table,
1437 },
1438#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001439/*
1440 * NOTE: do not add new entries to this table unless you have read
1441 * Documentation/sysctl/ctl_unnumbered.txt
1442 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001443 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444};
1445
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001446static struct ctl_table debug_table[] = {
David S. Miller4b177642010-03-01 00:02:23 -08001447#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001448 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001449 .procname = "exception-trace",
1450 .data = &show_unhandled_signals,
1451 .maxlen = sizeof(int),
1452 .mode = 0644,
1453 .proc_handler = proc_dointvec
1454 },
1455#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001456#if defined(CONFIG_OPTPROBES)
1457 {
1458 .procname = "kprobes-optimization",
1459 .data = &sysctl_kprobes_optimization,
1460 .maxlen = sizeof(int),
1461 .mode = 0644,
1462 .proc_handler = proc_kprobes_optimization_handler,
1463 .extra1 = &zero,
1464 .extra2 = &one,
1465 },
1466#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001467 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468};
1469
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001470static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001471 { }
Robert Love0eeca282005-07-12 17:06:03 -04001472};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473
Al Viro330d57f2005-11-04 10:18:40 +00001474static DEFINE_SPINLOCK(sysctl_lock);
1475
1476/* called under sysctl_lock */
1477static int use_table(struct ctl_table_header *p)
1478{
1479 if (unlikely(p->unregistering))
1480 return 0;
1481 p->used++;
1482 return 1;
1483}
1484
1485/* called under sysctl_lock */
1486static void unuse_table(struct ctl_table_header *p)
1487{
1488 if (!--p->used)
1489 if (unlikely(p->unregistering))
1490 complete(p->unregistering);
1491}
1492
1493/* called under sysctl_lock, will reacquire if has to wait */
1494static void start_unregistering(struct ctl_table_header *p)
1495{
1496 /*
1497 * if p->used is 0, nobody will ever touch that entry again;
1498 * we'll eliminate all paths to it before dropping sysctl_lock
1499 */
1500 if (unlikely(p->used)) {
1501 struct completion wait;
1502 init_completion(&wait);
1503 p->unregistering = &wait;
1504 spin_unlock(&sysctl_lock);
1505 wait_for_completion(&wait);
1506 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001507 } else {
1508 /* anything non-NULL; we'll never dereference it */
1509 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001510 }
1511 /*
1512 * do not remove from the list until nobody holds it; walking the
1513 * list in do_sysctl() relies on that.
1514 */
1515 list_del_init(&p->ctl_entry);
1516}
1517
Al Virof7e6ced2008-07-15 01:44:23 -04001518void sysctl_head_get(struct ctl_table_header *head)
1519{
1520 spin_lock(&sysctl_lock);
1521 head->count++;
1522 spin_unlock(&sysctl_lock);
1523}
1524
1525void sysctl_head_put(struct ctl_table_header *head)
1526{
1527 spin_lock(&sysctl_lock);
1528 if (!--head->count)
1529 kfree(head);
1530 spin_unlock(&sysctl_lock);
1531}
1532
1533struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1534{
1535 if (!head)
1536 BUG();
1537 spin_lock(&sysctl_lock);
1538 if (!use_table(head))
1539 head = ERR_PTR(-ENOENT);
1540 spin_unlock(&sysctl_lock);
1541 return head;
1542}
1543
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001544void sysctl_head_finish(struct ctl_table_header *head)
1545{
1546 if (!head)
1547 return;
1548 spin_lock(&sysctl_lock);
1549 unuse_table(head);
1550 spin_unlock(&sysctl_lock);
1551}
1552
Al Viro73455092008-07-14 21:22:20 -04001553static struct ctl_table_set *
1554lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1555{
1556 struct ctl_table_set *set = &root->default_set;
1557 if (root->lookup)
1558 set = root->lookup(root, namespaces);
1559 return set;
1560}
1561
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001562static struct list_head *
1563lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001564{
Al Viro73455092008-07-14 21:22:20 -04001565 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1566 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001567}
1568
1569struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1570 struct ctl_table_header *prev)
1571{
1572 struct ctl_table_root *root;
1573 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001574 struct ctl_table_header *head;
1575 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001576
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001577 spin_lock(&sysctl_lock);
1578 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001579 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001580 tmp = &prev->ctl_entry;
1581 unuse_table(prev);
1582 goto next;
1583 }
1584 tmp = &root_table_header.ctl_entry;
1585 for (;;) {
1586 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1587
1588 if (!use_table(head))
1589 goto next;
1590 spin_unlock(&sysctl_lock);
1591 return head;
1592 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001593 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001594 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001595 header_list = lookup_header_list(root, namespaces);
1596 if (tmp != header_list)
1597 continue;
1598
1599 do {
1600 root = list_entry(root->root_list.next,
1601 struct ctl_table_root, root_list);
1602 if (root == &sysctl_table_root)
1603 goto out;
1604 header_list = lookup_header_list(root, namespaces);
1605 } while (list_empty(header_list));
1606 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001607 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001608out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001609 spin_unlock(&sysctl_lock);
1610 return NULL;
1611}
1612
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001613struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1614{
1615 return __sysctl_head_next(current->nsproxy, prev);
1616}
1617
1618void register_sysctl_root(struct ctl_table_root *root)
1619{
1620 spin_lock(&sysctl_lock);
1621 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1622 spin_unlock(&sysctl_lock);
1623}
1624
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001626 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627 * some sysctl variables are readonly even to root.
1628 */
1629
1630static int test_perm(int mode, int op)
1631{
David Howells76aac0e2008-11-14 10:39:12 +11001632 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633 mode >>= 6;
1634 else if (in_egroup_p(0))
1635 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001636 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637 return 0;
1638 return -EACCES;
1639}
1640
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001641int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642{
1643 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001644 int mode;
1645
Al Viroe6305c42008-07-15 21:03:57 -04001646 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647 if (error)
1648 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001649
1650 if (root->permissions)
1651 mode = root->permissions(root, current->nsproxy, table);
1652 else
1653 mode = table->mode;
1654
1655 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656}
1657
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001658static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1659{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001660 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001661 table->parent = parent;
1662 if (table->child)
1663 sysctl_set_parent(table, table->child);
1664 }
1665}
1666
1667static __init int sysctl_init(void)
1668{
1669 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001670#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1671 {
1672 int err;
1673 err = sysctl_check_table(current->nsproxy, root_table);
1674 }
1675#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001676 return 0;
1677}
1678
1679core_initcall(sysctl_init);
1680
Al Virobfbcf032008-07-27 06:31:22 +01001681static struct ctl_table *is_branch_in(struct ctl_table *branch,
1682 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001683{
1684 struct ctl_table *p;
1685 const char *s = branch->procname;
1686
1687 /* branch should have named subdirectory as its first element */
1688 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001689 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001690
1691 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001692 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001693 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001694
1695 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001696 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001697 if (!p->child)
1698 continue;
1699 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001700 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001701 }
Al Virobfbcf032008-07-27 06:31:22 +01001702 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001703}
1704
1705/* see if attaching q to p would be an improvement */
1706static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1707{
1708 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001709 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001710 int is_better = 0;
1711 int not_in_parent = !p->attached_by;
1712
Al Virobfbcf032008-07-27 06:31:22 +01001713 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001714 if (by == q->attached_by)
1715 is_better = 1;
1716 if (to == p->attached_by)
1717 not_in_parent = 1;
1718 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001719 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001720 }
1721
1722 if (is_better && not_in_parent) {
1723 q->attached_by = by;
1724 q->attached_to = to;
1725 q->parent = p;
1726 }
1727}
1728
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001730 * __register_sysctl_paths - register a sysctl hierarchy
1731 * @root: List of sysctl headers to register on
1732 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001733 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 *
1736 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001737 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001739 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1742 * enter a sysctl file
1743 *
1744 * data - a pointer to data for use by proc_handler
1745 *
1746 * maxlen - the maximum size in bytes of the data
1747 *
1748 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1749 *
1750 * child - a pointer to the child sysctl table if this entry is a directory, or
1751 * %NULL.
1752 *
1753 * proc_handler - the text handler routine (described below)
1754 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 * de - for internal use by the sysctl routines
1756 *
1757 * extra1, extra2 - extra pointers usable by the proc handler routines
1758 *
1759 * Leaf nodes in the sysctl tree will be represented by a single file
1760 * under /proc; non-leaf nodes will be represented by directories.
1761 *
1762 * sysctl(2) can automatically manage read and write requests through
1763 * the sysctl table. The data and maxlen fields of the ctl_table
1764 * struct enable minimal validation of the values being written to be
1765 * performed, and the mode field allows minimal authentication.
1766 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767 * There must be a proc_handler routine for any terminal nodes
1768 * mirrored under /proc/sys (non-terminals are handled by a built-in
1769 * directory handler). Several default handlers are available to
1770 * cover common cases -
1771 *
1772 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1773 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1774 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1775 *
1776 * It is the handler's job to read the input buffer from user memory
1777 * and process it. The handler should return 0 on success.
1778 *
1779 * This routine returns %NULL on a failure to register, and a pointer
1780 * to the table header on success.
1781 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001782struct ctl_table_header *__register_sysctl_paths(
1783 struct ctl_table_root *root,
1784 struct nsproxy *namespaces,
1785 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001787 struct ctl_table_header *header;
1788 struct ctl_table *new, **prevp;
1789 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001790 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001791
1792 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001793 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001794 ;
1795
1796 /*
1797 * For each path component, allocate a 2-element ctl_table array.
1798 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001799 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001800 *
1801 * We allocate everything in one go so that we don't have to
1802 * worry about freeing additional memory in unregister_sysctl_table.
1803 */
1804 header = kzalloc(sizeof(struct ctl_table_header) +
1805 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1806 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001808
1809 new = (struct ctl_table *) (header + 1);
1810
1811 /* Now connect the dots */
1812 prevp = &header->ctl_table;
1813 for (n = 0; n < npath; ++n, ++path) {
1814 /* Copy the procname */
1815 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001816 new->mode = 0555;
1817
1818 *prevp = new;
1819 prevp = &new->child;
1820
1821 new += 2;
1822 }
1823 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001824 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001825
1826 INIT_LIST_HEAD(&header->ctl_entry);
1827 header->used = 0;
1828 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001829 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001830 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001831 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001832#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001833 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001834 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001835 return NULL;
1836 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001837#endif
Al Viro330d57f2005-11-04 10:18:40 +00001838 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001839 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001840 header->attached_by = header->ctl_table;
1841 header->attached_to = root_table;
1842 header->parent = &root_table_header;
1843 for (set = header->set; set; set = set->parent) {
1844 struct ctl_table_header *p;
1845 list_for_each_entry(p, &set->list, ctl_entry) {
1846 if (p->unregistering)
1847 continue;
1848 try_attach(p, header);
1849 }
1850 }
1851 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001852 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001853 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001854
1855 return header;
1856}
1857
1858/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001859 * register_sysctl_table_path - register a sysctl table hierarchy
1860 * @path: The path to the directory the sysctl table is in.
1861 * @table: the top-level table structure
1862 *
1863 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1864 * array. A completely 0 filled entry terminates the table.
1865 *
1866 * See __register_sysctl_paths for more details.
1867 */
1868struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1869 struct ctl_table *table)
1870{
1871 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1872 path, table);
1873}
1874
1875/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001876 * register_sysctl_table - register a sysctl table hierarchy
1877 * @table: the top-level table structure
1878 *
1879 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1880 * array. A completely 0 filled entry terminates the table.
1881 *
1882 * See register_sysctl_paths for more details.
1883 */
1884struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1885{
1886 static const struct ctl_path null_path[] = { {} };
1887
1888 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001889}
1890
1891/**
1892 * unregister_sysctl_table - unregister a sysctl table hierarchy
1893 * @header: the header returned from register_sysctl_table
1894 *
1895 * Unregisters the sysctl table and all children. proc entries may not
1896 * actually be removed until they are no longer used by anyone.
1897 */
1898void unregister_sysctl_table(struct ctl_table_header * header)
1899{
Al Viro330d57f2005-11-04 10:18:40 +00001900 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001901
1902 if (header == NULL)
1903 return;
1904
Al Viro330d57f2005-11-04 10:18:40 +00001905 spin_lock(&sysctl_lock);
1906 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001907 if (!--header->parent->count) {
1908 WARN_ON(1);
1909 kfree(header->parent);
1910 }
Al Virof7e6ced2008-07-15 01:44:23 -04001911 if (!--header->count)
1912 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001913 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914}
1915
Al Viro9043476f2008-07-15 08:54:06 -04001916int sysctl_is_seen(struct ctl_table_header *p)
1917{
1918 struct ctl_table_set *set = p->set;
1919 int res;
1920 spin_lock(&sysctl_lock);
1921 if (p->unregistering)
1922 res = 0;
1923 else if (!set->is_seen)
1924 res = 1;
1925 else
1926 res = set->is_seen(set);
1927 spin_unlock(&sysctl_lock);
1928 return res;
1929}
1930
Al Viro73455092008-07-14 21:22:20 -04001931void setup_sysctl_set(struct ctl_table_set *p,
1932 struct ctl_table_set *parent,
1933 int (*is_seen)(struct ctl_table_set *))
1934{
1935 INIT_LIST_HEAD(&p->list);
1936 p->parent = parent ? parent : &sysctl_table_root.default_set;
1937 p->is_seen = is_seen;
1938}
1939
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001940#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001941struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001942{
1943 return NULL;
1944}
1945
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001946struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1947 struct ctl_table *table)
1948{
1949 return NULL;
1950}
1951
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001952void unregister_sysctl_table(struct ctl_table_header * table)
1953{
1954}
1955
Al Viro73455092008-07-14 21:22:20 -04001956void setup_sysctl_set(struct ctl_table_set *p,
1957 struct ctl_table_set *parent,
1958 int (*is_seen)(struct ctl_table_set *))
1959{
1960}
1961
Al Virof7e6ced2008-07-15 01:44:23 -04001962void sysctl_head_put(struct ctl_table_header *head)
1963{
1964}
1965
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001966#endif /* CONFIG_SYSCTL */
1967
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968/*
1969 * /proc/sys support
1970 */
1971
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001972#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001974static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001975 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001976 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001977{
1978 size_t len;
1979 char __user *p;
1980 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001981
1982 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001983 *lenp = 0;
1984 return 0;
1985 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001986
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001987 if (write) {
1988 len = 0;
1989 p = buffer;
1990 while (len < *lenp) {
1991 if (get_user(c, p++))
1992 return -EFAULT;
1993 if (c == 0 || c == '\n')
1994 break;
1995 len++;
1996 }
1997 if (len >= maxlen)
1998 len = maxlen-1;
1999 if(copy_from_user(data, buffer, len))
2000 return -EFAULT;
2001 ((char *) data)[len] = 0;
2002 *ppos += *lenp;
2003 } else {
2004 len = strlen(data);
2005 if (len > maxlen)
2006 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002007
2008 if (*ppos > len) {
2009 *lenp = 0;
2010 return 0;
2011 }
2012
2013 data += *ppos;
2014 len -= *ppos;
2015
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002016 if (len > *lenp)
2017 len = *lenp;
2018 if (len)
2019 if(copy_to_user(buffer, data, len))
2020 return -EFAULT;
2021 if (len < *lenp) {
2022 if(put_user('\n', ((char __user *) buffer) + len))
2023 return -EFAULT;
2024 len++;
2025 }
2026 *lenp = len;
2027 *ppos += len;
2028 }
2029 return 0;
2030}
2031
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032/**
2033 * proc_dostring - read a string sysctl
2034 * @table: the sysctl table
2035 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036 * @buffer: the user buffer
2037 * @lenp: the size of the user buffer
2038 * @ppos: file position
2039 *
2040 * Reads/writes a string from/to the user buffer. If the kernel
2041 * buffer provided is not large enough to hold the string, the
2042 * string is truncated. The copied string is %NULL-terminated.
2043 * If the string is being read by the user process, it is copied
2044 * and a newline '\n' is added. It is truncated if the buffer is
2045 * not large enough.
2046 *
2047 * Returns 0 on success.
2048 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002049int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050 void __user *buffer, size_t *lenp, loff_t *ppos)
2051{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002052 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002053 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054}
2055
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056
2057static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2058 int *valp,
2059 int write, void *data)
2060{
2061 if (write) {
2062 *valp = *negp ? -*lvalp : *lvalp;
2063 } else {
2064 int val = *valp;
2065 if (val < 0) {
2066 *negp = -1;
2067 *lvalp = (unsigned long)-val;
2068 } else {
2069 *negp = 0;
2070 *lvalp = (unsigned long)val;
2071 }
2072 }
2073 return 0;
2074}
2075
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002076static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002077 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002078 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2080 int write, void *data),
2081 void *data)
2082{
2083#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002084 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 unsigned long lval;
2086 size_t left, len;
2087
2088 char buf[TMPBUFLEN], *p;
2089 char __user *s = buffer;
2090
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002091 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092 (*ppos && !write)) {
2093 *lenp = 0;
2094 return 0;
2095 }
2096
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002097 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 vleft = table->maxlen / sizeof(*i);
2099 left = *lenp;
2100
2101 if (!conv)
2102 conv = do_proc_dointvec_conv;
2103
2104 for (; left && vleft--; i++, first=0) {
2105 if (write) {
2106 while (left) {
2107 char c;
2108 if (get_user(c, s))
2109 return -EFAULT;
2110 if (!isspace(c))
2111 break;
2112 left--;
2113 s++;
2114 }
2115 if (!left)
2116 break;
2117 neg = 0;
2118 len = left;
2119 if (len > sizeof(buf) - 1)
2120 len = sizeof(buf) - 1;
2121 if (copy_from_user(buf, s, len))
2122 return -EFAULT;
2123 buf[len] = 0;
2124 p = buf;
2125 if (*p == '-' && left > 1) {
2126 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002127 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128 }
2129 if (*p < '0' || *p > '9')
2130 break;
2131
2132 lval = simple_strtoul(p, &p, 0);
2133
2134 len = p-buf;
2135 if ((len < left) && *p && !isspace(*p))
2136 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 s += len;
2138 left -= len;
2139
2140 if (conv(&neg, &lval, i, 1, data))
2141 break;
2142 } else {
2143 p = buf;
2144 if (!first)
2145 *p++ = '\t';
2146
2147 if (conv(&neg, &lval, i, 0, data))
2148 break;
2149
2150 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2151 len = strlen(buf);
2152 if (len > left)
2153 len = left;
2154 if(copy_to_user(s, buf, len))
2155 return -EFAULT;
2156 left -= len;
2157 s += len;
2158 }
2159 }
2160
2161 if (!write && !first && left) {
2162 if(put_user('\n', s))
2163 return -EFAULT;
2164 left--, s++;
2165 }
2166 if (write) {
2167 while (left) {
2168 char c;
2169 if (get_user(c, s++))
2170 return -EFAULT;
2171 if (!isspace(c))
2172 break;
2173 left--;
2174 }
2175 }
2176 if (write && first)
2177 return -EINVAL;
2178 *lenp -= left;
2179 *ppos += *lenp;
2180 return 0;
2181#undef TMPBUFLEN
2182}
2183
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002184static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002185 void __user *buffer, size_t *lenp, loff_t *ppos,
2186 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2187 int write, void *data),
2188 void *data)
2189{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002190 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002191 buffer, lenp, ppos, conv, data);
2192}
2193
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194/**
2195 * proc_dointvec - read a vector of integers
2196 * @table: the sysctl table
2197 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 * @buffer: the user buffer
2199 * @lenp: the size of the user buffer
2200 * @ppos: file position
2201 *
2202 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2203 * values from/to the user buffer, treated as an ASCII string.
2204 *
2205 * Returns 0 on success.
2206 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002207int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 void __user *buffer, size_t *lenp, loff_t *ppos)
2209{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002210 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 NULL,NULL);
2212}
2213
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002214/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002215 * Taint values can only be increased
2216 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002217 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002218static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002219 void __user *buffer, size_t *lenp, loff_t *ppos)
2220{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002221 struct ctl_table t;
2222 unsigned long tmptaint = get_taint();
2223 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002224
Bastian Blank91fcd412007-04-23 14:41:14 -07002225 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002226 return -EPERM;
2227
Andi Kleen25ddbb12008-10-15 22:01:41 -07002228 t = *table;
2229 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002230 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002231 if (err < 0)
2232 return err;
2233
2234 if (write) {
2235 /*
2236 * Poor man's atomic or. Not worth adding a primitive
2237 * to everyone's atomic.h for this
2238 */
2239 int i;
2240 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2241 if ((tmptaint >> i) & 1)
2242 add_taint(i);
2243 }
2244 }
2245
2246 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002247}
2248
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249struct do_proc_dointvec_minmax_conv_param {
2250 int *min;
2251 int *max;
2252};
2253
2254static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2255 int *valp,
2256 int write, void *data)
2257{
2258 struct do_proc_dointvec_minmax_conv_param *param = data;
2259 if (write) {
2260 int val = *negp ? -*lvalp : *lvalp;
2261 if ((param->min && *param->min > val) ||
2262 (param->max && *param->max < val))
2263 return -EINVAL;
2264 *valp = val;
2265 } else {
2266 int val = *valp;
2267 if (val < 0) {
2268 *negp = -1;
2269 *lvalp = (unsigned long)-val;
2270 } else {
2271 *negp = 0;
2272 *lvalp = (unsigned long)val;
2273 }
2274 }
2275 return 0;
2276}
2277
2278/**
2279 * proc_dointvec_minmax - read a vector of integers with min/max values
2280 * @table: the sysctl table
2281 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 * @buffer: the user buffer
2283 * @lenp: the size of the user buffer
2284 * @ppos: file position
2285 *
2286 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2287 * values from/to the user buffer, treated as an ASCII string.
2288 *
2289 * This routine will ensure the values are within the range specified by
2290 * table->extra1 (min) and table->extra2 (max).
2291 *
2292 * Returns 0 on success.
2293 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002294int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 void __user *buffer, size_t *lenp, loff_t *ppos)
2296{
2297 struct do_proc_dointvec_minmax_conv_param param = {
2298 .min = (int *) table->extra1,
2299 .max = (int *) table->extra2,
2300 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002301 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 do_proc_dointvec_minmax_conv, &param);
2303}
2304
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002305static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 void __user *buffer,
2307 size_t *lenp, loff_t *ppos,
2308 unsigned long convmul,
2309 unsigned long convdiv)
2310{
2311#define TMPBUFLEN 21
2312 unsigned long *i, *min, *max, val;
2313 int vleft, first=1, neg;
2314 size_t len, left;
2315 char buf[TMPBUFLEN], *p;
2316 char __user *s = buffer;
2317
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002318 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 (*ppos && !write)) {
2320 *lenp = 0;
2321 return 0;
2322 }
2323
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002324 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 min = (unsigned long *) table->extra1;
2326 max = (unsigned long *) table->extra2;
2327 vleft = table->maxlen / sizeof(unsigned long);
2328 left = *lenp;
2329
2330 for (; left && vleft--; i++, min++, max++, first=0) {
2331 if (write) {
2332 while (left) {
2333 char c;
2334 if (get_user(c, s))
2335 return -EFAULT;
2336 if (!isspace(c))
2337 break;
2338 left--;
2339 s++;
2340 }
2341 if (!left)
2342 break;
2343 neg = 0;
2344 len = left;
2345 if (len > TMPBUFLEN-1)
2346 len = TMPBUFLEN-1;
2347 if (copy_from_user(buf, s, len))
2348 return -EFAULT;
2349 buf[len] = 0;
2350 p = buf;
2351 if (*p == '-' && left > 1) {
2352 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002353 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 }
2355 if (*p < '0' || *p > '9')
2356 break;
2357 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2358 len = p-buf;
2359 if ((len < left) && *p && !isspace(*p))
2360 break;
2361 if (neg)
2362 val = -val;
2363 s += len;
2364 left -= len;
2365
2366 if(neg)
2367 continue;
2368 if ((min && val < *min) || (max && val > *max))
2369 continue;
2370 *i = val;
2371 } else {
2372 p = buf;
2373 if (!first)
2374 *p++ = '\t';
2375 sprintf(p, "%lu", convdiv * (*i) / convmul);
2376 len = strlen(buf);
2377 if (len > left)
2378 len = left;
2379 if(copy_to_user(s, buf, len))
2380 return -EFAULT;
2381 left -= len;
2382 s += len;
2383 }
2384 }
2385
2386 if (!write && !first && left) {
2387 if(put_user('\n', s))
2388 return -EFAULT;
2389 left--, s++;
2390 }
2391 if (write) {
2392 while (left) {
2393 char c;
2394 if (get_user(c, s++))
2395 return -EFAULT;
2396 if (!isspace(c))
2397 break;
2398 left--;
2399 }
2400 }
2401 if (write && first)
2402 return -EINVAL;
2403 *lenp -= left;
2404 *ppos += *lenp;
2405 return 0;
2406#undef TMPBUFLEN
2407}
2408
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002409static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002410 void __user *buffer,
2411 size_t *lenp, loff_t *ppos,
2412 unsigned long convmul,
2413 unsigned long convdiv)
2414{
2415 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002416 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002417}
2418
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419/**
2420 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2421 * @table: the sysctl table
2422 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 * @buffer: the user buffer
2424 * @lenp: the size of the user buffer
2425 * @ppos: file position
2426 *
2427 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2428 * values from/to the user buffer, treated as an ASCII string.
2429 *
2430 * This routine will ensure the values are within the range specified by
2431 * table->extra1 (min) and table->extra2 (max).
2432 *
2433 * Returns 0 on success.
2434 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002435int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 void __user *buffer, size_t *lenp, loff_t *ppos)
2437{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002438 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439}
2440
2441/**
2442 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2443 * @table: the sysctl table
2444 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 * @buffer: the user buffer
2446 * @lenp: the size of the user buffer
2447 * @ppos: file position
2448 *
2449 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2450 * values from/to the user buffer, treated as an ASCII string. The values
2451 * are treated as milliseconds, and converted to jiffies when they are stored.
2452 *
2453 * This routine will ensure the values are within the range specified by
2454 * table->extra1 (min) and table->extra2 (max).
2455 *
2456 * Returns 0 on success.
2457 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002458int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 void __user *buffer,
2460 size_t *lenp, loff_t *ppos)
2461{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002462 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463 lenp, ppos, HZ, 1000l);
2464}
2465
2466
2467static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2468 int *valp,
2469 int write, void *data)
2470{
2471 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002472 if (*lvalp > LONG_MAX / HZ)
2473 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2475 } else {
2476 int val = *valp;
2477 unsigned long lval;
2478 if (val < 0) {
2479 *negp = -1;
2480 lval = (unsigned long)-val;
2481 } else {
2482 *negp = 0;
2483 lval = (unsigned long)val;
2484 }
2485 *lvalp = lval / HZ;
2486 }
2487 return 0;
2488}
2489
2490static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2491 int *valp,
2492 int write, void *data)
2493{
2494 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002495 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2496 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2498 } else {
2499 int val = *valp;
2500 unsigned long lval;
2501 if (val < 0) {
2502 *negp = -1;
2503 lval = (unsigned long)-val;
2504 } else {
2505 *negp = 0;
2506 lval = (unsigned long)val;
2507 }
2508 *lvalp = jiffies_to_clock_t(lval);
2509 }
2510 return 0;
2511}
2512
2513static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2514 int *valp,
2515 int write, void *data)
2516{
2517 if (write) {
2518 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2519 } else {
2520 int val = *valp;
2521 unsigned long lval;
2522 if (val < 0) {
2523 *negp = -1;
2524 lval = (unsigned long)-val;
2525 } else {
2526 *negp = 0;
2527 lval = (unsigned long)val;
2528 }
2529 *lvalp = jiffies_to_msecs(lval);
2530 }
2531 return 0;
2532}
2533
2534/**
2535 * proc_dointvec_jiffies - read a vector of integers as seconds
2536 * @table: the sysctl table
2537 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538 * @buffer: the user buffer
2539 * @lenp: the size of the user buffer
2540 * @ppos: file position
2541 *
2542 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2543 * values from/to the user buffer, treated as an ASCII string.
2544 * The values read are assumed to be in seconds, and are converted into
2545 * jiffies.
2546 *
2547 * Returns 0 on success.
2548 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002549int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 void __user *buffer, size_t *lenp, loff_t *ppos)
2551{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002552 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 do_proc_dointvec_jiffies_conv,NULL);
2554}
2555
2556/**
2557 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2558 * @table: the sysctl table
2559 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 * @buffer: the user buffer
2561 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002562 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 *
2564 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2565 * values from/to the user buffer, treated as an ASCII string.
2566 * The values read are assumed to be in 1/USER_HZ seconds, and
2567 * are converted into jiffies.
2568 *
2569 * Returns 0 on success.
2570 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002571int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 void __user *buffer, size_t *lenp, loff_t *ppos)
2573{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002574 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 do_proc_dointvec_userhz_jiffies_conv,NULL);
2576}
2577
2578/**
2579 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2580 * @table: the sysctl table
2581 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 * @buffer: the user buffer
2583 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002584 * @ppos: file position
2585 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 *
2587 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2588 * values from/to the user buffer, treated as an ASCII string.
2589 * The values read are assumed to be in 1/1000 seconds, and
2590 * are converted into jiffies.
2591 *
2592 * Returns 0 on success.
2593 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002594int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 void __user *buffer, size_t *lenp, loff_t *ppos)
2596{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002597 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 do_proc_dointvec_ms_jiffies_conv, NULL);
2599}
2600
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002601static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002602 void __user *buffer, size_t *lenp, loff_t *ppos)
2603{
2604 struct pid *new_pid;
2605 pid_t tmp;
2606 int r;
2607
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002608 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002609
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002610 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002611 lenp, ppos, NULL, NULL);
2612 if (r || !write)
2613 return r;
2614
2615 new_pid = find_get_pid(tmp);
2616 if (!new_pid)
2617 return -ESRCH;
2618
2619 put_pid(xchg(&cad_pid, new_pid));
2620 return 0;
2621}
2622
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623#else /* CONFIG_PROC_FS */
2624
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002625int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626 void __user *buffer, size_t *lenp, loff_t *ppos)
2627{
2628 return -ENOSYS;
2629}
2630
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002631int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 void __user *buffer, size_t *lenp, loff_t *ppos)
2633{
2634 return -ENOSYS;
2635}
2636
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002637int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 void __user *buffer, size_t *lenp, loff_t *ppos)
2639{
2640 return -ENOSYS;
2641}
2642
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002643int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 void __user *buffer, size_t *lenp, loff_t *ppos)
2645{
2646 return -ENOSYS;
2647}
2648
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002649int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 void __user *buffer, size_t *lenp, loff_t *ppos)
2651{
2652 return -ENOSYS;
2653}
2654
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002655int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 void __user *buffer, size_t *lenp, loff_t *ppos)
2657{
2658 return -ENOSYS;
2659}
2660
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002661int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 void __user *buffer, size_t *lenp, loff_t *ppos)
2663{
2664 return -ENOSYS;
2665}
2666
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002667int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 void __user *buffer,
2669 size_t *lenp, loff_t *ppos)
2670{
2671 return -ENOSYS;
2672}
2673
2674
2675#endif /* CONFIG_PROC_FS */
2676
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677/*
2678 * No sense putting this after each symbol definition, twice,
2679 * exception granted :-)
2680 */
2681EXPORT_SYMBOL(proc_dointvec);
2682EXPORT_SYMBOL(proc_dointvec_jiffies);
2683EXPORT_SYMBOL(proc_dointvec_minmax);
2684EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2685EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2686EXPORT_SYMBOL(proc_dostring);
2687EXPORT_SYMBOL(proc_doulongvec_minmax);
2688EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2689EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002690EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691EXPORT_SYMBOL(unregister_sysctl_table);