blob: 83d907afb4a65a59c05f87c6e431ce2a26dcc828 [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>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#include <asm/uaccess.h>
69#include <asm/processor.h>
70
Andi Kleen29cbc782006-09-30 01:47:55 +020071#ifdef CONFIG_X86
72#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010073#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010074#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020075#endif
David Howellsd550bbd2012-03-28 18:30:03 +010076#ifdef CONFIG_SPARC
77#include <asm/setup.h>
78#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080079#ifdef CONFIG_BSD_PROCESS_ACCT
80#include <linux/acct.h>
81#endif
Dave Young4f0e0562010-03-10 15:24:09 -080082#ifdef CONFIG_RT_MUTEXES
83#include <linux/rtmutex.h>
84#endif
Dave Young2edf5e42010-03-10 15:24:10 -080085#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
86#include <linux/lockdep.h>
87#endif
Dave Young15485a42010-03-10 15:24:07 -080088#ifdef CONFIG_CHR_DEV_SG
89#include <scsi/sg.h>
90#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020091
Don Zickus58687ac2010-05-07 17:11:44 -040092#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050093#include <linux/nmi.h>
94#endif
95
Eric W. Biederman7058cb02007-10-18 03:05:58 -070096
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#if defined(CONFIG_SYSCTL)
98
99/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100extern int max_threads;
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200110extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100111extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400112extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000113#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages;
115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400118#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int sixty = 60;
120#endif
121
Aaron Tomlin270750db2014-01-20 17:34:13 +0000122static int __maybe_unused neg_one = -1;
123
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700125static int __maybe_unused one = 1;
126static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700127static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700133
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700134/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
135static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
138static int maxolduid = 65535;
139static int minolduid;
140
141static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700142static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Liu Hua80df2842014-04-07 15:38:57 -0700144/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
145#ifdef CONFIG_DETECT_HUNG_TASK
146static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
147#endif
148
Dave Youngd14f1722010-02-25 20:28:57 -0500149#ifdef CONFIG_INOTIFY_USER
150#include <linux/inotify.h>
151#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700152#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153#endif
154
155#ifdef __hppa__
156extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530157#endif
158
159#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160extern int unaligned_enabled;
161#endif
162
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800164extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800165#endif
166
Vineet Guptab6fca722013-01-09 20:06:28 +0530167#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
168extern int no_unaligned_warning;
169#endif
170
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700171#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700172
173#define SYSCTL_WRITES_LEGACY -1
174#define SYSCTL_WRITES_WARN 0
175#define SYSCTL_WRITES_STRICT 1
176
177static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
178
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700179static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700180 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700181static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800182 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700183#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700184
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700185#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700186static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700187 void __user *buffer, size_t *lenp, loff_t *ppos);
188#endif
189
Kees Cook54b50192012-07-30 14:39:18 -0700190static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
191 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700192#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700193static int proc_dostring_coredump(struct ctl_table *table, int write,
194 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700195#endif
Kees Cook54b50192012-07-30 14:39:18 -0700196
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700197#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800198/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100199static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700200
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700201static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700202 void __user *buffer, size_t *lenp,
203 loff_t *ppos)
204{
205 int error;
206
207 error = proc_dointvec(table, write, buffer, lenp, ppos);
208 if (error)
209 return error;
210
211 if (write)
212 sysrq_toggle_support(__sysrq_enabled);
213
214 return 0;
215}
216
217#endif
218
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700219static struct ctl_table kern_table[];
220static struct ctl_table vm_table[];
221static struct ctl_table fs_table[];
222static struct ctl_table debug_table[];
223static struct ctl_table dev_table[];
224extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800225#ifdef CONFIG_EPOLL
226extern struct ctl_table epoll_table[];
227#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
230int sysctl_legacy_va_layout;
231#endif
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233/* The default sysctl tables: */
234
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800235static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 .procname = "kernel",
238 .mode = 0555,
239 .child = kern_table,
240 },
241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .procname = "vm",
243 .mode = 0555,
244 .child = vm_table,
245 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .procname = "fs",
248 .mode = 0555,
249 .child = fs_table,
250 },
251 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 .procname = "debug",
253 .mode = 0555,
254 .child = debug_table,
255 },
256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 .procname = "dev",
258 .mode = 0555,
259 .child = dev_table,
260 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700261 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262};
263
Ingo Molnar77e54a12007-07-09 18:52:00 +0200264#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100265static int min_sched_granularity_ns = 100000; /* 100 usecs */
266static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
267static int min_wakeup_granularity_ns; /* 0 usecs */
268static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200269#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100270static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
271static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200272#endif /* CONFIG_SMP */
273#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200274
Mel Gorman5e771902010-05-24 14:32:31 -0700275#ifdef CONFIG_COMPACTION
276static int min_extfrag_threshold;
277static int max_extfrag_threshold = 1000;
278#endif
279
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700280static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200281 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200282 .procname = "sched_child_runs_first",
283 .data = &sysctl_sched_child_runs_first,
284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800286 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200287 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200288#ifdef CONFIG_SCHED_DEBUG
289 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100290 .procname = "sched_min_granularity_ns",
291 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200292 .maxlen = sizeof(unsigned int),
293 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800294 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100295 .extra1 = &min_sched_granularity_ns,
296 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200297 },
298 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200299 .procname = "sched_latency_ns",
300 .data = &sysctl_sched_latency,
301 .maxlen = sizeof(unsigned int),
302 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800303 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200304 .extra1 = &min_sched_granularity_ns,
305 .extra2 = &max_sched_granularity_ns,
306 },
307 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200308 .procname = "sched_wakeup_granularity_ns",
309 .data = &sysctl_sched_wakeup_granularity,
310 .maxlen = sizeof(unsigned int),
311 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800312 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200313 .extra1 = &min_wakeup_granularity_ns,
314 .extra2 = &max_wakeup_granularity_ns,
315 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200316#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200317 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100318 .procname = "sched_tunable_scaling",
319 .data = &sysctl_sched_tunable_scaling,
320 .maxlen = sizeof(enum sched_tunable_scaling),
321 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800322 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100323 .extra1 = &min_sched_tunable_scaling,
324 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200325 },
326 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900327 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200328 .data = &sysctl_sched_migration_cost,
329 .maxlen = sizeof(unsigned int),
330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200332 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100333 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100334 .procname = "sched_nr_migrate",
335 .data = &sysctl_sched_nr_migrate,
336 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100339 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530340 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900341 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200342 .data = &sysctl_sched_time_avg,
343 .maxlen = sizeof(unsigned int),
344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800345 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200346 },
347 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900348 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800349 .data = &sysctl_sched_shares_window,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
352 .proc_handler = proc_dointvec,
353 },
354 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530355 .procname = "timer_migration",
356 .data = &sysctl_timer_migration,
357 .maxlen = sizeof(unsigned int),
358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800359 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530360 .extra1 = &zero,
361 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530362 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200363#endif /* CONFIG_SMP */
364#ifdef CONFIG_NUMA_BALANCING
365 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200366 .procname = "numa_balancing_scan_delay_ms",
367 .data = &sysctl_numa_balancing_scan_delay,
368 .maxlen = sizeof(unsigned int),
369 .mode = 0644,
370 .proc_handler = proc_dointvec,
371 },
372 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200373 .procname = "numa_balancing_scan_period_min_ms",
374 .data = &sysctl_numa_balancing_scan_period_min,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = proc_dointvec,
378 },
379 {
380 .procname = "numa_balancing_scan_period_max_ms",
381 .data = &sysctl_numa_balancing_scan_period_max,
382 .maxlen = sizeof(unsigned int),
383 .mode = 0644,
384 .proc_handler = proc_dointvec,
385 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200386 {
387 .procname = "numa_balancing_scan_size_mb",
388 .data = &sysctl_numa_balancing_scan_size,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400391 .proc_handler = proc_dointvec_minmax,
392 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200393 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100394 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800395 .procname = "numa_balancing",
396 .data = NULL, /* filled in by handler */
397 .maxlen = sizeof(unsigned int),
398 .mode = 0644,
399 .proc_handler = sysctl_numa_balancing,
400 .extra1 = &zero,
401 .extra2 = &one,
402 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200403#endif /* CONFIG_NUMA_BALANCING */
404#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200405 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100406 .procname = "sched_rt_period_us",
407 .data = &sysctl_sched_rt_period,
408 .maxlen = sizeof(unsigned int),
409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800410 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100411 },
412 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100413 .procname = "sched_rt_runtime_us",
414 .data = &sysctl_sched_rt_runtime,
415 .maxlen = sizeof(int),
416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800417 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100418 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600419 {
420 .procname = "sched_rr_timeslice_ms",
421 .data = &sched_rr_timeslice,
422 .maxlen = sizeof(int),
423 .mode = 0644,
424 .proc_handler = sched_rr_handler,
425 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100426#ifdef CONFIG_SCHED_AUTOGROUP
427 {
428 .procname = "sched_autogroup_enabled",
429 .data = &sysctl_sched_autogroup_enabled,
430 .maxlen = sizeof(unsigned int),
431 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800432 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100433 .extra1 = &zero,
434 .extra2 = &one,
435 },
436#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700437#ifdef CONFIG_CFS_BANDWIDTH
438 {
439 .procname = "sched_cfs_bandwidth_slice_us",
440 .data = &sysctl_sched_cfs_bandwidth_slice,
441 .maxlen = sizeof(unsigned int),
442 .mode = 0644,
443 .proc_handler = proc_dointvec_minmax,
444 .extra1 = &one,
445 },
446#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700447#ifdef CONFIG_PROVE_LOCKING
448 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700449 .procname = "prove_locking",
450 .data = &prove_locking,
451 .maxlen = sizeof(int),
452 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800453 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454 },
455#endif
456#ifdef CONFIG_LOCK_STAT
457 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700458 .procname = "lock_stat",
459 .data = &lock_stat,
460 .maxlen = sizeof(int),
461 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800462 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700463 },
464#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 .procname = "panic",
467 .data = &panic_timeout,
468 .maxlen = sizeof(int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 },
Alex Kelly046d6622012-10-04 17:15:23 -0700472#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 .procname = "core_uses_pid",
475 .data = &core_uses_pid,
476 .maxlen = sizeof(int),
477 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800478 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 },
480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 .procname = "core_pattern",
482 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700483 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700485 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 },
Neil Hormana2939802009-09-23 15:56:56 -0700487 {
Neil Hormana2939802009-09-23 15:56:56 -0700488 .procname = "core_pipe_limit",
489 .data = &core_pipe_limit,
490 .maxlen = sizeof(unsigned int),
491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700493 },
Alex Kelly046d6622012-10-04 17:15:23 -0700494#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800495#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700498 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700502 {
503 .procname = "sysctl_writes_strict",
504 .data = &sysctl_writes_strict,
505 .maxlen = sizeof(int),
506 .mode = 0644,
507 .proc_handler = proc_dointvec_minmax,
508 .extra1 = &neg_one,
509 .extra2 = &one,
510 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800511#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100512#ifdef CONFIG_LATENCYTOP
513 {
514 .procname = "latencytop",
515 .data = &latencytop_enabled,
516 .maxlen = sizeof(int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100519 },
520#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521#ifdef CONFIG_BLK_DEV_INITRD
522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 .procname = "real-root-dev",
524 .data = &real_root_dev,
525 .maxlen = sizeof(int),
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 },
529#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700530 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700531 .procname = "print-fatal-signals",
532 .data = &print_fatal_signals,
533 .maxlen = sizeof(int),
534 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800535 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700536 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700537#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 .procname = "reboot-cmd",
540 .data = reboot_command,
541 .maxlen = 256,
542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800543 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 },
545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .procname = "stop-a",
547 .data = &stop_a_enabled,
548 .maxlen = sizeof (int),
549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800550 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 },
552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "scons-poweroff",
554 .data = &scons_pwroff,
555 .maxlen = sizeof (int),
556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
559#endif
David S. Miller08714202008-11-16 23:49:24 -0800560#ifdef CONFIG_SPARC64
561 {
David S. Miller08714202008-11-16 23:49:24 -0800562 .procname = "tsb-ratio",
563 .data = &sysctl_tsb_ratio,
564 .maxlen = sizeof (int),
565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800566 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800567 },
568#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569#ifdef __hppa__
570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .procname = "soft-power",
572 .data = &pwrsw_enabled,
573 .maxlen = sizeof (int),
574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800575 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530577#endif
578#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "unaligned-trap",
581 .data = &unaligned_enabled,
582 .maxlen = sizeof (int),
583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800584 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
586#endif
587 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 .procname = "ctrl-alt-del",
589 .data = &C_A_D,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400594#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200595 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200596 .procname = "ftrace_enabled",
597 .data = &ftrace_enabled,
598 .maxlen = sizeof(int),
599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800600 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200601 },
602#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500603#ifdef CONFIG_STACK_TRACER
604 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500605 .procname = "stack_tracer_enabled",
606 .data = &stack_tracer_enabled,
607 .maxlen = sizeof(int),
608 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800609 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500610 },
611#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400612#ifdef CONFIG_TRACING
613 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100614 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400615 .data = &ftrace_dump_on_oops,
616 .maxlen = sizeof(int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400619 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400620 {
621 .procname = "traceoff_on_warning",
622 .data = &__disable_trace_on_warning,
623 .maxlen = sizeof(__disable_trace_on_warning),
624 .mode = 0644,
625 .proc_handler = proc_dointvec,
626 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500627 {
628 .procname = "tracepoint_printk",
629 .data = &tracepoint_printk,
630 .maxlen = sizeof(tracepoint_printk),
631 .mode = 0644,
632 .proc_handler = proc_dointvec,
633 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400634#endif
Kees Cook79847542014-01-23 15:55:59 -0800635#ifdef CONFIG_KEXEC
636 {
637 .procname = "kexec_load_disabled",
638 .data = &kexec_load_disabled,
639 .maxlen = sizeof(int),
640 .mode = 0644,
641 /* only handle a transition from default "0" to "1" */
642 .proc_handler = proc_dointvec_minmax,
643 .extra1 = &one,
644 .extra2 = &one,
645 },
646#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200647#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 .procname = "modprobe",
650 .data = &modprobe_path,
651 .maxlen = KMOD_PATH_LEN,
652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 },
Kees Cook3d433212009-04-02 15:49:29 -0700655 {
Kees Cook3d433212009-04-02 15:49:29 -0700656 .procname = "modules_disabled",
657 .data = &modules_disabled,
658 .maxlen = sizeof(int),
659 .mode = 0644,
660 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700662 .extra1 = &one,
663 .extra2 = &one,
664 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700666#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100669 .data = &uevent_helper,
670 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800672 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 },
Michael Marineau86d56132014-04-10 14:09:31 -0700674#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675#ifdef CONFIG_CHR_DEV_SG
676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .procname = "sg-big-buff",
678 .data = &sg_big_buff,
679 .maxlen = sizeof (int),
680 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800681 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 },
683#endif
684#ifdef CONFIG_BSD_PROCESS_ACCT
685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "acct",
687 .data = &acct_parm,
688 .maxlen = 3*sizeof(int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 },
692#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693#ifdef CONFIG_MAGIC_SYSRQ
694 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800696 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .maxlen = sizeof (int),
698 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700699 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 },
701#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700702#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700705 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .maxlen = sizeof (int),
707 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700710#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "threads-max",
713 .data = &max_threads,
714 .maxlen = sizeof(int),
715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .procname = "random",
720 .mode = 0555,
721 .child = random_table,
722 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 {
Eric Paris17f60a72011-04-01 17:07:50 -0400724 .procname = "usermodehelper",
725 .mode = 0555,
726 .child = usermodehelper_table,
727 },
728 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 .procname = "overflowuid",
730 .data = &overflowuid,
731 .maxlen = sizeof(int),
732 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800733 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .extra1 = &minolduid,
735 .extra2 = &maxolduid,
736 },
737 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 .procname = "overflowgid",
739 .data = &overflowgid,
740 .maxlen = sizeof(int),
741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 .extra1 = &minolduid,
744 .extra2 = &maxolduid,
745 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800746#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747#ifdef CONFIG_MATHEMU
748 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .procname = "ieee_emulation_warnings",
750 .data = &sysctl_ieee_emulation_warnings,
751 .maxlen = sizeof(int),
752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 },
755#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200758 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .maxlen = sizeof(int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
763#endif
764 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 .procname = "pid_max",
766 .data = &pid_max,
767 .maxlen = sizeof (int),
768 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800769 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 .extra1 = &pid_max_min,
771 .extra2 = &pid_max_max,
772 },
773 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 .procname = "panic_on_oops",
775 .data = &panic_on_oops,
776 .maxlen = sizeof(int),
777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800778 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800780#if defined CONFIG_PRINTK
781 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800782 .procname = "printk",
783 .data = &console_loglevel,
784 .maxlen = 4*sizeof(int),
785 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800786 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800787 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700790 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 .maxlen = sizeof(int),
792 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800793 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 },
795 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700797 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 .maxlen = sizeof(int),
799 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800800 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 },
Dave Youngaf913222009-09-22 16:43:33 -0700802 {
Dave Youngaf913222009-09-22 16:43:33 -0700803 .procname = "printk_delay",
804 .data = &printk_delay_msec,
805 .maxlen = sizeof(int),
806 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700808 .extra1 = &zero,
809 .extra2 = &ten_thousand,
810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800812 .procname = "dmesg_restrict",
813 .data = &dmesg_restrict,
814 .maxlen = sizeof(int),
815 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700816 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800817 .extra1 = &zero,
818 .extra2 = &one,
819 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800820 {
821 .procname = "kptr_restrict",
822 .data = &kptr_restrict,
823 .maxlen = sizeof(int),
824 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700825 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800826 .extra1 = &zero,
827 .extra2 = &two,
828 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800829#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800830 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 .procname = "ngroups_max",
832 .data = &ngroups_max,
833 .maxlen = sizeof (int),
834 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800835 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 },
Dan Ballard73efc032011-10-31 17:11:20 -0700837 {
838 .procname = "cap_last_cap",
839 .data = (void *)&cap_last_cap,
840 .maxlen = sizeof(int),
841 .mode = 0444,
842 .proc_handler = proc_dointvec,
843 },
Don Zickus58687ac2010-05-07 17:11:44 -0400844#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500845 {
Don Zickus58687ac2010-05-07 17:11:44 -0400846 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200847 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500848 .maxlen = sizeof (int),
849 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700850 .proc_handler = proc_dowatchdog,
851 .extra1 = &zero,
852 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400853 },
854 {
855 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700856 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400857 .maxlen = sizeof(int),
858 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700859 .proc_handler = proc_dowatchdog,
Li Zefana6572f82013-05-17 10:31:04 +0800860 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400861 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500862 },
Don Zickus2508ce12010-05-07 17:11:46 -0400863 {
864 .procname = "softlockup_panic",
865 .data = &softlockup_panic,
866 .maxlen = sizeof(int),
867 .mode = 0644,
868 .proc_handler = proc_dointvec_minmax,
869 .extra1 = &zero,
870 .extra2 = &one,
871 },
Aaron Tomlined235872014-06-23 13:22:05 -0700872#ifdef CONFIG_SMP
873 {
874 .procname = "softlockup_all_cpu_backtrace",
875 .data = &sysctl_softlockup_all_cpu_backtrace,
876 .maxlen = sizeof(int),
877 .mode = 0644,
878 .proc_handler = proc_dointvec_minmax,
879 .extra1 = &zero,
880 .extra2 = &one,
881 },
882#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500883 {
884 .procname = "nmi_watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200885 .data = &watchdog_user_enabled,
Don Zickus5dc30552010-11-29 17:07:17 -0500886 .maxlen = sizeof (int),
887 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700888 .proc_handler = proc_dowatchdog,
889 .extra1 = &zero,
890 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500891 },
892#endif
893#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
894 {
895 .procname = "unknown_nmi_panic",
896 .data = &unknown_nmi_panic,
897 .maxlen = sizeof (int),
898 .mode = 0644,
899 .proc_handler = proc_dointvec,
900 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500901#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902#if defined(CONFIG_X86)
903 {
Don Zickus8da5add2006-09-26 10:52:27 +0200904 .procname = "panic_on_unrecovered_nmi",
905 .data = &panic_on_unrecovered_nmi,
906 .maxlen = sizeof(int),
907 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800908 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200909 },
910 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700911 .procname = "panic_on_io_nmi",
912 .data = &panic_on_io_nmi,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700916 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900917#ifdef CONFIG_DEBUG_STACKOVERFLOW
918 {
919 .procname = "panic_on_stackoverflow",
920 .data = &sysctl_panic_on_stackoverflow,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = proc_dointvec,
924 },
925#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700926 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 .procname = "bootloader_type",
928 .data = &bootloader_type,
929 .maxlen = sizeof (int),
930 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800931 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100933 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700934 .procname = "bootloader_version",
935 .data = &bootloader_version,
936 .maxlen = sizeof (int),
937 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700939 },
940 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100941 .procname = "kstack_depth_to_print",
942 .data = &kstack_depth_to_print,
943 .maxlen = sizeof(int),
944 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800945 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100946 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100947 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100948 .procname = "io_delay_type",
949 .data = &io_delay_type,
950 .maxlen = sizeof(int),
951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800952 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100953 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800955#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 .procname = "randomize_va_space",
958 .data = &randomize_va_space,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800963#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800964#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700965 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700966 .procname = "spin_retry",
967 .data = &spin_retry,
968 .maxlen = sizeof (int),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700971 },
972#endif
Len Brown673d5b42007-07-28 03:33:16 -0400973#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800974 {
Pavel Machekc255d842006-02-20 18:27:58 -0800975 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700976 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800977 .maxlen = sizeof (unsigned long),
978 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800979 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800980 },
981#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530982#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800983 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800984 .procname = "ignore-unaligned-usertrap",
985 .data = &no_unaligned_warning,
986 .maxlen = sizeof (int),
987 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800988 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800989 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530990#endif
991#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800992 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800993 .procname = "unaligned-dump-stack",
994 .data = &unaligned_dump_stack,
995 .maxlen = sizeof (int),
996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800998 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800999#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001000#ifdef CONFIG_DETECT_HUNG_TASK
1001 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001002 .procname = "hung_task_panic",
1003 .data = &sysctl_hung_task_panic,
1004 .maxlen = sizeof(int),
1005 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001006 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001007 .extra1 = &zero,
1008 .extra2 = &one,
1009 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001010 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001011 .procname = "hung_task_check_count",
1012 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001013 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001014 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001015 .proc_handler = proc_dointvec_minmax,
1016 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001017 },
1018 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001019 .procname = "hung_task_timeout_secs",
1020 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001021 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001024 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001025 },
1026 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001027 .procname = "hung_task_warnings",
1028 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001029 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001030 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001031 .proc_handler = proc_dointvec_minmax,
1032 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001033 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001034#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001035#ifdef CONFIG_COMPAT
1036 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001037 .procname = "compat-log",
1038 .data = &compat_log,
1039 .maxlen = sizeof (int),
1040 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001041 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001042 },
1043#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001044#ifdef CONFIG_RT_MUTEXES
1045 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001046 .procname = "max_lock_depth",
1047 .data = &max_lock_depth,
1048 .maxlen = sizeof(int),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001051 },
1052#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001053 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001054 .procname = "poweroff_cmd",
1055 .data = &poweroff_cmd,
1056 .maxlen = POWEROFF_CMD_PATH_LEN,
1057 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001058 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001059 },
David Howells0b77f5b2008-04-29 01:01:32 -07001060#ifdef CONFIG_KEYS
1061 {
David Howells0b77f5b2008-04-29 01:01:32 -07001062 .procname = "keys",
1063 .mode = 0555,
1064 .child = key_sysctls,
1065 },
1066#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001067#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001068 /*
1069 * User-space scripts rely on the existence of this file
1070 * as a feature check for perf_events being enabled.
1071 *
1072 * So it's an ABI, do not remove!
1073 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001074 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001075 .procname = "perf_event_paranoid",
1076 .data = &sysctl_perf_event_paranoid,
1077 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001078 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001079 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001080 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001081 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001082 .procname = "perf_event_mlock_kb",
1083 .data = &sysctl_perf_event_mlock,
1084 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001085 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001086 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001087 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001088 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001089 .procname = "perf_event_max_sample_rate",
1090 .data = &sysctl_perf_event_sample_rate,
1091 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001092 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001093 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001094 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001095 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001096 {
1097 .procname = "perf_cpu_time_max_percent",
1098 .data = &sysctl_perf_cpu_time_max_percent,
1099 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1100 .mode = 0644,
1101 .proc_handler = perf_cpu_time_max_percent_handler,
1102 .extra1 = &zero,
1103 .extra2 = &one_hundred,
1104 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001105#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001106#ifdef CONFIG_KMEMCHECK
1107 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001108 .procname = "kmemcheck",
1109 .data = &kmemcheck_enabled,
1110 .maxlen = sizeof(int),
1111 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001112 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001113 },
1114#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001115 {
1116 .procname = "panic_on_warn",
1117 .data = &panic_on_warn,
1118 .maxlen = sizeof(int),
1119 .mode = 0644,
1120 .proc_handler = proc_dointvec_minmax,
1121 .extra1 = &zero,
1122 .extra2 = &one,
1123 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001124 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125};
1126
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001127static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .procname = "overcommit_memory",
1130 .data = &sysctl_overcommit_memory,
1131 .maxlen = sizeof(sysctl_overcommit_memory),
1132 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001133 .proc_handler = proc_dointvec_minmax,
1134 .extra1 = &zero,
1135 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 },
1137 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001138 .procname = "panic_on_oom",
1139 .data = &sysctl_panic_on_oom,
1140 .maxlen = sizeof(sysctl_panic_on_oom),
1141 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001142 .proc_handler = proc_dointvec_minmax,
1143 .extra1 = &zero,
1144 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001145 },
1146 {
David Rientjesfe071d72007-10-16 23:25:56 -07001147 .procname = "oom_kill_allocating_task",
1148 .data = &sysctl_oom_kill_allocating_task,
1149 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1150 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001151 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001152 },
1153 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001154 .procname = "oom_dump_tasks",
1155 .data = &sysctl_oom_dump_tasks,
1156 .maxlen = sizeof(sysctl_oom_dump_tasks),
1157 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001158 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001159 },
1160 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .procname = "overcommit_ratio",
1162 .data = &sysctl_overcommit_ratio,
1163 .maxlen = sizeof(sysctl_overcommit_ratio),
1164 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001165 .proc_handler = overcommit_ratio_handler,
1166 },
1167 {
1168 .procname = "overcommit_kbytes",
1169 .data = &sysctl_overcommit_kbytes,
1170 .maxlen = sizeof(sysctl_overcommit_kbytes),
1171 .mode = 0644,
1172 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 },
1174 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 .procname = "page-cluster",
1176 .data = &page_cluster,
1177 .maxlen = sizeof(int),
1178 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001179 .proc_handler = proc_dointvec_minmax,
1180 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 },
1182 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 .procname = "dirty_background_ratio",
1184 .data = &dirty_background_ratio,
1185 .maxlen = sizeof(dirty_background_ratio),
1186 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001187 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 .extra1 = &zero,
1189 .extra2 = &one_hundred,
1190 },
1191 {
David Rientjes2da02992009-01-06 14:39:31 -08001192 .procname = "dirty_background_bytes",
1193 .data = &dirty_background_bytes,
1194 .maxlen = sizeof(dirty_background_bytes),
1195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001197 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001198 },
1199 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 .procname = "dirty_ratio",
1201 .data = &vm_dirty_ratio,
1202 .maxlen = sizeof(vm_dirty_ratio),
1203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001204 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 .extra1 = &zero,
1206 .extra2 = &one_hundred,
1207 },
1208 {
David Rientjes2da02992009-01-06 14:39:31 -08001209 .procname = "dirty_bytes",
1210 .data = &vm_dirty_bytes,
1211 .maxlen = sizeof(vm_dirty_bytes),
1212 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001213 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001214 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001215 },
1216 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001218 .data = &dirty_writeback_interval,
1219 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001221 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 },
1223 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001225 .data = &dirty_expire_interval,
1226 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001228 .proc_handler = proc_dointvec_minmax,
1229 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 },
1231 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001232 .procname = "nr_pdflush_threads",
1233 .mode = 0444 /* read-only */,
1234 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 },
1236 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237 .procname = "swappiness",
1238 .data = &vm_swappiness,
1239 .maxlen = sizeof(vm_swappiness),
1240 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001241 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 .extra1 = &zero,
1243 .extra2 = &one_hundred,
1244 },
1245#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001248 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249 .maxlen = sizeof(unsigned long),
1250 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001251 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001252 },
1253#ifdef CONFIG_NUMA
1254 {
1255 .procname = "nr_hugepages_mempolicy",
1256 .data = NULL,
1257 .maxlen = sizeof(unsigned long),
1258 .mode = 0644,
1259 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001260 },
1261#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 .procname = "hugetlb_shm_group",
1264 .data = &sysctl_hugetlb_shm_group,
1265 .maxlen = sizeof(gid_t),
1266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 },
Mel Gorman396faf02007-07-17 04:03:13 -07001269 {
Mel Gorman396faf02007-07-17 04:03:13 -07001270 .procname = "hugepages_treat_as_movable",
1271 .data = &hugepages_treat_as_movable,
1272 .maxlen = sizeof(int),
1273 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001274 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001275 },
Adam Litke54f9f802007-10-16 01:26:20 -07001276 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001277 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001278 .data = NULL,
1279 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001282 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283#endif
1284 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285 .procname = "lowmem_reserve_ratio",
1286 .data = &sysctl_lowmem_reserve_ratio,
1287 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001289 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 },
1291 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001292 .procname = "drop_caches",
1293 .data = &sysctl_drop_caches,
1294 .maxlen = sizeof(int),
1295 .mode = 0644,
1296 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001297 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001298 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001299 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001300#ifdef CONFIG_COMPACTION
1301 {
1302 .procname = "compact_memory",
1303 .data = &sysctl_compact_memory,
1304 .maxlen = sizeof(int),
1305 .mode = 0200,
1306 .proc_handler = sysctl_compaction_handler,
1307 },
Mel Gorman5e771902010-05-24 14:32:31 -07001308 {
1309 .procname = "extfrag_threshold",
1310 .data = &sysctl_extfrag_threshold,
1311 .maxlen = sizeof(int),
1312 .mode = 0644,
1313 .proc_handler = sysctl_extfrag_handler,
1314 .extra1 = &min_extfrag_threshold,
1315 .extra2 = &max_extfrag_threshold,
1316 },
1317
Mel Gorman76ab0f52010-05-24 14:32:28 -07001318#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "min_free_kbytes",
1321 .data = &min_free_kbytes,
1322 .maxlen = sizeof(min_free_kbytes),
1323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .extra1 = &zero,
1326 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001327 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001328 .procname = "percpu_pagelist_fraction",
1329 .data = &percpu_pagelist_fraction,
1330 .maxlen = sizeof(percpu_pagelist_fraction),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001333 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001334 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335#ifdef CONFIG_MMU
1336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "max_map_count",
1338 .data = &sysctl_max_map_count,
1339 .maxlen = sizeof(sysctl_max_map_count),
1340 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001341 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001342 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001344#else
1345 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001346 .procname = "nr_trim_pages",
1347 .data = &sysctl_nr_trim_pages,
1348 .maxlen = sizeof(sysctl_nr_trim_pages),
1349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001350 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001351 .extra1 = &zero,
1352 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353#endif
1354 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .procname = "laptop_mode",
1356 .data = &laptop_mode,
1357 .maxlen = sizeof(laptop_mode),
1358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001359 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 },
1361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 .procname = "block_dump",
1363 .data = &block_dump,
1364 .maxlen = sizeof(block_dump),
1365 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001366 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .extra1 = &zero,
1368 },
1369 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370 .procname = "vfs_cache_pressure",
1371 .data = &sysctl_vfs_cache_pressure,
1372 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1373 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001374 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 .extra1 = &zero,
1376 },
1377#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1378 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 .procname = "legacy_va_layout",
1380 .data = &sysctl_legacy_va_layout,
1381 .maxlen = sizeof(sysctl_legacy_va_layout),
1382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001383 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 .extra1 = &zero,
1385 },
1386#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001387#ifdef CONFIG_NUMA
1388 {
Christoph Lameter17436602006-01-18 17:42:32 -08001389 .procname = "zone_reclaim_mode",
1390 .data = &zone_reclaim_mode,
1391 .maxlen = sizeof(zone_reclaim_mode),
1392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001393 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001394 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001395 },
Christoph Lameter96146342006-07-03 00:24:13 -07001396 {
Christoph Lameter96146342006-07-03 00:24:13 -07001397 .procname = "min_unmapped_ratio",
1398 .data = &sysctl_min_unmapped_ratio,
1399 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001401 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001402 .extra1 = &zero,
1403 .extra2 = &one_hundred,
1404 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001405 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001406 .procname = "min_slab_ratio",
1407 .data = &sysctl_min_slab_ratio,
1408 .maxlen = sizeof(sysctl_min_slab_ratio),
1409 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001410 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001411 .extra1 = &zero,
1412 .extra2 = &one_hundred,
1413 },
Christoph Lameter17436602006-01-18 17:42:32 -08001414#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001415#ifdef CONFIG_SMP
1416 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001417 .procname = "stat_interval",
1418 .data = &sysctl_stat_interval,
1419 .maxlen = sizeof(sysctl_stat_interval),
1420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001421 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001422 },
1423#endif
David Howells6e141542009-12-15 19:27:45 +00001424#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001425 {
Eric Parised032182007-06-28 15:55:21 -04001426 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001427 .data = &dac_mmap_min_addr,
1428 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001429 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001430 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001431 },
David Howells6e141542009-12-15 19:27:45 +00001432#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001433#ifdef CONFIG_NUMA
1434 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001435 .procname = "numa_zonelist_order",
1436 .data = &numa_zonelist_order,
1437 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1438 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001439 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001440 },
1441#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001442#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001443 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001444 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001445 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001446#ifdef CONFIG_X86_32
1447 .data = &vdso32_enabled,
1448 .maxlen = sizeof(vdso32_enabled),
1449#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001450 .data = &vdso_enabled,
1451 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001452#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001455 .extra1 = &zero,
1456 },
1457#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001458#ifdef CONFIG_HIGHMEM
1459 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001460 .procname = "highmem_is_dirtyable",
1461 .data = &vm_highmem_is_dirtyable,
1462 .maxlen = sizeof(vm_highmem_is_dirtyable),
1463 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001464 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001465 .extra1 = &zero,
1466 .extra2 = &one,
1467 },
1468#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001469#ifdef CONFIG_MEMORY_FAILURE
1470 {
Andi Kleen6a460792009-09-16 11:50:15 +02001471 .procname = "memory_failure_early_kill",
1472 .data = &sysctl_memory_failure_early_kill,
1473 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001475 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001476 .extra1 = &zero,
1477 .extra2 = &one,
1478 },
1479 {
Andi Kleen6a460792009-09-16 11:50:15 +02001480 .procname = "memory_failure_recovery",
1481 .data = &sysctl_memory_failure_recovery,
1482 .maxlen = sizeof(sysctl_memory_failure_recovery),
1483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001484 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001485 .extra1 = &zero,
1486 .extra2 = &one,
1487 },
1488#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001489 {
1490 .procname = "user_reserve_kbytes",
1491 .data = &sysctl_user_reserve_kbytes,
1492 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1493 .mode = 0644,
1494 .proc_handler = proc_doulongvec_minmax,
1495 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001496 {
1497 .procname = "admin_reserve_kbytes",
1498 .data = &sysctl_admin_reserve_kbytes,
1499 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1500 .mode = 0644,
1501 .proc_handler = proc_doulongvec_minmax,
1502 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001503 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504};
1505
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001506#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001507static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001508 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001509};
1510#endif
1511
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001512static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001514 .procname = "inode-nr",
1515 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001516 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001518 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519 },
1520 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521 .procname = "inode-state",
1522 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001523 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001525 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526 },
1527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 .procname = "file-nr",
1529 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001530 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001531 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533 },
1534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 .procname = "file-max",
1536 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001537 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001538 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001539 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 },
1541 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001542 .procname = "nr_open",
1543 .data = &sysctl_nr_open,
1544 .maxlen = sizeof(int),
1545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001546 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001547 .extra1 = &sysctl_nr_open_min,
1548 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001549 },
1550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 .procname = "dentry-state",
1552 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001553 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001555 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556 },
1557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 .procname = "overflowuid",
1559 .data = &fs_overflowuid,
1560 .maxlen = sizeof(int),
1561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001562 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 .extra1 = &minolduid,
1564 .extra2 = &maxolduid,
1565 },
1566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 .procname = "overflowgid",
1568 .data = &fs_overflowgid,
1569 .maxlen = sizeof(int),
1570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001571 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 .extra1 = &minolduid,
1573 .extra2 = &maxolduid,
1574 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001575#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 .procname = "leases-enable",
1578 .data = &leases_enable,
1579 .maxlen = sizeof(int),
1580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001581 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001583#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001584#ifdef CONFIG_DNOTIFY
1585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 .procname = "dir-notify-enable",
1587 .data = &dir_notify_enable,
1588 .maxlen = sizeof(int),
1589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 },
1592#endif
1593#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001594#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 .procname = "lease-break-time",
1597 .data = &lease_break_time,
1598 .maxlen = sizeof(int),
1599 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001600 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001601 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001602#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001603#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605 .procname = "aio-nr",
1606 .data = &aio_nr,
1607 .maxlen = sizeof(aio_nr),
1608 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001609 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610 },
1611 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001612 .procname = "aio-max-nr",
1613 .data = &aio_max_nr,
1614 .maxlen = sizeof(aio_max_nr),
1615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001616 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001617 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001618#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001619#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001620 {
Robert Love0399cb02005-07-13 12:38:18 -04001621 .procname = "inotify",
1622 .mode = 0555,
1623 .child = inotify_table,
1624 },
1625#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001626#ifdef CONFIG_EPOLL
1627 {
1628 .procname = "epoll",
1629 .mode = 0555,
1630 .child = epoll_table,
1631 },
1632#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001634 {
Kees Cook800179c2012-07-25 17:29:07 -07001635 .procname = "protected_symlinks",
1636 .data = &sysctl_protected_symlinks,
1637 .maxlen = sizeof(int),
1638 .mode = 0600,
1639 .proc_handler = proc_dointvec_minmax,
1640 .extra1 = &zero,
1641 .extra2 = &one,
1642 },
1643 {
1644 .procname = "protected_hardlinks",
1645 .data = &sysctl_protected_hardlinks,
1646 .maxlen = sizeof(int),
1647 .mode = 0600,
1648 .proc_handler = proc_dointvec_minmax,
1649 .extra1 = &zero,
1650 .extra2 = &one,
1651 },
1652 {
Alan Coxd6e71142005-06-23 00:09:43 -07001653 .procname = "suid_dumpable",
1654 .data = &suid_dumpable,
1655 .maxlen = sizeof(int),
1656 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001657 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001658 .extra1 = &zero,
1659 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001660 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001661#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1662 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001663 .procname = "binfmt_misc",
1664 .mode = 0555,
1665 .child = binfmt_misc_table,
1666 },
1667#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001668 {
Jens Axboeff9da692010-06-03 14:54:39 +02001669 .procname = "pipe-max-size",
1670 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001671 .maxlen = sizeof(int),
1672 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001673 .proc_handler = &pipe_proc_fn,
1674 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001675 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001676 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677};
1678
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001679static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001680#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001681 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001682 .procname = "exception-trace",
1683 .data = &show_unhandled_signals,
1684 .maxlen = sizeof(int),
1685 .mode = 0644,
1686 .proc_handler = proc_dointvec
1687 },
1688#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001689#if defined(CONFIG_OPTPROBES)
1690 {
1691 .procname = "kprobes-optimization",
1692 .data = &sysctl_kprobes_optimization,
1693 .maxlen = sizeof(int),
1694 .mode = 0644,
1695 .proc_handler = proc_kprobes_optimization_handler,
1696 .extra1 = &zero,
1697 .extra2 = &one,
1698 },
1699#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001700 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701};
1702
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001703static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001704 { }
Robert Love0eeca282005-07-12 17:06:03 -04001705};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001707int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001708{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001709 struct ctl_table_header *hdr;
1710
1711 hdr = register_sysctl_table(sysctl_base_table);
1712 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001713 return 0;
1714}
1715
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001716#endif /* CONFIG_SYSCTL */
1717
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718/*
1719 * /proc/sys support
1720 */
1721
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001722#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001723
Kees Cookf8808302014-06-06 14:37:17 -07001724static int _proc_do_string(char *data, int maxlen, int write,
1725 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001726 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001727{
1728 size_t len;
1729 char __user *p;
1730 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001731
1732 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001733 *lenp = 0;
1734 return 0;
1735 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001736
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001737 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001738 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1739 /* Only continue writes not past the end of buffer. */
1740 len = strlen(data);
1741 if (len > maxlen - 1)
1742 len = maxlen - 1;
1743
1744 if (*ppos > len)
1745 return 0;
1746 len = *ppos;
1747 } else {
1748 /* Start writing from beginning of buffer. */
1749 len = 0;
1750 }
1751
Kees Cook2ca9bb42014-06-06 14:37:18 -07001752 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001753 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001754 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001755 if (get_user(c, p++))
1756 return -EFAULT;
1757 if (c == 0 || c == '\n')
1758 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001759 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001760 }
Kees Cookf8808302014-06-06 14:37:17 -07001761 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001762 } else {
1763 len = strlen(data);
1764 if (len > maxlen)
1765 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001766
1767 if (*ppos > len) {
1768 *lenp = 0;
1769 return 0;
1770 }
1771
1772 data += *ppos;
1773 len -= *ppos;
1774
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001775 if (len > *lenp)
1776 len = *lenp;
1777 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001778 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001779 return -EFAULT;
1780 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001781 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001782 return -EFAULT;
1783 len++;
1784 }
1785 *lenp = len;
1786 *ppos += len;
1787 }
1788 return 0;
1789}
1790
Kees Cookf4aacea2014-06-06 14:37:19 -07001791static void warn_sysctl_write(struct ctl_table *table)
1792{
1793 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1794 "This will not be supported in the future. To silence this\n"
1795 "warning, set kernel.sysctl_writes_strict = -1\n",
1796 current->comm, table->procname);
1797}
1798
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799/**
1800 * proc_dostring - read a string sysctl
1801 * @table: the sysctl table
1802 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803 * @buffer: the user buffer
1804 * @lenp: the size of the user buffer
1805 * @ppos: file position
1806 *
1807 * Reads/writes a string from/to the user buffer. If the kernel
1808 * buffer provided is not large enough to hold the string, the
1809 * string is truncated. The copied string is %NULL-terminated.
1810 * If the string is being read by the user process, it is copied
1811 * and a newline '\n' is added. It is truncated if the buffer is
1812 * not large enough.
1813 *
1814 * Returns 0 on success.
1815 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001816int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 void __user *buffer, size_t *lenp, loff_t *ppos)
1818{
Kees Cookf4aacea2014-06-06 14:37:19 -07001819 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1820 warn_sysctl_write(table);
1821
Kees Cookf8808302014-06-06 14:37:17 -07001822 return _proc_do_string((char *)(table->data), table->maxlen, write,
1823 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824}
1825
Amerigo Wang00b7c332010-05-05 00:26:45 +00001826static size_t proc_skip_spaces(char **buf)
1827{
1828 size_t ret;
1829 char *tmp = skip_spaces(*buf);
1830 ret = tmp - *buf;
1831 *buf = tmp;
1832 return ret;
1833}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001835static void proc_skip_char(char **buf, size_t *size, const char v)
1836{
1837 while (*size) {
1838 if (**buf != v)
1839 break;
1840 (*size)--;
1841 (*buf)++;
1842 }
1843}
1844
Amerigo Wang00b7c332010-05-05 00:26:45 +00001845#define TMPBUFLEN 22
1846/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001847 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001848 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001849 * @buf: a kernel buffer
1850 * @size: size of the kernel buffer
1851 * @val: this is where the number will be stored
1852 * @neg: set to %TRUE if number is negative
1853 * @perm_tr: a vector which contains the allowed trailers
1854 * @perm_tr_len: size of the perm_tr vector
1855 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001856 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001857 * In case of success %0 is returned and @buf and @size are updated with
1858 * the amount of bytes read. If @tr is non-NULL and a trailing
1859 * character exists (size is non-zero after returning from this
1860 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861 */
1862static int proc_get_long(char **buf, size_t *size,
1863 unsigned long *val, bool *neg,
1864 const char *perm_tr, unsigned perm_tr_len, char *tr)
1865{
1866 int len;
1867 char *p, tmp[TMPBUFLEN];
1868
1869 if (!*size)
1870 return -EINVAL;
1871
1872 len = *size;
1873 if (len > TMPBUFLEN - 1)
1874 len = TMPBUFLEN - 1;
1875
1876 memcpy(tmp, *buf, len);
1877
1878 tmp[len] = 0;
1879 p = tmp;
1880 if (*p == '-' && *size > 1) {
1881 *neg = true;
1882 p++;
1883 } else
1884 *neg = false;
1885 if (!isdigit(*p))
1886 return -EINVAL;
1887
1888 *val = simple_strtoul(p, &p, 0);
1889
1890 len = p - tmp;
1891
1892 /* We don't know if the next char is whitespace thus we may accept
1893 * invalid integers (e.g. 1234...a) or two integers instead of one
1894 * (e.g. 123...1). So lets not allow such large numbers. */
1895 if (len == TMPBUFLEN - 1)
1896 return -EINVAL;
1897
1898 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1899 return -EINVAL;
1900
1901 if (tr && (len < *size))
1902 *tr = *p;
1903
1904 *buf += len;
1905 *size -= len;
1906
1907 return 0;
1908}
1909
1910/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001911 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001912 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001913 * @buf: the user buffer
1914 * @size: the size of the user buffer
1915 * @val: the integer to be converted
1916 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001917 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001918 * In case of success %0 is returned and @buf and @size are updated with
1919 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001920 */
1921static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1922 bool neg)
1923{
1924 int len;
1925 char tmp[TMPBUFLEN], *p = tmp;
1926
1927 sprintf(p, "%s%lu", neg ? "-" : "", val);
1928 len = strlen(tmp);
1929 if (len > *size)
1930 len = *size;
1931 if (copy_to_user(*buf, tmp, len))
1932 return -EFAULT;
1933 *size -= len;
1934 *buf += len;
1935 return 0;
1936}
1937#undef TMPBUFLEN
1938
1939static int proc_put_char(void __user **buf, size_t *size, char c)
1940{
1941 if (*size) {
1942 char __user **buffer = (char __user **)buf;
1943 if (put_user(c, *buffer))
1944 return -EFAULT;
1945 (*size)--, (*buffer)++;
1946 *buf = *buffer;
1947 }
1948 return 0;
1949}
1950
1951static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952 int *valp,
1953 int write, void *data)
1954{
1955 if (write) {
1956 *valp = *negp ? -*lvalp : *lvalp;
1957 } else {
1958 int val = *valp;
1959 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001960 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 *lvalp = (unsigned long)-val;
1962 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00001963 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964 *lvalp = (unsigned long)val;
1965 }
1966 }
1967 return 0;
1968}
1969
Amerigo Wang00b7c332010-05-05 00:26:45 +00001970static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
1971
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001972static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001973 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001974 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00001975 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001976 int write, void *data),
1977 void *data)
1978{
Amerigo Wang00b7c332010-05-05 00:26:45 +00001979 int *i, vleft, first = 1, err = 0;
1980 unsigned long page = 0;
1981 size_t left;
1982 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001983
Amerigo Wang00b7c332010-05-05 00:26:45 +00001984 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985 *lenp = 0;
1986 return 0;
1987 }
1988
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001989 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990 vleft = table->maxlen / sizeof(*i);
1991 left = *lenp;
1992
1993 if (!conv)
1994 conv = do_proc_dointvec_conv;
1995
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001997 if (*ppos) {
1998 switch (sysctl_writes_strict) {
1999 case SYSCTL_WRITES_STRICT:
2000 goto out;
2001 case SYSCTL_WRITES_WARN:
2002 warn_sysctl_write(table);
2003 break;
2004 default:
2005 break;
2006 }
2007 }
2008
Amerigo Wang00b7c332010-05-05 00:26:45 +00002009 if (left > PAGE_SIZE - 1)
2010 left = PAGE_SIZE - 1;
2011 page = __get_free_page(GFP_TEMPORARY);
2012 kbuf = (char *) page;
2013 if (!kbuf)
2014 return -ENOMEM;
2015 if (copy_from_user(kbuf, buffer, left)) {
2016 err = -EFAULT;
2017 goto free;
2018 }
2019 kbuf[left] = 0;
2020 }
2021
2022 for (; left && vleft--; i++, first=0) {
2023 unsigned long lval;
2024 bool neg;
2025
2026 if (write) {
2027 left -= proc_skip_spaces(&kbuf);
2028
J. R. Okajima563b0462010-05-25 16:10:14 -07002029 if (!left)
2030 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002031 err = proc_get_long(&kbuf, &left, &lval, &neg,
2032 proc_wspace_sep,
2033 sizeof(proc_wspace_sep), NULL);
2034 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002036 if (conv(&neg, &lval, i, 1, data)) {
2037 err = -EINVAL;
2038 break;
2039 }
2040 } else {
2041 if (conv(&neg, &lval, i, 0, data)) {
2042 err = -EINVAL;
2043 break;
2044 }
2045 if (!first)
2046 err = proc_put_char(&buffer, &left, '\t');
2047 if (err)
2048 break;
2049 err = proc_put_long(&buffer, &left, lval, neg);
2050 if (err)
2051 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 }
2053 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002054
2055 if (!write && !first && left && !err)
2056 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002057 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002058 left -= proc_skip_spaces(&kbuf);
2059free:
2060 if (write) {
2061 free_page(page);
2062 if (first)
2063 return err ? : -EINVAL;
2064 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002066out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002068 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069}
2070
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002071static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002072 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002073 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002074 int write, void *data),
2075 void *data)
2076{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002077 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002078 buffer, lenp, ppos, conv, data);
2079}
2080
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081/**
2082 * proc_dointvec - read a vector of integers
2083 * @table: the sysctl table
2084 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 * @buffer: the user buffer
2086 * @lenp: the size of the user buffer
2087 * @ppos: file position
2088 *
2089 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2090 * values from/to the user buffer, treated as an ASCII string.
2091 *
2092 * Returns 0 on success.
2093 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002094int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 void __user *buffer, size_t *lenp, loff_t *ppos)
2096{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002097 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 NULL,NULL);
2099}
2100
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002101/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002102 * Taint values can only be increased
2103 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002104 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002105static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002106 void __user *buffer, size_t *lenp, loff_t *ppos)
2107{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002108 struct ctl_table t;
2109 unsigned long tmptaint = get_taint();
2110 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002111
Bastian Blank91fcd412007-04-23 14:41:14 -07002112 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002113 return -EPERM;
2114
Andi Kleen25ddbb12008-10-15 22:01:41 -07002115 t = *table;
2116 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002117 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002118 if (err < 0)
2119 return err;
2120
2121 if (write) {
2122 /*
2123 * Poor man's atomic or. Not worth adding a primitive
2124 * to everyone's atomic.h for this
2125 */
2126 int i;
2127 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2128 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302129 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002130 }
2131 }
2132
2133 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002134}
2135
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002136#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002137static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002138 void __user *buffer, size_t *lenp, loff_t *ppos)
2139{
2140 if (write && !capable(CAP_SYS_ADMIN))
2141 return -EPERM;
2142
2143 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2144}
2145#endif
2146
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147struct do_proc_dointvec_minmax_conv_param {
2148 int *min;
2149 int *max;
2150};
2151
Amerigo Wang00b7c332010-05-05 00:26:45 +00002152static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2153 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 int write, void *data)
2155{
2156 struct do_proc_dointvec_minmax_conv_param *param = data;
2157 if (write) {
2158 int val = *negp ? -*lvalp : *lvalp;
2159 if ((param->min && *param->min > val) ||
2160 (param->max && *param->max < val))
2161 return -EINVAL;
2162 *valp = val;
2163 } else {
2164 int val = *valp;
2165 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002166 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167 *lvalp = (unsigned long)-val;
2168 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002169 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 *lvalp = (unsigned long)val;
2171 }
2172 }
2173 return 0;
2174}
2175
2176/**
2177 * proc_dointvec_minmax - read a vector of integers with min/max values
2178 * @table: the sysctl table
2179 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 * @buffer: the user buffer
2181 * @lenp: the size of the user buffer
2182 * @ppos: file position
2183 *
2184 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2185 * values from/to the user buffer, treated as an ASCII string.
2186 *
2187 * This routine will ensure the values are within the range specified by
2188 * table->extra1 (min) and table->extra2 (max).
2189 *
2190 * Returns 0 on success.
2191 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002192int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193 void __user *buffer, size_t *lenp, loff_t *ppos)
2194{
2195 struct do_proc_dointvec_minmax_conv_param param = {
2196 .min = (int *) table->extra1,
2197 .max = (int *) table->extra2,
2198 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002199 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 do_proc_dointvec_minmax_conv, &param);
2201}
2202
Kees Cook54b50192012-07-30 14:39:18 -07002203static void validate_coredump_safety(void)
2204{
Alex Kelly046d6622012-10-04 17:15:23 -07002205#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002206 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002207 core_pattern[0] != '/' && core_pattern[0] != '|') {
2208 printk(KERN_WARNING "Unsafe core_pattern used with "\
2209 "suid_dumpable=2. Pipe handler or fully qualified "\
2210 "core dump path required.\n");
2211 }
Alex Kelly046d6622012-10-04 17:15:23 -07002212#endif
Kees Cook54b50192012-07-30 14:39:18 -07002213}
2214
2215static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2216 void __user *buffer, size_t *lenp, loff_t *ppos)
2217{
2218 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2219 if (!error)
2220 validate_coredump_safety();
2221 return error;
2222}
2223
Alex Kelly046d6622012-10-04 17:15:23 -07002224#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002225static int proc_dostring_coredump(struct ctl_table *table, int write,
2226 void __user *buffer, size_t *lenp, loff_t *ppos)
2227{
2228 int error = proc_dostring(table, write, buffer, lenp, ppos);
2229 if (!error)
2230 validate_coredump_safety();
2231 return error;
2232}
Alex Kelly046d6622012-10-04 17:15:23 -07002233#endif
Kees Cook54b50192012-07-30 14:39:18 -07002234
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002235static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 void __user *buffer,
2237 size_t *lenp, loff_t *ppos,
2238 unsigned long convmul,
2239 unsigned long convdiv)
2240{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002241 unsigned long *i, *min, *max;
2242 int vleft, first = 1, err = 0;
2243 unsigned long page = 0;
2244 size_t left;
2245 char *kbuf;
2246
2247 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248 *lenp = 0;
2249 return 0;
2250 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002251
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002252 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 min = (unsigned long *) table->extra1;
2254 max = (unsigned long *) table->extra2;
2255 vleft = table->maxlen / sizeof(unsigned long);
2256 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002257
2258 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002259 if (*ppos) {
2260 switch (sysctl_writes_strict) {
2261 case SYSCTL_WRITES_STRICT:
2262 goto out;
2263 case SYSCTL_WRITES_WARN:
2264 warn_sysctl_write(table);
2265 break;
2266 default:
2267 break;
2268 }
2269 }
2270
Amerigo Wang00b7c332010-05-05 00:26:45 +00002271 if (left > PAGE_SIZE - 1)
2272 left = PAGE_SIZE - 1;
2273 page = __get_free_page(GFP_TEMPORARY);
2274 kbuf = (char *) page;
2275 if (!kbuf)
2276 return -ENOMEM;
2277 if (copy_from_user(kbuf, buffer, left)) {
2278 err = -EFAULT;
2279 goto free;
2280 }
2281 kbuf[left] = 0;
2282 }
2283
Eric Dumazet27b3d802010-10-07 12:59:29 -07002284 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002285 unsigned long val;
2286
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002288 bool neg;
2289
2290 left -= proc_skip_spaces(&kbuf);
2291
2292 err = proc_get_long(&kbuf, &left, &val, &neg,
2293 proc_wspace_sep,
2294 sizeof(proc_wspace_sep), NULL);
2295 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 break;
2297 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 continue;
2299 if ((min && val < *min) || (max && val > *max))
2300 continue;
2301 *i = val;
2302 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002303 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002304 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002305 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002306 if (err)
2307 break;
2308 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002309 err = proc_put_long(&buffer, &left, val, false);
2310 if (err)
2311 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 }
2313 }
2314
Amerigo Wang00b7c332010-05-05 00:26:45 +00002315 if (!write && !first && left && !err)
2316 err = proc_put_char(&buffer, &left, '\n');
2317 if (write && !err)
2318 left -= proc_skip_spaces(&kbuf);
2319free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002321 free_page(page);
2322 if (first)
2323 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002326out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002328 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329}
2330
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002331static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002332 void __user *buffer,
2333 size_t *lenp, loff_t *ppos,
2334 unsigned long convmul,
2335 unsigned long convdiv)
2336{
2337 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002338 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002339}
2340
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341/**
2342 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2343 * @table: the sysctl table
2344 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345 * @buffer: the user buffer
2346 * @lenp: the size of the user buffer
2347 * @ppos: file position
2348 *
2349 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2350 * values from/to the user buffer, treated as an ASCII string.
2351 *
2352 * This routine will ensure the values are within the range specified by
2353 * table->extra1 (min) and table->extra2 (max).
2354 *
2355 * Returns 0 on success.
2356 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002357int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 void __user *buffer, size_t *lenp, loff_t *ppos)
2359{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002360 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361}
2362
2363/**
2364 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2365 * @table: the sysctl table
2366 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 * @buffer: the user buffer
2368 * @lenp: the size of the user buffer
2369 * @ppos: file position
2370 *
2371 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2372 * values from/to the user buffer, treated as an ASCII string. The values
2373 * are treated as milliseconds, and converted to jiffies when they are stored.
2374 *
2375 * This routine will ensure the values are within the range specified by
2376 * table->extra1 (min) and table->extra2 (max).
2377 *
2378 * Returns 0 on success.
2379 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002380int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 void __user *buffer,
2382 size_t *lenp, loff_t *ppos)
2383{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002384 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 lenp, ppos, HZ, 1000l);
2386}
2387
2388
Amerigo Wang00b7c332010-05-05 00:26:45 +00002389static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 int *valp,
2391 int write, void *data)
2392{
2393 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002394 if (*lvalp > LONG_MAX / HZ)
2395 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2397 } else {
2398 int val = *valp;
2399 unsigned long lval;
2400 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002401 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 lval = (unsigned long)-val;
2403 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002404 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 lval = (unsigned long)val;
2406 }
2407 *lvalp = lval / HZ;
2408 }
2409 return 0;
2410}
2411
Amerigo Wang00b7c332010-05-05 00:26:45 +00002412static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 int *valp,
2414 int write, void *data)
2415{
2416 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002417 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2418 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2420 } else {
2421 int val = *valp;
2422 unsigned long lval;
2423 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002424 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 lval = (unsigned long)-val;
2426 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002427 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 lval = (unsigned long)val;
2429 }
2430 *lvalp = jiffies_to_clock_t(lval);
2431 }
2432 return 0;
2433}
2434
Amerigo Wang00b7c332010-05-05 00:26:45 +00002435static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 int *valp,
2437 int write, void *data)
2438{
2439 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002440 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2441
2442 if (jif > INT_MAX)
2443 return 1;
2444 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 } else {
2446 int val = *valp;
2447 unsigned long lval;
2448 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002449 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 lval = (unsigned long)-val;
2451 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002452 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 lval = (unsigned long)val;
2454 }
2455 *lvalp = jiffies_to_msecs(lval);
2456 }
2457 return 0;
2458}
2459
2460/**
2461 * proc_dointvec_jiffies - read a vector of integers as seconds
2462 * @table: the sysctl table
2463 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002464 * @buffer: the user buffer
2465 * @lenp: the size of the user buffer
2466 * @ppos: file position
2467 *
2468 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2469 * values from/to the user buffer, treated as an ASCII string.
2470 * The values read are assumed to be in seconds, and are converted into
2471 * jiffies.
2472 *
2473 * Returns 0 on success.
2474 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002475int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 void __user *buffer, size_t *lenp, loff_t *ppos)
2477{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002478 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479 do_proc_dointvec_jiffies_conv,NULL);
2480}
2481
2482/**
2483 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2484 * @table: the sysctl table
2485 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486 * @buffer: the user buffer
2487 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002488 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002489 *
2490 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2491 * values from/to the user buffer, treated as an ASCII string.
2492 * The values read are assumed to be in 1/USER_HZ seconds, and
2493 * are converted into jiffies.
2494 *
2495 * Returns 0 on success.
2496 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002497int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 void __user *buffer, size_t *lenp, loff_t *ppos)
2499{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002500 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 do_proc_dointvec_userhz_jiffies_conv,NULL);
2502}
2503
2504/**
2505 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2506 * @table: the sysctl table
2507 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 * @buffer: the user buffer
2509 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002510 * @ppos: file position
2511 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 *
2513 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2514 * values from/to the user buffer, treated as an ASCII string.
2515 * The values read are assumed to be in 1/1000 seconds, and
2516 * are converted into jiffies.
2517 *
2518 * Returns 0 on success.
2519 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002520int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 void __user *buffer, size_t *lenp, loff_t *ppos)
2522{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002523 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 do_proc_dointvec_ms_jiffies_conv, NULL);
2525}
2526
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002527static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002528 void __user *buffer, size_t *lenp, loff_t *ppos)
2529{
2530 struct pid *new_pid;
2531 pid_t tmp;
2532 int r;
2533
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002534 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002535
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002536 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002537 lenp, ppos, NULL, NULL);
2538 if (r || !write)
2539 return r;
2540
2541 new_pid = find_get_pid(tmp);
2542 if (!new_pid)
2543 return -ESRCH;
2544
2545 put_pid(xchg(&cad_pid, new_pid));
2546 return 0;
2547}
2548
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002549/**
2550 * proc_do_large_bitmap - read/write from/to a large bitmap
2551 * @table: the sysctl table
2552 * @write: %TRUE if this is a write to the sysctl file
2553 * @buffer: the user buffer
2554 * @lenp: the size of the user buffer
2555 * @ppos: file position
2556 *
2557 * The bitmap is stored at table->data and the bitmap length (in bits)
2558 * in table->maxlen.
2559 *
2560 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2561 * large bitmaps may be represented in a compact manner. Writing into
2562 * the file will clear the bitmap then update it with the given input.
2563 *
2564 * Returns 0 on success.
2565 */
2566int proc_do_large_bitmap(struct ctl_table *table, int write,
2567 void __user *buffer, size_t *lenp, loff_t *ppos)
2568{
2569 int err = 0;
2570 bool first = 1;
2571 size_t left = *lenp;
2572 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002573 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002574 unsigned long *tmp_bitmap = NULL;
2575 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2576
WANG Cong122ff242014-05-12 16:04:53 -07002577 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002578 *lenp = 0;
2579 return 0;
2580 }
2581
2582 if (write) {
2583 unsigned long page = 0;
2584 char *kbuf;
2585
2586 if (left > PAGE_SIZE - 1)
2587 left = PAGE_SIZE - 1;
2588
2589 page = __get_free_page(GFP_TEMPORARY);
2590 kbuf = (char *) page;
2591 if (!kbuf)
2592 return -ENOMEM;
2593 if (copy_from_user(kbuf, buffer, left)) {
2594 free_page(page);
2595 return -EFAULT;
2596 }
2597 kbuf[left] = 0;
2598
2599 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2600 GFP_KERNEL);
2601 if (!tmp_bitmap) {
2602 free_page(page);
2603 return -ENOMEM;
2604 }
2605 proc_skip_char(&kbuf, &left, '\n');
2606 while (!err && left) {
2607 unsigned long val_a, val_b;
2608 bool neg;
2609
2610 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2611 sizeof(tr_a), &c);
2612 if (err)
2613 break;
2614 if (val_a >= bitmap_len || neg) {
2615 err = -EINVAL;
2616 break;
2617 }
2618
2619 val_b = val_a;
2620 if (left) {
2621 kbuf++;
2622 left--;
2623 }
2624
2625 if (c == '-') {
2626 err = proc_get_long(&kbuf, &left, &val_b,
2627 &neg, tr_b, sizeof(tr_b),
2628 &c);
2629 if (err)
2630 break;
2631 if (val_b >= bitmap_len || neg ||
2632 val_a > val_b) {
2633 err = -EINVAL;
2634 break;
2635 }
2636 if (left) {
2637 kbuf++;
2638 left--;
2639 }
2640 }
2641
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002642 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002643 first = 0;
2644 proc_skip_char(&kbuf, &left, '\n');
2645 }
2646 free_page(page);
2647 } else {
2648 unsigned long bit_a, bit_b = 0;
2649
2650 while (left) {
2651 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2652 if (bit_a >= bitmap_len)
2653 break;
2654 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2655 bit_a + 1) - 1;
2656
2657 if (!first) {
2658 err = proc_put_char(&buffer, &left, ',');
2659 if (err)
2660 break;
2661 }
2662 err = proc_put_long(&buffer, &left, bit_a, false);
2663 if (err)
2664 break;
2665 if (bit_a != bit_b) {
2666 err = proc_put_char(&buffer, &left, '-');
2667 if (err)
2668 break;
2669 err = proc_put_long(&buffer, &left, bit_b, false);
2670 if (err)
2671 break;
2672 }
2673
2674 first = 0; bit_b++;
2675 }
2676 if (!err)
2677 err = proc_put_char(&buffer, &left, '\n');
2678 }
2679
2680 if (!err) {
2681 if (write) {
2682 if (*ppos)
2683 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2684 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002685 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002686 }
2687 kfree(tmp_bitmap);
2688 *lenp -= left;
2689 *ppos += *lenp;
2690 return 0;
2691 } else {
2692 kfree(tmp_bitmap);
2693 return err;
2694 }
2695}
2696
Jovi Zhang55610502011-01-12 17:00:45 -08002697#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002698
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002699int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002700 void __user *buffer, size_t *lenp, loff_t *ppos)
2701{
2702 return -ENOSYS;
2703}
2704
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002705int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 void __user *buffer, size_t *lenp, loff_t *ppos)
2707{
2708 return -ENOSYS;
2709}
2710
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002711int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 void __user *buffer, size_t *lenp, loff_t *ppos)
2713{
2714 return -ENOSYS;
2715}
2716
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002717int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 void __user *buffer, size_t *lenp, loff_t *ppos)
2719{
2720 return -ENOSYS;
2721}
2722
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002723int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724 void __user *buffer, size_t *lenp, loff_t *ppos)
2725{
2726 return -ENOSYS;
2727}
2728
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002729int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 void __user *buffer, size_t *lenp, loff_t *ppos)
2731{
2732 return -ENOSYS;
2733}
2734
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002735int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736 void __user *buffer, size_t *lenp, loff_t *ppos)
2737{
2738 return -ENOSYS;
2739}
2740
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002741int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742 void __user *buffer,
2743 size_t *lenp, loff_t *ppos)
2744{
2745 return -ENOSYS;
2746}
2747
2748
Jovi Zhang55610502011-01-12 17:00:45 -08002749#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751/*
2752 * No sense putting this after each symbol definition, twice,
2753 * exception granted :-)
2754 */
2755EXPORT_SYMBOL(proc_dointvec);
2756EXPORT_SYMBOL(proc_dointvec_jiffies);
2757EXPORT_SYMBOL(proc_dointvec_minmax);
2758EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2759EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2760EXPORT_SYMBOL(proc_dostring);
2761EXPORT_SYMBOL(proc_doulongvec_minmax);
2762EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);