Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
Christoph Hellwig | e2e40f2 | 2015-02-22 08:58:50 -0800 | [diff] [blame] | 22 | #include <linux/aio.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/mm.h> |
| 24 | #include <linux/swap.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/sysctl.h> |
Akinobu Mita | 5a04cca | 2012-03-28 14:42:50 -0700 | [diff] [blame] | 27 | #include <linux/bitmap.h> |
Dave Young | d33ed52 | 2010-03-10 15:23:59 -0800 | [diff] [blame] | 28 | #include <linux/signal.h> |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 29 | #include <linux/printk.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/proc_fs.h> |
Andrew Morgan | 72c2d58 | 2007-10-18 03:05:59 -0700 | [diff] [blame] | 31 | #include <linux/security.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/ctype.h> |
Vegard Nossum | dfec072 | 2008-04-04 00:51:41 +0200 | [diff] [blame] | 33 | #include <linux/kmemcheck.h> |
Steven Rostedt | fd4b616 | 2012-07-30 14:42:48 -0700 | [diff] [blame] | 34 | #include <linux/kmemleak.h> |
Adrian Bunk | 62239ac | 2007-07-17 04:03:45 -0700 | [diff] [blame] | 35 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/init.h> |
| 37 | #include <linux/kernel.h> |
Kay Sievers | 0296b22 | 2005-11-11 05:33:52 +0100 | [diff] [blame] | 38 | #include <linux/kobject.h> |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 39 | #include <linux/net.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/sysrq.h> |
| 41 | #include <linux/highuid.h> |
| 42 | #include <linux/writeback.h> |
Ingo Molnar | 3fff4c4 | 2009-09-22 16:18:09 +0200 | [diff] [blame] | 43 | #include <linux/ratelimit.h> |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 44 | #include <linux/compaction.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <linux/hugetlb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <linux/initrd.h> |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 47 | #include <linux/key.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <linux/times.h> |
| 49 | #include <linux/limits.h> |
| 50 | #include <linux/dcache.h> |
Alexey Dobriyan | 6e00670 | 2010-01-20 22:27:56 +0200 | [diff] [blame] | 51 | #include <linux/dnotify.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include <linux/syscalls.h> |
Adrian Bunk | c748e13 | 2008-07-23 21:27:03 -0700 | [diff] [blame] | 53 | #include <linux/vmstat.h> |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 54 | #include <linux/nfs_fs.h> |
| 55 | #include <linux/acpi.h> |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 56 | #include <linux/reboot.h> |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 57 | #include <linux/ftrace.h> |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 58 | #include <linux/perf_event.h> |
Masami Hiramatsu | b2be84d | 2010-02-25 08:34:15 -0500 | [diff] [blame] | 59 | #include <linux/kprobes.h> |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 60 | #include <linux/pipe_fs_i.h> |
David Rientjes | 8e4228e | 2010-08-09 17:18:56 -0700 | [diff] [blame] | 61 | #include <linux/oom.h> |
Eric Paris | 17f60a7 | 2011-04-01 17:07:50 -0400 | [diff] [blame] | 62 | #include <linux/kmod.h> |
Dan Ballard | 73efc03 | 2011-10-31 17:11:20 -0700 | [diff] [blame] | 63 | #include <linux/capability.h> |
Al Viro | 4040153 | 2012-02-13 03:58:52 +0000 | [diff] [blame] | 64 | #include <linux/binfmts.h> |
Clark Williams | cf4aebc2 | 2013-02-07 09:46:59 -0600 | [diff] [blame] | 65 | #include <linux/sched/sysctl.h> |
Kees Cook | 7984754 | 2014-01-23 15:55:59 -0800 | [diff] [blame] | 66 | #include <linux/kexec.h> |
Alexei Starovoitov | 1be7f75 | 2015-10-07 22:23:21 -0700 | [diff] [blame] | 67 | #include <linux/bpf.h> |
Eric W. Biederman | d292168 | 2016-09-28 00:27:17 -0500 | [diff] [blame] | 68 | #include <linux/mount.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | #include <asm/uaccess.h> |
| 71 | #include <asm/processor.h> |
| 72 | |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 73 | #ifdef CONFIG_X86 |
| 74 | #include <asm/nmi.h> |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 75 | #include <asm/stacktrace.h> |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 76 | #include <asm/io.h> |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 77 | #endif |
David Howells | d550bbd | 2012-03-28 18:30:03 +0100 | [diff] [blame] | 78 | #ifdef CONFIG_SPARC |
| 79 | #include <asm/setup.h> |
| 80 | #endif |
Dave Young | c55b7c3 | 2010-03-10 15:24:08 -0800 | [diff] [blame] | 81 | #ifdef CONFIG_BSD_PROCESS_ACCT |
| 82 | #include <linux/acct.h> |
| 83 | #endif |
Dave Young | 4f0e056 | 2010-03-10 15:24:09 -0800 | [diff] [blame] | 84 | #ifdef CONFIG_RT_MUTEXES |
| 85 | #include <linux/rtmutex.h> |
| 86 | #endif |
Dave Young | 2edf5e4 | 2010-03-10 15:24:10 -0800 | [diff] [blame] | 87 | #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) |
| 88 | #include <linux/lockdep.h> |
| 89 | #endif |
Dave Young | 15485a4 | 2010-03-10 15:24:07 -0800 | [diff] [blame] | 90 | #ifdef CONFIG_CHR_DEV_SG |
| 91 | #include <scsi/sg.h> |
| 92 | #endif |
Andi Kleen | 29cbc78 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 93 | |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 94 | #ifdef CONFIG_LOCKUP_DETECTOR |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 95 | #include <linux/nmi.h> |
| 96 | #endif |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #if defined(CONFIG_SYSCTL) |
| 99 | |
| 100 | /* External variables not in a header file. */ |
Daniel Micay | 15169fa | 2017-05-16 17:51:48 -0400 | [diff] [blame] | 101 | #ifdef CONFIG_USB |
| 102 | extern int deny_new_usb; |
| 103 | #endif |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 104 | extern int suid_dumpable; |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 105 | #ifdef CONFIG_COREDUMP |
| 106 | extern int core_uses_pid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | extern char core_pattern[]; |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 108 | extern unsigned int core_pipe_limit; |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 109 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | extern int pid_max; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | extern int pid_max_min, pid_max_max; |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 112 | extern int percpu_pagelist_fraction; |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 113 | extern int latencytop_enabled; |
Alexey Dobriyan | 9b80a18 | 2016-09-02 00:38:52 +0300 | [diff] [blame] | 114 | extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max; |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 115 | #ifndef CONFIG_MMU |
| 116 | extern int sysctl_nr_trim_pages; |
| 117 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 119 | /* Constants used for minimum and maximum */ |
Don Zickus | 2508ce1 | 2010-05-07 17:11:46 -0400 | [diff] [blame] | 120 | #ifdef CONFIG_LOCKUP_DETECTOR |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 121 | static int sixty = 60; |
| 122 | #endif |
| 123 | |
Aaron Tomlin | 270750db | 2014-01-20 17:34:13 +0000 | [diff] [blame] | 124 | static int __maybe_unused neg_one = -1; |
| 125 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 126 | static int zero; |
Linus Torvalds | cd5f9a4 | 2009-04-06 13:38:46 -0700 | [diff] [blame] | 127 | static int __maybe_unused one = 1; |
| 128 | static int __maybe_unused two = 2; |
Syed Rameez Mustafa | 084075b | 2016-08-31 16:54:12 -0700 | [diff] [blame] | 129 | static int __maybe_unused three = 3; |
Dave Hansen | 5509a5d | 2014-04-03 14:48:19 -0700 | [diff] [blame] | 130 | static int __maybe_unused four = 4; |
Will Deacon | 3141fcc | 2019-04-05 18:39:38 -0700 | [diff] [blame] | 131 | static unsigned long zero_ul; |
Sven Wegener | fc3501d | 2009-02-11 13:04:23 -0800 | [diff] [blame] | 132 | static unsigned long one_ul = 1; |
Christian Brauner | 6b65c26 | 2019-03-07 16:29:43 -0800 | [diff] [blame] | 133 | static unsigned long long_max = LONG_MAX; |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 134 | static int one_hundred = 100; |
Abhijeet Dharmapurikar | 53ee423 | 2018-06-15 09:34:34 -0700 | [diff] [blame] | 135 | static int __maybe_unused one_thousand = 1000; |
Satya Durga Srinivasu Prabhala | c18b403 | 2018-04-17 11:21:23 -0700 | [diff] [blame] | 136 | #ifdef CONFIG_SCHED_WALT |
| 137 | static int two_million = 2000000; |
| 138 | #endif |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 139 | #ifdef CONFIG_PRINTK |
| 140 | static int ten_thousand = 10000; |
| 141 | #endif |
Arnaldo Carvalho de Melo | c5dfd78 | 2016-04-21 12:28:50 -0300 | [diff] [blame] | 142 | #ifdef CONFIG_PERF_EVENTS |
| 143 | static int six_hundred_forty_kb = 640 * 1024; |
| 144 | #endif |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 145 | |
Andrea Righi | 9e4a5bd | 2009-04-30 15:08:57 -0700 | [diff] [blame] | 146 | /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ |
| 147 | static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; |
| 148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ |
| 150 | static int maxolduid = 65535; |
| 151 | static int minolduid; |
| 152 | |
| 153 | static int ngroups_max = NGROUPS_MAX; |
Dan Ballard | 73efc03 | 2011-10-31 17:11:20 -0700 | [diff] [blame] | 154 | static const int cap_last_cap = CAP_LAST_CAP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Liu Hua | 80df284 | 2014-04-07 15:38:57 -0700 | [diff] [blame] | 156 | /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */ |
| 157 | #ifdef CONFIG_DETECT_HUNG_TASK |
| 158 | static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); |
| 159 | #endif |
| 160 | |
Dave Young | d14f172 | 2010-02-25 20:28:57 -0500 | [diff] [blame] | 161 | #ifdef CONFIG_INOTIFY_USER |
| 162 | #include <linux/inotify.h> |
| 163 | #endif |
David S. Miller | 72c57ed | 2008-09-11 23:29:54 -0700 | [diff] [blame] | 164 | #ifdef CONFIG_SPARC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | #endif |
| 166 | |
| 167 | #ifdef __hppa__ |
| 168 | extern int pwrsw_enabled; |
Vineet Gupta | bf14e3b | 2013-01-18 15:12:24 +0530 | [diff] [blame] | 169 | #endif |
| 170 | |
| 171 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | extern int unaligned_enabled; |
| 173 | #endif |
| 174 | |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 175 | #ifdef CONFIG_IA64 |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 176 | extern int unaligned_dump_stack; |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 177 | #endif |
| 178 | |
Vineet Gupta | b6fca72 | 2013-01-09 20:06:28 +0530 | [diff] [blame] | 179 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN |
| 180 | extern int no_unaligned_warning; |
| 181 | #endif |
| 182 | |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 183 | #ifdef CONFIG_PROC_SYSCTL |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 184 | |
| 185 | #define SYSCTL_WRITES_LEGACY -1 |
| 186 | #define SYSCTL_WRITES_WARN 0 |
| 187 | #define SYSCTL_WRITES_STRICT 1 |
| 188 | |
Kees Cook | 41662f5 | 2016-01-20 15:00:45 -0800 | [diff] [blame] | 189 | static int sysctl_writes_strict = SYSCTL_WRITES_STRICT; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 190 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 191 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 192 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 193 | static int proc_taint(struct ctl_table *table, int write, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 194 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 195 | #endif |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 196 | |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 197 | #ifdef CONFIG_PRINTK |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 198 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 199 | void __user *buffer, size_t *lenp, loff_t *ppos); |
| 200 | #endif |
| 201 | |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 202 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, |
| 203 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 204 | #ifdef CONFIG_COREDUMP |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 205 | static int proc_dostring_coredump(struct ctl_table *table, int write, |
| 206 | void __user *buffer, size_t *lenp, loff_t *ppos); |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 207 | #endif |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 208 | |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 209 | #ifdef CONFIG_MAGIC_SYSRQ |
Andy Whitcroft | 8c6a98b | 2011-01-24 09:31:38 -0800 | [diff] [blame] | 210 | /* Note: sysrq code uses it's own private copy */ |
Ben Hutchings | 8eaede4 | 2013-10-07 01:05:46 +0100 | [diff] [blame] | 211 | static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 212 | |
Joe Perches | 6f8fd1d | 2014-06-06 14:38:08 -0700 | [diff] [blame] | 213 | static int sysrq_sysctl_handler(struct ctl_table *table, int write, |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 214 | void __user *buffer, size_t *lenp, |
| 215 | loff_t *ppos) |
| 216 | { |
| 217 | int error; |
| 218 | |
| 219 | error = proc_dointvec(table, write, buffer, lenp, ppos); |
| 220 | if (error) |
| 221 | return error; |
| 222 | |
| 223 | if (write) |
| 224 | sysrq_toggle_support(__sysrq_enabled); |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | #endif |
| 230 | |
Daniel Borkmann | b6ef4bc | 2021-05-11 22:35:17 +0200 | [diff] [blame] | 231 | #ifdef CONFIG_BPF_SYSCALL |
Josh Poimboeuf | 6481835 | 2022-02-18 11:49:08 -0800 | [diff] [blame] | 232 | |
| 233 | void __weak unpriv_ebpf_notify(int new_state) |
| 234 | { |
| 235 | } |
| 236 | |
Daniel Borkmann | b6ef4bc | 2021-05-11 22:35:17 +0200 | [diff] [blame] | 237 | static int bpf_unpriv_handler(struct ctl_table *table, int write, |
| 238 | void *buffer, size_t *lenp, loff_t *ppos) |
| 239 | { |
| 240 | int ret, unpriv_enable = *(int *)table->data; |
| 241 | bool locked_state = unpriv_enable == 1; |
| 242 | struct ctl_table tmp = *table; |
| 243 | |
| 244 | if (write && !capable(CAP_SYS_ADMIN)) |
| 245 | return -EPERM; |
| 246 | |
| 247 | tmp.data = &unpriv_enable; |
| 248 | ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
| 249 | if (write && !ret) { |
| 250 | if (locked_state && unpriv_enable != 1) |
| 251 | return -EPERM; |
| 252 | *(int *)table->data = unpriv_enable; |
| 253 | } |
Josh Poimboeuf | 6481835 | 2022-02-18 11:49:08 -0800 | [diff] [blame] | 254 | |
| 255 | unpriv_ebpf_notify(unpriv_enable); |
| 256 | |
Daniel Borkmann | b6ef4bc | 2021-05-11 22:35:17 +0200 | [diff] [blame] | 257 | return ret; |
| 258 | } |
| 259 | #endif |
| 260 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 261 | static struct ctl_table kern_table[]; |
| 262 | static struct ctl_table vm_table[]; |
| 263 | static struct ctl_table fs_table[]; |
| 264 | static struct ctl_table debug_table[]; |
| 265 | static struct ctl_table dev_table[]; |
| 266 | extern struct ctl_table random_table[]; |
Davide Libenzi | 7ef9964 | 2008-12-01 13:13:55 -0800 | [diff] [blame] | 267 | #ifdef CONFIG_EPOLL |
| 268 | extern struct ctl_table epoll_table[]; |
| 269 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
| 272 | int sysctl_legacy_va_layout; |
| 273 | #endif |
| 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | /* The default sysctl tables: */ |
| 276 | |
Eric W. Biederman | de4e83bd | 2012-01-06 03:34:20 -0800 | [diff] [blame] | 277 | static struct ctl_table sysctl_base_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | .procname = "kernel", |
| 280 | .mode = 0555, |
| 281 | .child = kern_table, |
| 282 | }, |
| 283 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | .procname = "vm", |
| 285 | .mode = 0555, |
| 286 | .child = vm_table, |
| 287 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | .procname = "fs", |
| 290 | .mode = 0555, |
| 291 | .child = fs_table, |
| 292 | }, |
| 293 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | .procname = "debug", |
| 295 | .mode = 0555, |
| 296 | .child = debug_table, |
| 297 | }, |
| 298 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | .procname = "dev", |
| 300 | .mode = 0555, |
| 301 | .child = dev_table, |
| 302 | }, |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 303 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | }; |
| 305 | |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 306 | #ifdef CONFIG_SCHED_DEBUG |
Eric Dumazet | 73c4efd | 2007-12-18 15:21:13 +0100 | [diff] [blame] | 307 | static int min_sched_granularity_ns = 100000; /* 100 usecs */ |
| 308 | static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
| 309 | static int min_wakeup_granularity_ns; /* 0 usecs */ |
| 310 | static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 311 | #ifdef CONFIG_SMP |
Christian Ehrhardt | 1983a92 | 2009-11-30 12:16:47 +0100 | [diff] [blame] | 312 | static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; |
| 313 | static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 314 | #endif /* CONFIG_SMP */ |
| 315 | #endif /* CONFIG_SCHED_DEBUG */ |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 316 | |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 317 | #ifdef CONFIG_COMPACTION |
| 318 | static int min_extfrag_threshold; |
| 319 | static int max_extfrag_threshold = 1000; |
| 320 | #endif |
| 321 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 322 | static struct ctl_table kern_table[] = { |
Mike Galbraith | 2bba22c | 2009-09-09 15:41:37 +0200 | [diff] [blame] | 323 | { |
Mike Galbraith | 2bba22c | 2009-09-09 15:41:37 +0200 | [diff] [blame] | 324 | .procname = "sched_child_runs_first", |
| 325 | .data = &sysctl_sched_child_runs_first, |
| 326 | .maxlen = sizeof(unsigned int), |
| 327 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 328 | .proc_handler = proc_dointvec, |
Mike Galbraith | 2bba22c | 2009-09-09 15:41:37 +0200 | [diff] [blame] | 329 | }, |
Pavankumar Kondeti | 97f08d4 | 2018-01-09 11:02:30 +0530 | [diff] [blame] | 330 | #if defined(CONFIG_PREEMPT_TRACER) || defined(CONFIG_IRQSOFF_TRACER) |
| 331 | { |
| 332 | .procname = "preemptoff_tracing_threshold_ns", |
| 333 | .data = &sysctl_preemptoff_tracing_threshold_ns, |
| 334 | .maxlen = sizeof(unsigned int), |
| 335 | .mode = 0644, |
| 336 | .proc_handler = proc_dointvec, |
| 337 | }, |
Pavankumar Kondeti | 0d2621b | 2018-03-26 15:56:26 +0530 | [diff] [blame] | 338 | { |
| 339 | .procname = "irqsoff_tracing_threshold_ns", |
| 340 | .data = &sysctl_irqsoff_tracing_threshold_ns, |
| 341 | .maxlen = sizeof(unsigned int), |
| 342 | .mode = 0644, |
| 343 | .proc_handler = proc_dointvec, |
| 344 | }, |
Pavankumar Kondeti | 97f08d4 | 2018-01-09 11:02:30 +0530 | [diff] [blame] | 345 | #endif |
Joonwoo Park | f7d6cd4 | 2017-01-17 15:19:43 -0800 | [diff] [blame] | 346 | #ifdef CONFIG_SCHED_WALT |
| 347 | { |
| 348 | .procname = "sched_cpu_high_irqload", |
| 349 | .data = &sysctl_sched_cpu_high_irqload, |
| 350 | .maxlen = sizeof(unsigned int), |
| 351 | .mode = 0644, |
| 352 | .proc_handler = proc_dointvec, |
| 353 | }, |
Joonwoo Park | 6f18847 | 2017-06-16 11:32:17 -0700 | [diff] [blame] | 354 | { |
| 355 | .procname = "sched_group_upmigrate", |
| 356 | .data = &sysctl_sched_group_upmigrate_pct, |
| 357 | .maxlen = sizeof(unsigned int), |
| 358 | .mode = 0644, |
Joonwoo Park | 6f18847 | 2017-06-16 11:32:17 -0700 | [diff] [blame] | 359 | .proc_handler = walt_proc_update_handler, |
Joonwoo Park | 6f18847 | 2017-06-16 11:32:17 -0700 | [diff] [blame] | 360 | .extra1 = &sysctl_sched_group_downmigrate_pct, |
| 361 | }, |
| 362 | { |
| 363 | .procname = "sched_group_downmigrate", |
| 364 | .data = &sysctl_sched_group_downmigrate_pct, |
| 365 | .maxlen = sizeof(unsigned int), |
| 366 | .mode = 0644, |
Joonwoo Park | 6f18847 | 2017-06-16 11:32:17 -0700 | [diff] [blame] | 367 | .proc_handler = walt_proc_update_handler, |
Joonwoo Park | 6f18847 | 2017-06-16 11:32:17 -0700 | [diff] [blame] | 368 | .extra1 = &zero, |
| 369 | .extra2 = &sysctl_sched_group_upmigrate_pct, |
| 370 | }, |
Pavankumar Kondeti | d0b9bfb | 2018-01-11 13:46:34 +0530 | [diff] [blame] | 371 | { |
| 372 | .procname = "sched_boost", |
| 373 | .data = &sysctl_sched_boost, |
| 374 | .maxlen = sizeof(unsigned int), |
| 375 | .mode = 0644, |
| 376 | .proc_handler = sched_boost_handler, |
| 377 | .extra1 = &zero, |
| 378 | .extra2 = &three, |
| 379 | }, |
Pavankumar Kondeti | 4e13d11 | 2018-01-25 01:12:08 +0530 | [diff] [blame] | 380 | { |
| 381 | .procname = "sched_walt_rotate_big_tasks", |
| 382 | .data = &sysctl_sched_walt_rotate_big_tasks, |
| 383 | .maxlen = sizeof(unsigned int), |
| 384 | .mode = 0644, |
| 385 | .proc_handler = proc_dointvec_minmax, |
| 386 | .extra1 = &zero, |
| 387 | .extra2 = &one, |
| 388 | }, |
Lingutla Chandrasekhar | 57eb071 | 2018-03-12 10:20:08 +0530 | [diff] [blame] | 389 | { |
| 390 | .procname = "sched_initial_task_util", |
| 391 | .data = &sysctl_sched_init_task_load_pct, |
| 392 | .maxlen = sizeof(unsigned int), |
| 393 | .mode = 0644, |
| 394 | .proc_handler = proc_dointvec, |
| 395 | }, |
Abhijeet Dharmapurikar | 53ee423 | 2018-06-15 09:34:34 -0700 | [diff] [blame] | 396 | { |
| 397 | .procname = "sched_min_task_util_for_boost_colocation", |
| 398 | .data = &sysctl_sched_min_task_util_for_boost_colocation, |
| 399 | .maxlen = sizeof(unsigned int), |
| 400 | .mode = 0644, |
| 401 | .proc_handler = proc_dointvec_minmax, |
| 402 | .extra1 = &zero, |
| 403 | .extra2 = &one_thousand, |
| 404 | }, |
Satya Durga Srinivasu Prabhala | c18b403 | 2018-04-17 11:21:23 -0700 | [diff] [blame] | 405 | { |
| 406 | .procname = "sched_little_cluster_coloc_fmin_khz", |
| 407 | .data = &sysctl_sched_little_cluster_coloc_fmin_khz, |
| 408 | .maxlen = sizeof(unsigned int), |
| 409 | .mode = 0644, |
| 410 | .proc_handler = sched_little_cluster_coloc_fmin_khz_handler, |
| 411 | .extra1 = &zero, |
| 412 | .extra2 = &two_million, |
| 413 | }, |
Joonwoo Park | f7d6cd4 | 2017-01-17 15:19:43 -0800 | [diff] [blame] | 414 | #endif |
Pavankumar Kondeti | d0b9bfb | 2018-01-11 13:46:34 +0530 | [diff] [blame] | 415 | { |
| 416 | .procname = "sched_upmigrate", |
| 417 | .data = &sysctl_sched_capacity_margin, |
| 418 | .maxlen = sizeof(unsigned int), |
| 419 | .mode = 0644, |
| 420 | .proc_handler = sched_updown_migrate_handler, |
| 421 | }, |
| 422 | { |
| 423 | .procname = "sched_downmigrate", |
| 424 | .data = &sysctl_sched_capacity_margin_down, |
| 425 | .maxlen = sizeof(unsigned int), |
| 426 | .mode = 0644, |
| 427 | .proc_handler = sched_updown_migrate_handler, |
| 428 | }, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 429 | #ifdef CONFIG_SCHED_DEBUG |
| 430 | { |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 431 | .procname = "sched_min_granularity_ns", |
| 432 | .data = &sysctl_sched_min_granularity, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 433 | .maxlen = sizeof(unsigned int), |
| 434 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 435 | .proc_handler = sched_proc_update_handler, |
Peter Zijlstra | b2be5e9 | 2007-11-09 22:39:37 +0100 | [diff] [blame] | 436 | .extra1 = &min_sched_granularity_ns, |
| 437 | .extra2 = &max_sched_granularity_ns, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 438 | }, |
| 439 | { |
Peter Zijlstra | 2180508 | 2007-08-25 18:41:53 +0200 | [diff] [blame] | 440 | .procname = "sched_latency_ns", |
| 441 | .data = &sysctl_sched_latency, |
| 442 | .maxlen = sizeof(unsigned int), |
| 443 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 444 | .proc_handler = sched_proc_update_handler, |
Peter Zijlstra | 2180508 | 2007-08-25 18:41:53 +0200 | [diff] [blame] | 445 | .extra1 = &min_sched_granularity_ns, |
| 446 | .extra2 = &max_sched_granularity_ns, |
| 447 | }, |
| 448 | { |
Dietmar Eggemann | ea5a7f2 | 2017-01-13 13:51:24 +0000 | [diff] [blame] | 449 | .procname = "sched_sync_hint_enable", |
| 450 | .data = &sysctl_sched_sync_hint_enable, |
Juri Lelli | 1931b93 | 2016-07-29 14:04:11 +0100 | [diff] [blame] | 451 | .maxlen = sizeof(unsigned int), |
| 452 | .mode = 0644, |
| 453 | .proc_handler = proc_dointvec, |
| 454 | }, |
| 455 | { |
Srinath Sridharan | bf47bdd | 2016-07-14 09:57:29 +0100 | [diff] [blame] | 456 | .procname = "sched_cstate_aware", |
| 457 | .data = &sysctl_sched_cstate_aware, |
| 458 | .maxlen = sizeof(unsigned int), |
| 459 | .mode = 0644, |
| 460 | .proc_handler = proc_dointvec, |
| 461 | }, |
| 462 | { |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 463 | .procname = "sched_wakeup_granularity_ns", |
| 464 | .data = &sysctl_sched_wakeup_granularity, |
| 465 | .maxlen = sizeof(unsigned int), |
| 466 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 467 | .proc_handler = sched_proc_update_handler, |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 468 | .extra1 = &min_wakeup_granularity_ns, |
| 469 | .extra2 = &max_wakeup_granularity_ns, |
| 470 | }, |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 471 | #ifdef CONFIG_SMP |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 472 | { |
Christian Ehrhardt | 1983a92 | 2009-11-30 12:16:47 +0100 | [diff] [blame] | 473 | .procname = "sched_tunable_scaling", |
| 474 | .data = &sysctl_sched_tunable_scaling, |
| 475 | .maxlen = sizeof(enum sched_tunable_scaling), |
| 476 | .mode = 0644, |
Linus Torvalds | 702a7c7 | 2009-12-12 11:34:10 -0800 | [diff] [blame] | 477 | .proc_handler = sched_proc_update_handler, |
Christian Ehrhardt | 1983a92 | 2009-11-30 12:16:47 +0100 | [diff] [blame] | 478 | .extra1 = &min_sched_tunable_scaling, |
| 479 | .extra2 = &max_sched_tunable_scaling, |
Peter Zijlstra | 2398f2c | 2008-06-27 13:41:35 +0200 | [diff] [blame] | 480 | }, |
| 481 | { |
Namhyung Kim | d00535d | 2012-08-16 11:15:30 +0900 | [diff] [blame] | 482 | .procname = "sched_migration_cost_ns", |
Ingo Molnar | da84d96 | 2007-10-15 17:00:18 +0200 | [diff] [blame] | 483 | .data = &sysctl_sched_migration_cost, |
| 484 | .maxlen = sizeof(unsigned int), |
| 485 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 486 | .proc_handler = proc_dointvec, |
Ingo Molnar | da84d96 | 2007-10-15 17:00:18 +0200 | [diff] [blame] | 487 | }, |
Peter Zijlstra | b82d9fd | 2007-11-09 22:39:39 +0100 | [diff] [blame] | 488 | { |
Peter Zijlstra | b82d9fd | 2007-11-09 22:39:39 +0100 | [diff] [blame] | 489 | .procname = "sched_nr_migrate", |
| 490 | .data = &sysctl_sched_nr_migrate, |
| 491 | .maxlen = sizeof(unsigned int), |
Peter Zijlstra | fa85ae2 | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 492 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 493 | .proc_handler = proc_dointvec, |
Peter Zijlstra | fa85ae2 | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 494 | }, |
Arun R Bharadwaj | cd1bb94 | 2009-04-16 12:15:34 +0530 | [diff] [blame] | 495 | { |
Namhyung Kim | d00535d | 2012-08-16 11:15:30 +0900 | [diff] [blame] | 496 | .procname = "sched_time_avg_ms", |
Peter Zijlstra | e9e9250 | 2009-09-01 10:34:37 +0200 | [diff] [blame] | 497 | .data = &sysctl_sched_time_avg, |
| 498 | .maxlen = sizeof(unsigned int), |
| 499 | .mode = 0644, |
Pavankumar Kondeti | 1293949 | 2017-02-02 14:24:34 +0530 | [diff] [blame] | 500 | .proc_handler = proc_dointvec_minmax, |
| 501 | .extra1 = &one, |
Peter Zijlstra | e9e9250 | 2009-09-01 10:34:37 +0200 | [diff] [blame] | 502 | }, |
| 503 | { |
Namhyung Kim | d00535d | 2012-08-16 11:15:30 +0900 | [diff] [blame] | 504 | .procname = "sched_shares_window_ns", |
Paul Turner | a7a4f8a | 2010-11-15 15:47:06 -0800 | [diff] [blame] | 505 | .data = &sysctl_sched_shares_window, |
| 506 | .maxlen = sizeof(unsigned int), |
| 507 | .mode = 0644, |
| 508 | .proc_handler = proc_dointvec, |
| 509 | }, |
Mel Gorman | cb25176 | 2016-02-05 09:08:36 +0000 | [diff] [blame] | 510 | #ifdef CONFIG_SCHEDSTATS |
| 511 | { |
| 512 | .procname = "sched_schedstats", |
| 513 | .data = NULL, |
| 514 | .maxlen = sizeof(unsigned int), |
| 515 | .mode = 0644, |
| 516 | .proc_handler = sysctl_schedstats, |
| 517 | .extra1 = &zero, |
| 518 | .extra2 = &one, |
| 519 | }, |
| 520 | #endif /* CONFIG_SCHEDSTATS */ |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 521 | #endif /* CONFIG_SMP */ |
| 522 | #ifdef CONFIG_NUMA_BALANCING |
| 523 | { |
Peter Zijlstra | 4b96a29 | 2012-10-25 14:16:47 +0200 | [diff] [blame] | 524 | .procname = "numa_balancing_scan_delay_ms", |
| 525 | .data = &sysctl_numa_balancing_scan_delay, |
| 526 | .maxlen = sizeof(unsigned int), |
| 527 | .mode = 0644, |
| 528 | .proc_handler = proc_dointvec, |
| 529 | }, |
| 530 | { |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 531 | .procname = "numa_balancing_scan_period_min_ms", |
| 532 | .data = &sysctl_numa_balancing_scan_period_min, |
| 533 | .maxlen = sizeof(unsigned int), |
| 534 | .mode = 0644, |
| 535 | .proc_handler = proc_dointvec, |
| 536 | }, |
| 537 | { |
| 538 | .procname = "numa_balancing_scan_period_max_ms", |
| 539 | .data = &sysctl_numa_balancing_scan_period_max, |
| 540 | .maxlen = sizeof(unsigned int), |
| 541 | .mode = 0644, |
| 542 | .proc_handler = proc_dointvec, |
| 543 | }, |
Peter Zijlstra | 6e5fb22 | 2012-10-25 14:16:45 +0200 | [diff] [blame] | 544 | { |
| 545 | .procname = "numa_balancing_scan_size_mb", |
| 546 | .data = &sysctl_numa_balancing_scan_size, |
| 547 | .maxlen = sizeof(unsigned int), |
| 548 | .mode = 0644, |
Kirill Tkhai | 6419265 | 2014-10-16 14:39:37 +0400 | [diff] [blame] | 549 | .proc_handler = proc_dointvec_minmax, |
| 550 | .extra1 = &one, |
Peter Zijlstra | 6e5fb22 | 2012-10-25 14:16:45 +0200 | [diff] [blame] | 551 | }, |
Mel Gorman | 3a7053b | 2013-10-07 11:29:00 +0100 | [diff] [blame] | 552 | { |
Andi Kleen | 54a43d5 | 2014-01-23 15:53:13 -0800 | [diff] [blame] | 553 | .procname = "numa_balancing", |
| 554 | .data = NULL, /* filled in by handler */ |
| 555 | .maxlen = sizeof(unsigned int), |
| 556 | .mode = 0644, |
| 557 | .proc_handler = sysctl_numa_balancing, |
| 558 | .extra1 = &zero, |
| 559 | .extra2 = &one, |
| 560 | }, |
Peter Zijlstra | cbee9f8 | 2012-10-25 14:16:43 +0200 | [diff] [blame] | 561 | #endif /* CONFIG_NUMA_BALANCING */ |
| 562 | #endif /* CONFIG_SCHED_DEBUG */ |
Ingo Molnar | 1799e35 | 2007-09-19 23:34:46 +0200 | [diff] [blame] | 563 | { |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 564 | .procname = "sched_rt_period_us", |
| 565 | .data = &sysctl_sched_rt_period, |
| 566 | .maxlen = sizeof(unsigned int), |
| 567 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 568 | .proc_handler = sched_rt_handler, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 569 | }, |
| 570 | { |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 571 | .procname = "sched_rt_runtime_us", |
| 572 | .data = &sysctl_sched_rt_runtime, |
| 573 | .maxlen = sizeof(int), |
| 574 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 575 | .proc_handler = sched_rt_handler, |
Peter Zijlstra | 9f0c1e5 | 2008-02-13 15:45:39 +0100 | [diff] [blame] | 576 | }, |
Clark Williams | ce0dbbb | 2013-02-07 09:47:04 -0600 | [diff] [blame] | 577 | { |
| 578 | .procname = "sched_rr_timeslice_ms", |
Shile Zhang | 0c19934 | 2017-01-28 22:00:49 +0800 | [diff] [blame] | 579 | .data = &sysctl_sched_rr_timeslice, |
Clark Williams | ce0dbbb | 2013-02-07 09:47:04 -0600 | [diff] [blame] | 580 | .maxlen = sizeof(int), |
| 581 | .mode = 0644, |
| 582 | .proc_handler = sched_rr_handler, |
| 583 | }, |
Mike Galbraith | 5091faa | 2010-11-30 14:18:03 +0100 | [diff] [blame] | 584 | #ifdef CONFIG_SCHED_AUTOGROUP |
| 585 | { |
| 586 | .procname = "sched_autogroup_enabled", |
| 587 | .data = &sysctl_sched_autogroup_enabled, |
| 588 | .maxlen = sizeof(unsigned int), |
| 589 | .mode = 0644, |
Yong Zhang | 1747b21 | 2011-02-20 15:08:12 +0800 | [diff] [blame] | 590 | .proc_handler = proc_dointvec_minmax, |
Mike Galbraith | 5091faa | 2010-11-30 14:18:03 +0100 | [diff] [blame] | 591 | .extra1 = &zero, |
| 592 | .extra2 = &one, |
| 593 | }, |
| 594 | #endif |
Paul Turner | ec12cb7 | 2011-07-21 09:43:30 -0700 | [diff] [blame] | 595 | #ifdef CONFIG_CFS_BANDWIDTH |
| 596 | { |
| 597 | .procname = "sched_cfs_bandwidth_slice_us", |
| 598 | .data = &sysctl_sched_cfs_bandwidth_slice, |
| 599 | .maxlen = sizeof(unsigned int), |
| 600 | .mode = 0644, |
| 601 | .proc_handler = proc_dointvec_minmax, |
| 602 | .extra1 = &one, |
| 603 | }, |
| 604 | #endif |
Patrick Bellasi | 62c1c06 | 2015-06-22 18:11:44 +0100 | [diff] [blame] | 605 | #ifdef CONFIG_SCHED_TUNE |
| 606 | { |
| 607 | .procname = "sched_cfs_boost", |
| 608 | .data = &sysctl_sched_cfs_boost, |
| 609 | .maxlen = sizeof(sysctl_sched_cfs_boost), |
Patrick Bellasi | ffbceda | 2015-06-23 09:17:54 +0100 | [diff] [blame] | 610 | #ifdef CONFIG_CGROUP_SCHEDTUNE |
| 611 | .mode = 0444, |
| 612 | #else |
Patrick Bellasi | 62c1c06 | 2015-06-22 18:11:44 +0100 | [diff] [blame] | 613 | .mode = 0644, |
Patrick Bellasi | ffbceda | 2015-06-23 09:17:54 +0100 | [diff] [blame] | 614 | #endif |
Patrick Bellasi | 62c1c06 | 2015-06-22 18:11:44 +0100 | [diff] [blame] | 615 | .proc_handler = &sysctl_sched_cfs_boost_handler, |
| 616 | .extra1 = &zero, |
| 617 | .extra2 = &one_hundred, |
| 618 | }, |
| 619 | #endif |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 620 | #ifdef CONFIG_PROVE_LOCKING |
| 621 | { |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 622 | .procname = "prove_locking", |
| 623 | .data = &prove_locking, |
| 624 | .maxlen = sizeof(int), |
| 625 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 626 | .proc_handler = proc_dointvec, |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 627 | }, |
| 628 | #endif |
| 629 | #ifdef CONFIG_LOCK_STAT |
| 630 | { |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 631 | .procname = "lock_stat", |
| 632 | .data = &lock_stat, |
| 633 | .maxlen = sizeof(int), |
| 634 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 635 | .proc_handler = proc_dointvec, |
Peter Zijlstra | f20786f | 2007-07-19 01:48:56 -0700 | [diff] [blame] | 636 | }, |
| 637 | #endif |
Ingo Molnar | 77e54a1 | 2007-07-09 18:52:00 +0200 | [diff] [blame] | 638 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | .procname = "panic", |
| 640 | .data = &panic_timeout, |
| 641 | .maxlen = sizeof(int), |
| 642 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 643 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | }, |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 645 | #ifdef CONFIG_COREDUMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | .procname = "core_uses_pid", |
| 648 | .data = &core_uses_pid, |
| 649 | .maxlen = sizeof(int), |
| 650 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 651 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | }, |
| 653 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | .procname = "core_pattern", |
| 655 | .data = core_pattern, |
Dan Aloni | 71ce92f | 2007-05-16 22:11:16 -0700 | [diff] [blame] | 656 | .maxlen = CORENAME_MAX_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | .mode = 0644, |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 658 | .proc_handler = proc_dostring_coredump, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | }, |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 660 | { |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 661 | .procname = "core_pipe_limit", |
| 662 | .data = &core_pipe_limit, |
| 663 | .maxlen = sizeof(unsigned int), |
| 664 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 665 | .proc_handler = proc_dointvec, |
Neil Horman | a293980 | 2009-09-23 15:56:56 -0700 | [diff] [blame] | 666 | }, |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 667 | #endif |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 668 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | .procname = "tainted", |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 671 | .maxlen = sizeof(long), |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 672 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 673 | .proc_handler = proc_taint, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | }, |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 675 | { |
| 676 | .procname = "sysctl_writes_strict", |
| 677 | .data = &sysctl_writes_strict, |
| 678 | .maxlen = sizeof(int), |
| 679 | .mode = 0644, |
| 680 | .proc_handler = proc_dointvec_minmax, |
| 681 | .extra1 = &neg_one, |
| 682 | .extra2 = &one, |
| 683 | }, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 684 | #endif |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 685 | #ifdef CONFIG_LATENCYTOP |
| 686 | { |
| 687 | .procname = "latencytop", |
| 688 | .data = &latencytop_enabled, |
| 689 | .maxlen = sizeof(int), |
| 690 | .mode = 0644, |
Mel Gorman | cb25176 | 2016-02-05 09:08:36 +0000 | [diff] [blame] | 691 | .proc_handler = sysctl_latencytop, |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 692 | }, |
| 693 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | #ifdef CONFIG_BLK_DEV_INITRD |
| 695 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | .procname = "real-root-dev", |
| 697 | .data = &real_root_dev, |
| 698 | .maxlen = sizeof(int), |
| 699 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 700 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | }, |
| 702 | #endif |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 703 | { |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 704 | .procname = "print-fatal-signals", |
| 705 | .data = &print_fatal_signals, |
| 706 | .maxlen = sizeof(int), |
| 707 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 708 | .proc_handler = proc_dointvec, |
Ingo Molnar | 45807a1 | 2007-07-15 23:40:10 -0700 | [diff] [blame] | 709 | }, |
David S. Miller | 72c57ed | 2008-09-11 23:29:54 -0700 | [diff] [blame] | 710 | #ifdef CONFIG_SPARC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | .procname = "reboot-cmd", |
| 713 | .data = reboot_command, |
| 714 | .maxlen = 256, |
| 715 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 716 | .proc_handler = proc_dostring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | }, |
| 718 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | .procname = "stop-a", |
| 720 | .data = &stop_a_enabled, |
| 721 | .maxlen = sizeof (int), |
| 722 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 723 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | }, |
| 725 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | .procname = "scons-poweroff", |
| 727 | .data = &scons_pwroff, |
| 728 | .maxlen = sizeof (int), |
| 729 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 730 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | }, |
| 732 | #endif |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 733 | #ifdef CONFIG_SPARC64 |
| 734 | { |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 735 | .procname = "tsb-ratio", |
| 736 | .data = &sysctl_tsb_ratio, |
| 737 | .maxlen = sizeof (int), |
| 738 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 739 | .proc_handler = proc_dointvec, |
David S. Miller | 0871420 | 2008-11-16 23:49:24 -0800 | [diff] [blame] | 740 | }, |
| 741 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | #ifdef __hppa__ |
| 743 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | .procname = "soft-power", |
| 745 | .data = &pwrsw_enabled, |
| 746 | .maxlen = sizeof (int), |
| 747 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 748 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | }, |
Vineet Gupta | bf14e3b | 2013-01-18 15:12:24 +0530 | [diff] [blame] | 750 | #endif |
| 751 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | .procname = "unaligned-trap", |
| 754 | .data = &unaligned_enabled, |
| 755 | .maxlen = sizeof (int), |
| 756 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 757 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | }, |
| 759 | #endif |
| 760 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | .procname = "ctrl-alt-del", |
| 762 | .data = &C_A_D, |
| 763 | .maxlen = sizeof(int), |
| 764 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 765 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | }, |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 767 | #ifdef CONFIG_FUNCTION_TRACER |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 768 | { |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 769 | .procname = "ftrace_enabled", |
| 770 | .data = &ftrace_enabled, |
| 771 | .maxlen = sizeof(int), |
| 772 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 773 | .proc_handler = ftrace_enable_sysctl, |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 774 | }, |
| 775 | #endif |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 776 | #ifdef CONFIG_STACK_TRACER |
| 777 | { |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 778 | .procname = "stack_tracer_enabled", |
| 779 | .data = &stack_tracer_enabled, |
| 780 | .maxlen = sizeof(int), |
| 781 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 782 | .proc_handler = stack_trace_sysctl, |
Steven Rostedt | f38f1d2 | 2008-12-16 23:06:40 -0500 | [diff] [blame] | 783 | }, |
| 784 | #endif |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 785 | #ifdef CONFIG_TRACING |
| 786 | { |
Peter Zijlstra | 3299b4d | 2008-11-04 11:58:21 +0100 | [diff] [blame] | 787 | .procname = "ftrace_dump_on_oops", |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 788 | .data = &ftrace_dump_on_oops, |
| 789 | .maxlen = sizeof(int), |
| 790 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 791 | .proc_handler = proc_dointvec, |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 792 | }, |
Steven Rostedt (Red Hat) | de7edd3 | 2013-06-14 16:21:43 -0400 | [diff] [blame] | 793 | { |
| 794 | .procname = "traceoff_on_warning", |
| 795 | .data = &__disable_trace_on_warning, |
| 796 | .maxlen = sizeof(__disable_trace_on_warning), |
| 797 | .mode = 0644, |
| 798 | .proc_handler = proc_dointvec, |
| 799 | }, |
Steven Rostedt (Red Hat) | 0daa2302 | 2014-12-12 22:27:10 -0500 | [diff] [blame] | 800 | { |
| 801 | .procname = "tracepoint_printk", |
| 802 | .data = &tracepoint_printk, |
| 803 | .maxlen = sizeof(tracepoint_printk), |
| 804 | .mode = 0644, |
| 805 | .proc_handler = proc_dointvec, |
| 806 | }, |
Steven Rostedt | 944ac42 | 2008-10-23 19:26:08 -0400 | [diff] [blame] | 807 | #endif |
Dave Young | 2965faa | 2015-09-09 15:38:55 -0700 | [diff] [blame] | 808 | #ifdef CONFIG_KEXEC_CORE |
Kees Cook | 7984754 | 2014-01-23 15:55:59 -0800 | [diff] [blame] | 809 | { |
| 810 | .procname = "kexec_load_disabled", |
| 811 | .data = &kexec_load_disabled, |
| 812 | .maxlen = sizeof(int), |
| 813 | .mode = 0644, |
| 814 | /* only handle a transition from default "0" to "1" */ |
| 815 | .proc_handler = proc_dointvec_minmax, |
| 816 | .extra1 = &one, |
| 817 | .extra2 = &one, |
| 818 | }, |
| 819 | #endif |
Johannes Berg | a1ef5ad | 2008-07-08 19:00:17 +0200 | [diff] [blame] | 820 | #ifdef CONFIG_MODULES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | .procname = "modprobe", |
| 823 | .data = &modprobe_path, |
| 824 | .maxlen = KMOD_PATH_LEN, |
| 825 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 826 | .proc_handler = proc_dostring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | }, |
Kees Cook | 3d43321 | 2009-04-02 15:49:29 -0700 | [diff] [blame] | 828 | { |
Kees Cook | 3d43321 | 2009-04-02 15:49:29 -0700 | [diff] [blame] | 829 | .procname = "modules_disabled", |
| 830 | .data = &modules_disabled, |
| 831 | .maxlen = sizeof(int), |
| 832 | .mode = 0644, |
| 833 | /* only handle a transition from default "0" to "1" */ |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 834 | .proc_handler = proc_dointvec_minmax, |
Kees Cook | 3d43321 | 2009-04-02 15:49:29 -0700 | [diff] [blame] | 835 | .extra1 = &one, |
| 836 | .extra2 = &one, |
| 837 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | #endif |
Michael Marineau | 86d5613 | 2014-04-10 14:09:31 -0700 | [diff] [blame] | 839 | #ifdef CONFIG_UEVENT_HELPER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | .procname = "hotplug", |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 842 | .data = &uevent_helper, |
| 843 | .maxlen = UEVENT_HELPER_PATH_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 845 | .proc_handler = proc_dostring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | }, |
Michael Marineau | 86d5613 | 2014-04-10 14:09:31 -0700 | [diff] [blame] | 847 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | #ifdef CONFIG_CHR_DEV_SG |
| 849 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | .procname = "sg-big-buff", |
| 851 | .data = &sg_big_buff, |
| 852 | .maxlen = sizeof (int), |
| 853 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 854 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | }, |
| 856 | #endif |
| 857 | #ifdef CONFIG_BSD_PROCESS_ACCT |
| 858 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | .procname = "acct", |
| 860 | .data = &acct_parm, |
| 861 | .maxlen = 3*sizeof(int), |
| 862 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 863 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | }, |
| 865 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | #ifdef CONFIG_MAGIC_SYSRQ |
| 867 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | .procname = "sysrq", |
Ingo Molnar | 5d6f647 | 2006-12-13 00:34:36 -0800 | [diff] [blame] | 869 | .data = &__sysrq_enabled, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | .maxlen = sizeof (int), |
| 871 | .mode = 0644, |
Dmitry Torokhov | 97f5f0c | 2010-03-21 22:31:26 -0700 | [diff] [blame] | 872 | .proc_handler = sysrq_sysctl_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | }, |
| 874 | #endif |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 875 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | .procname = "cad_pid", |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 878 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | .maxlen = sizeof (int), |
| 880 | .mode = 0600, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 881 | .proc_handler = proc_do_cad_pid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | }, |
Randy Dunlap | d6f8ff7 | 2006-10-19 23:28:34 -0700 | [diff] [blame] | 883 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | .procname = "threads-max", |
Heinrich Schuchardt | 16db3d3 | 2015-04-16 12:47:50 -0700 | [diff] [blame] | 886 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | .maxlen = sizeof(int), |
| 888 | .mode = 0644, |
Heinrich Schuchardt | 16db3d3 | 2015-04-16 12:47:50 -0700 | [diff] [blame] | 889 | .proc_handler = sysctl_max_threads, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | }, |
| 891 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | .procname = "random", |
| 893 | .mode = 0555, |
| 894 | .child = random_table, |
| 895 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | { |
Eric Paris | 17f60a7 | 2011-04-01 17:07:50 -0400 | [diff] [blame] | 897 | .procname = "usermodehelper", |
| 898 | .mode = 0555, |
| 899 | .child = usermodehelper_table, |
| 900 | }, |
| 901 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | .procname = "overflowuid", |
| 903 | .data = &overflowuid, |
| 904 | .maxlen = sizeof(int), |
| 905 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 906 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | .extra1 = &minolduid, |
| 908 | .extra2 = &maxolduid, |
| 909 | }, |
| 910 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | .procname = "overflowgid", |
| 912 | .data = &overflowgid, |
| 913 | .maxlen = sizeof(int), |
| 914 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 915 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | .extra1 = &minolduid, |
| 917 | .extra2 = &maxolduid, |
| 918 | }, |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 919 | #ifdef CONFIG_S390 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | #ifdef CONFIG_MATHEMU |
| 921 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | .procname = "ieee_emulation_warnings", |
| 923 | .data = &sysctl_ieee_emulation_warnings, |
| 924 | .maxlen = sizeof(int), |
| 925 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 926 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | }, |
| 928 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | .procname = "userprocess_debug", |
Heiko Carstens | ab3c68e | 2010-05-17 10:00:21 +0200 | [diff] [blame] | 931 | .data = &show_unhandled_signals, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | .maxlen = sizeof(int), |
| 933 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 934 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | }, |
| 936 | #endif |
| 937 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | .procname = "pid_max", |
| 939 | .data = &pid_max, |
| 940 | .maxlen = sizeof (int), |
| 941 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 942 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | .extra1 = &pid_max_min, |
| 944 | .extra2 = &pid_max_max, |
| 945 | }, |
| 946 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | .procname = "panic_on_oops", |
| 948 | .data = &panic_on_oops, |
| 949 | .maxlen = sizeof(int), |
| 950 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 951 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | }, |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 953 | #if defined CONFIG_PRINTK |
| 954 | { |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 955 | .procname = "printk", |
| 956 | .data = &console_loglevel, |
| 957 | .maxlen = 4*sizeof(int), |
| 958 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 959 | .proc_handler = proc_dointvec, |
Joe Perches | 7ef3d2f | 2008-02-08 04:21:25 -0800 | [diff] [blame] | 960 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | .procname = "printk_ratelimit", |
Dave Young | 717115e | 2008-07-25 01:45:58 -0700 | [diff] [blame] | 963 | .data = &printk_ratelimit_state.interval, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | .maxlen = sizeof(int), |
| 965 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 966 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | }, |
| 968 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | .procname = "printk_ratelimit_burst", |
Dave Young | 717115e | 2008-07-25 01:45:58 -0700 | [diff] [blame] | 970 | .data = &printk_ratelimit_state.burst, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | .maxlen = sizeof(int), |
| 972 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 973 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | }, |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 975 | { |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 976 | .procname = "printk_delay", |
| 977 | .data = &printk_delay_msec, |
| 978 | .maxlen = sizeof(int), |
| 979 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 980 | .proc_handler = proc_dointvec_minmax, |
Dave Young | af91322 | 2009-09-22 16:43:33 -0700 | [diff] [blame] | 981 | .extra1 = &zero, |
| 982 | .extra2 = &ten_thousand, |
| 983 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | { |
Borislav Petkov | 750afe7 | 2016-08-02 14:04:07 -0700 | [diff] [blame] | 985 | .procname = "printk_devkmsg", |
| 986 | .data = devkmsg_log_str, |
| 987 | .maxlen = DEVKMSG_STR_MAX_SIZE, |
| 988 | .mode = 0644, |
| 989 | .proc_handler = devkmsg_sysctl_set_loglvl, |
| 990 | }, |
| 991 | { |
Dan Rosenberg | eaf06b2 | 2010-11-11 14:05:18 -0800 | [diff] [blame] | 992 | .procname = "dmesg_restrict", |
| 993 | .data = &dmesg_restrict, |
| 994 | .maxlen = sizeof(int), |
| 995 | .mode = 0644, |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 996 | .proc_handler = proc_dointvec_minmax_sysadmin, |
Dan Rosenberg | eaf06b2 | 2010-11-11 14:05:18 -0800 | [diff] [blame] | 997 | .extra1 = &zero, |
| 998 | .extra2 = &one, |
| 999 | }, |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 1000 | { |
| 1001 | .procname = "kptr_restrict", |
| 1002 | .data = &kptr_restrict, |
| 1003 | .maxlen = sizeof(int), |
| 1004 | .mode = 0644, |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 1005 | .proc_handler = proc_dointvec_minmax_sysadmin, |
Dan Rosenberg | 455cd5a | 2011-01-12 16:59:41 -0800 | [diff] [blame] | 1006 | .extra1 = &zero, |
| 1007 | .extra2 = &two, |
| 1008 | }, |
Joe Perches | df6e61d | 2010-11-15 21:17:27 -0800 | [diff] [blame] | 1009 | #endif |
Daniel Micay | 15169fa | 2017-05-16 17:51:48 -0400 | [diff] [blame] | 1010 | #ifdef CONFIG_USB |
| 1011 | { |
| 1012 | .procname = "deny_new_usb", |
| 1013 | .data = &deny_new_usb, |
| 1014 | .maxlen = sizeof(int), |
| 1015 | .mode = 0644, |
| 1016 | .proc_handler = proc_dointvec_minmax_sysadmin, |
| 1017 | .extra1 = &zero, |
| 1018 | .extra2 = &one, |
| 1019 | }, |
| 1020 | #endif |
Dan Rosenberg | eaf06b2 | 2010-11-11 14:05:18 -0800 | [diff] [blame] | 1021 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | .procname = "ngroups_max", |
| 1023 | .data = &ngroups_max, |
| 1024 | .maxlen = sizeof (int), |
| 1025 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1026 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | }, |
Dan Ballard | 73efc03 | 2011-10-31 17:11:20 -0700 | [diff] [blame] | 1028 | { |
| 1029 | .procname = "cap_last_cap", |
| 1030 | .data = (void *)&cap_last_cap, |
| 1031 | .maxlen = sizeof(int), |
| 1032 | .mode = 0444, |
| 1033 | .proc_handler = proc_dointvec, |
| 1034 | }, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 1035 | #if defined(CONFIG_LOCKUP_DETECTOR) |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 1036 | { |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 1037 | .procname = "watchdog", |
Frederic Weisbecker | 3c00ea8 | 2013-05-19 20:45:15 +0200 | [diff] [blame] | 1038 | .data = &watchdog_user_enabled, |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 1039 | .maxlen = sizeof (int), |
| 1040 | .mode = 0644, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 1041 | .proc_handler = proc_watchdog, |
Mandeep Singh Baines | 586692a | 2011-05-22 22:10:22 -0700 | [diff] [blame] | 1042 | .extra1 = &zero, |
| 1043 | .extra2 = &one, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 1044 | }, |
| 1045 | { |
| 1046 | .procname = "watchdog_thresh", |
Mandeep Singh Baines | 586692a | 2011-05-22 22:10:22 -0700 | [diff] [blame] | 1047 | .data = &watchdog_thresh, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 1048 | .maxlen = sizeof(int), |
| 1049 | .mode = 0644, |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 1050 | .proc_handler = proc_watchdog_thresh, |
Li Zefan | a6572f8 | 2013-05-17 10:31:04 +0800 | [diff] [blame] | 1051 | .extra1 = &zero, |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 1052 | .extra2 = &sixty, |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 1053 | }, |
Don Zickus | 2508ce1 | 2010-05-07 17:11:46 -0400 | [diff] [blame] | 1054 | { |
Ulrich Obergfell | 195daf6 | 2015-04-14 15:44:13 -0700 | [diff] [blame] | 1055 | .procname = "nmi_watchdog", |
| 1056 | .data = &nmi_watchdog_enabled, |
| 1057 | .maxlen = sizeof (int), |
| 1058 | .mode = 0644, |
| 1059 | .proc_handler = proc_nmi_watchdog, |
| 1060 | .extra1 = &zero, |
| 1061 | #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) |
| 1062 | .extra2 = &one, |
| 1063 | #else |
| 1064 | .extra2 = &zero, |
| 1065 | #endif |
| 1066 | }, |
| 1067 | { |
| 1068 | .procname = "soft_watchdog", |
| 1069 | .data = &soft_watchdog_enabled, |
| 1070 | .maxlen = sizeof (int), |
| 1071 | .mode = 0644, |
| 1072 | .proc_handler = proc_soft_watchdog, |
| 1073 | .extra1 = &zero, |
| 1074 | .extra2 = &one, |
| 1075 | }, |
| 1076 | { |
Chris Metcalf | fe4ba3c | 2015-06-24 16:55:45 -0700 | [diff] [blame] | 1077 | .procname = "watchdog_cpumask", |
| 1078 | .data = &watchdog_cpumask_bits, |
| 1079 | .maxlen = NR_CPUS, |
| 1080 | .mode = 0644, |
| 1081 | .proc_handler = proc_watchdog_cpumask, |
| 1082 | }, |
| 1083 | { |
Don Zickus | 2508ce1 | 2010-05-07 17:11:46 -0400 | [diff] [blame] | 1084 | .procname = "softlockup_panic", |
| 1085 | .data = &softlockup_panic, |
| 1086 | .maxlen = sizeof(int), |
| 1087 | .mode = 0644, |
| 1088 | .proc_handler = proc_dointvec_minmax, |
| 1089 | .extra1 = &zero, |
| 1090 | .extra2 = &one, |
| 1091 | }, |
Don Zickus | ac1f591 | 2015-11-05 18:44:44 -0800 | [diff] [blame] | 1092 | #ifdef CONFIG_HARDLOCKUP_DETECTOR |
| 1093 | { |
| 1094 | .procname = "hardlockup_panic", |
| 1095 | .data = &hardlockup_panic, |
| 1096 | .maxlen = sizeof(int), |
| 1097 | .mode = 0644, |
| 1098 | .proc_handler = proc_dointvec_minmax, |
| 1099 | .extra1 = &zero, |
| 1100 | .extra2 = &one, |
| 1101 | }, |
| 1102 | #endif |
Aaron Tomlin | ed23587 | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 1103 | #ifdef CONFIG_SMP |
| 1104 | { |
| 1105 | .procname = "softlockup_all_cpu_backtrace", |
| 1106 | .data = &sysctl_softlockup_all_cpu_backtrace, |
| 1107 | .maxlen = sizeof(int), |
| 1108 | .mode = 0644, |
| 1109 | .proc_handler = proc_dointvec_minmax, |
| 1110 | .extra1 = &zero, |
| 1111 | .extra2 = &one, |
| 1112 | }, |
Jiri Kosina | 5553787 | 2015-11-05 18:44:41 -0800 | [diff] [blame] | 1113 | { |
| 1114 | .procname = "hardlockup_all_cpu_backtrace", |
| 1115 | .data = &sysctl_hardlockup_all_cpu_backtrace, |
| 1116 | .maxlen = sizeof(int), |
| 1117 | .mode = 0644, |
| 1118 | .proc_handler = proc_dointvec_minmax, |
| 1119 | .extra1 = &zero, |
| 1120 | .extra2 = &one, |
| 1121 | }, |
Aaron Tomlin | ed23587 | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 1122 | #endif /* CONFIG_SMP */ |
Don Zickus | 5dc3055 | 2010-11-29 17:07:17 -0500 | [diff] [blame] | 1123 | #endif |
| 1124 | #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) |
| 1125 | { |
| 1126 | .procname = "unknown_nmi_panic", |
| 1127 | .data = &unknown_nmi_panic, |
| 1128 | .maxlen = sizeof (int), |
| 1129 | .mode = 0644, |
| 1130 | .proc_handler = proc_dointvec, |
| 1131 | }, |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 1132 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | #if defined(CONFIG_X86) |
| 1134 | { |
Don Zickus | 8da5add | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 1135 | .procname = "panic_on_unrecovered_nmi", |
| 1136 | .data = &panic_on_unrecovered_nmi, |
| 1137 | .maxlen = sizeof(int), |
| 1138 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1139 | .proc_handler = proc_dointvec, |
Don Zickus | 8da5add | 2006-09-26 10:52:27 +0200 | [diff] [blame] | 1140 | }, |
| 1141 | { |
Kurt Garloff | 5211a24 | 2009-06-24 14:32:11 -0700 | [diff] [blame] | 1142 | .procname = "panic_on_io_nmi", |
| 1143 | .data = &panic_on_io_nmi, |
| 1144 | .maxlen = sizeof(int), |
| 1145 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1146 | .proc_handler = proc_dointvec, |
Kurt Garloff | 5211a24 | 2009-06-24 14:32:11 -0700 | [diff] [blame] | 1147 | }, |
Mitsuo Hayasaka | 55af779 | 2011-11-29 15:08:36 +0900 | [diff] [blame] | 1148 | #ifdef CONFIG_DEBUG_STACKOVERFLOW |
| 1149 | { |
| 1150 | .procname = "panic_on_stackoverflow", |
| 1151 | .data = &sysctl_panic_on_stackoverflow, |
| 1152 | .maxlen = sizeof(int), |
| 1153 | .mode = 0644, |
| 1154 | .proc_handler = proc_dointvec, |
| 1155 | }, |
| 1156 | #endif |
Kurt Garloff | 5211a24 | 2009-06-24 14:32:11 -0700 | [diff] [blame] | 1157 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | .procname = "bootloader_type", |
| 1159 | .data = &bootloader_type, |
| 1160 | .maxlen = sizeof (int), |
| 1161 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1162 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | }, |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 1164 | { |
H. Peter Anvin | 5031296 | 2009-05-07 16:54:11 -0700 | [diff] [blame] | 1165 | .procname = "bootloader_version", |
| 1166 | .data = &bootloader_version, |
| 1167 | .maxlen = sizeof (int), |
| 1168 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1169 | .proc_handler = proc_dointvec, |
H. Peter Anvin | 5031296 | 2009-05-07 16:54:11 -0700 | [diff] [blame] | 1170 | }, |
| 1171 | { |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 1172 | .procname = "kstack_depth_to_print", |
| 1173 | .data = &kstack_depth_to_print, |
| 1174 | .maxlen = sizeof(int), |
| 1175 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1176 | .proc_handler = proc_dointvec, |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 1177 | }, |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 1178 | { |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 1179 | .procname = "io_delay_type", |
| 1180 | .data = &io_delay_type, |
| 1181 | .maxlen = sizeof(int), |
| 1182 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1183 | .proc_handler = proc_dointvec, |
Ingo Molnar | 6e7c402 | 2008-01-30 13:30:05 +0100 | [diff] [blame] | 1184 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | #endif |
Luke Yang | 7a9166e | 2006-02-20 18:28:07 -0800 | [diff] [blame] | 1186 | #if defined(CONFIG_MMU) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | .procname = "randomize_va_space", |
| 1189 | .data = &randomize_va_space, |
| 1190 | .maxlen = sizeof(int), |
| 1191 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1192 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | }, |
Luke Yang | 7a9166e | 2006-02-20 18:28:07 -0800 | [diff] [blame] | 1194 | #endif |
Martin Schwidefsky | 0152fb3 | 2006-01-14 13:21:00 -0800 | [diff] [blame] | 1195 | #if defined(CONFIG_S390) && defined(CONFIG_SMP) |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 1196 | { |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 1197 | .procname = "spin_retry", |
| 1198 | .data = &spin_retry, |
| 1199 | .maxlen = sizeof (int), |
| 1200 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1201 | .proc_handler = proc_dointvec, |
Martin Schwidefsky | 951f22d | 2005-07-27 11:44:57 -0700 | [diff] [blame] | 1202 | }, |
| 1203 | #endif |
Len Brown | 673d5b4 | 2007-07-28 03:33:16 -0400 | [diff] [blame] | 1204 | #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1205 | { |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1206 | .procname = "acpi_video_flags", |
Pavel Machek | 77afcf7 | 2007-07-19 01:47:41 -0700 | [diff] [blame] | 1207 | .data = &acpi_realmode_flags, |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1208 | .maxlen = sizeof (unsigned long), |
| 1209 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1210 | .proc_handler = proc_doulongvec_minmax, |
Pavel Machek | c255d84 | 2006-02-20 18:27:58 -0800 | [diff] [blame] | 1211 | }, |
| 1212 | #endif |
Vineet Gupta | b6fca72 | 2013-01-09 20:06:28 +0530 | [diff] [blame] | 1213 | #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1214 | { |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1215 | .procname = "ignore-unaligned-usertrap", |
| 1216 | .data = &no_unaligned_warning, |
| 1217 | .maxlen = sizeof (int), |
| 1218 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1219 | .proc_handler = proc_dointvec, |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1220 | }, |
Vineet Gupta | b6fca72 | 2013-01-09 20:06:28 +0530 | [diff] [blame] | 1221 | #endif |
| 1222 | #ifdef CONFIG_IA64 |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 1223 | { |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 1224 | .procname = "unaligned-dump-stack", |
| 1225 | .data = &unaligned_dump_stack, |
| 1226 | .maxlen = sizeof (int), |
| 1227 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1228 | .proc_handler = proc_dointvec, |
Doug Chapman | 88fc241 | 2009-01-15 10:38:56 -0800 | [diff] [blame] | 1229 | }, |
Jes Sorensen | d2b176e | 2006-02-28 09:42:23 -0800 | [diff] [blame] | 1230 | #endif |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 1231 | #ifdef CONFIG_DETECT_HUNG_TASK |
| 1232 | { |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 1233 | .procname = "hung_task_panic", |
| 1234 | .data = &sysctl_hung_task_panic, |
| 1235 | .maxlen = sizeof(int), |
| 1236 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1237 | .proc_handler = proc_dointvec_minmax, |
Mandeep Singh Baines | e162b39 | 2009-01-15 11:08:40 -0800 | [diff] [blame] | 1238 | .extra1 = &zero, |
| 1239 | .extra2 = &one, |
| 1240 | }, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1241 | { |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1242 | .procname = "hung_task_check_count", |
| 1243 | .data = &sysctl_hung_task_check_count, |
Li Zefan | cd64647 | 2013-09-23 16:43:58 +0800 | [diff] [blame] | 1244 | .maxlen = sizeof(int), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1245 | .mode = 0644, |
Li Zefan | cd64647 | 2013-09-23 16:43:58 +0800 | [diff] [blame] | 1246 | .proc_handler = proc_dointvec_minmax, |
| 1247 | .extra1 = &zero, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1248 | }, |
| 1249 | { |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1250 | .procname = "hung_task_timeout_secs", |
| 1251 | .data = &sysctl_hung_task_timeout_secs, |
Ingo Molnar | 9073908 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 1252 | .maxlen = sizeof(unsigned long), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1253 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1254 | .proc_handler = proc_dohung_task_timeout_secs, |
Liu Hua | 80df284 | 2014-04-07 15:38:57 -0700 | [diff] [blame] | 1255 | .extra2 = &hung_task_timeout_max, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1256 | }, |
| 1257 | { |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1258 | .procname = "hung_task_warnings", |
| 1259 | .data = &sysctl_hung_task_warnings, |
Aaron Tomlin | 270750db | 2014-01-20 17:34:13 +0000 | [diff] [blame] | 1260 | .maxlen = sizeof(int), |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1261 | .mode = 0644, |
Aaron Tomlin | 270750db | 2014-01-20 17:34:13 +0000 | [diff] [blame] | 1262 | .proc_handler = proc_dointvec_minmax, |
| 1263 | .extra1 = &neg_one, |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 1264 | }, |
Imran Khan | a9788f4 | 2017-09-18 15:48:30 +0530 | [diff] [blame] | 1265 | { |
| 1266 | .procname = "hung_task_selective_monitoring", |
| 1267 | .data = &sysctl_hung_task_selective_monitoring, |
| 1268 | .maxlen = sizeof(int), |
| 1269 | .mode = 0644, |
| 1270 | .proc_handler = proc_dointvec_minmax, |
| 1271 | .extra1 = &zero, |
| 1272 | .extra2 = &one, |
| 1273 | }, |
| 1274 | |
Ravikiran G Thirumalai | c4f3b63 | 2007-10-16 23:26:09 -0700 | [diff] [blame] | 1275 | #endif |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 1276 | #ifdef CONFIG_RT_MUTEXES |
| 1277 | { |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 1278 | .procname = "max_lock_depth", |
| 1279 | .data = &max_lock_depth, |
| 1280 | .maxlen = sizeof(int), |
| 1281 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1282 | .proc_handler = proc_dointvec, |
Ingo Molnar | 23f78d4a | 2006-06-27 02:54:53 -0700 | [diff] [blame] | 1283 | }, |
| 1284 | #endif |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 1285 | { |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 1286 | .procname = "poweroff_cmd", |
| 1287 | .data = &poweroff_cmd, |
| 1288 | .maxlen = POWEROFF_CMD_PATH_LEN, |
| 1289 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1290 | .proc_handler = proc_dostring, |
Jeremy Fitzhardinge | 10a0a8d | 2007-07-17 18:37:02 -0700 | [diff] [blame] | 1291 | }, |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 1292 | #ifdef CONFIG_KEYS |
| 1293 | { |
David Howells | 0b77f5b | 2008-04-29 01:01:32 -0700 | [diff] [blame] | 1294 | .procname = "keys", |
| 1295 | .mode = 0555, |
| 1296 | .child = key_sysctls, |
| 1297 | }, |
| 1298 | #endif |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1299 | #ifdef CONFIG_PERF_EVENTS |
Vince Weaver | aa4a221 | 2011-06-03 17:54:40 -0400 | [diff] [blame] | 1300 | /* |
| 1301 | * User-space scripts rely on the existence of this file |
| 1302 | * as a feature check for perf_events being enabled. |
| 1303 | * |
| 1304 | * So it's an ABI, do not remove! |
| 1305 | */ |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1306 | { |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1307 | .procname = "perf_event_paranoid", |
| 1308 | .data = &sysctl_perf_event_paranoid, |
| 1309 | .maxlen = sizeof(sysctl_perf_event_paranoid), |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1310 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1311 | .proc_handler = proc_dointvec, |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1312 | }, |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 1313 | { |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1314 | .procname = "perf_event_mlock_kb", |
| 1315 | .data = &sysctl_perf_event_mlock, |
| 1316 | .maxlen = sizeof(sysctl_perf_event_mlock), |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 1317 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1318 | .proc_handler = proc_dointvec, |
Peter Zijlstra | c5078f7 | 2009-05-05 17:50:24 +0200 | [diff] [blame] | 1319 | }, |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 1320 | { |
Ingo Molnar | cdd6c48 | 2009-09-21 12:02:48 +0200 | [diff] [blame] | 1321 | .procname = "perf_event_max_sample_rate", |
| 1322 | .data = &sysctl_perf_event_sample_rate, |
| 1323 | .maxlen = sizeof(sysctl_perf_event_sample_rate), |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 1324 | .mode = 0644, |
Peter Zijlstra | 163ec43 | 2011-02-16 11:22:34 +0100 | [diff] [blame] | 1325 | .proc_handler = perf_proc_update_handler, |
Knut Petersen | 723478c | 2013-09-25 14:29:37 +0200 | [diff] [blame] | 1326 | .extra1 = &one, |
Peter Zijlstra | a78ac32 | 2009-05-25 17:39:05 +0200 | [diff] [blame] | 1327 | }, |
Dave Hansen | 14c63f1 | 2013-06-21 08:51:36 -0700 | [diff] [blame] | 1328 | { |
| 1329 | .procname = "perf_cpu_time_max_percent", |
| 1330 | .data = &sysctl_perf_cpu_time_max_percent, |
| 1331 | .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), |
| 1332 | .mode = 0644, |
| 1333 | .proc_handler = perf_cpu_time_max_percent_handler, |
| 1334 | .extra1 = &zero, |
| 1335 | .extra2 = &one_hundred, |
| 1336 | }, |
Arnaldo Carvalho de Melo | c5dfd78 | 2016-04-21 12:28:50 -0300 | [diff] [blame] | 1337 | { |
| 1338 | .procname = "perf_event_max_stack", |
Arnaldo Carvalho de Melo | a831100 | 2016-05-10 16:34:53 -0300 | [diff] [blame] | 1339 | .data = &sysctl_perf_event_max_stack, |
Arnaldo Carvalho de Melo | c5dfd78 | 2016-04-21 12:28:50 -0300 | [diff] [blame] | 1340 | .maxlen = sizeof(sysctl_perf_event_max_stack), |
| 1341 | .mode = 0644, |
| 1342 | .proc_handler = perf_event_max_stack_handler, |
| 1343 | .extra1 = &zero, |
| 1344 | .extra2 = &six_hundred_forty_kb, |
| 1345 | }, |
Arnaldo Carvalho de Melo | c85b033 | 2016-05-12 13:06:21 -0300 | [diff] [blame] | 1346 | { |
| 1347 | .procname = "perf_event_max_contexts_per_stack", |
| 1348 | .data = &sysctl_perf_event_max_contexts_per_stack, |
| 1349 | .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), |
| 1350 | .mode = 0644, |
| 1351 | .proc_handler = perf_event_max_stack_handler, |
| 1352 | .extra1 = &zero, |
| 1353 | .extra2 = &one_thousand, |
| 1354 | }, |
Peter Zijlstra | 1ccd154 | 2009-04-09 10:53:45 +0200 | [diff] [blame] | 1355 | #endif |
Vegard Nossum | dfec072 | 2008-04-04 00:51:41 +0200 | [diff] [blame] | 1356 | #ifdef CONFIG_KMEMCHECK |
| 1357 | { |
Vegard Nossum | dfec072 | 2008-04-04 00:51:41 +0200 | [diff] [blame] | 1358 | .procname = "kmemcheck", |
| 1359 | .data = &kmemcheck_enabled, |
| 1360 | .maxlen = sizeof(int), |
| 1361 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1362 | .proc_handler = proc_dointvec, |
Vegard Nossum | dfec072 | 2008-04-04 00:51:41 +0200 | [diff] [blame] | 1363 | }, |
| 1364 | #endif |
Prarit Bhargava | 9e3961a | 2014-12-10 15:45:50 -0800 | [diff] [blame] | 1365 | { |
| 1366 | .procname = "panic_on_warn", |
| 1367 | .data = &panic_on_warn, |
| 1368 | .maxlen = sizeof(int), |
| 1369 | .mode = 0644, |
| 1370 | .proc_handler = proc_dointvec_minmax, |
| 1371 | .extra1 = &zero, |
| 1372 | .extra2 = &one, |
| 1373 | }, |
Thomas Gleixner | bc7a34b | 2015-05-26 22:50:33 +0000 | [diff] [blame] | 1374 | #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) |
| 1375 | { |
| 1376 | .procname = "timer_migration", |
| 1377 | .data = &sysctl_timer_migration, |
| 1378 | .maxlen = sizeof(unsigned int), |
| 1379 | .mode = 0644, |
| 1380 | .proc_handler = timer_migration_handler, |
Myungho Jung | 4c00015 | 2017-04-19 15:24:50 -0700 | [diff] [blame] | 1381 | .extra1 = &zero, |
| 1382 | .extra2 = &one, |
Thomas Gleixner | bc7a34b | 2015-05-26 22:50:33 +0000 | [diff] [blame] | 1383 | }, |
| 1384 | #endif |
Alexei Starovoitov | 1be7f75 | 2015-10-07 22:23:21 -0700 | [diff] [blame] | 1385 | #ifdef CONFIG_BPF_SYSCALL |
| 1386 | { |
| 1387 | .procname = "unprivileged_bpf_disabled", |
| 1388 | .data = &sysctl_unprivileged_bpf_disabled, |
| 1389 | .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), |
| 1390 | .mode = 0644, |
Daniel Borkmann | b6ef4bc | 2021-05-11 22:35:17 +0200 | [diff] [blame] | 1391 | .proc_handler = bpf_unpriv_handler, |
| 1392 | .extra1 = &zero, |
| 1393 | .extra2 = &two, |
Alexei Starovoitov | 1be7f75 | 2015-10-07 22:23:21 -0700 | [diff] [blame] | 1394 | }, |
| 1395 | #endif |
Daniel Bristot de Oliveira | 088e9d2 | 2016-06-02 13:51:41 -0300 | [diff] [blame] | 1396 | #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU) |
| 1397 | { |
| 1398 | .procname = "panic_on_rcu_stall", |
| 1399 | .data = &sysctl_panic_on_rcu_stall, |
| 1400 | .maxlen = sizeof(sysctl_panic_on_rcu_stall), |
| 1401 | .mode = 0644, |
| 1402 | .proc_handler = proc_dointvec_minmax, |
| 1403 | .extra1 = &zero, |
| 1404 | .extra2 = &one, |
| 1405 | }, |
| 1406 | #endif |
David Collins | a1792ad | 2014-01-10 14:11:24 -0800 | [diff] [blame] | 1407 | #if defined(CONFIG_ARM) || defined(CONFIG_ARM64) |
Rick Adams | ea449ff | 2010-09-28 10:21:07 -0700 | [diff] [blame] | 1408 | { |
| 1409 | .procname = "boot_reason", |
| 1410 | .data = &boot_reason, |
| 1411 | .maxlen = sizeof(int), |
| 1412 | .mode = 0444, |
| 1413 | .proc_handler = proc_dointvec, |
David Keitel | 381adf3 | 2013-03-26 18:50:03 -0700 | [diff] [blame] | 1414 | }, |
| 1415 | |
| 1416 | { |
| 1417 | .procname = "cold_boot", |
| 1418 | .data = &cold_boot, |
| 1419 | .maxlen = sizeof(int), |
| 1420 | .mode = 0444, |
| 1421 | .proc_handler = proc_dointvec, |
| 1422 | }, |
Rick Adams | ea449ff | 2010-09-28 10:21:07 -0700 | [diff] [blame] | 1423 | #endif |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1424 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | }; |
| 1426 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1427 | static struct ctl_table vm_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | .procname = "overcommit_memory", |
| 1430 | .data = &sysctl_overcommit_memory, |
| 1431 | .maxlen = sizeof(sysctl_overcommit_memory), |
| 1432 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1433 | .proc_handler = proc_dointvec_minmax, |
| 1434 | .extra1 = &zero, |
| 1435 | .extra2 = &two, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | }, |
| 1437 | { |
KAMEZAWA Hiroyuki | fadd8fb | 2006-06-23 02:03:13 -0700 | [diff] [blame] | 1438 | .procname = "panic_on_oom", |
| 1439 | .data = &sysctl_panic_on_oom, |
| 1440 | .maxlen = sizeof(sysctl_panic_on_oom), |
| 1441 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1442 | .proc_handler = proc_dointvec_minmax, |
| 1443 | .extra1 = &zero, |
| 1444 | .extra2 = &two, |
KAMEZAWA Hiroyuki | fadd8fb | 2006-06-23 02:03:13 -0700 | [diff] [blame] | 1445 | }, |
| 1446 | { |
David Rientjes | fe071d7 | 2007-10-16 23:25:56 -0700 | [diff] [blame] | 1447 | .procname = "oom_kill_allocating_task", |
| 1448 | .data = &sysctl_oom_kill_allocating_task, |
| 1449 | .maxlen = sizeof(sysctl_oom_kill_allocating_task), |
| 1450 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1451 | .proc_handler = proc_dointvec, |
David Rientjes | fe071d7 | 2007-10-16 23:25:56 -0700 | [diff] [blame] | 1452 | }, |
| 1453 | { |
David Rientjes | fef1bdd | 2008-02-07 00:14:07 -0800 | [diff] [blame] | 1454 | .procname = "oom_dump_tasks", |
| 1455 | .data = &sysctl_oom_dump_tasks, |
| 1456 | .maxlen = sizeof(sysctl_oom_dump_tasks), |
| 1457 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1458 | .proc_handler = proc_dointvec, |
David Rientjes | fef1bdd | 2008-02-07 00:14:07 -0800 | [diff] [blame] | 1459 | }, |
| 1460 | { |
Charan Teja Reddy | f9920cf | 2018-05-01 20:20:20 +0530 | [diff] [blame] | 1461 | .procname = "reap_mem_on_sigkill", |
| 1462 | .data = &sysctl_reap_mem_on_sigkill, |
| 1463 | .maxlen = sizeof(sysctl_reap_mem_on_sigkill), |
| 1464 | .mode = 0644, |
| 1465 | .proc_handler = proc_dointvec, |
| 1466 | }, |
| 1467 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | .procname = "overcommit_ratio", |
| 1469 | .data = &sysctl_overcommit_ratio, |
| 1470 | .maxlen = sizeof(sysctl_overcommit_ratio), |
| 1471 | .mode = 0644, |
Jerome Marchand | 49f0ce5 | 2014-01-21 15:49:14 -0800 | [diff] [blame] | 1472 | .proc_handler = overcommit_ratio_handler, |
| 1473 | }, |
| 1474 | { |
| 1475 | .procname = "overcommit_kbytes", |
| 1476 | .data = &sysctl_overcommit_kbytes, |
| 1477 | .maxlen = sizeof(sysctl_overcommit_kbytes), |
| 1478 | .mode = 0644, |
| 1479 | .proc_handler = overcommit_kbytes_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | }, |
| 1481 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | .procname = "page-cluster", |
| 1483 | .data = &page_cluster, |
| 1484 | .maxlen = sizeof(int), |
| 1485 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1486 | .proc_handler = proc_dointvec_minmax, |
| 1487 | .extra1 = &zero, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | }, |
| 1489 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | .procname = "dirty_background_ratio", |
| 1491 | .data = &dirty_background_ratio, |
| 1492 | .maxlen = sizeof(dirty_background_ratio), |
| 1493 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1494 | .proc_handler = dirty_background_ratio_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | .extra1 = &zero, |
| 1496 | .extra2 = &one_hundred, |
| 1497 | }, |
| 1498 | { |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1499 | .procname = "dirty_background_bytes", |
| 1500 | .data = &dirty_background_bytes, |
| 1501 | .maxlen = sizeof(dirty_background_bytes), |
| 1502 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1503 | .proc_handler = dirty_background_bytes_handler, |
Sven Wegener | fc3501d | 2009-02-11 13:04:23 -0800 | [diff] [blame] | 1504 | .extra1 = &one_ul, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1505 | }, |
| 1506 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | .procname = "dirty_ratio", |
| 1508 | .data = &vm_dirty_ratio, |
| 1509 | .maxlen = sizeof(vm_dirty_ratio), |
| 1510 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1511 | .proc_handler = dirty_ratio_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | .extra1 = &zero, |
| 1513 | .extra2 = &one_hundred, |
| 1514 | }, |
| 1515 | { |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1516 | .procname = "dirty_bytes", |
| 1517 | .data = &vm_dirty_bytes, |
| 1518 | .maxlen = sizeof(vm_dirty_bytes), |
| 1519 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1520 | .proc_handler = dirty_bytes_handler, |
Andrea Righi | 9e4a5bd | 2009-04-30 15:08:57 -0700 | [diff] [blame] | 1521 | .extra1 = &dirty_bytes_min, |
David Rientjes | 2da0299 | 2009-01-06 14:39:31 -0800 | [diff] [blame] | 1522 | }, |
| 1523 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | .procname = "dirty_writeback_centisecs", |
Bart Samwel | f6ef943 | 2006-03-24 03:15:48 -0800 | [diff] [blame] | 1525 | .data = &dirty_writeback_interval, |
| 1526 | .maxlen = sizeof(dirty_writeback_interval), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1528 | .proc_handler = dirty_writeback_centisecs_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | }, |
| 1530 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | .procname = "dirty_expire_centisecs", |
Bart Samwel | f6ef943 | 2006-03-24 03:15:48 -0800 | [diff] [blame] | 1532 | .data = &dirty_expire_interval, |
| 1533 | .maxlen = sizeof(dirty_expire_interval), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | .mode = 0644, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1535 | .proc_handler = proc_dointvec_minmax, |
| 1536 | .extra1 = &zero, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | }, |
| 1538 | { |
Theodore Ts'o | 1efff91 | 2015-03-17 12:23:32 -0400 | [diff] [blame] | 1539 | .procname = "dirtytime_expire_seconds", |
| 1540 | .data = &dirtytime_expire_interval, |
| 1541 | .maxlen = sizeof(dirty_expire_interval), |
| 1542 | .mode = 0644, |
| 1543 | .proc_handler = dirtytime_interval_handler, |
| 1544 | .extra1 = &zero, |
| 1545 | }, |
| 1546 | { |
Wanpeng Li | 3965c9a | 2012-07-31 16:41:52 -0700 | [diff] [blame] | 1547 | .procname = "nr_pdflush_threads", |
| 1548 | .mode = 0444 /* read-only */, |
| 1549 | .proc_handler = pdflush_proc_obsolete, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | }, |
| 1551 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | .procname = "swappiness", |
| 1553 | .data = &vm_swappiness, |
| 1554 | .maxlen = sizeof(vm_swappiness), |
| 1555 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1556 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | .extra1 = &zero, |
| 1558 | .extra2 = &one_hundred, |
| 1559 | }, |
Vinayak Menon | b9e4cc2b | 2018-06-11 18:58:39 +0530 | [diff] [blame] | 1560 | { |
| 1561 | .procname = "want_old_faultaround_pte", |
| 1562 | .data = &want_old_faultaround_pte, |
| 1563 | .maxlen = sizeof(want_old_faultaround_pte), |
| 1564 | .mode = 0644, |
| 1565 | .proc_handler = proc_dointvec_minmax, |
| 1566 | .extra1 = &zero, |
| 1567 | .extra2 = &one, |
| 1568 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | #ifdef CONFIG_HUGETLB_PAGE |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1570 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | .procname = "nr_hugepages", |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1572 | .data = NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | .maxlen = sizeof(unsigned long), |
| 1574 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1575 | .proc_handler = hugetlb_sysctl_handler, |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1576 | }, |
| 1577 | #ifdef CONFIG_NUMA |
| 1578 | { |
| 1579 | .procname = "nr_hugepages_mempolicy", |
| 1580 | .data = NULL, |
| 1581 | .maxlen = sizeof(unsigned long), |
| 1582 | .mode = 0644, |
| 1583 | .proc_handler = &hugetlb_mempolicy_sysctl_handler, |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 1584 | }, |
| 1585 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1586 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | .procname = "hugetlb_shm_group", |
| 1588 | .data = &sysctl_hugetlb_shm_group, |
| 1589 | .maxlen = sizeof(gid_t), |
| 1590 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1591 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | }, |
Mel Gorman | 396faf0 | 2007-07-17 04:03:13 -0700 | [diff] [blame] | 1593 | { |
Mel Gorman | 396faf0 | 2007-07-17 04:03:13 -0700 | [diff] [blame] | 1594 | .procname = "hugepages_treat_as_movable", |
| 1595 | .data = &hugepages_treat_as_movable, |
| 1596 | .maxlen = sizeof(int), |
| 1597 | .mode = 0644, |
Naoya Horiguchi | 86cdb46 | 2013-09-11 14:22:13 -0700 | [diff] [blame] | 1598 | .proc_handler = proc_dointvec, |
Mel Gorman | 396faf0 | 2007-07-17 04:03:13 -0700 | [diff] [blame] | 1599 | }, |
Adam Litke | 54f9f80 | 2007-10-16 01:26:20 -0700 | [diff] [blame] | 1600 | { |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1601 | .procname = "nr_overcommit_hugepages", |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 1602 | .data = NULL, |
| 1603 | .maxlen = sizeof(unsigned long), |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1604 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1605 | .proc_handler = hugetlb_overcommit_handler, |
Nishanth Aravamudan | d1c3fb1 | 2007-12-17 16:20:12 -0800 | [diff] [blame] | 1606 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | #endif |
| 1608 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | .procname = "lowmem_reserve_ratio", |
| 1610 | .data = &sysctl_lowmem_reserve_ratio, |
| 1611 | .maxlen = sizeof(sysctl_lowmem_reserve_ratio), |
| 1612 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1613 | .proc_handler = lowmem_reserve_ratio_sysctl_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | }, |
| 1615 | { |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1616 | .procname = "drop_caches", |
| 1617 | .data = &sysctl_drop_caches, |
| 1618 | .maxlen = sizeof(int), |
Johannes Weiner | b231f9d | 2019-11-30 17:56:08 -0800 | [diff] [blame] | 1619 | .mode = 0200, |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1620 | .proc_handler = drop_caches_sysctl_handler, |
Petr Holasek | cb16e95 | 2011-03-23 16:43:09 -0700 | [diff] [blame] | 1621 | .extra1 = &one, |
Dave Hansen | 5509a5d | 2014-04-03 14:48:19 -0700 | [diff] [blame] | 1622 | .extra2 = &four, |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1623 | }, |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 1624 | #ifdef CONFIG_COMPACTION |
| 1625 | { |
| 1626 | .procname = "compact_memory", |
| 1627 | .data = &sysctl_compact_memory, |
| 1628 | .maxlen = sizeof(int), |
| 1629 | .mode = 0200, |
| 1630 | .proc_handler = sysctl_compaction_handler, |
| 1631 | }, |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 1632 | { |
| 1633 | .procname = "extfrag_threshold", |
| 1634 | .data = &sysctl_extfrag_threshold, |
| 1635 | .maxlen = sizeof(int), |
| 1636 | .mode = 0644, |
| 1637 | .proc_handler = sysctl_extfrag_handler, |
| 1638 | .extra1 = &min_extfrag_threshold, |
| 1639 | .extra2 = &max_extfrag_threshold, |
| 1640 | }, |
Eric B Munson | 5bbe354 | 2015-04-15 16:13:20 -0700 | [diff] [blame] | 1641 | { |
| 1642 | .procname = "compact_unevictable_allowed", |
| 1643 | .data = &sysctl_compact_unevictable_allowed, |
| 1644 | .maxlen = sizeof(int), |
| 1645 | .mode = 0644, |
| 1646 | .proc_handler = proc_dointvec, |
| 1647 | .extra1 = &zero, |
| 1648 | .extra2 = &one, |
| 1649 | }, |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 1650 | |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 1651 | #endif /* CONFIG_COMPACTION */ |
Andrew Morton | 9d0243b | 2006-01-08 01:00:39 -0800 | [diff] [blame] | 1652 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1653 | .procname = "min_free_kbytes", |
| 1654 | .data = &min_free_kbytes, |
| 1655 | .maxlen = sizeof(min_free_kbytes), |
| 1656 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1657 | .proc_handler = min_free_kbytes_sysctl_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1658 | .extra1 = &zero, |
| 1659 | }, |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1660 | { |
Johannes Weiner | 795ae7a | 2016-03-17 14:19:14 -0700 | [diff] [blame] | 1661 | .procname = "watermark_scale_factor", |
| 1662 | .data = &watermark_scale_factor, |
| 1663 | .maxlen = sizeof(watermark_scale_factor), |
| 1664 | .mode = 0644, |
| 1665 | .proc_handler = watermark_scale_factor_sysctl_handler, |
Rik van Riel | 1246275 | 2011-09-01 15:26:50 -0400 | [diff] [blame] | 1666 | .extra1 = &zero, |
| 1667 | .extra2 = &zero, |
| 1668 | }, |
| 1669 | { |
| 1670 | .procname = "extra_free_kbytes", |
| 1671 | .data = &extra_free_kbytes, |
| 1672 | .maxlen = sizeof(extra_free_kbytes), |
| 1673 | .mode = 0644, |
| 1674 | .proc_handler = min_free_kbytes_sysctl_handler, |
| 1675 | .extra1 = &zero, |
Johannes Weiner | 795ae7a | 2016-03-17 14:19:14 -0700 | [diff] [blame] | 1676 | }, |
| 1677 | { |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1678 | .procname = "percpu_pagelist_fraction", |
| 1679 | .data = &percpu_pagelist_fraction, |
| 1680 | .maxlen = sizeof(percpu_pagelist_fraction), |
| 1681 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1682 | .proc_handler = percpu_pagelist_fraction_sysctl_handler, |
David Rientjes | 7cd2b0a | 2014-06-23 13:22:04 -0700 | [diff] [blame] | 1683 | .extra1 = &zero, |
Rohit Seth | 8ad4b1f | 2006-01-08 01:00:40 -0800 | [diff] [blame] | 1684 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1685 | #ifdef CONFIG_MMU |
| 1686 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | .procname = "max_map_count", |
| 1688 | .data = &sysctl_max_map_count, |
| 1689 | .maxlen = sizeof(sysctl_max_map_count), |
| 1690 | .mode = 0644, |
WANG Cong | 3e26120 | 2009-12-17 15:27:05 -0800 | [diff] [blame] | 1691 | .proc_handler = proc_dointvec_minmax, |
Amerigo Wang | 70da234 | 2009-12-14 17:59:52 -0800 | [diff] [blame] | 1692 | .extra1 = &zero, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | }, |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1694 | #else |
| 1695 | { |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1696 | .procname = "nr_trim_pages", |
| 1697 | .data = &sysctl_nr_trim_pages, |
| 1698 | .maxlen = sizeof(sysctl_nr_trim_pages), |
| 1699 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1700 | .proc_handler = proc_dointvec_minmax, |
Paul Mundt | dd8632a | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 1701 | .extra1 = &zero, |
| 1702 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | #endif |
| 1704 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | .procname = "laptop_mode", |
| 1706 | .data = &laptop_mode, |
| 1707 | .maxlen = sizeof(laptop_mode), |
| 1708 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1709 | .proc_handler = proc_dointvec_jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | }, |
| 1711 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | .procname = "block_dump", |
| 1713 | .data = &block_dump, |
| 1714 | .maxlen = sizeof(block_dump), |
| 1715 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1716 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | .extra1 = &zero, |
| 1718 | }, |
| 1719 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | .procname = "vfs_cache_pressure", |
| 1721 | .data = &sysctl_vfs_cache_pressure, |
| 1722 | .maxlen = sizeof(sysctl_vfs_cache_pressure), |
| 1723 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1724 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | .extra1 = &zero, |
| 1726 | }, |
| 1727 | #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT |
| 1728 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | .procname = "legacy_va_layout", |
| 1730 | .data = &sysctl_legacy_va_layout, |
| 1731 | .maxlen = sizeof(sysctl_legacy_va_layout), |
| 1732 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1733 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | .extra1 = &zero, |
| 1735 | }, |
| 1736 | #endif |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1737 | #ifdef CONFIG_NUMA |
| 1738 | { |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1739 | .procname = "zone_reclaim_mode", |
Mel Gorman | a5f5f91 | 2016-07-28 15:46:32 -0700 | [diff] [blame] | 1740 | .data = &node_reclaim_mode, |
| 1741 | .maxlen = sizeof(node_reclaim_mode), |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1742 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1743 | .proc_handler = proc_dointvec, |
Christoph Lameter | c84db23 | 2006-02-01 03:05:29 -0800 | [diff] [blame] | 1744 | .extra1 = &zero, |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1745 | }, |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1746 | { |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1747 | .procname = "min_unmapped_ratio", |
| 1748 | .data = &sysctl_min_unmapped_ratio, |
| 1749 | .maxlen = sizeof(sysctl_min_unmapped_ratio), |
| 1750 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1751 | .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, |
Christoph Lameter | 9614634 | 2006-07-03 00:24:13 -0700 | [diff] [blame] | 1752 | .extra1 = &zero, |
| 1753 | .extra2 = &one_hundred, |
| 1754 | }, |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1755 | { |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1756 | .procname = "min_slab_ratio", |
| 1757 | .data = &sysctl_min_slab_ratio, |
| 1758 | .maxlen = sizeof(sysctl_min_slab_ratio), |
| 1759 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1760 | .proc_handler = sysctl_min_slab_ratio_sysctl_handler, |
Christoph Lameter | 0ff3849 | 2006-09-25 23:31:52 -0700 | [diff] [blame] | 1761 | .extra1 = &zero, |
| 1762 | .extra2 = &one_hundred, |
| 1763 | }, |
Christoph Lameter | 1743660 | 2006-01-18 17:42:32 -0800 | [diff] [blame] | 1764 | #endif |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1765 | #ifdef CONFIG_SMP |
| 1766 | { |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1767 | .procname = "stat_interval", |
| 1768 | .data = &sysctl_stat_interval, |
| 1769 | .maxlen = sizeof(sysctl_stat_interval), |
| 1770 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1771 | .proc_handler = proc_dointvec_jiffies, |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1772 | }, |
Hugh Dickins | 52b6f46 | 2016-05-19 17:12:50 -0700 | [diff] [blame] | 1773 | { |
| 1774 | .procname = "stat_refresh", |
| 1775 | .data = NULL, |
| 1776 | .maxlen = 0, |
| 1777 | .mode = 0600, |
| 1778 | .proc_handler = vmstat_refresh, |
| 1779 | }, |
Christoph Lameter | 77461ab | 2007-05-09 02:35:13 -0700 | [diff] [blame] | 1780 | #endif |
David Howells | 6e14154 | 2009-12-15 19:27:45 +0000 | [diff] [blame] | 1781 | #ifdef CONFIG_MMU |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1782 | { |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1783 | .procname = "mmap_min_addr", |
Eric Paris | 788084a | 2009-07-31 12:54:11 -0400 | [diff] [blame] | 1784 | .data = &dac_mmap_min_addr, |
| 1785 | .maxlen = sizeof(unsigned long), |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1786 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1787 | .proc_handler = mmap_min_addr_handler, |
Eric Paris | ed03218 | 2007-06-28 15:55:21 -0400 | [diff] [blame] | 1788 | }, |
David Howells | 6e14154 | 2009-12-15 19:27:45 +0000 | [diff] [blame] | 1789 | #endif |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1790 | #ifdef CONFIG_NUMA |
| 1791 | { |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1792 | .procname = "numa_zonelist_order", |
| 1793 | .data = &numa_zonelist_order, |
| 1794 | .maxlen = NUMA_ZONELIST_ORDER_LEN, |
| 1795 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1796 | .proc_handler = numa_zonelist_order_handler, |
KAMEZAWA Hiroyuki | f0c0b2b | 2007-07-15 23:38:01 -0700 | [diff] [blame] | 1797 | }, |
| 1798 | #endif |
Al Viro | 2b8232c | 2007-10-13 08:16:04 +0100 | [diff] [blame] | 1799 | #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ |
Paul Mundt | 5c36e65 | 2007-03-01 10:07:42 +0900 | [diff] [blame] | 1800 | (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1801 | { |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1802 | .procname = "vdso_enabled", |
Andy Lutomirski | 3d7ee96 | 2014-05-05 12:19:32 -0700 | [diff] [blame] | 1803 | #ifdef CONFIG_X86_32 |
| 1804 | .data = &vdso32_enabled, |
| 1805 | .maxlen = sizeof(vdso32_enabled), |
| 1806 | #else |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1807 | .data = &vdso_enabled, |
| 1808 | .maxlen = sizeof(vdso_enabled), |
Andy Lutomirski | 3d7ee96 | 2014-05-05 12:19:32 -0700 | [diff] [blame] | 1809 | #endif |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1810 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1811 | .proc_handler = proc_dointvec, |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 1812 | .extra1 = &zero, |
| 1813 | }, |
| 1814 | #endif |
Bron Gondwana | 195cf45 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1815 | #ifdef CONFIG_HIGHMEM |
| 1816 | { |
Bron Gondwana | 195cf45 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1817 | .procname = "highmem_is_dirtyable", |
| 1818 | .data = &vm_highmem_is_dirtyable, |
| 1819 | .maxlen = sizeof(vm_highmem_is_dirtyable), |
| 1820 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1821 | .proc_handler = proc_dointvec_minmax, |
Bron Gondwana | 195cf45 | 2008-02-04 22:29:20 -0800 | [diff] [blame] | 1822 | .extra1 = &zero, |
| 1823 | .extra2 = &one, |
| 1824 | }, |
| 1825 | #endif |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1826 | #ifdef CONFIG_MEMORY_FAILURE |
| 1827 | { |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1828 | .procname = "memory_failure_early_kill", |
| 1829 | .data = &sysctl_memory_failure_early_kill, |
| 1830 | .maxlen = sizeof(sysctl_memory_failure_early_kill), |
| 1831 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1832 | .proc_handler = proc_dointvec_minmax, |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1833 | .extra1 = &zero, |
| 1834 | .extra2 = &one, |
| 1835 | }, |
| 1836 | { |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1837 | .procname = "memory_failure_recovery", |
| 1838 | .data = &sysctl_memory_failure_recovery, |
| 1839 | .maxlen = sizeof(sysctl_memory_failure_recovery), |
| 1840 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1841 | .proc_handler = proc_dointvec_minmax, |
Andi Kleen | 6a46079 | 2009-09-16 11:50:15 +0200 | [diff] [blame] | 1842 | .extra1 = &zero, |
| 1843 | .extra2 = &one, |
| 1844 | }, |
| 1845 | #endif |
Andrew Shewmaker | c9b1d09 | 2013-04-29 15:08:10 -0700 | [diff] [blame] | 1846 | { |
| 1847 | .procname = "user_reserve_kbytes", |
| 1848 | .data = &sysctl_user_reserve_kbytes, |
| 1849 | .maxlen = sizeof(sysctl_user_reserve_kbytes), |
| 1850 | .mode = 0644, |
| 1851 | .proc_handler = proc_doulongvec_minmax, |
| 1852 | }, |
Andrew Shewmaker | 4eeab4f | 2013-04-29 15:08:11 -0700 | [diff] [blame] | 1853 | { |
| 1854 | .procname = "admin_reserve_kbytes", |
| 1855 | .data = &sysctl_admin_reserve_kbytes, |
| 1856 | .maxlen = sizeof(sysctl_admin_reserve_kbytes), |
| 1857 | .mode = 0644, |
| 1858 | .proc_handler = proc_doulongvec_minmax, |
| 1859 | }, |
Daniel Cashman | d07e225 | 2016-01-14 15:19:53 -0800 | [diff] [blame] | 1860 | #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS |
| 1861 | { |
| 1862 | .procname = "mmap_rnd_bits", |
| 1863 | .data = &mmap_rnd_bits, |
| 1864 | .maxlen = sizeof(mmap_rnd_bits), |
| 1865 | .mode = 0600, |
| 1866 | .proc_handler = proc_dointvec_minmax, |
| 1867 | .extra1 = (void *)&mmap_rnd_bits_min, |
| 1868 | .extra2 = (void *)&mmap_rnd_bits_max, |
| 1869 | }, |
| 1870 | #endif |
| 1871 | #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS |
| 1872 | { |
| 1873 | .procname = "mmap_rnd_compat_bits", |
| 1874 | .data = &mmap_rnd_compat_bits, |
| 1875 | .maxlen = sizeof(mmap_rnd_compat_bits), |
| 1876 | .mode = 0600, |
| 1877 | .proc_handler = proc_dointvec_minmax, |
| 1878 | .extra1 = (void *)&mmap_rnd_compat_bits_min, |
| 1879 | .extra2 = (void *)&mmap_rnd_compat_bits_max, |
| 1880 | }, |
| 1881 | #endif |
Vinayak Menon | c1c6a99 | 2015-12-21 13:00:58 +0530 | [diff] [blame] | 1882 | #ifdef CONFIG_SWAP |
| 1883 | { |
| 1884 | .procname = "swap_ratio", |
| 1885 | .data = &sysctl_swap_ratio, |
| 1886 | .maxlen = sizeof(sysctl_swap_ratio), |
| 1887 | .mode = 0644, |
| 1888 | .proc_handler = proc_dointvec_minmax, |
| 1889 | }, |
| 1890 | { |
| 1891 | .procname = "swap_ratio_enable", |
| 1892 | .data = &sysctl_swap_ratio_enable, |
| 1893 | .maxlen = sizeof(sysctl_swap_ratio_enable), |
| 1894 | .mode = 0644, |
| 1895 | .proc_handler = proc_dointvec_minmax, |
| 1896 | }, |
| 1897 | #endif |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 1898 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | }; |
| 1900 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 1901 | static struct ctl_table fs_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1902 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1903 | .procname = "inode-nr", |
| 1904 | .data = &inodes_stat, |
Glauber Costa | 3942c07 | 2013-08-28 10:17:53 +1000 | [diff] [blame] | 1905 | .maxlen = 2*sizeof(long), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1906 | .mode = 0444, |
Dave Chinner | cffbc8a | 2010-10-23 05:03:02 -0400 | [diff] [blame] | 1907 | .proc_handler = proc_nr_inodes, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1908 | }, |
| 1909 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1910 | .procname = "inode-state", |
| 1911 | .data = &inodes_stat, |
Glauber Costa | 3942c07 | 2013-08-28 10:17:53 +1000 | [diff] [blame] | 1912 | .maxlen = 7*sizeof(long), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | .mode = 0444, |
Dave Chinner | cffbc8a | 2010-10-23 05:03:02 -0400 | [diff] [blame] | 1914 | .proc_handler = proc_nr_inodes, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1915 | }, |
| 1916 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1917 | .procname = "file-nr", |
| 1918 | .data = &files_stat, |
Eric Dumazet | 518de9b | 2010-10-26 14:22:44 -0700 | [diff] [blame] | 1919 | .maxlen = sizeof(files_stat), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1921 | .proc_handler = proc_nr_files, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1922 | }, |
| 1923 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1924 | .procname = "file-max", |
| 1925 | .data = &files_stat.max_files, |
Eric Dumazet | 518de9b | 2010-10-26 14:22:44 -0700 | [diff] [blame] | 1926 | .maxlen = sizeof(files_stat.max_files), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | .mode = 0644, |
Eric Dumazet | 518de9b | 2010-10-26 14:22:44 -0700 | [diff] [blame] | 1928 | .proc_handler = proc_doulongvec_minmax, |
Will Deacon | 3141fcc | 2019-04-05 18:39:38 -0700 | [diff] [blame] | 1929 | .extra1 = &zero_ul, |
Christian Brauner | 6b65c26 | 2019-03-07 16:29:43 -0800 | [diff] [blame] | 1930 | .extra2 = &long_max, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1931 | }, |
| 1932 | { |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1933 | .procname = "nr_open", |
| 1934 | .data = &sysctl_nr_open, |
Alexey Dobriyan | 9b80a18 | 2016-09-02 00:38:52 +0300 | [diff] [blame] | 1935 | .maxlen = sizeof(unsigned int), |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1936 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1937 | .proc_handler = proc_dointvec_minmax, |
Al Viro | eceea0b | 2008-05-10 10:08:32 -0400 | [diff] [blame] | 1938 | .extra1 = &sysctl_nr_open_min, |
| 1939 | .extra2 = &sysctl_nr_open_max, |
Eric Dumazet | 9cfe015 | 2008-02-06 01:37:16 -0800 | [diff] [blame] | 1940 | }, |
| 1941 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1942 | .procname = "dentry-state", |
| 1943 | .data = &dentry_stat, |
Glauber Costa | 3942c07 | 2013-08-28 10:17:53 +1000 | [diff] [blame] | 1944 | .maxlen = 6*sizeof(long), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1945 | .mode = 0444, |
Christoph Hellwig | 312d3ca | 2010-10-10 05:36:23 -0400 | [diff] [blame] | 1946 | .proc_handler = proc_nr_dentry, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1947 | }, |
| 1948 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1949 | .procname = "overflowuid", |
| 1950 | .data = &fs_overflowuid, |
| 1951 | .maxlen = sizeof(int), |
| 1952 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1953 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1954 | .extra1 = &minolduid, |
| 1955 | .extra2 = &maxolduid, |
| 1956 | }, |
| 1957 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1958 | .procname = "overflowgid", |
| 1959 | .data = &fs_overflowgid, |
| 1960 | .maxlen = sizeof(int), |
| 1961 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1962 | .proc_handler = proc_dointvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | .extra1 = &minolduid, |
| 1964 | .extra2 = &maxolduid, |
| 1965 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1966 | #ifdef CONFIG_FILE_LOCKING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1967 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1968 | .procname = "leases-enable", |
| 1969 | .data = &leases_enable, |
| 1970 | .maxlen = sizeof(int), |
| 1971 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1972 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1973 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1974 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1975 | #ifdef CONFIG_DNOTIFY |
| 1976 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1977 | .procname = "dir-notify-enable", |
| 1978 | .data = &dir_notify_enable, |
| 1979 | .maxlen = sizeof(int), |
| 1980 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1981 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | }, |
| 1983 | #endif |
| 1984 | #ifdef CONFIG_MMU |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1985 | #ifdef CONFIG_FILE_LOCKING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1986 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1987 | .procname = "lease-break-time", |
| 1988 | .data = &lease_break_time, |
| 1989 | .maxlen = sizeof(int), |
| 1990 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 1991 | .proc_handler = proc_dointvec, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | }, |
Thomas Petazzoni | bfcd17a | 2008-08-06 15:12:22 +0200 | [diff] [blame] | 1993 | #endif |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 1994 | #ifdef CONFIG_AIO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1996 | .procname = "aio-nr", |
| 1997 | .data = &aio_nr, |
| 1998 | .maxlen = sizeof(aio_nr), |
| 1999 | .mode = 0444, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 2000 | .proc_handler = proc_doulongvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | }, |
| 2002 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | .procname = "aio-max-nr", |
| 2004 | .data = &aio_max_nr, |
| 2005 | .maxlen = sizeof(aio_max_nr), |
| 2006 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 2007 | .proc_handler = proc_doulongvec_minmax, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | }, |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 2009 | #endif /* CONFIG_AIO */ |
Amy Griffis | 2d9048e | 2006-06-01 13:10:59 -0700 | [diff] [blame] | 2010 | #ifdef CONFIG_INOTIFY_USER |
Robert Love | 0399cb0 | 2005-07-13 12:38:18 -0400 | [diff] [blame] | 2011 | { |
Robert Love | 0399cb0 | 2005-07-13 12:38:18 -0400 | [diff] [blame] | 2012 | .procname = "inotify", |
| 2013 | .mode = 0555, |
| 2014 | .child = inotify_table, |
| 2015 | }, |
| 2016 | #endif |
Davide Libenzi | 7ef9964 | 2008-12-01 13:13:55 -0800 | [diff] [blame] | 2017 | #ifdef CONFIG_EPOLL |
| 2018 | { |
| 2019 | .procname = "epoll", |
| 2020 | .mode = 0555, |
| 2021 | .child = epoll_table, |
| 2022 | }, |
| 2023 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | #endif |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 2025 | { |
Kees Cook | 800179c | 2012-07-25 17:29:07 -0700 | [diff] [blame] | 2026 | .procname = "protected_symlinks", |
| 2027 | .data = &sysctl_protected_symlinks, |
| 2028 | .maxlen = sizeof(int), |
| 2029 | .mode = 0600, |
| 2030 | .proc_handler = proc_dointvec_minmax, |
| 2031 | .extra1 = &zero, |
| 2032 | .extra2 = &one, |
| 2033 | }, |
| 2034 | { |
| 2035 | .procname = "protected_hardlinks", |
| 2036 | .data = &sysctl_protected_hardlinks, |
| 2037 | .maxlen = sizeof(int), |
| 2038 | .mode = 0600, |
| 2039 | .proc_handler = proc_dointvec_minmax, |
| 2040 | .extra1 = &zero, |
| 2041 | .extra2 = &one, |
| 2042 | }, |
| 2043 | { |
Salvatore Mesoraca | 0c41bee | 2018-08-23 17:00:35 -0700 | [diff] [blame] | 2044 | .procname = "protected_fifos", |
| 2045 | .data = &sysctl_protected_fifos, |
| 2046 | .maxlen = sizeof(int), |
| 2047 | .mode = 0600, |
| 2048 | .proc_handler = proc_dointvec_minmax, |
| 2049 | .extra1 = &zero, |
| 2050 | .extra2 = &two, |
| 2051 | }, |
| 2052 | { |
| 2053 | .procname = "protected_regular", |
| 2054 | .data = &sysctl_protected_regular, |
| 2055 | .maxlen = sizeof(int), |
| 2056 | .mode = 0600, |
| 2057 | .proc_handler = proc_dointvec_minmax, |
| 2058 | .extra1 = &zero, |
| 2059 | .extra2 = &two, |
| 2060 | }, |
| 2061 | { |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 2062 | .procname = "suid_dumpable", |
| 2063 | .data = &suid_dumpable, |
| 2064 | .maxlen = sizeof(int), |
| 2065 | .mode = 0644, |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2066 | .proc_handler = proc_dointvec_minmax_coredump, |
Matthew Wilcox | 8e654fb | 2009-04-02 16:58:33 -0700 | [diff] [blame] | 2067 | .extra1 = &zero, |
| 2068 | .extra2 = &two, |
Alan Cox | d6e7114 | 2005-06-23 00:09:43 -0700 | [diff] [blame] | 2069 | }, |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 2070 | #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) |
| 2071 | { |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 2072 | .procname = "binfmt_misc", |
| 2073 | .mode = 0555, |
Eric W. Biederman | f9bd673 | 2015-05-09 22:09:14 -0500 | [diff] [blame] | 2074 | .child = sysctl_mount_point, |
Eric W. Biederman | 2abc26f | 2007-02-14 00:34:07 -0800 | [diff] [blame] | 2075 | }, |
| 2076 | #endif |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 2077 | { |
Jens Axboe | ff9da69 | 2010-06-03 14:54:39 +0200 | [diff] [blame] | 2078 | .procname = "pipe-max-size", |
| 2079 | .data = &pipe_max_size, |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 2080 | .maxlen = sizeof(int), |
| 2081 | .mode = 0644, |
Jens Axboe | ff9da69 | 2010-06-03 14:54:39 +0200 | [diff] [blame] | 2082 | .proc_handler = &pipe_proc_fn, |
| 2083 | .extra1 = &pipe_min_size, |
Jens Axboe | b492e95 | 2010-05-19 21:03:16 +0200 | [diff] [blame] | 2084 | }, |
Willy Tarreau | 759c011 | 2016-01-18 16:36:09 +0100 | [diff] [blame] | 2085 | { |
| 2086 | .procname = "pipe-user-pages-hard", |
| 2087 | .data = &pipe_user_pages_hard, |
| 2088 | .maxlen = sizeof(pipe_user_pages_hard), |
| 2089 | .mode = 0644, |
| 2090 | .proc_handler = proc_doulongvec_minmax, |
| 2091 | }, |
| 2092 | { |
| 2093 | .procname = "pipe-user-pages-soft", |
| 2094 | .data = &pipe_user_pages_soft, |
| 2095 | .maxlen = sizeof(pipe_user_pages_soft), |
| 2096 | .mode = 0644, |
| 2097 | .proc_handler = proc_doulongvec_minmax, |
| 2098 | }, |
Eric W. Biederman | d292168 | 2016-09-28 00:27:17 -0500 | [diff] [blame] | 2099 | { |
| 2100 | .procname = "mount-max", |
| 2101 | .data = &sysctl_mount_max, |
| 2102 | .maxlen = sizeof(unsigned int), |
| 2103 | .mode = 0644, |
| 2104 | .proc_handler = proc_dointvec_minmax, |
| 2105 | .extra1 = &one, |
| 2106 | }, |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 2107 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | }; |
| 2109 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2110 | static struct ctl_table debug_table[] = { |
Catalin Marinas | 7ac57a8 | 2012-10-08 16:28:16 -0700 | [diff] [blame] | 2111 | #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 2112 | { |
Masoud Asgharifard Sharbiani | abd4f75 | 2007-07-22 11:12:28 +0200 | [diff] [blame] | 2113 | .procname = "exception-trace", |
| 2114 | .data = &show_unhandled_signals, |
| 2115 | .maxlen = sizeof(int), |
| 2116 | .mode = 0644, |
| 2117 | .proc_handler = proc_dointvec |
| 2118 | }, |
| 2119 | #endif |
Masami Hiramatsu | b2be84d | 2010-02-25 08:34:15 -0500 | [diff] [blame] | 2120 | #if defined(CONFIG_OPTPROBES) |
| 2121 | { |
| 2122 | .procname = "kprobes-optimization", |
| 2123 | .data = &sysctl_kprobes_optimization, |
| 2124 | .maxlen = sizeof(int), |
| 2125 | .mode = 0644, |
| 2126 | .proc_handler = proc_kprobes_optimization_handler, |
| 2127 | .extra1 = &zero, |
| 2128 | .extra2 = &one, |
| 2129 | }, |
| 2130 | #endif |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 2131 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | }; |
| 2133 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2134 | static struct ctl_table dev_table[] = { |
Eric W. Biederman | 6fce56e | 2009-04-03 02:30:53 -0700 | [diff] [blame] | 2135 | { } |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 2136 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2137 | |
Eric W. Biederman | de4e83bd | 2012-01-06 03:34:20 -0800 | [diff] [blame] | 2138 | int __init sysctl_init(void) |
Al Viro | 330d57f | 2005-11-04 10:18:40 +0000 | [diff] [blame] | 2139 | { |
Steven Rostedt | fd4b616 | 2012-07-30 14:42:48 -0700 | [diff] [blame] | 2140 | struct ctl_table_header *hdr; |
| 2141 | |
| 2142 | hdr = register_sysctl_table(sysctl_base_table); |
| 2143 | kmemleak_not_leak(hdr); |
Eric W. Biederman | d912b0c | 2007-02-14 00:34:13 -0800 | [diff] [blame] | 2144 | return 0; |
| 2145 | } |
| 2146 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2147 | #endif /* CONFIG_SYSCTL */ |
| 2148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | /* |
| 2150 | * /proc/sys support |
| 2151 | */ |
| 2152 | |
Eric W. Biederman | b89a817 | 2006-09-27 01:51:04 -0700 | [diff] [blame] | 2153 | #ifdef CONFIG_PROC_SYSCTL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2155 | static int _proc_do_string(char *data, int maxlen, int write, |
| 2156 | char __user *buffer, |
Adrian Bunk | b1ba4dd | 2006-10-02 02:18:05 -0700 | [diff] [blame] | 2157 | size_t *lenp, loff_t *ppos) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2158 | { |
| 2159 | size_t len; |
| 2160 | char __user *p; |
| 2161 | char c; |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2162 | |
| 2163 | if (!data || !maxlen || !*lenp) { |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2164 | *lenp = 0; |
| 2165 | return 0; |
| 2166 | } |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2167 | |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2168 | if (write) { |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2169 | if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { |
| 2170 | /* Only continue writes not past the end of buffer. */ |
| 2171 | len = strlen(data); |
| 2172 | if (len > maxlen - 1) |
| 2173 | len = maxlen - 1; |
| 2174 | |
| 2175 | if (*ppos > len) |
| 2176 | return 0; |
| 2177 | len = *ppos; |
| 2178 | } else { |
| 2179 | /* Start writing from beginning of buffer. */ |
| 2180 | len = 0; |
| 2181 | } |
| 2182 | |
Kees Cook | 2ca9bb4 | 2014-06-06 14:37:18 -0700 | [diff] [blame] | 2183 | *ppos += *lenp; |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2184 | p = buffer; |
Kees Cook | 2ca9bb4 | 2014-06-06 14:37:18 -0700 | [diff] [blame] | 2185 | while ((p - buffer) < *lenp && len < maxlen - 1) { |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2186 | if (get_user(c, p++)) |
| 2187 | return -EFAULT; |
| 2188 | if (c == 0 || c == '\n') |
| 2189 | break; |
Kees Cook | 2ca9bb4 | 2014-06-06 14:37:18 -0700 | [diff] [blame] | 2190 | data[len++] = c; |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2191 | } |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2192 | data[len] = 0; |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2193 | } else { |
| 2194 | len = strlen(data); |
| 2195 | if (len > maxlen) |
| 2196 | len = maxlen; |
Oleg Nesterov | 8d06087 | 2007-02-10 01:46:38 -0800 | [diff] [blame] | 2197 | |
| 2198 | if (*ppos > len) { |
| 2199 | *lenp = 0; |
| 2200 | return 0; |
| 2201 | } |
| 2202 | |
| 2203 | data += *ppos; |
| 2204 | len -= *ppos; |
| 2205 | |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2206 | if (len > *lenp) |
| 2207 | len = *lenp; |
| 2208 | if (len) |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2209 | if (copy_to_user(buffer, data, len)) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2210 | return -EFAULT; |
| 2211 | if (len < *lenp) { |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2212 | if (put_user('\n', buffer + len)) |
Sam Vilain | f5dd3d6 | 2006-10-02 02:18:04 -0700 | [diff] [blame] | 2213 | return -EFAULT; |
| 2214 | len++; |
| 2215 | } |
| 2216 | *lenp = len; |
| 2217 | *ppos += len; |
| 2218 | } |
| 2219 | return 0; |
| 2220 | } |
| 2221 | |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2222 | static void warn_sysctl_write(struct ctl_table *table) |
| 2223 | { |
| 2224 | pr_warn_once("%s wrote to %s when file position was not 0!\n" |
| 2225 | "This will not be supported in the future. To silence this\n" |
| 2226 | "warning, set kernel.sysctl_writes_strict = -1\n", |
| 2227 | current->comm, table->procname); |
| 2228 | } |
| 2229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | /** |
| 2231 | * proc_dostring - read a string sysctl |
| 2232 | * @table: the sysctl table |
| 2233 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | * @buffer: the user buffer |
| 2235 | * @lenp: the size of the user buffer |
| 2236 | * @ppos: file position |
| 2237 | * |
| 2238 | * Reads/writes a string from/to the user buffer. If the kernel |
| 2239 | * buffer provided is not large enough to hold the string, the |
| 2240 | * string is truncated. The copied string is %NULL-terminated. |
| 2241 | * If the string is being read by the user process, it is copied |
| 2242 | * and a newline '\n' is added. It is truncated if the buffer is |
| 2243 | * not large enough. |
| 2244 | * |
| 2245 | * Returns 0 on success. |
| 2246 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2247 | int proc_dostring(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2249 | { |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2250 | if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN) |
| 2251 | warn_sysctl_write(table); |
| 2252 | |
Kees Cook | f880830 | 2014-06-06 14:37:17 -0700 | [diff] [blame] | 2253 | return _proc_do_string((char *)(table->data), table->maxlen, write, |
| 2254 | (char __user *)buffer, lenp, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | } |
| 2256 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2257 | static size_t proc_skip_spaces(char **buf) |
| 2258 | { |
| 2259 | size_t ret; |
| 2260 | char *tmp = skip_spaces(*buf); |
| 2261 | ret = tmp - *buf; |
| 2262 | *buf = tmp; |
| 2263 | return ret; |
| 2264 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 2266 | static void proc_skip_char(char **buf, size_t *size, const char v) |
| 2267 | { |
| 2268 | while (*size) { |
| 2269 | if (**buf != v) |
| 2270 | break; |
| 2271 | (*size)--; |
| 2272 | (*buf)++; |
| 2273 | } |
| 2274 | } |
| 2275 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2276 | #define TMPBUFLEN 22 |
| 2277 | /** |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2278 | * proc_get_long - reads an ASCII formatted integer from a user buffer |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2279 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2280 | * @buf: a kernel buffer |
| 2281 | * @size: size of the kernel buffer |
| 2282 | * @val: this is where the number will be stored |
| 2283 | * @neg: set to %TRUE if number is negative |
| 2284 | * @perm_tr: a vector which contains the allowed trailers |
| 2285 | * @perm_tr_len: size of the perm_tr vector |
| 2286 | * @tr: pointer to store the trailer character |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2287 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2288 | * In case of success %0 is returned and @buf and @size are updated with |
| 2289 | * the amount of bytes read. If @tr is non-NULL and a trailing |
| 2290 | * character exists (size is non-zero after returning from this |
| 2291 | * function), @tr is updated with the trailing character. |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2292 | */ |
| 2293 | static int proc_get_long(char **buf, size_t *size, |
| 2294 | unsigned long *val, bool *neg, |
| 2295 | const char *perm_tr, unsigned perm_tr_len, char *tr) |
| 2296 | { |
| 2297 | int len; |
| 2298 | char *p, tmp[TMPBUFLEN]; |
| 2299 | |
| 2300 | if (!*size) |
| 2301 | return -EINVAL; |
| 2302 | |
| 2303 | len = *size; |
| 2304 | if (len > TMPBUFLEN - 1) |
| 2305 | len = TMPBUFLEN - 1; |
| 2306 | |
| 2307 | memcpy(tmp, *buf, len); |
| 2308 | |
| 2309 | tmp[len] = 0; |
| 2310 | p = tmp; |
| 2311 | if (*p == '-' && *size > 1) { |
| 2312 | *neg = true; |
| 2313 | p++; |
| 2314 | } else |
| 2315 | *neg = false; |
| 2316 | if (!isdigit(*p)) |
| 2317 | return -EINVAL; |
| 2318 | |
| 2319 | *val = simple_strtoul(p, &p, 0); |
| 2320 | |
| 2321 | len = p - tmp; |
| 2322 | |
| 2323 | /* We don't know if the next char is whitespace thus we may accept |
| 2324 | * invalid integers (e.g. 1234...a) or two integers instead of one |
| 2325 | * (e.g. 123...1). So lets not allow such large numbers. */ |
| 2326 | if (len == TMPBUFLEN - 1) |
| 2327 | return -EINVAL; |
| 2328 | |
| 2329 | if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) |
| 2330 | return -EINVAL; |
| 2331 | |
| 2332 | if (tr && (len < *size)) |
| 2333 | *tr = *p; |
| 2334 | |
| 2335 | *buf += len; |
| 2336 | *size -= len; |
| 2337 | |
| 2338 | return 0; |
| 2339 | } |
| 2340 | |
| 2341 | /** |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2342 | * proc_put_long - converts an integer to a decimal ASCII formatted string |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2343 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2344 | * @buf: the user buffer |
| 2345 | * @size: the size of the user buffer |
| 2346 | * @val: the integer to be converted |
| 2347 | * @neg: sign of the number, %TRUE for negative |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2348 | * |
Randy Dunlap | 0fc377b | 2010-05-21 11:29:53 -0700 | [diff] [blame] | 2349 | * In case of success %0 is returned and @buf and @size are updated with |
| 2350 | * the amount of bytes written. |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2351 | */ |
| 2352 | static int proc_put_long(void __user **buf, size_t *size, unsigned long val, |
| 2353 | bool neg) |
| 2354 | { |
| 2355 | int len; |
| 2356 | char tmp[TMPBUFLEN], *p = tmp; |
| 2357 | |
| 2358 | sprintf(p, "%s%lu", neg ? "-" : "", val); |
| 2359 | len = strlen(tmp); |
| 2360 | if (len > *size) |
| 2361 | len = *size; |
| 2362 | if (copy_to_user(*buf, tmp, len)) |
| 2363 | return -EFAULT; |
| 2364 | *size -= len; |
| 2365 | *buf += len; |
| 2366 | return 0; |
| 2367 | } |
| 2368 | #undef TMPBUFLEN |
| 2369 | |
| 2370 | static int proc_put_char(void __user **buf, size_t *size, char c) |
| 2371 | { |
| 2372 | if (*size) { |
| 2373 | char __user **buffer = (char __user **)buf; |
| 2374 | if (put_user(c, *buffer)) |
| 2375 | return -EFAULT; |
| 2376 | (*size)--, (*buffer)++; |
| 2377 | *buf = *buffer; |
| 2378 | } |
| 2379 | return 0; |
| 2380 | } |
| 2381 | |
| 2382 | static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | int *valp, |
| 2384 | int write, void *data) |
| 2385 | { |
| 2386 | if (write) { |
Heinrich Schuchardt | 230633d | 2015-04-16 12:48:07 -0700 | [diff] [blame] | 2387 | if (*negp) { |
| 2388 | if (*lvalp > (unsigned long) INT_MAX + 1) |
| 2389 | return -EINVAL; |
| 2390 | *valp = -*lvalp; |
| 2391 | } else { |
| 2392 | if (*lvalp > (unsigned long) INT_MAX) |
| 2393 | return -EINVAL; |
| 2394 | *valp = *lvalp; |
| 2395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | } else { |
| 2397 | int val = *valp; |
| 2398 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2399 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2400 | *lvalp = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2402 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | *lvalp = (unsigned long)val; |
| 2404 | } |
| 2405 | } |
| 2406 | return 0; |
| 2407 | } |
| 2408 | |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2409 | static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp, |
| 2410 | int *valp, |
| 2411 | int write, void *data) |
| 2412 | { |
| 2413 | if (write) { |
| 2414 | if (*negp) |
| 2415 | return -EINVAL; |
Liping Zhang | 7bdacd3 | 2017-04-07 23:51:07 +0800 | [diff] [blame] | 2416 | if (*lvalp > UINT_MAX) |
| 2417 | return -EINVAL; |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2418 | *valp = *lvalp; |
| 2419 | } else { |
| 2420 | unsigned int val = *valp; |
Liping Zhang | 3a20c57 | 2017-04-07 23:51:06 +0800 | [diff] [blame] | 2421 | *negp = false; |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2422 | *lvalp = (unsigned long)val; |
| 2423 | } |
| 2424 | return 0; |
| 2425 | } |
| 2426 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2427 | static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; |
| 2428 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2429 | static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2430 | int write, void __user *buffer, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2431 | size_t *lenp, loff_t *ppos, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2432 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2433 | int write, void *data), |
| 2434 | void *data) |
| 2435 | { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2436 | int *i, vleft, first = 1, err = 0; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2437 | size_t left; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2438 | char *kbuf = NULL, *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2440 | if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | *lenp = 0; |
| 2442 | return 0; |
| 2443 | } |
| 2444 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2445 | i = (int *) tbl_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2446 | vleft = table->maxlen / sizeof(*i); |
| 2447 | left = *lenp; |
| 2448 | |
| 2449 | if (!conv) |
| 2450 | conv = do_proc_dointvec_conv; |
| 2451 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2452 | if (write) { |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2453 | if (*ppos) { |
| 2454 | switch (sysctl_writes_strict) { |
| 2455 | case SYSCTL_WRITES_STRICT: |
| 2456 | goto out; |
| 2457 | case SYSCTL_WRITES_WARN: |
| 2458 | warn_sysctl_write(table); |
| 2459 | break; |
| 2460 | default: |
| 2461 | break; |
| 2462 | } |
| 2463 | } |
| 2464 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2465 | if (left > PAGE_SIZE - 1) |
| 2466 | left = PAGE_SIZE - 1; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2467 | p = kbuf = memdup_user_nul(buffer, left); |
| 2468 | if (IS_ERR(kbuf)) |
| 2469 | return PTR_ERR(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2470 | } |
| 2471 | |
| 2472 | for (; left && vleft--; i++, first=0) { |
| 2473 | unsigned long lval; |
| 2474 | bool neg; |
| 2475 | |
| 2476 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2477 | left -= proc_skip_spaces(&p); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2478 | |
J. R. Okajima | 563b046 | 2010-05-25 16:10:14 -0700 | [diff] [blame] | 2479 | if (!left) |
| 2480 | break; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2481 | err = proc_get_long(&p, &left, &lval, &neg, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2482 | proc_wspace_sep, |
| 2483 | sizeof(proc_wspace_sep), NULL); |
| 2484 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2485 | break; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2486 | if (conv(&neg, &lval, i, 1, data)) { |
| 2487 | err = -EINVAL; |
| 2488 | break; |
| 2489 | } |
| 2490 | } else { |
| 2491 | if (conv(&neg, &lval, i, 0, data)) { |
| 2492 | err = -EINVAL; |
| 2493 | break; |
| 2494 | } |
| 2495 | if (!first) |
| 2496 | err = proc_put_char(&buffer, &left, '\t'); |
| 2497 | if (err) |
| 2498 | break; |
| 2499 | err = proc_put_long(&buffer, &left, lval, neg); |
| 2500 | if (err) |
| 2501 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | } |
| 2503 | } |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2504 | |
| 2505 | if (!write && !first && left && !err) |
| 2506 | err = proc_put_char(&buffer, &left, '\n'); |
J. R. Okajima | 563b046 | 2010-05-25 16:10:14 -0700 | [diff] [blame] | 2507 | if (write && !err && left) |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2508 | left -= proc_skip_spaces(&p); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2509 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2510 | kfree(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2511 | if (first) |
| 2512 | return err ? : -EINVAL; |
| 2513 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2514 | *lenp -= left; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2515 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | *ppos += *lenp; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2517 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2518 | } |
| 2519 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2520 | static int do_proc_dointvec(struct ctl_table *table, int write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2521 | void __user *buffer, size_t *lenp, loff_t *ppos, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2522 | int (*conv)(bool *negp, unsigned long *lvalp, int *valp, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2523 | int write, void *data), |
| 2524 | void *data) |
| 2525 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2526 | return __do_proc_dointvec(table->data, table, write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2527 | buffer, lenp, ppos, conv, data); |
| 2528 | } |
| 2529 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | /** |
| 2531 | * proc_dointvec - read a vector of integers |
| 2532 | * @table: the sysctl table |
| 2533 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | * @buffer: the user buffer |
| 2535 | * @lenp: the size of the user buffer |
| 2536 | * @ppos: file position |
| 2537 | * |
| 2538 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2539 | * values from/to the user buffer, treated as an ASCII string. |
| 2540 | * |
| 2541 | * Returns 0 on success. |
| 2542 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2543 | int proc_dointvec(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2545 | { |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 2546 | return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); |
| 2547 | } |
| 2548 | |
| 2549 | /** |
| 2550 | * proc_douintvec - read a vector of unsigned integers |
| 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 | * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer |
| 2558 | * values from/to the user buffer, treated as an ASCII string. |
| 2559 | * |
| 2560 | * Returns 0 on success. |
| 2561 | */ |
| 2562 | int proc_douintvec(struct ctl_table *table, int write, |
| 2563 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2564 | { |
| 2565 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
| 2566 | do_proc_douintvec_conv, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2567 | } |
| 2568 | |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2569 | /* |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2570 | * Taint values can only be increased |
| 2571 | * This means we can safely use a temporary. |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2572 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2573 | static int proc_taint(struct ctl_table *table, int write, |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2574 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2575 | { |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2576 | struct ctl_table t; |
| 2577 | unsigned long tmptaint = get_taint(); |
| 2578 | int err; |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2579 | |
Bastian Blank | 91fcd41 | 2007-04-23 14:41:14 -0700 | [diff] [blame] | 2580 | if (write && !capable(CAP_SYS_ADMIN)) |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2581 | return -EPERM; |
| 2582 | |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2583 | t = *table; |
| 2584 | t.data = &tmptaint; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2585 | err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2586 | if (err < 0) |
| 2587 | return err; |
| 2588 | |
| 2589 | if (write) { |
| 2590 | /* |
| 2591 | * Poor man's atomic or. Not worth adding a primitive |
| 2592 | * to everyone's atomic.h for this |
| 2593 | */ |
| 2594 | int i; |
| 2595 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { |
| 2596 | if ((tmptaint >> i) & 1) |
Rusty Russell | 373d4d0 | 2013-01-21 17:17:39 +1030 | [diff] [blame] | 2597 | add_taint(i, LOCKDEP_STILL_OK); |
Andi Kleen | 25ddbb1 | 2008-10-15 22:01:41 -0700 | [diff] [blame] | 2598 | } |
| 2599 | } |
| 2600 | |
| 2601 | return err; |
Theodore Ts'o | 34f5a39 | 2007-02-10 01:45:24 -0800 | [diff] [blame] | 2602 | } |
| 2603 | |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 2604 | #ifdef CONFIG_PRINTK |
Kees Cook | 620f6e8 | 2012-04-04 11:40:19 -0700 | [diff] [blame] | 2605 | static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, |
Richard Weinberger | bfdc0b4 | 2011-03-23 16:43:11 -0700 | [diff] [blame] | 2606 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2607 | { |
| 2608 | if (write && !capable(CAP_SYS_ADMIN)) |
| 2609 | return -EPERM; |
| 2610 | |
| 2611 | return proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
| 2612 | } |
| 2613 | #endif |
| 2614 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | struct do_proc_dointvec_minmax_conv_param { |
| 2616 | int *min; |
| 2617 | int *max; |
| 2618 | }; |
| 2619 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2620 | static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, |
| 2621 | int *valp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | int write, void *data) |
| 2623 | { |
| 2624 | struct do_proc_dointvec_minmax_conv_param *param = data; |
| 2625 | if (write) { |
Zev Weiss | 45a67f1 | 2019-03-11 23:28:02 -0700 | [diff] [blame] | 2626 | int val; |
| 2627 | if (*negp) { |
| 2628 | if (*lvalp > (unsigned long) INT_MAX + 1) |
| 2629 | return -EINVAL; |
| 2630 | val = -*lvalp; |
| 2631 | } else { |
| 2632 | if (*lvalp > (unsigned long) INT_MAX) |
| 2633 | return -EINVAL; |
| 2634 | val = *lvalp; |
| 2635 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | if ((param->min && *param->min > val) || |
| 2637 | (param->max && *param->max < val)) |
| 2638 | return -EINVAL; |
| 2639 | *valp = val; |
| 2640 | } else { |
| 2641 | int val = *valp; |
| 2642 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2643 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2644 | *lvalp = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2645 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2646 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | *lvalp = (unsigned long)val; |
| 2648 | } |
| 2649 | } |
| 2650 | return 0; |
| 2651 | } |
| 2652 | |
| 2653 | /** |
| 2654 | * proc_dointvec_minmax - read a vector of integers with min/max values |
| 2655 | * @table: the sysctl table |
| 2656 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | * @buffer: the user buffer |
| 2658 | * @lenp: the size of the user buffer |
| 2659 | * @ppos: file position |
| 2660 | * |
| 2661 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2662 | * values from/to the user buffer, treated as an ASCII string. |
| 2663 | * |
| 2664 | * This routine will ensure the values are within the range specified by |
| 2665 | * table->extra1 (min) and table->extra2 (max). |
| 2666 | * |
| 2667 | * Returns 0 on success. |
| 2668 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2669 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2671 | { |
| 2672 | struct do_proc_dointvec_minmax_conv_param param = { |
| 2673 | .min = (int *) table->extra1, |
| 2674 | .max = (int *) table->extra2, |
| 2675 | }; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2676 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2677 | do_proc_dointvec_minmax_conv, ¶m); |
| 2678 | } |
| 2679 | |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2680 | static void validate_coredump_safety(void) |
| 2681 | { |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2682 | #ifdef CONFIG_COREDUMP |
Kees Cook | e579d2c | 2013-02-27 17:03:15 -0800 | [diff] [blame] | 2683 | if (suid_dumpable == SUID_DUMP_ROOT && |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2684 | core_pattern[0] != '/' && core_pattern[0] != '|') { |
| 2685 | printk(KERN_WARNING "Unsafe core_pattern used with "\ |
| 2686 | "suid_dumpable=2. Pipe handler or fully qualified "\ |
| 2687 | "core dump path required.\n"); |
| 2688 | } |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2689 | #endif |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2690 | } |
| 2691 | |
| 2692 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, |
| 2693 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2694 | { |
| 2695 | int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
| 2696 | if (!error) |
| 2697 | validate_coredump_safety(); |
| 2698 | return error; |
| 2699 | } |
| 2700 | |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2701 | #ifdef CONFIG_COREDUMP |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2702 | static int proc_dostring_coredump(struct ctl_table *table, int write, |
| 2703 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2704 | { |
| 2705 | int error = proc_dostring(table, write, buffer, lenp, ppos); |
| 2706 | if (!error) |
| 2707 | validate_coredump_safety(); |
| 2708 | return error; |
| 2709 | } |
Alex Kelly | 046d662 | 2012-10-04 17:15:23 -0700 | [diff] [blame] | 2710 | #endif |
Kees Cook | 54b5019 | 2012-07-30 14:39:18 -0700 | [diff] [blame] | 2711 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2712 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2713 | void __user *buffer, |
| 2714 | size_t *lenp, loff_t *ppos, |
| 2715 | unsigned long convmul, |
| 2716 | unsigned long convdiv) |
| 2717 | { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2718 | unsigned long *i, *min, *max; |
| 2719 | int vleft, first = 1, err = 0; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2720 | size_t left; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2721 | char *kbuf = NULL, *p; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2722 | |
| 2723 | if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2724 | *lenp = 0; |
| 2725 | return 0; |
| 2726 | } |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2727 | |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2728 | i = (unsigned long *) data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2729 | min = (unsigned long *) table->extra1; |
| 2730 | max = (unsigned long *) table->extra2; |
| 2731 | vleft = table->maxlen / sizeof(unsigned long); |
| 2732 | left = *lenp; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2733 | |
| 2734 | if (write) { |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2735 | if (*ppos) { |
| 2736 | switch (sysctl_writes_strict) { |
| 2737 | case SYSCTL_WRITES_STRICT: |
| 2738 | goto out; |
| 2739 | case SYSCTL_WRITES_WARN: |
| 2740 | warn_sysctl_write(table); |
| 2741 | break; |
| 2742 | default: |
| 2743 | break; |
| 2744 | } |
| 2745 | } |
| 2746 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2747 | if (left > PAGE_SIZE - 1) |
| 2748 | left = PAGE_SIZE - 1; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2749 | p = kbuf = memdup_user_nul(buffer, left); |
| 2750 | if (IS_ERR(kbuf)) |
| 2751 | return PTR_ERR(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2752 | } |
| 2753 | |
Eric Dumazet | 27b3d80 | 2010-10-07 12:59:29 -0700 | [diff] [blame] | 2754 | for (; left && vleft--; i++, first = 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2755 | unsigned long val; |
| 2756 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2757 | if (write) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2758 | bool neg; |
| 2759 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2760 | left -= proc_skip_spaces(&p); |
Cheng Lin | 0e5c750 | 2019-01-03 15:26:13 -0800 | [diff] [blame] | 2761 | if (!left) |
| 2762 | break; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2763 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2764 | err = proc_get_long(&p, &left, &val, &neg, |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2765 | proc_wspace_sep, |
| 2766 | sizeof(proc_wspace_sep), NULL); |
| 2767 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2768 | break; |
| 2769 | if (neg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2770 | continue; |
Eric Dumazet | 03707d6 | 2017-01-25 18:20:55 -0800 | [diff] [blame] | 2771 | val = convmul * val / convdiv; |
Christian Brauner | 726f69d | 2019-05-14 15:44:55 -0700 | [diff] [blame] | 2772 | if ((min && val < *min) || (max && val > *max)) { |
| 2773 | err = -EINVAL; |
| 2774 | break; |
| 2775 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2776 | *i = val; |
| 2777 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2778 | val = convdiv * (*i) / convmul; |
Chen Gang | 7833819 | 2013-11-12 15:11:21 -0800 | [diff] [blame] | 2779 | if (!first) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2780 | err = proc_put_char(&buffer, &left, '\t'); |
Chen Gang | 7833819 | 2013-11-12 15:11:21 -0800 | [diff] [blame] | 2781 | if (err) |
| 2782 | break; |
| 2783 | } |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2784 | err = proc_put_long(&buffer, &left, val, false); |
| 2785 | if (err) |
| 2786 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2787 | } |
| 2788 | } |
| 2789 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2790 | if (!write && !first && left && !err) |
| 2791 | err = proc_put_char(&buffer, &left, '\n'); |
| 2792 | if (write && !err) |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2793 | left -= proc_skip_spaces(&p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2794 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 2795 | kfree(kbuf); |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2796 | if (first) |
| 2797 | return err ? : -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2798 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2799 | *lenp -= left; |
Kees Cook | f4aacea | 2014-06-06 14:37:19 -0700 | [diff] [blame] | 2800 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2801 | *ppos += *lenp; |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2802 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2803 | } |
| 2804 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2805 | static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2806 | void __user *buffer, |
| 2807 | size_t *lenp, loff_t *ppos, |
| 2808 | unsigned long convmul, |
| 2809 | unsigned long convdiv) |
| 2810 | { |
| 2811 | return __do_proc_doulongvec_minmax(table->data, table, write, |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2812 | buffer, lenp, ppos, convmul, convdiv); |
Kirill Korotaev | fcfbd54 | 2006-10-02 02:18:23 -0700 | [diff] [blame] | 2813 | } |
| 2814 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2815 | /** |
| 2816 | * proc_doulongvec_minmax - read a vector of long integers with min/max values |
| 2817 | * @table: the sysctl table |
| 2818 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2819 | * @buffer: the user buffer |
| 2820 | * @lenp: the size of the user buffer |
| 2821 | * @ppos: file position |
| 2822 | * |
| 2823 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
| 2824 | * values from/to the user buffer, treated as an ASCII string. |
| 2825 | * |
| 2826 | * This routine will ensure the values are within the range specified by |
| 2827 | * table->extra1 (min) and table->extra2 (max). |
| 2828 | * |
| 2829 | * Returns 0 on success. |
| 2830 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2831 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2832 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2833 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2834 | return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2835 | } |
| 2836 | |
| 2837 | /** |
| 2838 | * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values |
| 2839 | * @table: the sysctl table |
| 2840 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2841 | * @buffer: the user buffer |
| 2842 | * @lenp: the size of the user buffer |
| 2843 | * @ppos: file position |
| 2844 | * |
| 2845 | * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long |
| 2846 | * values from/to the user buffer, treated as an ASCII string. The values |
| 2847 | * are treated as milliseconds, and converted to jiffies when they are stored. |
| 2848 | * |
| 2849 | * This routine will ensure the values are within the range specified by |
| 2850 | * table->extra1 (min) and table->extra2 (max). |
| 2851 | * |
| 2852 | * Returns 0 on success. |
| 2853 | */ |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 2854 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2855 | void __user *buffer, |
| 2856 | size_t *lenp, loff_t *ppos) |
| 2857 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2858 | return do_proc_doulongvec_minmax(table, write, buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2859 | lenp, ppos, HZ, 1000l); |
| 2860 | } |
| 2861 | |
| 2862 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2863 | static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2864 | int *valp, |
| 2865 | int write, void *data) |
| 2866 | { |
| 2867 | if (write) { |
Bart Samwel | cba9f33 | 2006-03-24 03:15:50 -0800 | [diff] [blame] | 2868 | if (*lvalp > LONG_MAX / HZ) |
| 2869 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2870 | *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); |
| 2871 | } else { |
| 2872 | int val = *valp; |
| 2873 | unsigned long lval; |
| 2874 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2875 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2876 | lval = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2877 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2878 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2879 | lval = (unsigned long)val; |
| 2880 | } |
| 2881 | *lvalp = lval / HZ; |
| 2882 | } |
| 2883 | return 0; |
| 2884 | } |
| 2885 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2886 | static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | int *valp, |
| 2888 | int write, void *data) |
| 2889 | { |
| 2890 | if (write) { |
Bart Samwel | cba9f33 | 2006-03-24 03:15:50 -0800 | [diff] [blame] | 2891 | if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) |
| 2892 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2893 | *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); |
| 2894 | } else { |
| 2895 | int val = *valp; |
| 2896 | unsigned long lval; |
| 2897 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2898 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2899 | lval = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2900 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2901 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2902 | lval = (unsigned long)val; |
| 2903 | } |
| 2904 | *lvalp = jiffies_to_clock_t(lval); |
| 2905 | } |
| 2906 | return 0; |
| 2907 | } |
| 2908 | |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2909 | static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2910 | int *valp, |
| 2911 | int write, void *data) |
| 2912 | { |
| 2913 | if (write) { |
Francesco Fusco | d738ce8 | 2013-07-24 10:39:07 +0200 | [diff] [blame] | 2914 | unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); |
| 2915 | |
| 2916 | if (jif > INT_MAX) |
| 2917 | return 1; |
| 2918 | *valp = (int)jif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2919 | } else { |
| 2920 | int val = *valp; |
| 2921 | unsigned long lval; |
| 2922 | if (val < 0) { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2923 | *negp = true; |
Ilya Dryomov | 9a5bc72 | 2015-09-09 15:39:06 -0700 | [diff] [blame] | 2924 | lval = -(unsigned long)val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2925 | } else { |
Amerigo Wang | 00b7c33 | 2010-05-05 00:26:45 +0000 | [diff] [blame] | 2926 | *negp = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2927 | lval = (unsigned long)val; |
| 2928 | } |
| 2929 | *lvalp = jiffies_to_msecs(lval); |
| 2930 | } |
| 2931 | return 0; |
| 2932 | } |
| 2933 | |
| 2934 | /** |
| 2935 | * proc_dointvec_jiffies - read a vector of integers as seconds |
| 2936 | * @table: the sysctl table |
| 2937 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2938 | * @buffer: the user buffer |
| 2939 | * @lenp: the size of the user buffer |
| 2940 | * @ppos: file position |
| 2941 | * |
| 2942 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2943 | * values from/to the user buffer, treated as an ASCII string. |
| 2944 | * The values read are assumed to be in seconds, and are converted into |
| 2945 | * jiffies. |
| 2946 | * |
| 2947 | * Returns 0 on success. |
| 2948 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2949 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2950 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2951 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2952 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | do_proc_dointvec_jiffies_conv,NULL); |
| 2954 | } |
| 2955 | |
| 2956 | /** |
| 2957 | * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds |
| 2958 | * @table: the sysctl table |
| 2959 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2960 | * @buffer: the user buffer |
| 2961 | * @lenp: the size of the user buffer |
Randy Dunlap | 1e5d533 | 2005-11-07 01:01:06 -0800 | [diff] [blame] | 2962 | * @ppos: pointer to the file position |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2963 | * |
| 2964 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2965 | * values from/to the user buffer, treated as an ASCII string. |
| 2966 | * The values read are assumed to be in 1/USER_HZ seconds, and |
| 2967 | * are converted into jiffies. |
| 2968 | * |
| 2969 | * Returns 0 on success. |
| 2970 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2971 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2972 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2973 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2974 | return do_proc_dointvec(table,write,buffer,lenp,ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2975 | do_proc_dointvec_userhz_jiffies_conv,NULL); |
| 2976 | } |
| 2977 | |
| 2978 | /** |
| 2979 | * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds |
| 2980 | * @table: the sysctl table |
| 2981 | * @write: %TRUE if this is a write to the sysctl file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2982 | * @buffer: the user buffer |
| 2983 | * @lenp: the size of the user buffer |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 2984 | * @ppos: file position |
| 2985 | * @ppos: the current position in the file |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2986 | * |
| 2987 | * Reads/writes up to table->maxlen/sizeof(unsigned int) integer |
| 2988 | * values from/to the user buffer, treated as an ASCII string. |
| 2989 | * The values read are assumed to be in 1/1000 seconds, and |
| 2990 | * are converted into jiffies. |
| 2991 | * |
| 2992 | * Returns 0 on success. |
| 2993 | */ |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2994 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2995 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 2996 | { |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 2997 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2998 | do_proc_dointvec_ms_jiffies_conv, NULL); |
| 2999 | } |
| 3000 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3001 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 3002 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3003 | { |
| 3004 | struct pid *new_pid; |
| 3005 | pid_t tmp; |
| 3006 | int r; |
| 3007 | |
Pavel Emelyanov | 6c5f3e7 | 2008-02-08 04:19:20 -0800 | [diff] [blame] | 3008 | tmp = pid_vnr(cad_pid); |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 3009 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3010 | r = __do_proc_dointvec(&tmp, table, write, buffer, |
Cedric Le Goater | 9ec5209 | 2006-10-02 02:19:00 -0700 | [diff] [blame] | 3011 | lenp, ppos, NULL, NULL); |
| 3012 | if (r || !write) |
| 3013 | return r; |
| 3014 | |
| 3015 | new_pid = find_get_pid(tmp); |
| 3016 | if (!new_pid) |
| 3017 | return -ESRCH; |
| 3018 | |
| 3019 | put_pid(xchg(&cad_pid, new_pid)); |
| 3020 | return 0; |
| 3021 | } |
| 3022 | |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3023 | /** |
| 3024 | * proc_do_large_bitmap - read/write from/to a large bitmap |
| 3025 | * @table: the sysctl table |
| 3026 | * @write: %TRUE if this is a write to the sysctl file |
| 3027 | * @buffer: the user buffer |
| 3028 | * @lenp: the size of the user buffer |
| 3029 | * @ppos: file position |
| 3030 | * |
| 3031 | * The bitmap is stored at table->data and the bitmap length (in bits) |
| 3032 | * in table->maxlen. |
| 3033 | * |
| 3034 | * We use a range comma separated format (e.g. 1,3-4,10-10) so that |
| 3035 | * large bitmaps may be represented in a compact manner. Writing into |
| 3036 | * the file will clear the bitmap then update it with the given input. |
| 3037 | * |
| 3038 | * Returns 0 on success. |
| 3039 | */ |
| 3040 | int proc_do_large_bitmap(struct ctl_table *table, int write, |
| 3041 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3042 | { |
| 3043 | int err = 0; |
| 3044 | bool first = 1; |
| 3045 | size_t left = *lenp; |
| 3046 | unsigned long bitmap_len = table->maxlen; |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 3047 | unsigned long *bitmap = *(unsigned long **) table->data; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3048 | unsigned long *tmp_bitmap = NULL; |
| 3049 | char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; |
| 3050 | |
WANG Cong | 122ff24 | 2014-05-12 16:04:53 -0700 | [diff] [blame] | 3051 | if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3052 | *lenp = 0; |
| 3053 | return 0; |
| 3054 | } |
| 3055 | |
| 3056 | if (write) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3057 | char *kbuf, *p; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3058 | |
| 3059 | if (left > PAGE_SIZE - 1) |
| 3060 | left = PAGE_SIZE - 1; |
| 3061 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3062 | p = kbuf = memdup_user_nul(buffer, left); |
| 3063 | if (IS_ERR(kbuf)) |
| 3064 | return PTR_ERR(kbuf); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3065 | |
| 3066 | tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), |
| 3067 | GFP_KERNEL); |
| 3068 | if (!tmp_bitmap) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3069 | kfree(kbuf); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3070 | return -ENOMEM; |
| 3071 | } |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3072 | proc_skip_char(&p, &left, '\n'); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3073 | while (!err && left) { |
| 3074 | unsigned long val_a, val_b; |
| 3075 | bool neg; |
| 3076 | |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3077 | err = proc_get_long(&p, &left, &val_a, &neg, tr_a, |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3078 | sizeof(tr_a), &c); |
| 3079 | if (err) |
| 3080 | break; |
| 3081 | if (val_a >= bitmap_len || neg) { |
| 3082 | err = -EINVAL; |
| 3083 | break; |
| 3084 | } |
| 3085 | |
| 3086 | val_b = val_a; |
| 3087 | if (left) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3088 | p++; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3089 | left--; |
| 3090 | } |
| 3091 | |
| 3092 | if (c == '-') { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3093 | err = proc_get_long(&p, &left, &val_b, |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3094 | &neg, tr_b, sizeof(tr_b), |
| 3095 | &c); |
| 3096 | if (err) |
| 3097 | break; |
| 3098 | if (val_b >= bitmap_len || neg || |
| 3099 | val_a > val_b) { |
| 3100 | err = -EINVAL; |
| 3101 | break; |
| 3102 | } |
| 3103 | if (left) { |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3104 | p++; |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3105 | left--; |
| 3106 | } |
| 3107 | } |
| 3108 | |
Akinobu Mita | 5a04cca | 2012-03-28 14:42:50 -0700 | [diff] [blame] | 3109 | bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3110 | first = 0; |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3111 | proc_skip_char(&p, &left, '\n'); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3112 | } |
Al Viro | 70f6cbb | 2015-12-24 00:13:10 -0500 | [diff] [blame] | 3113 | kfree(kbuf); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3114 | } else { |
| 3115 | unsigned long bit_a, bit_b = 0; |
| 3116 | |
| 3117 | while (left) { |
| 3118 | bit_a = find_next_bit(bitmap, bitmap_len, bit_b); |
| 3119 | if (bit_a >= bitmap_len) |
| 3120 | break; |
| 3121 | bit_b = find_next_zero_bit(bitmap, bitmap_len, |
| 3122 | bit_a + 1) - 1; |
| 3123 | |
| 3124 | if (!first) { |
| 3125 | err = proc_put_char(&buffer, &left, ','); |
| 3126 | if (err) |
| 3127 | break; |
| 3128 | } |
| 3129 | err = proc_put_long(&buffer, &left, bit_a, false); |
| 3130 | if (err) |
| 3131 | break; |
| 3132 | if (bit_a != bit_b) { |
| 3133 | err = proc_put_char(&buffer, &left, '-'); |
| 3134 | if (err) |
| 3135 | break; |
| 3136 | err = proc_put_long(&buffer, &left, bit_b, false); |
| 3137 | if (err) |
| 3138 | break; |
| 3139 | } |
| 3140 | |
| 3141 | first = 0; bit_b++; |
| 3142 | } |
| 3143 | if (!err) |
| 3144 | err = proc_put_char(&buffer, &left, '\n'); |
| 3145 | } |
| 3146 | |
| 3147 | if (!err) { |
| 3148 | if (write) { |
| 3149 | if (*ppos) |
| 3150 | bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); |
| 3151 | else |
Akinobu Mita | 5a04cca | 2012-03-28 14:42:50 -0700 | [diff] [blame] | 3152 | bitmap_copy(bitmap, tmp_bitmap, bitmap_len); |
Octavian Purdila | 9f977fb | 2010-05-05 00:26:55 +0000 | [diff] [blame] | 3153 | } |
| 3154 | kfree(tmp_bitmap); |
| 3155 | *lenp -= left; |
| 3156 | *ppos += *lenp; |
| 3157 | return 0; |
| 3158 | } else { |
| 3159 | kfree(tmp_bitmap); |
| 3160 | return err; |
| 3161 | } |
| 3162 | } |
| 3163 | |
Joonwoo Park | b02fc00 | 2017-06-16 11:58:58 -0700 | [diff] [blame] | 3164 | static int do_proc_douintvec_capacity_conv(bool *negp, unsigned long *lvalp, |
| 3165 | int *valp, int write, void *data) |
| 3166 | { |
| 3167 | if (write) { |
Satya Durga Srinivasu Prabhala | 3929bf0 | 2018-08-24 12:23:08 -0700 | [diff] [blame] | 3168 | if (*negp || *lvalp == 0) |
Joonwoo Park | b02fc00 | 2017-06-16 11:58:58 -0700 | [diff] [blame] | 3169 | return -EINVAL; |
| 3170 | *valp = SCHED_FIXEDPOINT_SCALE * 100 / *lvalp; |
| 3171 | } else { |
| 3172 | *negp = false; |
| 3173 | *lvalp = SCHED_FIXEDPOINT_SCALE * 100 / *valp; |
| 3174 | } |
| 3175 | |
| 3176 | return 0; |
| 3177 | } |
| 3178 | |
| 3179 | /** |
| 3180 | * proc_douintvec_capacity - read a vector of integers in percentage and convert |
| 3181 | * into sched capacity |
| 3182 | * @table: the sysctl table |
| 3183 | * @write: %TRUE if this is a write to the sysctl file |
| 3184 | * @buffer: the user buffer |
| 3185 | * @lenp: the size of the user buffer |
| 3186 | * @ppos: file position |
| 3187 | * |
| 3188 | * Returns 0 on success. |
| 3189 | */ |
| 3190 | int proc_douintvec_capacity(struct ctl_table *table, int write, |
| 3191 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3192 | { |
| 3193 | return do_proc_dointvec(table, write, buffer, lenp, ppos, |
| 3194 | do_proc_douintvec_capacity_conv, NULL); |
| 3195 | } |
| 3196 | |
Jovi Zhang | 5561050 | 2011-01-12 17:00:45 -0800 | [diff] [blame] | 3197 | #else /* CONFIG_PROC_SYSCTL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3198 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3199 | int proc_dostring(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3200 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3201 | { |
| 3202 | return -ENOSYS; |
| 3203 | } |
| 3204 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3205 | int proc_dointvec(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3206 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3207 | { |
| 3208 | return -ENOSYS; |
| 3209 | } |
| 3210 | |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 3211 | int proc_douintvec(struct ctl_table *table, int write, |
| 3212 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3213 | { |
| 3214 | return -ENOSYS; |
| 3215 | } |
| 3216 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3217 | int proc_dointvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3218 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3219 | { |
| 3220 | return -ENOSYS; |
| 3221 | } |
| 3222 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3223 | int proc_dointvec_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3224 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3225 | { |
| 3226 | return -ENOSYS; |
| 3227 | } |
| 3228 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3229 | int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3231 | { |
| 3232 | return -ENOSYS; |
| 3233 | } |
| 3234 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3235 | int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3236 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3237 | { |
| 3238 | return -ENOSYS; |
| 3239 | } |
| 3240 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 3241 | int proc_doulongvec_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3242 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3243 | { |
| 3244 | return -ENOSYS; |
| 3245 | } |
| 3246 | |
Eric W. Biederman | d8217f0 | 2007-10-18 03:05:22 -0700 | [diff] [blame] | 3247 | int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3248 | void __user *buffer, |
| 3249 | size_t *lenp, loff_t *ppos) |
| 3250 | { |
| 3251 | return -ENOSYS; |
| 3252 | } |
| 3253 | |
Joonwoo Park | b02fc00 | 2017-06-16 11:58:58 -0700 | [diff] [blame] | 3254 | int proc_douintvec_capacity(struct ctl_table *table, int write, |
| 3255 | void __user *buffer, size_t *lenp, loff_t *ppos) |
| 3256 | { |
| 3257 | return -ENOSYS; |
| 3258 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | |
Jovi Zhang | 5561050 | 2011-01-12 17:00:45 -0800 | [diff] [blame] | 3260 | #endif /* CONFIG_PROC_SYSCTL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3262 | /* |
| 3263 | * No sense putting this after each symbol definition, twice, |
| 3264 | * exception granted :-) |
| 3265 | */ |
| 3266 | EXPORT_SYMBOL(proc_dointvec); |
Subash Abhinov Kasiviswanathan | e7d316a | 2016-08-25 15:16:51 -0700 | [diff] [blame] | 3267 | EXPORT_SYMBOL(proc_douintvec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3268 | EXPORT_SYMBOL(proc_dointvec_jiffies); |
| 3269 | EXPORT_SYMBOL(proc_dointvec_minmax); |
| 3270 | EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); |
| 3271 | EXPORT_SYMBOL(proc_dointvec_ms_jiffies); |
| 3272 | EXPORT_SYMBOL(proc_dostring); |
| 3273 | EXPORT_SYMBOL(proc_doulongvec_minmax); |
| 3274 | EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); |