blob: 90f536d846439439593af5f85c92bace046c611e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Dave Youngd33ed522010-03-10 15:23:59 -080026#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070028#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020030#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070031#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/init.h>
33#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010034#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030035#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020039#include <linux/ratelimit.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070042#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/times.h>
44#include <linux/limits.h>
45#include <linux/dcache.h>
46#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070047#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080048#include <linux/nfs_fs.h>
49#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070050#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020051#include <linux/ftrace.h>
David Howells12e22c52009-04-03 16:42:35 +010052#include <linux/slow-work.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020053#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050054#include <linux/kprobes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56#include <asm/uaccess.h>
57#include <asm/processor.h>
58
Andi Kleen29cbc782006-09-30 01:47:55 +020059#ifdef CONFIG_X86
60#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010061#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010062#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020063#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080064#ifdef CONFIG_BSD_PROCESS_ACCT
65#include <linux/acct.h>
66#endif
Dave Young4f0e0562010-03-10 15:24:09 -080067#ifdef CONFIG_RT_MUTEXES
68#include <linux/rtmutex.h>
69#endif
Dave Young2edf5e42010-03-10 15:24:10 -080070#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
71#include <linux/lockdep.h>
72#endif
Dave Young15485a42010-03-10 15:24:07 -080073#ifdef CONFIG_CHR_DEV_SG
74#include <scsi/sg.h>
75#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020076
Eric W. Biederman7058cb02007-10-18 03:05:58 -070077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#if defined(CONFIG_SYSCTL)
79
80/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern int sysctl_overcommit_memory;
82extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070083extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070084extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080085extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070088extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070090extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091extern int pid_max;
92extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080094extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080095extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020096extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010097extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040098extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000099#ifndef CONFIG_MMU
100extern int sysctl_nr_trim_pages;
101#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200102#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200103extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200104#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700106/* Constants used for minimum and maximum */
Bron Gondwana195cf452008-02-04 22:29:20 -0800107#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700108static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200109static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700110#endif
111
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700112static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700113static int __maybe_unused one = 1;
114static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800115static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700117#ifdef CONFIG_PRINTK
118static int ten_thousand = 10000;
119#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700121/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
122static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
125static int maxolduid = 65535;
126static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800127static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129static int ngroups_max = NGROUPS_MAX;
130
David S. Miller72c57ed2008-09-11 23:29:54 -0700131#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700132#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133#endif
134
David S. Miller08714202008-11-16 23:49:24 -0800135#ifdef CONFIG_SPARC64
136extern int sysctl_tsb_ratio;
137#endif
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#ifdef __hppa__
140extern int pwrsw_enabled;
141extern int unaligned_enabled;
142#endif
143
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800144#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#ifdef CONFIG_MATHEMU
146extern int sysctl_ieee_emulation_warnings;
147#endif
148extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700149extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#endif
151
Jes Sorensend2b176e2006-02-28 09:42:23 -0800152#ifdef CONFIG_IA64
153extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800154extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800155#endif
156
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200157extern struct ratelimit_state printk_ratelimit_state;
158
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700159#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700160static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700161 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700162static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800163 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700164#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700166static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100167static struct ctl_table_root sysctl_table_root;
168static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100169 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100170 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400171 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100172 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400173 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174};
175static struct ctl_table_root sysctl_table_root = {
176 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400177 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100178};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700180static struct ctl_table kern_table[];
181static struct ctl_table vm_table[];
182static struct ctl_table fs_table[];
183static struct ctl_table debug_table[];
184static struct ctl_table dev_table[];
185extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700186#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700187extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400188#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800189#ifdef CONFIG_EPOLL
190extern struct ctl_table epoll_table[];
191#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
193#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
194int sysctl_legacy_va_layout;
195#endif
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197/* The default sysctl tables: */
198
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700199static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 .procname = "kernel",
202 .mode = 0555,
203 .child = kern_table,
204 },
205 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 .procname = "vm",
207 .mode = 0555,
208 .child = vm_table,
209 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 .procname = "fs",
212 .mode = 0555,
213 .child = fs_table,
214 },
215 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 .procname = "debug",
217 .mode = 0555,
218 .child = debug_table,
219 },
220 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 .procname = "dev",
222 .mode = 0555,
223 .child = dev_table,
224 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700225/*
226 * NOTE: do not add new entries to this table unless you have read
227 * Documentation/sysctl/ctl_unnumbered.txt
228 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700229 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230};
231
Ingo Molnar77e54a12007-07-09 18:52:00 +0200232#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100233static int min_sched_granularity_ns = 100000; /* 100 usecs */
234static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
235static int min_wakeup_granularity_ns; /* 0 usecs */
236static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100237static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
238static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100239static int min_sched_shares_ratelimit = 100000; /* 100 usec */
240static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200241#endif
242
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700243static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200244 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200245 .procname = "sched_child_runs_first",
246 .data = &sysctl_sched_child_runs_first,
247 .maxlen = sizeof(unsigned int),
248 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800249 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200250 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200251#ifdef CONFIG_SCHED_DEBUG
252 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100253 .procname = "sched_min_granularity_ns",
254 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200255 .maxlen = sizeof(unsigned int),
256 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800257 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100258 .extra1 = &min_sched_granularity_ns,
259 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200260 },
261 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200262 .procname = "sched_latency_ns",
263 .data = &sysctl_sched_latency,
264 .maxlen = sizeof(unsigned int),
265 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800266 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200267 .extra1 = &min_sched_granularity_ns,
268 .extra2 = &max_sched_granularity_ns,
269 },
270 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200271 .procname = "sched_wakeup_granularity_ns",
272 .data = &sysctl_sched_wakeup_granularity,
273 .maxlen = sizeof(unsigned int),
274 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800275 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200276 .extra1 = &min_wakeup_granularity_ns,
277 .extra2 = &max_wakeup_granularity_ns,
278 },
279 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200280 .procname = "sched_shares_ratelimit",
281 .data = &sysctl_sched_shares_ratelimit,
282 .maxlen = sizeof(unsigned int),
283 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800284 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100285 .extra1 = &min_sched_shares_ratelimit,
286 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200287 },
288 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100289 .procname = "sched_tunable_scaling",
290 .data = &sysctl_sched_tunable_scaling,
291 .maxlen = sizeof(enum sched_tunable_scaling),
292 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800293 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100294 .extra1 = &min_sched_tunable_scaling,
295 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200296 },
297 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200298 .procname = "sched_shares_thresh",
299 .data = &sysctl_sched_shares_thresh,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800302 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200303 .extra1 = &zero,
304 },
305 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200306 .procname = "sched_migration_cost",
307 .data = &sysctl_sched_migration_cost,
308 .maxlen = sizeof(unsigned int),
309 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800310 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200311 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100312 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100313 .procname = "sched_nr_migrate",
314 .data = &sysctl_sched_nr_migrate,
315 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800317 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100318 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530319 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200320 .procname = "sched_time_avg",
321 .data = &sysctl_sched_time_avg,
322 .maxlen = sizeof(unsigned int),
323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800324 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200325 },
326 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530327 .procname = "timer_migration",
328 .data = &sysctl_timer_migration,
329 .maxlen = sizeof(unsigned int),
330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530332 .extra1 = &zero,
333 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530334 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200335#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200336 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100337 .procname = "sched_rt_period_us",
338 .data = &sysctl_sched_rt_period,
339 .maxlen = sizeof(unsigned int),
340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800341 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100342 },
343 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100344 .procname = "sched_rt_runtime_us",
345 .data = &sysctl_sched_rt_runtime,
346 .maxlen = sizeof(int),
347 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800348 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100349 },
350 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200351 .procname = "sched_compat_yield",
352 .data = &sysctl_sched_compat_yield,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800355 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200356 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700357#ifdef CONFIG_PROVE_LOCKING
358 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700359 .procname = "prove_locking",
360 .data = &prove_locking,
361 .maxlen = sizeof(int),
362 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800363 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700364 },
365#endif
366#ifdef CONFIG_LOCK_STAT
367 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700368 .procname = "lock_stat",
369 .data = &lock_stat,
370 .maxlen = sizeof(int),
371 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800372 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700373 },
374#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200375 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 .procname = "panic",
377 .data = &panic_timeout,
378 .maxlen = sizeof(int),
379 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800380 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 },
382 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 .procname = "core_uses_pid",
384 .data = &core_uses_pid,
385 .maxlen = sizeof(int),
386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800387 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 },
389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 .procname = "core_pattern",
391 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700392 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800394 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 },
Neil Hormana2939802009-09-23 15:56:56 -0700396 {
Neil Hormana2939802009-09-23 15:56:56 -0700397 .procname = "core_pipe_limit",
398 .data = &core_pipe_limit,
399 .maxlen = sizeof(unsigned int),
400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700402 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800403#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700406 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800410#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100411#ifdef CONFIG_LATENCYTOP
412 {
413 .procname = "latencytop",
414 .data = &latencytop_enabled,
415 .maxlen = sizeof(int),
416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800417 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100418 },
419#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420#ifdef CONFIG_BLK_DEV_INITRD
421 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 .procname = "real-root-dev",
423 .data = &real_root_dev,
424 .maxlen = sizeof(int),
425 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800426 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 },
428#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700429 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700430 .procname = "print-fatal-signals",
431 .data = &print_fatal_signals,
432 .maxlen = sizeof(int),
433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800434 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700435 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700436#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 .procname = "reboot-cmd",
439 .data = reboot_command,
440 .maxlen = 256,
441 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800442 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 },
444 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 .procname = "stop-a",
446 .data = &stop_a_enabled,
447 .maxlen = sizeof (int),
448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800449 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 },
451 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 .procname = "scons-poweroff",
453 .data = &scons_pwroff,
454 .maxlen = sizeof (int),
455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800456 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 },
458#endif
David S. Miller08714202008-11-16 23:49:24 -0800459#ifdef CONFIG_SPARC64
460 {
David S. Miller08714202008-11-16 23:49:24 -0800461 .procname = "tsb-ratio",
462 .data = &sysctl_tsb_ratio,
463 .maxlen = sizeof (int),
464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800465 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800466 },
467#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468#ifdef __hppa__
469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 .procname = "soft-power",
471 .data = &pwrsw_enabled,
472 .maxlen = sizeof (int),
473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800474 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 },
476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 .procname = "unaligned-trap",
478 .data = &unaligned_enabled,
479 .maxlen = sizeof (int),
480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800481 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 },
483#endif
484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .procname = "ctrl-alt-del",
486 .data = &C_A_D,
487 .maxlen = sizeof(int),
488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800489 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400491#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200492 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200493 .procname = "ftrace_enabled",
494 .data = &ftrace_enabled,
495 .maxlen = sizeof(int),
496 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800497 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200498 },
499#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500500#ifdef CONFIG_STACK_TRACER
501 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500502 .procname = "stack_tracer_enabled",
503 .data = &stack_tracer_enabled,
504 .maxlen = sizeof(int),
505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500507 },
508#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400509#ifdef CONFIG_TRACING
510 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100511 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400512 .data = &ftrace_dump_on_oops,
513 .maxlen = sizeof(int),
514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800515 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400516 },
517#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200518#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 .procname = "modprobe",
521 .data = &modprobe_path,
522 .maxlen = KMOD_PATH_LEN,
523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800524 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 },
Kees Cook3d433212009-04-02 15:49:29 -0700526 {
Kees Cook3d433212009-04-02 15:49:29 -0700527 .procname = "modules_disabled",
528 .data = &modules_disabled,
529 .maxlen = sizeof(int),
530 .mode = 0644,
531 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700533 .extra1 = &one,
534 .extra2 = &one,
535 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700537#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100540 .data = &uevent_helper,
541 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800543 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 },
545#endif
546#ifdef CONFIG_CHR_DEV_SG
547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 .procname = "sg-big-buff",
549 .data = &sg_big_buff,
550 .maxlen = sizeof (int),
551 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800552 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 },
554#endif
555#ifdef CONFIG_BSD_PROCESS_ACCT
556 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 .procname = "acct",
558 .data = &acct_parm,
559 .maxlen = 3*sizeof(int),
560 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800561 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 },
563#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564#ifdef CONFIG_MAGIC_SYSRQ
565 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800567 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 .maxlen = sizeof (int),
569 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800570 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 },
572#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700573#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700576 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .maxlen = sizeof (int),
578 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700581#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 .procname = "threads-max",
584 .data = &max_threads,
585 .maxlen = sizeof(int),
586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800587 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 },
589 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .procname = "random",
591 .mode = 0555,
592 .child = random_table,
593 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 .procname = "overflowuid",
596 .data = &overflowuid,
597 .maxlen = sizeof(int),
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .extra1 = &minolduid,
601 .extra2 = &maxolduid,
602 },
603 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 .procname = "overflowgid",
605 .data = &overflowgid,
606 .maxlen = sizeof(int),
607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 .extra1 = &minolduid,
610 .extra2 = &maxolduid,
611 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800612#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613#ifdef CONFIG_MATHEMU
614 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 .procname = "ieee_emulation_warnings",
616 .data = &sysctl_ieee_emulation_warnings,
617 .maxlen = sizeof(int),
618 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800619 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
621#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200624 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .maxlen = sizeof(int),
626 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800627 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 },
629#endif
630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .procname = "pid_max",
632 .data = &pid_max,
633 .maxlen = sizeof (int),
634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800635 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 .extra1 = &pid_max_min,
637 .extra2 = &pid_max_max,
638 },
639 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .procname = "panic_on_oops",
641 .data = &panic_on_oops,
642 .maxlen = sizeof(int),
643 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800644 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800646#if defined CONFIG_PRINTK
647 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800648 .procname = "printk",
649 .data = &console_loglevel,
650 .maxlen = 4*sizeof(int),
651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800652 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800653 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700656 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .maxlen = sizeof(int),
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 },
661 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700663 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 .maxlen = sizeof(int),
665 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 },
Dave Youngaf913222009-09-22 16:43:33 -0700668 {
Dave Youngaf913222009-09-22 16:43:33 -0700669 .procname = "printk_delay",
670 .data = &printk_delay_msec,
671 .maxlen = sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700674 .extra1 = &zero,
675 .extra2 = &ten_thousand,
676 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800677#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .procname = "ngroups_max",
680 .data = &ngroups_max,
681 .maxlen = sizeof (int),
682 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 },
685#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "unknown_nmi_panic",
688 .data = &unknown_nmi_panic,
689 .maxlen = sizeof (int),
690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800691 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
Don Zickus407984f2006-09-26 10:52:27 +0200693 {
Don Zickus407984f2006-09-26 10:52:27 +0200694 .procname = "nmi_watchdog",
695 .data = &nmi_watchdog_enabled,
696 .maxlen = sizeof (int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
700#endif
701#if defined(CONFIG_X86)
702 {
Don Zickus8da5add2006-09-26 10:52:27 +0200703 .procname = "panic_on_unrecovered_nmi",
704 .data = &panic_on_unrecovered_nmi,
705 .maxlen = sizeof(int),
706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800707 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200708 },
709 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700710 .procname = "panic_on_io_nmi",
711 .data = &panic_on_io_nmi,
712 .maxlen = sizeof(int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700715 },
716 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 .procname = "bootloader_type",
718 .data = &bootloader_type,
719 .maxlen = sizeof (int),
720 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800721 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100723 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700724 .procname = "bootloader_version",
725 .data = &bootloader_version,
726 .maxlen = sizeof (int),
727 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800728 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700729 },
730 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100731 .procname = "kstack_depth_to_print",
732 .data = &kstack_depth_to_print,
733 .maxlen = sizeof(int),
734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100736 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100737 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100738 .procname = "io_delay_type",
739 .data = &io_delay_type,
740 .maxlen = sizeof(int),
741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100743 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800745#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 .procname = "randomize_va_space",
748 .data = &randomize_va_space,
749 .maxlen = sizeof(int),
750 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800751 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800753#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800754#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700755 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700756 .procname = "spin_retry",
757 .data = &spin_retry,
758 .maxlen = sizeof (int),
759 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800760 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700761 },
762#endif
Len Brown673d5b42007-07-28 03:33:16 -0400763#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800764 {
Pavel Machekc255d842006-02-20 18:27:58 -0800765 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700766 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800767 .maxlen = sizeof (unsigned long),
768 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800769 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800770 },
771#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800772#ifdef CONFIG_IA64
773 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800774 .procname = "ignore-unaligned-usertrap",
775 .data = &no_unaligned_warning,
776 .maxlen = sizeof (int),
777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800778 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800779 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800780 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800781 .procname = "unaligned-dump-stack",
782 .data = &unaligned_dump_stack,
783 .maxlen = sizeof (int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800786 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800787#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700788#ifdef CONFIG_DETECT_SOFTLOCKUP
789 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200790 .procname = "softlockup_panic",
791 .data = &softlockup_panic,
792 .maxlen = sizeof(int),
793 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800794 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200795 .extra1 = &zero,
796 .extra2 = &one,
797 },
798 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700799 .procname = "softlockup_thresh",
800 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200801 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700802 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800803 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200804 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700805 .extra2 = &sixty,
806 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800807#endif
808#ifdef CONFIG_DETECT_HUNG_TASK
809 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800810 .procname = "hung_task_panic",
811 .data = &sysctl_hung_task_panic,
812 .maxlen = sizeof(int),
813 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800814 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800815 .extra1 = &zero,
816 .extra2 = &one,
817 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100818 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100819 .procname = "hung_task_check_count",
820 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100821 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100822 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800823 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100824 },
825 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100826 .procname = "hung_task_timeout_secs",
827 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100828 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100829 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800830 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100831 },
832 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100833 .procname = "hung_task_warnings",
834 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100835 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100836 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800837 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100838 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700839#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200840#ifdef CONFIG_COMPAT
841 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200842 .procname = "compat-log",
843 .data = &compat_log,
844 .maxlen = sizeof (int),
845 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800846 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200847 },
848#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700849#ifdef CONFIG_RT_MUTEXES
850 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700851 .procname = "max_lock_depth",
852 .data = &max_lock_depth,
853 .maxlen = sizeof(int),
854 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800855 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700856 },
857#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700858 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700859 .procname = "poweroff_cmd",
860 .data = &poweroff_cmd,
861 .maxlen = POWEROFF_CMD_PATH_LEN,
862 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800863 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700864 },
David Howells0b77f5b2008-04-29 01:01:32 -0700865#ifdef CONFIG_KEYS
866 {
David Howells0b77f5b2008-04-29 01:01:32 -0700867 .procname = "keys",
868 .mode = 0555,
869 .child = key_sysctls,
870 },
871#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700872#ifdef CONFIG_RCU_TORTURE_TEST
873 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700874 .procname = "rcutorture_runnable",
875 .data = &rcutorture_runnable,
876 .maxlen = sizeof(int),
877 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800878 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700879 },
880#endif
David Howells12e22c52009-04-03 16:42:35 +0100881#ifdef CONFIG_SLOW_WORK
882 {
David Howells12e22c52009-04-03 16:42:35 +0100883 .procname = "slow-work",
884 .mode = 0555,
885 .child = slow_work_sysctls,
886 },
887#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200888#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200889 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200890 .procname = "perf_event_paranoid",
891 .data = &sysctl_perf_event_paranoid,
892 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200893 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800894 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200895 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200896 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200897 .procname = "perf_event_mlock_kb",
898 .data = &sysctl_perf_event_mlock,
899 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200900 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200902 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200903 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200904 .procname = "perf_event_max_sample_rate",
905 .data = &sysctl_perf_event_sample_rate,
906 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200907 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800908 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200909 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200910#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200911#ifdef CONFIG_KMEMCHECK
912 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200913 .procname = "kmemcheck",
914 .data = &kmemcheck_enabled,
915 .maxlen = sizeof(int),
916 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800917 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200918 },
919#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200920#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200921 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200922 .procname = "blk_iopoll",
923 .data = &blk_iopoll_enabled,
924 .maxlen = sizeof(int),
925 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800926 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200927 },
Jens Axboecb684b52009-09-15 21:53:11 +0200928#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700929/*
930 * NOTE: do not add new entries to this table unless you have read
931 * Documentation/sysctl/ctl_unnumbered.txt
932 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700933 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934};
935
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700936static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 .procname = "overcommit_memory",
939 .data = &sysctl_overcommit_memory,
940 .maxlen = sizeof(sysctl_overcommit_memory),
941 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800942 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 },
944 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700945 .procname = "panic_on_oom",
946 .data = &sysctl_panic_on_oom,
947 .maxlen = sizeof(sysctl_panic_on_oom),
948 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800949 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700950 },
951 {
David Rientjesfe071d72007-10-16 23:25:56 -0700952 .procname = "oom_kill_allocating_task",
953 .data = &sysctl_oom_kill_allocating_task,
954 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800956 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700957 },
958 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800959 .procname = "oom_dump_tasks",
960 .data = &sysctl_oom_dump_tasks,
961 .maxlen = sizeof(sysctl_oom_dump_tasks),
962 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800964 },
965 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 .procname = "overcommit_ratio",
967 .data = &sysctl_overcommit_ratio,
968 .maxlen = sizeof(sysctl_overcommit_ratio),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 },
972 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 .procname = "page-cluster",
974 .data = &page_cluster,
975 .maxlen = sizeof(int),
976 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 },
979 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 .procname = "dirty_background_ratio",
981 .data = &dirty_background_ratio,
982 .maxlen = sizeof(dirty_background_ratio),
983 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 .extra1 = &zero,
986 .extra2 = &one_hundred,
987 },
988 {
David Rientjes2da02992009-01-06 14:39:31 -0800989 .procname = "dirty_background_bytes",
990 .data = &dirty_background_bytes,
991 .maxlen = sizeof(dirty_background_bytes),
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800994 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -0800995 },
996 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 .procname = "dirty_ratio",
998 .data = &vm_dirty_ratio,
999 .maxlen = sizeof(vm_dirty_ratio),
1000 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001001 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 .extra1 = &zero,
1003 .extra2 = &one_hundred,
1004 },
1005 {
David Rientjes2da02992009-01-06 14:39:31 -08001006 .procname = "dirty_bytes",
1007 .data = &vm_dirty_bytes,
1008 .maxlen = sizeof(vm_dirty_bytes),
1009 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001010 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001011 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001012 },
1013 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001015 .data = &dirty_writeback_interval,
1016 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001018 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019 },
1020 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001022 .data = &dirty_expire_interval,
1023 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001025 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 },
1027 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 .procname = "nr_pdflush_threads",
1029 .data = &nr_pdflush_threads,
1030 .maxlen = sizeof nr_pdflush_threads,
1031 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001032 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033 },
1034 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035 .procname = "swappiness",
1036 .data = &vm_swappiness,
1037 .maxlen = sizeof(vm_swappiness),
1038 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001039 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 .extra1 = &zero,
1041 .extra2 = &one_hundred,
1042 },
1043#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001044 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001046 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 .maxlen = sizeof(unsigned long),
1048 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001049 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 .extra1 = (void *)&hugetlb_zero,
1051 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001052 },
1053#ifdef CONFIG_NUMA
1054 {
1055 .procname = "nr_hugepages_mempolicy",
1056 .data = NULL,
1057 .maxlen = sizeof(unsigned long),
1058 .mode = 0644,
1059 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1060 .extra1 = (void *)&hugetlb_zero,
1061 .extra2 = (void *)&hugetlb_infinity,
1062 },
1063#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 .procname = "hugetlb_shm_group",
1066 .data = &sysctl_hugetlb_shm_group,
1067 .maxlen = sizeof(gid_t),
1068 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001069 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 },
Mel Gorman396faf02007-07-17 04:03:13 -07001071 {
Mel Gorman396faf02007-07-17 04:03:13 -07001072 .procname = "hugepages_treat_as_movable",
1073 .data = &hugepages_treat_as_movable,
1074 .maxlen = sizeof(int),
1075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001077 },
Adam Litke54f9f802007-10-16 01:26:20 -07001078 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001079 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001080 .data = NULL,
1081 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001082 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001083 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001084 .extra1 = (void *)&hugetlb_zero,
1085 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001086 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087#endif
1088 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 .procname = "lowmem_reserve_ratio",
1090 .data = &sysctl_lowmem_reserve_ratio,
1091 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1092 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001093 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 },
1095 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001096 .procname = "drop_caches",
1097 .data = &sysctl_drop_caches,
1098 .maxlen = sizeof(int),
1099 .mode = 0644,
1100 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001101 },
1102 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 .procname = "min_free_kbytes",
1104 .data = &min_free_kbytes,
1105 .maxlen = sizeof(min_free_kbytes),
1106 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001107 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 .extra1 = &zero,
1109 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001110 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001111 .procname = "percpu_pagelist_fraction",
1112 .data = &percpu_pagelist_fraction,
1113 .maxlen = sizeof(percpu_pagelist_fraction),
1114 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001115 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001116 .extra1 = &min_percpu_pagelist_fract,
1117 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118#ifdef CONFIG_MMU
1119 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 .procname = "max_map_count",
1121 .data = &sysctl_max_map_count,
1122 .maxlen = sizeof(sysctl_max_map_count),
1123 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001124 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001125 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001127#else
1128 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001129 .procname = "nr_trim_pages",
1130 .data = &sysctl_nr_trim_pages,
1131 .maxlen = sizeof(sysctl_nr_trim_pages),
1132 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001133 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001134 .extra1 = &zero,
1135 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136#endif
1137 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 .procname = "laptop_mode",
1139 .data = &laptop_mode,
1140 .maxlen = sizeof(laptop_mode),
1141 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001142 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 },
1144 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 .procname = "block_dump",
1146 .data = &block_dump,
1147 .maxlen = sizeof(block_dump),
1148 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001149 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 .extra1 = &zero,
1151 },
1152 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 .procname = "vfs_cache_pressure",
1154 .data = &sysctl_vfs_cache_pressure,
1155 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001157 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 .extra1 = &zero,
1159 },
1160#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1161 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 .procname = "legacy_va_layout",
1163 .data = &sysctl_legacy_va_layout,
1164 .maxlen = sizeof(sysctl_legacy_va_layout),
1165 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001166 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 .extra1 = &zero,
1168 },
1169#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001170#ifdef CONFIG_NUMA
1171 {
Christoph Lameter17436602006-01-18 17:42:32 -08001172 .procname = "zone_reclaim_mode",
1173 .data = &zone_reclaim_mode,
1174 .maxlen = sizeof(zone_reclaim_mode),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001177 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001178 },
Christoph Lameter96146342006-07-03 00:24:13 -07001179 {
Christoph Lameter96146342006-07-03 00:24:13 -07001180 .procname = "min_unmapped_ratio",
1181 .data = &sysctl_min_unmapped_ratio,
1182 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1183 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001184 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001185 .extra1 = &zero,
1186 .extra2 = &one_hundred,
1187 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001188 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001189 .procname = "min_slab_ratio",
1190 .data = &sysctl_min_slab_ratio,
1191 .maxlen = sizeof(sysctl_min_slab_ratio),
1192 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001193 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001194 .extra1 = &zero,
1195 .extra2 = &one_hundred,
1196 },
Christoph Lameter17436602006-01-18 17:42:32 -08001197#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001198#ifdef CONFIG_SMP
1199 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001200 .procname = "stat_interval",
1201 .data = &sysctl_stat_interval,
1202 .maxlen = sizeof(sysctl_stat_interval),
1203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001204 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001205 },
1206#endif
David Howells6e141542009-12-15 19:27:45 +00001207#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001208 {
Eric Parised032182007-06-28 15:55:21 -04001209 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001210 .data = &dac_mmap_min_addr,
1211 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001212 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001213 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001214 },
David Howells6e141542009-12-15 19:27:45 +00001215#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001216#ifdef CONFIG_NUMA
1217 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001218 .procname = "numa_zonelist_order",
1219 .data = &numa_zonelist_order,
1220 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1221 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001222 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001223 },
1224#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001225#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001226 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001227 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001228 .procname = "vdso_enabled",
1229 .data = &vdso_enabled,
1230 .maxlen = sizeof(vdso_enabled),
1231 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001232 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001233 .extra1 = &zero,
1234 },
1235#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001236#ifdef CONFIG_HIGHMEM
1237 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001238 .procname = "highmem_is_dirtyable",
1239 .data = &vm_highmem_is_dirtyable,
1240 .maxlen = sizeof(vm_highmem_is_dirtyable),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001243 .extra1 = &zero,
1244 .extra2 = &one,
1245 },
1246#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001247 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001248 .procname = "scan_unevictable_pages",
1249 .data = &scan_unevictable_pages,
1250 .maxlen = sizeof(scan_unevictable_pages),
1251 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001252 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001253 },
Andi Kleen6a460792009-09-16 11:50:15 +02001254#ifdef CONFIG_MEMORY_FAILURE
1255 {
Andi Kleen6a460792009-09-16 11:50:15 +02001256 .procname = "memory_failure_early_kill",
1257 .data = &sysctl_memory_failure_early_kill,
1258 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1259 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001260 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001261 .extra1 = &zero,
1262 .extra2 = &one,
1263 },
1264 {
Andi Kleen6a460792009-09-16 11:50:15 +02001265 .procname = "memory_failure_recovery",
1266 .data = &sysctl_memory_failure_recovery,
1267 .maxlen = sizeof(sysctl_memory_failure_recovery),
1268 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001269 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001270 .extra1 = &zero,
1271 .extra2 = &one,
1272 },
1273#endif
1274
Andrew Morton2be7fe02007-07-15 23:41:21 -07001275/*
1276 * NOTE: do not add new entries to this table unless you have read
1277 * Documentation/sysctl/ctl_unnumbered.txt
1278 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001279 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280};
1281
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001282#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001283static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001284 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001285};
1286#endif
1287
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001288static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 .procname = "inode-nr",
1291 .data = &inodes_stat,
1292 .maxlen = 2*sizeof(int),
1293 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001294 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 },
1296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .procname = "inode-state",
1298 .data = &inodes_stat,
1299 .maxlen = 7*sizeof(int),
1300 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 },
1303 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 .procname = "file-nr",
1305 .data = &files_stat,
1306 .maxlen = 3*sizeof(int),
1307 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001308 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 },
1310 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 .procname = "file-max",
1312 .data = &files_stat.max_files,
1313 .maxlen = sizeof(int),
1314 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 },
1317 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001318 .procname = "nr_open",
1319 .data = &sysctl_nr_open,
1320 .maxlen = sizeof(int),
1321 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001322 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001323 .extra1 = &sysctl_nr_open_min,
1324 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001325 },
1326 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 .procname = "dentry-state",
1328 .data = &dentry_stat,
1329 .maxlen = 6*sizeof(int),
1330 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001331 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 },
1333 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 .procname = "overflowuid",
1335 .data = &fs_overflowuid,
1336 .maxlen = sizeof(int),
1337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001338 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 .extra1 = &minolduid,
1340 .extra2 = &maxolduid,
1341 },
1342 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 .procname = "overflowgid",
1344 .data = &fs_overflowgid,
1345 .maxlen = sizeof(int),
1346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001347 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 .extra1 = &minolduid,
1349 .extra2 = &maxolduid,
1350 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001351#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "leases-enable",
1354 .data = &leases_enable,
1355 .maxlen = sizeof(int),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001359#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360#ifdef CONFIG_DNOTIFY
1361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 .procname = "dir-notify-enable",
1363 .data = &dir_notify_enable,
1364 .maxlen = sizeof(int),
1365 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001366 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 },
1368#endif
1369#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001370#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 .procname = "lease-break-time",
1373 .data = &lease_break_time,
1374 .maxlen = sizeof(int),
1375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001376 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001378#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001379#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 .procname = "aio-nr",
1382 .data = &aio_nr,
1383 .maxlen = sizeof(aio_nr),
1384 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 },
1387 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 .procname = "aio-max-nr",
1389 .data = &aio_max_nr,
1390 .maxlen = sizeof(aio_max_nr),
1391 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001392 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001394#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001395#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001396 {
Robert Love0399cb02005-07-13 12:38:18 -04001397 .procname = "inotify",
1398 .mode = 0555,
1399 .child = inotify_table,
1400 },
1401#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001402#ifdef CONFIG_EPOLL
1403 {
1404 .procname = "epoll",
1405 .mode = 0555,
1406 .child = epoll_table,
1407 },
1408#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001410 {
Alan Coxd6e71142005-06-23 00:09:43 -07001411 .procname = "suid_dumpable",
1412 .data = &suid_dumpable,
1413 .maxlen = sizeof(int),
1414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001415 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001416 .extra1 = &zero,
1417 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001418 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001419#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1420 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001421 .procname = "binfmt_misc",
1422 .mode = 0555,
1423 .child = binfmt_misc_table,
1424 },
1425#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001426/*
1427 * NOTE: do not add new entries to this table unless you have read
1428 * Documentation/sysctl/ctl_unnumbered.txt
1429 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001430 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431};
1432
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001433static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001434#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
1435 defined(CONFIG_S390)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001436 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001437 .procname = "exception-trace",
1438 .data = &show_unhandled_signals,
1439 .maxlen = sizeof(int),
1440 .mode = 0644,
1441 .proc_handler = proc_dointvec
1442 },
1443#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001444#if defined(CONFIG_OPTPROBES)
1445 {
1446 .procname = "kprobes-optimization",
1447 .data = &sysctl_kprobes_optimization,
1448 .maxlen = sizeof(int),
1449 .mode = 0644,
1450 .proc_handler = proc_kprobes_optimization_handler,
1451 .extra1 = &zero,
1452 .extra2 = &one,
1453 },
1454#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001455 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456};
1457
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001458static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001459 { }
Robert Love0eeca282005-07-12 17:06:03 -04001460};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461
Al Viro330d57f2005-11-04 10:18:40 +00001462static DEFINE_SPINLOCK(sysctl_lock);
1463
1464/* called under sysctl_lock */
1465static int use_table(struct ctl_table_header *p)
1466{
1467 if (unlikely(p->unregistering))
1468 return 0;
1469 p->used++;
1470 return 1;
1471}
1472
1473/* called under sysctl_lock */
1474static void unuse_table(struct ctl_table_header *p)
1475{
1476 if (!--p->used)
1477 if (unlikely(p->unregistering))
1478 complete(p->unregistering);
1479}
1480
1481/* called under sysctl_lock, will reacquire if has to wait */
1482static void start_unregistering(struct ctl_table_header *p)
1483{
1484 /*
1485 * if p->used is 0, nobody will ever touch that entry again;
1486 * we'll eliminate all paths to it before dropping sysctl_lock
1487 */
1488 if (unlikely(p->used)) {
1489 struct completion wait;
1490 init_completion(&wait);
1491 p->unregistering = &wait;
1492 spin_unlock(&sysctl_lock);
1493 wait_for_completion(&wait);
1494 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001495 } else {
1496 /* anything non-NULL; we'll never dereference it */
1497 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001498 }
1499 /*
1500 * do not remove from the list until nobody holds it; walking the
1501 * list in do_sysctl() relies on that.
1502 */
1503 list_del_init(&p->ctl_entry);
1504}
1505
Al Virof7e6ced2008-07-15 01:44:23 -04001506void sysctl_head_get(struct ctl_table_header *head)
1507{
1508 spin_lock(&sysctl_lock);
1509 head->count++;
1510 spin_unlock(&sysctl_lock);
1511}
1512
1513void sysctl_head_put(struct ctl_table_header *head)
1514{
1515 spin_lock(&sysctl_lock);
1516 if (!--head->count)
1517 kfree(head);
1518 spin_unlock(&sysctl_lock);
1519}
1520
1521struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1522{
1523 if (!head)
1524 BUG();
1525 spin_lock(&sysctl_lock);
1526 if (!use_table(head))
1527 head = ERR_PTR(-ENOENT);
1528 spin_unlock(&sysctl_lock);
1529 return head;
1530}
1531
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001532void sysctl_head_finish(struct ctl_table_header *head)
1533{
1534 if (!head)
1535 return;
1536 spin_lock(&sysctl_lock);
1537 unuse_table(head);
1538 spin_unlock(&sysctl_lock);
1539}
1540
Al Viro73455092008-07-14 21:22:20 -04001541static struct ctl_table_set *
1542lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1543{
1544 struct ctl_table_set *set = &root->default_set;
1545 if (root->lookup)
1546 set = root->lookup(root, namespaces);
1547 return set;
1548}
1549
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001550static struct list_head *
1551lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001552{
Al Viro73455092008-07-14 21:22:20 -04001553 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1554 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001555}
1556
1557struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1558 struct ctl_table_header *prev)
1559{
1560 struct ctl_table_root *root;
1561 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001562 struct ctl_table_header *head;
1563 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001564
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001565 spin_lock(&sysctl_lock);
1566 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001567 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001568 tmp = &prev->ctl_entry;
1569 unuse_table(prev);
1570 goto next;
1571 }
1572 tmp = &root_table_header.ctl_entry;
1573 for (;;) {
1574 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1575
1576 if (!use_table(head))
1577 goto next;
1578 spin_unlock(&sysctl_lock);
1579 return head;
1580 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001581 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001582 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001583 header_list = lookup_header_list(root, namespaces);
1584 if (tmp != header_list)
1585 continue;
1586
1587 do {
1588 root = list_entry(root->root_list.next,
1589 struct ctl_table_root, root_list);
1590 if (root == &sysctl_table_root)
1591 goto out;
1592 header_list = lookup_header_list(root, namespaces);
1593 } while (list_empty(header_list));
1594 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001595 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001596out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001597 spin_unlock(&sysctl_lock);
1598 return NULL;
1599}
1600
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001601struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1602{
1603 return __sysctl_head_next(current->nsproxy, prev);
1604}
1605
1606void register_sysctl_root(struct ctl_table_root *root)
1607{
1608 spin_lock(&sysctl_lock);
1609 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1610 spin_unlock(&sysctl_lock);
1611}
1612
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613/*
Eric W. Biederman1ff007eb2007-02-14 00:34:11 -08001614 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615 * some sysctl variables are readonly even to root.
1616 */
1617
1618static int test_perm(int mode, int op)
1619{
David Howells76aac0e2008-11-14 10:39:12 +11001620 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621 mode >>= 6;
1622 else if (in_egroup_p(0))
1623 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001624 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625 return 0;
1626 return -EACCES;
1627}
1628
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001629int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630{
1631 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001632 int mode;
1633
Al Viroe6305c42008-07-15 21:03:57 -04001634 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635 if (error)
1636 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001637
1638 if (root->permissions)
1639 mode = root->permissions(root, current->nsproxy, table);
1640 else
1641 mode = table->mode;
1642
1643 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644}
1645
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001646static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1647{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001648 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001649 table->parent = parent;
1650 if (table->child)
1651 sysctl_set_parent(table, table->child);
1652 }
1653}
1654
1655static __init int sysctl_init(void)
1656{
1657 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001658#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1659 {
1660 int err;
1661 err = sysctl_check_table(current->nsproxy, root_table);
1662 }
1663#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001664 return 0;
1665}
1666
1667core_initcall(sysctl_init);
1668
Al Virobfbcf032008-07-27 06:31:22 +01001669static struct ctl_table *is_branch_in(struct ctl_table *branch,
1670 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001671{
1672 struct ctl_table *p;
1673 const char *s = branch->procname;
1674
1675 /* branch should have named subdirectory as its first element */
1676 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001677 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001678
1679 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001680 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001681 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001682
1683 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001684 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001685 if (!p->child)
1686 continue;
1687 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001688 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001689 }
Al Virobfbcf032008-07-27 06:31:22 +01001690 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001691}
1692
1693/* see if attaching q to p would be an improvement */
1694static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1695{
1696 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001697 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001698 int is_better = 0;
1699 int not_in_parent = !p->attached_by;
1700
Al Virobfbcf032008-07-27 06:31:22 +01001701 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001702 if (by == q->attached_by)
1703 is_better = 1;
1704 if (to == p->attached_by)
1705 not_in_parent = 1;
1706 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001707 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001708 }
1709
1710 if (is_better && not_in_parent) {
1711 q->attached_by = by;
1712 q->attached_to = to;
1713 q->parent = p;
1714 }
1715}
1716
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001718 * __register_sysctl_paths - register a sysctl hierarchy
1719 * @root: List of sysctl headers to register on
1720 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001721 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001723 *
1724 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001725 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001727 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1730 * enter a sysctl file
1731 *
1732 * data - a pointer to data for use by proc_handler
1733 *
1734 * maxlen - the maximum size in bytes of the data
1735 *
1736 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1737 *
1738 * child - a pointer to the child sysctl table if this entry is a directory, or
1739 * %NULL.
1740 *
1741 * proc_handler - the text handler routine (described below)
1742 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 * de - for internal use by the sysctl routines
1744 *
1745 * extra1, extra2 - extra pointers usable by the proc handler routines
1746 *
1747 * Leaf nodes in the sysctl tree will be represented by a single file
1748 * under /proc; non-leaf nodes will be represented by directories.
1749 *
1750 * sysctl(2) can automatically manage read and write requests through
1751 * the sysctl table. The data and maxlen fields of the ctl_table
1752 * struct enable minimal validation of the values being written to be
1753 * performed, and the mode field allows minimal authentication.
1754 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 * There must be a proc_handler routine for any terminal nodes
1756 * mirrored under /proc/sys (non-terminals are handled by a built-in
1757 * directory handler). Several default handlers are available to
1758 * cover common cases -
1759 *
1760 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1761 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1762 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1763 *
1764 * It is the handler's job to read the input buffer from user memory
1765 * and process it. The handler should return 0 on success.
1766 *
1767 * This routine returns %NULL on a failure to register, and a pointer
1768 * to the table header on success.
1769 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001770struct ctl_table_header *__register_sysctl_paths(
1771 struct ctl_table_root *root,
1772 struct nsproxy *namespaces,
1773 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001775 struct ctl_table_header *header;
1776 struct ctl_table *new, **prevp;
1777 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001778 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001779
1780 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001781 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001782 ;
1783
1784 /*
1785 * For each path component, allocate a 2-element ctl_table array.
1786 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001787 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001788 *
1789 * We allocate everything in one go so that we don't have to
1790 * worry about freeing additional memory in unregister_sysctl_table.
1791 */
1792 header = kzalloc(sizeof(struct ctl_table_header) +
1793 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1794 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001796
1797 new = (struct ctl_table *) (header + 1);
1798
1799 /* Now connect the dots */
1800 prevp = &header->ctl_table;
1801 for (n = 0; n < npath; ++n, ++path) {
1802 /* Copy the procname */
1803 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001804 new->mode = 0555;
1805
1806 *prevp = new;
1807 prevp = &new->child;
1808
1809 new += 2;
1810 }
1811 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001812 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001813
1814 INIT_LIST_HEAD(&header->ctl_entry);
1815 header->used = 0;
1816 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001817 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001818 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001819 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001820#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001821 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001822 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001823 return NULL;
1824 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001825#endif
Al Viro330d57f2005-11-04 10:18:40 +00001826 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001827 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001828 header->attached_by = header->ctl_table;
1829 header->attached_to = root_table;
1830 header->parent = &root_table_header;
1831 for (set = header->set; set; set = set->parent) {
1832 struct ctl_table_header *p;
1833 list_for_each_entry(p, &set->list, ctl_entry) {
1834 if (p->unregistering)
1835 continue;
1836 try_attach(p, header);
1837 }
1838 }
1839 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001840 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001841 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001842
1843 return header;
1844}
1845
1846/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001847 * register_sysctl_table_path - register a sysctl table hierarchy
1848 * @path: The path to the directory the sysctl table is in.
1849 * @table: the top-level table structure
1850 *
1851 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1852 * array. A completely 0 filled entry terminates the table.
1853 *
1854 * See __register_sysctl_paths for more details.
1855 */
1856struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1857 struct ctl_table *table)
1858{
1859 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1860 path, table);
1861}
1862
1863/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001864 * register_sysctl_table - register a sysctl table hierarchy
1865 * @table: the top-level table structure
1866 *
1867 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1868 * array. A completely 0 filled entry terminates the table.
1869 *
1870 * See register_sysctl_paths for more details.
1871 */
1872struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1873{
1874 static const struct ctl_path null_path[] = { {} };
1875
1876 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877}
1878
1879/**
1880 * unregister_sysctl_table - unregister a sysctl table hierarchy
1881 * @header: the header returned from register_sysctl_table
1882 *
1883 * Unregisters the sysctl table and all children. proc entries may not
1884 * actually be removed until they are no longer used by anyone.
1885 */
1886void unregister_sysctl_table(struct ctl_table_header * header)
1887{
Al Viro330d57f2005-11-04 10:18:40 +00001888 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001889
1890 if (header == NULL)
1891 return;
1892
Al Viro330d57f2005-11-04 10:18:40 +00001893 spin_lock(&sysctl_lock);
1894 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001895 if (!--header->parent->count) {
1896 WARN_ON(1);
1897 kfree(header->parent);
1898 }
Al Virof7e6ced2008-07-15 01:44:23 -04001899 if (!--header->count)
1900 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001901 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902}
1903
Al Viro90434762008-07-15 08:54:06 -04001904int sysctl_is_seen(struct ctl_table_header *p)
1905{
1906 struct ctl_table_set *set = p->set;
1907 int res;
1908 spin_lock(&sysctl_lock);
1909 if (p->unregistering)
1910 res = 0;
1911 else if (!set->is_seen)
1912 res = 1;
1913 else
1914 res = set->is_seen(set);
1915 spin_unlock(&sysctl_lock);
1916 return res;
1917}
1918
Al Viro73455092008-07-14 21:22:20 -04001919void setup_sysctl_set(struct ctl_table_set *p,
1920 struct ctl_table_set *parent,
1921 int (*is_seen)(struct ctl_table_set *))
1922{
1923 INIT_LIST_HEAD(&p->list);
1924 p->parent = parent ? parent : &sysctl_table_root.default_set;
1925 p->is_seen = is_seen;
1926}
1927
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001928#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001929struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001930{
1931 return NULL;
1932}
1933
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001934struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1935 struct ctl_table *table)
1936{
1937 return NULL;
1938}
1939
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001940void unregister_sysctl_table(struct ctl_table_header * table)
1941{
1942}
1943
Al Viro73455092008-07-14 21:22:20 -04001944void setup_sysctl_set(struct ctl_table_set *p,
1945 struct ctl_table_set *parent,
1946 int (*is_seen)(struct ctl_table_set *))
1947{
1948}
1949
Al Virof7e6ced2008-07-15 01:44:23 -04001950void sysctl_head_put(struct ctl_table_header *head)
1951{
1952}
1953
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001954#endif /* CONFIG_SYSCTL */
1955
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956/*
1957 * /proc/sys support
1958 */
1959
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001960#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001962static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001963 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001964 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001965{
1966 size_t len;
1967 char __user *p;
1968 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001969
1970 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001971 *lenp = 0;
1972 return 0;
1973 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001974
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001975 if (write) {
1976 len = 0;
1977 p = buffer;
1978 while (len < *lenp) {
1979 if (get_user(c, p++))
1980 return -EFAULT;
1981 if (c == 0 || c == '\n')
1982 break;
1983 len++;
1984 }
1985 if (len >= maxlen)
1986 len = maxlen-1;
1987 if(copy_from_user(data, buffer, len))
1988 return -EFAULT;
1989 ((char *) data)[len] = 0;
1990 *ppos += *lenp;
1991 } else {
1992 len = strlen(data);
1993 if (len > maxlen)
1994 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001995
1996 if (*ppos > len) {
1997 *lenp = 0;
1998 return 0;
1999 }
2000
2001 data += *ppos;
2002 len -= *ppos;
2003
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002004 if (len > *lenp)
2005 len = *lenp;
2006 if (len)
2007 if(copy_to_user(buffer, data, len))
2008 return -EFAULT;
2009 if (len < *lenp) {
2010 if(put_user('\n', ((char __user *) buffer) + len))
2011 return -EFAULT;
2012 len++;
2013 }
2014 *lenp = len;
2015 *ppos += len;
2016 }
2017 return 0;
2018}
2019
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020/**
2021 * proc_dostring - read a string sysctl
2022 * @table: the sysctl table
2023 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024 * @buffer: the user buffer
2025 * @lenp: the size of the user buffer
2026 * @ppos: file position
2027 *
2028 * Reads/writes a string from/to the user buffer. If the kernel
2029 * buffer provided is not large enough to hold the string, the
2030 * string is truncated. The copied string is %NULL-terminated.
2031 * If the string is being read by the user process, it is copied
2032 * and a newline '\n' is added. It is truncated if the buffer is
2033 * not large enough.
2034 *
2035 * Returns 0 on success.
2036 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002037int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038 void __user *buffer, size_t *lenp, loff_t *ppos)
2039{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002040 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002041 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042}
2043
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044
2045static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2046 int *valp,
2047 int write, void *data)
2048{
2049 if (write) {
2050 *valp = *negp ? -*lvalp : *lvalp;
2051 } else {
2052 int val = *valp;
2053 if (val < 0) {
2054 *negp = -1;
2055 *lvalp = (unsigned long)-val;
2056 } else {
2057 *negp = 0;
2058 *lvalp = (unsigned long)val;
2059 }
2060 }
2061 return 0;
2062}
2063
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002064static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002065 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002066 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2068 int write, void *data),
2069 void *data)
2070{
2071#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002072 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 unsigned long lval;
2074 size_t left, len;
2075
2076 char buf[TMPBUFLEN], *p;
2077 char __user *s = buffer;
2078
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002079 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080 (*ppos && !write)) {
2081 *lenp = 0;
2082 return 0;
2083 }
2084
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002085 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086 vleft = table->maxlen / sizeof(*i);
2087 left = *lenp;
2088
2089 if (!conv)
2090 conv = do_proc_dointvec_conv;
2091
2092 for (; left && vleft--; i++, first=0) {
2093 if (write) {
2094 while (left) {
2095 char c;
2096 if (get_user(c, s))
2097 return -EFAULT;
2098 if (!isspace(c))
2099 break;
2100 left--;
2101 s++;
2102 }
2103 if (!left)
2104 break;
2105 neg = 0;
2106 len = left;
2107 if (len > sizeof(buf) - 1)
2108 len = sizeof(buf) - 1;
2109 if (copy_from_user(buf, s, len))
2110 return -EFAULT;
2111 buf[len] = 0;
2112 p = buf;
2113 if (*p == '-' && left > 1) {
2114 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002115 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 }
2117 if (*p < '0' || *p > '9')
2118 break;
2119
2120 lval = simple_strtoul(p, &p, 0);
2121
2122 len = p-buf;
2123 if ((len < left) && *p && !isspace(*p))
2124 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 s += len;
2126 left -= len;
2127
2128 if (conv(&neg, &lval, i, 1, data))
2129 break;
2130 } else {
2131 p = buf;
2132 if (!first)
2133 *p++ = '\t';
2134
2135 if (conv(&neg, &lval, i, 0, data))
2136 break;
2137
2138 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2139 len = strlen(buf);
2140 if (len > left)
2141 len = left;
2142 if(copy_to_user(s, buf, len))
2143 return -EFAULT;
2144 left -= len;
2145 s += len;
2146 }
2147 }
2148
2149 if (!write && !first && left) {
2150 if(put_user('\n', s))
2151 return -EFAULT;
2152 left--, s++;
2153 }
2154 if (write) {
2155 while (left) {
2156 char c;
2157 if (get_user(c, s++))
2158 return -EFAULT;
2159 if (!isspace(c))
2160 break;
2161 left--;
2162 }
2163 }
2164 if (write && first)
2165 return -EINVAL;
2166 *lenp -= left;
2167 *ppos += *lenp;
2168 return 0;
2169#undef TMPBUFLEN
2170}
2171
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002172static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002173 void __user *buffer, size_t *lenp, loff_t *ppos,
2174 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2175 int write, void *data),
2176 void *data)
2177{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002178 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002179 buffer, lenp, ppos, conv, data);
2180}
2181
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182/**
2183 * proc_dointvec - read a vector of integers
2184 * @table: the sysctl table
2185 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 * @buffer: the user buffer
2187 * @lenp: the size of the user buffer
2188 * @ppos: file position
2189 *
2190 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2191 * values from/to the user buffer, treated as an ASCII string.
2192 *
2193 * Returns 0 on success.
2194 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002195int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 void __user *buffer, size_t *lenp, loff_t *ppos)
2197{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002198 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 NULL,NULL);
2200}
2201
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002202/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002203 * Taint values can only be increased
2204 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002205 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002206static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002207 void __user *buffer, size_t *lenp, loff_t *ppos)
2208{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002209 struct ctl_table t;
2210 unsigned long tmptaint = get_taint();
2211 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002212
Bastian Blank91fcd412007-04-23 14:41:14 -07002213 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002214 return -EPERM;
2215
Andi Kleen25ddbb12008-10-15 22:01:41 -07002216 t = *table;
2217 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002218 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002219 if (err < 0)
2220 return err;
2221
2222 if (write) {
2223 /*
2224 * Poor man's atomic or. Not worth adding a primitive
2225 * to everyone's atomic.h for this
2226 */
2227 int i;
2228 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2229 if ((tmptaint >> i) & 1)
2230 add_taint(i);
2231 }
2232 }
2233
2234 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002235}
2236
Linus Torvalds1da177e2005-04-16 15:20:36 -07002237struct do_proc_dointvec_minmax_conv_param {
2238 int *min;
2239 int *max;
2240};
2241
2242static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2243 int *valp,
2244 int write, void *data)
2245{
2246 struct do_proc_dointvec_minmax_conv_param *param = data;
2247 if (write) {
2248 int val = *negp ? -*lvalp : *lvalp;
2249 if ((param->min && *param->min > val) ||
2250 (param->max && *param->max < val))
2251 return -EINVAL;
2252 *valp = val;
2253 } else {
2254 int val = *valp;
2255 if (val < 0) {
2256 *negp = -1;
2257 *lvalp = (unsigned long)-val;
2258 } else {
2259 *negp = 0;
2260 *lvalp = (unsigned long)val;
2261 }
2262 }
2263 return 0;
2264}
2265
2266/**
2267 * proc_dointvec_minmax - read a vector of integers with min/max values
2268 * @table: the sysctl table
2269 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 * @buffer: the user buffer
2271 * @lenp: the size of the user buffer
2272 * @ppos: file position
2273 *
2274 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2275 * values from/to the user buffer, treated as an ASCII string.
2276 *
2277 * This routine will ensure the values are within the range specified by
2278 * table->extra1 (min) and table->extra2 (max).
2279 *
2280 * Returns 0 on success.
2281 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002282int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 void __user *buffer, size_t *lenp, loff_t *ppos)
2284{
2285 struct do_proc_dointvec_minmax_conv_param param = {
2286 .min = (int *) table->extra1,
2287 .max = (int *) table->extra2,
2288 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002289 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 do_proc_dointvec_minmax_conv, &param);
2291}
2292
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002293static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 void __user *buffer,
2295 size_t *lenp, loff_t *ppos,
2296 unsigned long convmul,
2297 unsigned long convdiv)
2298{
2299#define TMPBUFLEN 21
2300 unsigned long *i, *min, *max, val;
2301 int vleft, first=1, neg;
2302 size_t len, left;
2303 char buf[TMPBUFLEN], *p;
2304 char __user *s = buffer;
2305
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002306 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002307 (*ppos && !write)) {
2308 *lenp = 0;
2309 return 0;
2310 }
2311
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002312 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 min = (unsigned long *) table->extra1;
2314 max = (unsigned long *) table->extra2;
2315 vleft = table->maxlen / sizeof(unsigned long);
2316 left = *lenp;
2317
2318 for (; left && vleft--; i++, min++, max++, first=0) {
2319 if (write) {
2320 while (left) {
2321 char c;
2322 if (get_user(c, s))
2323 return -EFAULT;
2324 if (!isspace(c))
2325 break;
2326 left--;
2327 s++;
2328 }
2329 if (!left)
2330 break;
2331 neg = 0;
2332 len = left;
2333 if (len > TMPBUFLEN-1)
2334 len = TMPBUFLEN-1;
2335 if (copy_from_user(buf, s, len))
2336 return -EFAULT;
2337 buf[len] = 0;
2338 p = buf;
2339 if (*p == '-' && left > 1) {
2340 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002341 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 }
2343 if (*p < '0' || *p > '9')
2344 break;
2345 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2346 len = p-buf;
2347 if ((len < left) && *p && !isspace(*p))
2348 break;
2349 if (neg)
2350 val = -val;
2351 s += len;
2352 left -= len;
2353
2354 if(neg)
2355 continue;
2356 if ((min && val < *min) || (max && val > *max))
2357 continue;
2358 *i = val;
2359 } else {
2360 p = buf;
2361 if (!first)
2362 *p++ = '\t';
2363 sprintf(p, "%lu", convdiv * (*i) / convmul);
2364 len = strlen(buf);
2365 if (len > left)
2366 len = left;
2367 if(copy_to_user(s, buf, len))
2368 return -EFAULT;
2369 left -= len;
2370 s += len;
2371 }
2372 }
2373
2374 if (!write && !first && left) {
2375 if(put_user('\n', s))
2376 return -EFAULT;
2377 left--, s++;
2378 }
2379 if (write) {
2380 while (left) {
2381 char c;
2382 if (get_user(c, s++))
2383 return -EFAULT;
2384 if (!isspace(c))
2385 break;
2386 left--;
2387 }
2388 }
2389 if (write && first)
2390 return -EINVAL;
2391 *lenp -= left;
2392 *ppos += *lenp;
2393 return 0;
2394#undef TMPBUFLEN
2395}
2396
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002397static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002398 void __user *buffer,
2399 size_t *lenp, loff_t *ppos,
2400 unsigned long convmul,
2401 unsigned long convdiv)
2402{
2403 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002404 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002405}
2406
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407/**
2408 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2409 * @table: the sysctl table
2410 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 * @buffer: the user buffer
2412 * @lenp: the size of the user buffer
2413 * @ppos: file position
2414 *
2415 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2416 * values from/to the user buffer, treated as an ASCII string.
2417 *
2418 * This routine will ensure the values are within the range specified by
2419 * table->extra1 (min) and table->extra2 (max).
2420 *
2421 * Returns 0 on success.
2422 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002423int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 void __user *buffer, size_t *lenp, loff_t *ppos)
2425{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002426 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427}
2428
2429/**
2430 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2431 * @table: the sysctl table
2432 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 * @buffer: the user buffer
2434 * @lenp: the size of the user buffer
2435 * @ppos: file position
2436 *
2437 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2438 * values from/to the user buffer, treated as an ASCII string. The values
2439 * are treated as milliseconds, and converted to jiffies when they are stored.
2440 *
2441 * This routine will ensure the values are within the range specified by
2442 * table->extra1 (min) and table->extra2 (max).
2443 *
2444 * Returns 0 on success.
2445 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002446int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 void __user *buffer,
2448 size_t *lenp, loff_t *ppos)
2449{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002450 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 lenp, ppos, HZ, 1000l);
2452}
2453
2454
2455static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2456 int *valp,
2457 int write, void *data)
2458{
2459 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002460 if (*lvalp > LONG_MAX / HZ)
2461 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2463 } else {
2464 int val = *valp;
2465 unsigned long lval;
2466 if (val < 0) {
2467 *negp = -1;
2468 lval = (unsigned long)-val;
2469 } else {
2470 *negp = 0;
2471 lval = (unsigned long)val;
2472 }
2473 *lvalp = lval / HZ;
2474 }
2475 return 0;
2476}
2477
2478static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2479 int *valp,
2480 int write, void *data)
2481{
2482 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002483 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2484 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2486 } else {
2487 int val = *valp;
2488 unsigned long lval;
2489 if (val < 0) {
2490 *negp = -1;
2491 lval = (unsigned long)-val;
2492 } else {
2493 *negp = 0;
2494 lval = (unsigned long)val;
2495 }
2496 *lvalp = jiffies_to_clock_t(lval);
2497 }
2498 return 0;
2499}
2500
2501static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2502 int *valp,
2503 int write, void *data)
2504{
2505 if (write) {
2506 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2507 } else {
2508 int val = *valp;
2509 unsigned long lval;
2510 if (val < 0) {
2511 *negp = -1;
2512 lval = (unsigned long)-val;
2513 } else {
2514 *negp = 0;
2515 lval = (unsigned long)val;
2516 }
2517 *lvalp = jiffies_to_msecs(lval);
2518 }
2519 return 0;
2520}
2521
2522/**
2523 * proc_dointvec_jiffies - read a vector of integers as seconds
2524 * @table: the sysctl table
2525 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 * @buffer: the user buffer
2527 * @lenp: the size of the user buffer
2528 * @ppos: file position
2529 *
2530 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2531 * values from/to the user buffer, treated as an ASCII string.
2532 * The values read are assumed to be in seconds, and are converted into
2533 * jiffies.
2534 *
2535 * Returns 0 on success.
2536 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002537int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538 void __user *buffer, size_t *lenp, loff_t *ppos)
2539{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002540 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541 do_proc_dointvec_jiffies_conv,NULL);
2542}
2543
2544/**
2545 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002550 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 *
2552 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2553 * values from/to the user buffer, treated as an ASCII string.
2554 * The values read are assumed to be in 1/USER_HZ seconds, and
2555 * are converted into jiffies.
2556 *
2557 * Returns 0 on success.
2558 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002559int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 void __user *buffer, size_t *lenp, loff_t *ppos)
2561{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002562 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 do_proc_dointvec_userhz_jiffies_conv,NULL);
2564}
2565
2566/**
2567 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2568 * @table: the sysctl table
2569 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 * @buffer: the user buffer
2571 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002572 * @ppos: file position
2573 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 *
2575 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2576 * values from/to the user buffer, treated as an ASCII string.
2577 * The values read are assumed to be in 1/1000 seconds, and
2578 * are converted into jiffies.
2579 *
2580 * Returns 0 on success.
2581 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002582int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 void __user *buffer, size_t *lenp, loff_t *ppos)
2584{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002585 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 do_proc_dointvec_ms_jiffies_conv, NULL);
2587}
2588
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002589static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002590 void __user *buffer, size_t *lenp, loff_t *ppos)
2591{
2592 struct pid *new_pid;
2593 pid_t tmp;
2594 int r;
2595
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002596 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002597
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002598 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002599 lenp, ppos, NULL, NULL);
2600 if (r || !write)
2601 return r;
2602
2603 new_pid = find_get_pid(tmp);
2604 if (!new_pid)
2605 return -ESRCH;
2606
2607 put_pid(xchg(&cad_pid, new_pid));
2608 return 0;
2609}
2610
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611#else /* CONFIG_PROC_FS */
2612
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002613int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 void __user *buffer, size_t *lenp, loff_t *ppos)
2615{
2616 return -ENOSYS;
2617}
2618
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002619int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 void __user *buffer, size_t *lenp, loff_t *ppos)
2621{
2622 return -ENOSYS;
2623}
2624
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002625int proc_dointvec_minmax(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_jiffies(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_userhz_jiffies(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_ms_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_doulongvec_minmax(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
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002655int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 void __user *buffer,
2657 size_t *lenp, loff_t *ppos)
2658{
2659 return -ENOSYS;
2660}
2661
2662
2663#endif /* CONFIG_PROC_FS */
2664
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665/*
2666 * No sense putting this after each symbol definition, twice,
2667 * exception granted :-)
2668 */
2669EXPORT_SYMBOL(proc_dointvec);
2670EXPORT_SYMBOL(proc_dointvec_jiffies);
2671EXPORT_SYMBOL(proc_dointvec_minmax);
2672EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2673EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2674EXPORT_SYMBOL(proc_dostring);
2675EXPORT_SYMBOL(proc_doulongvec_minmax);
2676EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2677EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002678EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679EXPORT_SYMBOL(unregister_sysctl_table);