1457c8996SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * sysctl.c: General linux system control interface 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Begun 24 March 1995, Stephen Tweedie 61da177e4SLinus Torvalds * Added /proc support, Dec 1995 71da177e4SLinus Torvalds * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 81da177e4SLinus Torvalds * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. 91da177e4SLinus Torvalds * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. 101da177e4SLinus Torvalds * Dynamic registration fixes, Stephen Tweedie. 111da177e4SLinus Torvalds * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. 121da177e4SLinus Torvalds * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris 131da177e4SLinus Torvalds * Horn. 141da177e4SLinus Torvalds * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. 151da177e4SLinus Torvalds * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. 161da177e4SLinus Torvalds * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill 171da177e4SLinus Torvalds * Wendling. 181da177e4SLinus Torvalds * The list_for_each() macro wasn't appropriate for the sysctl loop. 191da177e4SLinus Torvalds * Removed it and replaced it with older style, 03/23/00, Bill Wendling 201da177e4SLinus Torvalds */ 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #include <linux/module.h> 23e2e40f2cSChristoph Hellwig #include <linux/aio.h> 241da177e4SLinus Torvalds #include <linux/mm.h> 251da177e4SLinus Torvalds #include <linux/swap.h> 261da177e4SLinus Torvalds #include <linux/slab.h> 271da177e4SLinus Torvalds #include <linux/sysctl.h> 285a04cca6SAkinobu Mita #include <linux/bitmap.h> 29d33ed52dSDave Young #include <linux/signal.h> 30455cd5abSDan Rosenberg #include <linux/printk.h> 311da177e4SLinus Torvalds #include <linux/proc_fs.h> 3272c2d582SAndrew Morgan #include <linux/security.h> 331da177e4SLinus Torvalds #include <linux/ctype.h> 34fd4b616bSSteven Rostedt #include <linux/kmemleak.h> 3562239ac2SAdrian Bunk #include <linux/fs.h> 361da177e4SLinus Torvalds #include <linux/init.h> 371da177e4SLinus Torvalds #include <linux/kernel.h> 380296b228SKay Sievers #include <linux/kobject.h> 3920380731SArnaldo Carvalho de Melo #include <linux/net.h> 401da177e4SLinus Torvalds #include <linux/sysrq.h> 411da177e4SLinus Torvalds #include <linux/highuid.h> 421da177e4SLinus Torvalds #include <linux/writeback.h> 433fff4c42SIngo Molnar #include <linux/ratelimit.h> 4476ab0f53SMel Gorman #include <linux/compaction.h> 451da177e4SLinus Torvalds #include <linux/hugetlb.h> 461da177e4SLinus Torvalds #include <linux/initrd.h> 470b77f5bfSDavid Howells #include <linux/key.h> 481da177e4SLinus Torvalds #include <linux/times.h> 491da177e4SLinus Torvalds #include <linux/limits.h> 501da177e4SLinus Torvalds #include <linux/dcache.h> 516e006701SAlexey Dobriyan #include <linux/dnotify.h> 521da177e4SLinus Torvalds #include <linux/syscalls.h> 53c748e134SAdrian Bunk #include <linux/vmstat.h> 54c255d844SPavel Machek #include <linux/nfs_fs.h> 55c255d844SPavel Machek #include <linux/acpi.h> 5610a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 57b0fc494fSSteven Rostedt #include <linux/ftrace.h> 58cdd6c482SIngo Molnar #include <linux/perf_event.h> 59b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 60b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 618e4228e1SDavid Rientjes #include <linux/oom.h> 6217f60a7dSEric Paris #include <linux/kmod.h> 6373efc039SDan Ballard #include <linux/capability.h> 6440401530SAl Viro #include <linux/binfmts.h> 65cf4aebc2SClark Williams #include <linux/sched/sysctl.h> 66f7ccbae4SIngo Molnar #include <linux/sched/coredump.h> 677984754bSKees Cook #include <linux/kexec.h> 681be7f75dSAlexei Starovoitov #include <linux/bpf.h> 69d2921684SEric W. Biederman #include <linux/mount.h> 70cefdca0aSPeter Xu #include <linux/userfaultfd_k.h> 712374c09bSChristoph Hellwig #include <linux/coredump.h> 722374c09bSChristoph Hellwig #include <linux/latencytop.h> 732374c09bSChristoph Hellwig #include <linux/pid.h> 741da177e4SLinus Torvalds 757f2923c4SChristian Brauner #include "../lib/kstrtox.h" 767f2923c4SChristian Brauner 777c0f6ba6SLinus Torvalds #include <linux/uaccess.h> 781da177e4SLinus Torvalds #include <asm/processor.h> 791da177e4SLinus Torvalds 8029cbc78bSAndi Kleen #ifdef CONFIG_X86 8129cbc78bSAndi Kleen #include <asm/nmi.h> 820741f4d2SChuck Ebbert #include <asm/stacktrace.h> 836e7c4025SIngo Molnar #include <asm/io.h> 8429cbc78bSAndi Kleen #endif 85d550bbd4SDavid Howells #ifdef CONFIG_SPARC 86d550bbd4SDavid Howells #include <asm/setup.h> 87d550bbd4SDavid Howells #endif 88c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 89c55b7c3eSDave Young #include <linux/acct.h> 90c55b7c3eSDave Young #endif 914f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 924f0e056fSDave Young #include <linux/rtmutex.h> 934f0e056fSDave Young #endif 942edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 952edf5e49SDave Young #include <linux/lockdep.h> 962edf5e49SDave Young #endif 9715485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 9815485a46SDave Young #include <scsi/sg.h> 9915485a46SDave Young #endif 100964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 101964c9dffSAlexander Popov #include <linux/stackleak.h> 102964c9dffSAlexander Popov #endif 10358687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 104504d7cf1SDon Zickus #include <linux/nmi.h> 105504d7cf1SDon Zickus #endif 106504d7cf1SDon Zickus 1071da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 1081da177e4SLinus Torvalds 109c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1102508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 111c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 112c4f3b63fSRavikiran G Thirumalai #endif 113c4f3b63fSRavikiran G Thirumalai 114270750dbSAaron Tomlin static int __maybe_unused neg_one = -1; 115cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 1165509a5d2SDave Hansen static int __maybe_unused four = 4; 1179002b214SWill Deacon static unsigned long zero_ul; 118fc3501d4SSven Wegener static unsigned long one_ul = 1; 11932a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX; 120c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 121795ae7a0SJohannes Weiner static int one_thousand = 1000; 122af91322eSDave Young #ifdef CONFIG_PRINTK 123af91322eSDave Young static int ten_thousand = 10000; 124af91322eSDave Young #endif 125c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS 126c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024; 127c5dfd78eSArnaldo Carvalho de Melo #endif 128c4f3b63fSRavikiran G Thirumalai 1299e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1309e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1319e4a5bdaSAndrea Righi 1321da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1331da177e4SLinus Torvalds static int maxolduid = 65535; 1341da177e4SLinus Torvalds static int minolduid; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 13773efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1381da177e4SLinus Torvalds 139a2e51445SDmitry Vyukov /* 140a2e51445SDmitry Vyukov * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs 141a2e51445SDmitry Vyukov * and hung_task_check_interval_secs 142a2e51445SDmitry Vyukov */ 14380df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK 14480df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); 14580df2847SLiu Hua #endif 14680df2847SLiu Hua 147d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 148d14f1729SDave Young #include <linux/inotify.h> 149d14f1729SDave Young #endif 150b6fca725SVineet Gupta 151d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 152f4aacea2SKees Cook 153a19ac337SLuis R. Rodriguez /** 154a19ac337SLuis R. Rodriguez * enum sysctl_writes_mode - supported sysctl write modes 155a19ac337SLuis R. Rodriguez * 156a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 157a19ac337SLuis R. Rodriguez * to be written, and multiple writes on the same sysctl file descriptor 158a19ac337SLuis R. Rodriguez * will rewrite the sysctl value, regardless of file position. No warning 159a19ac337SLuis R. Rodriguez * is issued when the initial position is not 0. 160a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 161a19ac337SLuis R. Rodriguez * not 0. 162a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 163a19ac337SLuis R. Rodriguez * file position 0 and the value must be fully contained in the buffer 164a19ac337SLuis R. Rodriguez * sent to the write syscall. If dealing with strings respect the file 165a19ac337SLuis R. Rodriguez * position, but restrict this to the max length of the buffer, anything 16665f50f25SWeitao Hou * passed the max length will be ignored. Multiple writes will append 167a19ac337SLuis R. Rodriguez * to the buffer. 168a19ac337SLuis R. Rodriguez * 169a19ac337SLuis R. Rodriguez * These write modes control how current file position affects the behavior of 170a19ac337SLuis R. Rodriguez * updating sysctl values through the proc interface on each write. 171a19ac337SLuis R. Rodriguez */ 172a19ac337SLuis R. Rodriguez enum sysctl_writes_mode { 173a19ac337SLuis R. Rodriguez SYSCTL_WRITES_LEGACY = -1, 174a19ac337SLuis R. Rodriguez SYSCTL_WRITES_WARN = 0, 175a19ac337SLuis R. Rodriguez SYSCTL_WRITES_STRICT = 1, 176a19ac337SLuis R. Rodriguez }; 177f4aacea2SKees Cook 178a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 179*f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 180ceb18132SLuis R. Rodriguez 18167f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 18267f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 1831da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1841da177e4SLinus Torvalds #endif 1851da177e4SLinus Torvalds 18677e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 18773c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 18873c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 18973c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 19073c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 191cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 1921983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 1931983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 194cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 195cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 19677e54a1fSIngo Molnar 1975e771905SMel Gorman #ifdef CONFIG_COMPACTION 1985e771905SMel Gorman static int min_extfrag_threshold; 1995e771905SMel Gorman static int max_extfrag_threshold = 1000; 2005e771905SMel Gorman #endif 2015e771905SMel Gorman 202*f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */ 203*f461d2dcSChristoph Hellwig 204*f461d2dcSChristoph Hellwig /* 205*f461d2dcSChristoph Hellwig * /proc/sys support 206*f461d2dcSChristoph Hellwig */ 207*f461d2dcSChristoph Hellwig 208*f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL 209*f461d2dcSChristoph Hellwig 210*f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write, 211*f461d2dcSChristoph Hellwig char __user *buffer, 212*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos) 213*f461d2dcSChristoph Hellwig { 214*f461d2dcSChristoph Hellwig size_t len; 215*f461d2dcSChristoph Hellwig char __user *p; 216*f461d2dcSChristoph Hellwig char c; 217*f461d2dcSChristoph Hellwig 218*f461d2dcSChristoph Hellwig if (!data || !maxlen || !*lenp) { 219*f461d2dcSChristoph Hellwig *lenp = 0; 220*f461d2dcSChristoph Hellwig return 0; 221*f461d2dcSChristoph Hellwig } 222*f461d2dcSChristoph Hellwig 223*f461d2dcSChristoph Hellwig if (write) { 224*f461d2dcSChristoph Hellwig if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 225*f461d2dcSChristoph Hellwig /* Only continue writes not past the end of buffer. */ 226*f461d2dcSChristoph Hellwig len = strlen(data); 227*f461d2dcSChristoph Hellwig if (len > maxlen - 1) 228*f461d2dcSChristoph Hellwig len = maxlen - 1; 229*f461d2dcSChristoph Hellwig 230*f461d2dcSChristoph Hellwig if (*ppos > len) 231*f461d2dcSChristoph Hellwig return 0; 232*f461d2dcSChristoph Hellwig len = *ppos; 233*f461d2dcSChristoph Hellwig } else { 234*f461d2dcSChristoph Hellwig /* Start writing from beginning of buffer. */ 235*f461d2dcSChristoph Hellwig len = 0; 236*f461d2dcSChristoph Hellwig } 237*f461d2dcSChristoph Hellwig 238*f461d2dcSChristoph Hellwig *ppos += *lenp; 239*f461d2dcSChristoph Hellwig p = buffer; 240*f461d2dcSChristoph Hellwig while ((p - buffer) < *lenp && len < maxlen - 1) { 241*f461d2dcSChristoph Hellwig if (get_user(c, p++)) 242*f461d2dcSChristoph Hellwig return -EFAULT; 243*f461d2dcSChristoph Hellwig if (c == 0 || c == '\n') 244*f461d2dcSChristoph Hellwig break; 245*f461d2dcSChristoph Hellwig data[len++] = c; 246*f461d2dcSChristoph Hellwig } 247*f461d2dcSChristoph Hellwig data[len] = 0; 248*f461d2dcSChristoph Hellwig } else { 249*f461d2dcSChristoph Hellwig len = strlen(data); 250*f461d2dcSChristoph Hellwig if (len > maxlen) 251*f461d2dcSChristoph Hellwig len = maxlen; 252*f461d2dcSChristoph Hellwig 253*f461d2dcSChristoph Hellwig if (*ppos > len) { 254*f461d2dcSChristoph Hellwig *lenp = 0; 255*f461d2dcSChristoph Hellwig return 0; 256*f461d2dcSChristoph Hellwig } 257*f461d2dcSChristoph Hellwig 258*f461d2dcSChristoph Hellwig data += *ppos; 259*f461d2dcSChristoph Hellwig len -= *ppos; 260*f461d2dcSChristoph Hellwig 261*f461d2dcSChristoph Hellwig if (len > *lenp) 262*f461d2dcSChristoph Hellwig len = *lenp; 263*f461d2dcSChristoph Hellwig if (len) 264*f461d2dcSChristoph Hellwig if (copy_to_user(buffer, data, len)) 265*f461d2dcSChristoph Hellwig return -EFAULT; 266*f461d2dcSChristoph Hellwig if (len < *lenp) { 267*f461d2dcSChristoph Hellwig if (put_user('\n', buffer + len)) 268*f461d2dcSChristoph Hellwig return -EFAULT; 269*f461d2dcSChristoph Hellwig len++; 270*f461d2dcSChristoph Hellwig } 271*f461d2dcSChristoph Hellwig *lenp = len; 272*f461d2dcSChristoph Hellwig *ppos += len; 273*f461d2dcSChristoph Hellwig } 274*f461d2dcSChristoph Hellwig return 0; 275*f461d2dcSChristoph Hellwig } 276*f461d2dcSChristoph Hellwig 277*f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table) 278*f461d2dcSChristoph Hellwig { 279*f461d2dcSChristoph Hellwig pr_warn_once("%s wrote to %s when file position was not 0!\n" 280*f461d2dcSChristoph Hellwig "This will not be supported in the future. To silence this\n" 281*f461d2dcSChristoph Hellwig "warning, set kernel.sysctl_writes_strict = -1\n", 282*f461d2dcSChristoph Hellwig current->comm, table->procname); 283*f461d2dcSChristoph Hellwig } 284*f461d2dcSChristoph Hellwig 285*f461d2dcSChristoph Hellwig /** 286*f461d2dcSChristoph Hellwig * proc_first_pos_non_zero_ignore - check if first position is allowed 287*f461d2dcSChristoph Hellwig * @ppos: file position 288*f461d2dcSChristoph Hellwig * @table: the sysctl table 289*f461d2dcSChristoph Hellwig * 290*f461d2dcSChristoph Hellwig * Returns true if the first position is non-zero and the sysctl_writes_strict 291*f461d2dcSChristoph Hellwig * mode indicates this is not allowed for numeric input types. String proc 292*f461d2dcSChristoph Hellwig * handlers can ignore the return value. 293*f461d2dcSChristoph Hellwig */ 294*f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 295*f461d2dcSChristoph Hellwig struct ctl_table *table) 296*f461d2dcSChristoph Hellwig { 297*f461d2dcSChristoph Hellwig if (!*ppos) 298*f461d2dcSChristoph Hellwig return false; 299*f461d2dcSChristoph Hellwig 300*f461d2dcSChristoph Hellwig switch (sysctl_writes_strict) { 301*f461d2dcSChristoph Hellwig case SYSCTL_WRITES_STRICT: 302*f461d2dcSChristoph Hellwig return true; 303*f461d2dcSChristoph Hellwig case SYSCTL_WRITES_WARN: 304*f461d2dcSChristoph Hellwig warn_sysctl_write(table); 305*f461d2dcSChristoph Hellwig return false; 306*f461d2dcSChristoph Hellwig default: 307*f461d2dcSChristoph Hellwig return false; 308*f461d2dcSChristoph Hellwig } 309*f461d2dcSChristoph Hellwig } 310*f461d2dcSChristoph Hellwig 311*f461d2dcSChristoph Hellwig /** 312*f461d2dcSChristoph Hellwig * proc_dostring - read a string sysctl 313*f461d2dcSChristoph Hellwig * @table: the sysctl table 314*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 315*f461d2dcSChristoph Hellwig * @buffer: the user buffer 316*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 317*f461d2dcSChristoph Hellwig * @ppos: file position 318*f461d2dcSChristoph Hellwig * 319*f461d2dcSChristoph Hellwig * Reads/writes a string from/to the user buffer. If the kernel 320*f461d2dcSChristoph Hellwig * buffer provided is not large enough to hold the string, the 321*f461d2dcSChristoph Hellwig * string is truncated. The copied string is %NULL-terminated. 322*f461d2dcSChristoph Hellwig * If the string is being read by the user process, it is copied 323*f461d2dcSChristoph Hellwig * and a newline '\n' is added. It is truncated if the buffer is 324*f461d2dcSChristoph Hellwig * not large enough. 325*f461d2dcSChristoph Hellwig * 326*f461d2dcSChristoph Hellwig * Returns 0 on success. 327*f461d2dcSChristoph Hellwig */ 328*f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 329*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 330*f461d2dcSChristoph Hellwig { 331*f461d2dcSChristoph Hellwig if (write) 332*f461d2dcSChristoph Hellwig proc_first_pos_non_zero_ignore(ppos, table); 333*f461d2dcSChristoph Hellwig 334*f461d2dcSChristoph Hellwig return _proc_do_string((char *)(table->data), table->maxlen, write, 335*f461d2dcSChristoph Hellwig (char __user *)buffer, lenp, ppos); 336*f461d2dcSChristoph Hellwig } 337*f461d2dcSChristoph Hellwig 338*f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf) 339*f461d2dcSChristoph Hellwig { 340*f461d2dcSChristoph Hellwig size_t ret; 341*f461d2dcSChristoph Hellwig char *tmp = skip_spaces(*buf); 342*f461d2dcSChristoph Hellwig ret = tmp - *buf; 343*f461d2dcSChristoph Hellwig *buf = tmp; 344*f461d2dcSChristoph Hellwig return ret; 345*f461d2dcSChristoph Hellwig } 346*f461d2dcSChristoph Hellwig 347*f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v) 348*f461d2dcSChristoph Hellwig { 349*f461d2dcSChristoph Hellwig while (*size) { 350*f461d2dcSChristoph Hellwig if (**buf != v) 351*f461d2dcSChristoph Hellwig break; 352*f461d2dcSChristoph Hellwig (*size)--; 353*f461d2dcSChristoph Hellwig (*buf)++; 354*f461d2dcSChristoph Hellwig } 355*f461d2dcSChristoph Hellwig } 356*f461d2dcSChristoph Hellwig 357*f461d2dcSChristoph Hellwig /** 358*f461d2dcSChristoph Hellwig * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 359*f461d2dcSChristoph Hellwig * fail on overflow 360*f461d2dcSChristoph Hellwig * 361*f461d2dcSChristoph Hellwig * @cp: kernel buffer containing the string to parse 362*f461d2dcSChristoph Hellwig * @endp: pointer to store the trailing characters 363*f461d2dcSChristoph Hellwig * @base: the base to use 364*f461d2dcSChristoph Hellwig * @res: where the parsed integer will be stored 365*f461d2dcSChristoph Hellwig * 366*f461d2dcSChristoph Hellwig * In case of success 0 is returned and @res will contain the parsed integer, 367*f461d2dcSChristoph Hellwig * @endp will hold any trailing characters. 368*f461d2dcSChristoph Hellwig * This function will fail the parse on overflow. If there wasn't an overflow 369*f461d2dcSChristoph Hellwig * the function will defer the decision what characters count as invalid to the 370*f461d2dcSChristoph Hellwig * caller. 371*f461d2dcSChristoph Hellwig */ 372*f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 373*f461d2dcSChristoph Hellwig unsigned long *res) 374*f461d2dcSChristoph Hellwig { 375*f461d2dcSChristoph Hellwig unsigned long long result; 376*f461d2dcSChristoph Hellwig unsigned int rv; 377*f461d2dcSChristoph Hellwig 378*f461d2dcSChristoph Hellwig cp = _parse_integer_fixup_radix(cp, &base); 379*f461d2dcSChristoph Hellwig rv = _parse_integer(cp, base, &result); 380*f461d2dcSChristoph Hellwig if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 381*f461d2dcSChristoph Hellwig return -ERANGE; 382*f461d2dcSChristoph Hellwig 383*f461d2dcSChristoph Hellwig cp += rv; 384*f461d2dcSChristoph Hellwig 385*f461d2dcSChristoph Hellwig if (endp) 386*f461d2dcSChristoph Hellwig *endp = (char *)cp; 387*f461d2dcSChristoph Hellwig 388*f461d2dcSChristoph Hellwig *res = (unsigned long)result; 389*f461d2dcSChristoph Hellwig return 0; 390*f461d2dcSChristoph Hellwig } 391*f461d2dcSChristoph Hellwig 392*f461d2dcSChristoph Hellwig #define TMPBUFLEN 22 393*f461d2dcSChristoph Hellwig /** 394*f461d2dcSChristoph Hellwig * proc_get_long - reads an ASCII formatted integer from a user buffer 395*f461d2dcSChristoph Hellwig * 396*f461d2dcSChristoph Hellwig * @buf: a kernel buffer 397*f461d2dcSChristoph Hellwig * @size: size of the kernel buffer 398*f461d2dcSChristoph Hellwig * @val: this is where the number will be stored 399*f461d2dcSChristoph Hellwig * @neg: set to %TRUE if number is negative 400*f461d2dcSChristoph Hellwig * @perm_tr: a vector which contains the allowed trailers 401*f461d2dcSChristoph Hellwig * @perm_tr_len: size of the perm_tr vector 402*f461d2dcSChristoph Hellwig * @tr: pointer to store the trailer character 403*f461d2dcSChristoph Hellwig * 404*f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 405*f461d2dcSChristoph Hellwig * the amount of bytes read. If @tr is non-NULL and a trailing 406*f461d2dcSChristoph Hellwig * character exists (size is non-zero after returning from this 407*f461d2dcSChristoph Hellwig * function), @tr is updated with the trailing character. 408*f461d2dcSChristoph Hellwig */ 409*f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size, 410*f461d2dcSChristoph Hellwig unsigned long *val, bool *neg, 411*f461d2dcSChristoph Hellwig const char *perm_tr, unsigned perm_tr_len, char *tr) 412*f461d2dcSChristoph Hellwig { 413*f461d2dcSChristoph Hellwig int len; 414*f461d2dcSChristoph Hellwig char *p, tmp[TMPBUFLEN]; 415*f461d2dcSChristoph Hellwig 416*f461d2dcSChristoph Hellwig if (!*size) 417*f461d2dcSChristoph Hellwig return -EINVAL; 418*f461d2dcSChristoph Hellwig 419*f461d2dcSChristoph Hellwig len = *size; 420*f461d2dcSChristoph Hellwig if (len > TMPBUFLEN - 1) 421*f461d2dcSChristoph Hellwig len = TMPBUFLEN - 1; 422*f461d2dcSChristoph Hellwig 423*f461d2dcSChristoph Hellwig memcpy(tmp, *buf, len); 424*f461d2dcSChristoph Hellwig 425*f461d2dcSChristoph Hellwig tmp[len] = 0; 426*f461d2dcSChristoph Hellwig p = tmp; 427*f461d2dcSChristoph Hellwig if (*p == '-' && *size > 1) { 428*f461d2dcSChristoph Hellwig *neg = true; 429*f461d2dcSChristoph Hellwig p++; 430*f461d2dcSChristoph Hellwig } else 431*f461d2dcSChristoph Hellwig *neg = false; 432*f461d2dcSChristoph Hellwig if (!isdigit(*p)) 433*f461d2dcSChristoph Hellwig return -EINVAL; 434*f461d2dcSChristoph Hellwig 435*f461d2dcSChristoph Hellwig if (strtoul_lenient(p, &p, 0, val)) 436*f461d2dcSChristoph Hellwig return -EINVAL; 437*f461d2dcSChristoph Hellwig 438*f461d2dcSChristoph Hellwig len = p - tmp; 439*f461d2dcSChristoph Hellwig 440*f461d2dcSChristoph Hellwig /* We don't know if the next char is whitespace thus we may accept 441*f461d2dcSChristoph Hellwig * invalid integers (e.g. 1234...a) or two integers instead of one 442*f461d2dcSChristoph Hellwig * (e.g. 123...1). So lets not allow such large numbers. */ 443*f461d2dcSChristoph Hellwig if (len == TMPBUFLEN - 1) 444*f461d2dcSChristoph Hellwig return -EINVAL; 445*f461d2dcSChristoph Hellwig 446*f461d2dcSChristoph Hellwig if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 447*f461d2dcSChristoph Hellwig return -EINVAL; 448*f461d2dcSChristoph Hellwig 449*f461d2dcSChristoph Hellwig if (tr && (len < *size)) 450*f461d2dcSChristoph Hellwig *tr = *p; 451*f461d2dcSChristoph Hellwig 452*f461d2dcSChristoph Hellwig *buf += len; 453*f461d2dcSChristoph Hellwig *size -= len; 454*f461d2dcSChristoph Hellwig 455*f461d2dcSChristoph Hellwig return 0; 456*f461d2dcSChristoph Hellwig } 457*f461d2dcSChristoph Hellwig 458*f461d2dcSChristoph Hellwig /** 459*f461d2dcSChristoph Hellwig * proc_put_long - converts an integer to a decimal ASCII formatted string 460*f461d2dcSChristoph Hellwig * 461*f461d2dcSChristoph Hellwig * @buf: the user buffer 462*f461d2dcSChristoph Hellwig * @size: the size of the user buffer 463*f461d2dcSChristoph Hellwig * @val: the integer to be converted 464*f461d2dcSChristoph Hellwig * @neg: sign of the number, %TRUE for negative 465*f461d2dcSChristoph Hellwig * 466*f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 467*f461d2dcSChristoph Hellwig * the amount of bytes written. 468*f461d2dcSChristoph Hellwig */ 469*f461d2dcSChristoph Hellwig static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 470*f461d2dcSChristoph Hellwig bool neg) 471*f461d2dcSChristoph Hellwig { 472*f461d2dcSChristoph Hellwig int len; 473*f461d2dcSChristoph Hellwig char tmp[TMPBUFLEN], *p = tmp; 474*f461d2dcSChristoph Hellwig 475*f461d2dcSChristoph Hellwig sprintf(p, "%s%lu", neg ? "-" : "", val); 476*f461d2dcSChristoph Hellwig len = strlen(tmp); 477*f461d2dcSChristoph Hellwig if (len > *size) 478*f461d2dcSChristoph Hellwig len = *size; 479*f461d2dcSChristoph Hellwig if (copy_to_user(*buf, tmp, len)) 480*f461d2dcSChristoph Hellwig return -EFAULT; 481*f461d2dcSChristoph Hellwig *size -= len; 482*f461d2dcSChristoph Hellwig *buf += len; 483*f461d2dcSChristoph Hellwig return 0; 484*f461d2dcSChristoph Hellwig } 485*f461d2dcSChristoph Hellwig #undef TMPBUFLEN 486*f461d2dcSChristoph Hellwig 487*f461d2dcSChristoph Hellwig static int proc_put_char(void __user **buf, size_t *size, char c) 488*f461d2dcSChristoph Hellwig { 489*f461d2dcSChristoph Hellwig if (*size) { 490*f461d2dcSChristoph Hellwig char __user **buffer = (char __user **)buf; 491*f461d2dcSChristoph Hellwig if (put_user(c, *buffer)) 492*f461d2dcSChristoph Hellwig return -EFAULT; 493*f461d2dcSChristoph Hellwig (*size)--, (*buffer)++; 494*f461d2dcSChristoph Hellwig *buf = *buffer; 495*f461d2dcSChristoph Hellwig } 496*f461d2dcSChristoph Hellwig return 0; 497*f461d2dcSChristoph Hellwig } 498*f461d2dcSChristoph Hellwig 499*f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 500*f461d2dcSChristoph Hellwig int *valp, 501*f461d2dcSChristoph Hellwig int write, void *data) 502*f461d2dcSChristoph Hellwig { 503*f461d2dcSChristoph Hellwig if (write) { 504*f461d2dcSChristoph Hellwig if (*negp) { 505*f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX + 1) 506*f461d2dcSChristoph Hellwig return -EINVAL; 507*f461d2dcSChristoph Hellwig *valp = -*lvalp; 508*f461d2dcSChristoph Hellwig } else { 509*f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX) 510*f461d2dcSChristoph Hellwig return -EINVAL; 511*f461d2dcSChristoph Hellwig *valp = *lvalp; 512*f461d2dcSChristoph Hellwig } 513*f461d2dcSChristoph Hellwig } else { 514*f461d2dcSChristoph Hellwig int val = *valp; 515*f461d2dcSChristoph Hellwig if (val < 0) { 516*f461d2dcSChristoph Hellwig *negp = true; 517*f461d2dcSChristoph Hellwig *lvalp = -(unsigned long)val; 518*f461d2dcSChristoph Hellwig } else { 519*f461d2dcSChristoph Hellwig *negp = false; 520*f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 521*f461d2dcSChristoph Hellwig } 522*f461d2dcSChristoph Hellwig } 523*f461d2dcSChristoph Hellwig return 0; 524*f461d2dcSChristoph Hellwig } 525*f461d2dcSChristoph Hellwig 526*f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp, 527*f461d2dcSChristoph Hellwig unsigned int *valp, 528*f461d2dcSChristoph Hellwig int write, void *data) 529*f461d2dcSChristoph Hellwig { 530*f461d2dcSChristoph Hellwig if (write) { 531*f461d2dcSChristoph Hellwig if (*lvalp > UINT_MAX) 532*f461d2dcSChristoph Hellwig return -EINVAL; 533*f461d2dcSChristoph Hellwig *valp = *lvalp; 534*f461d2dcSChristoph Hellwig } else { 535*f461d2dcSChristoph Hellwig unsigned int val = *valp; 536*f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 537*f461d2dcSChristoph Hellwig } 538*f461d2dcSChristoph Hellwig return 0; 539*f461d2dcSChristoph Hellwig } 540*f461d2dcSChristoph Hellwig 541*f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 542*f461d2dcSChristoph Hellwig 543*f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 544*f461d2dcSChristoph Hellwig int write, void __user *buffer, 545*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 546*f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 547*f461d2dcSChristoph Hellwig int write, void *data), 548*f461d2dcSChristoph Hellwig void *data) 549*f461d2dcSChristoph Hellwig { 550*f461d2dcSChristoph Hellwig int *i, vleft, first = 1, err = 0; 551*f461d2dcSChristoph Hellwig size_t left; 552*f461d2dcSChristoph Hellwig char *kbuf = NULL, *p; 553*f461d2dcSChristoph Hellwig 554*f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 555*f461d2dcSChristoph Hellwig *lenp = 0; 556*f461d2dcSChristoph Hellwig return 0; 557*f461d2dcSChristoph Hellwig } 558*f461d2dcSChristoph Hellwig 559*f461d2dcSChristoph Hellwig i = (int *) tbl_data; 560*f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 561*f461d2dcSChristoph Hellwig left = *lenp; 562*f461d2dcSChristoph Hellwig 563*f461d2dcSChristoph Hellwig if (!conv) 564*f461d2dcSChristoph Hellwig conv = do_proc_dointvec_conv; 565*f461d2dcSChristoph Hellwig 566*f461d2dcSChristoph Hellwig if (write) { 567*f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 568*f461d2dcSChristoph Hellwig goto out; 569*f461d2dcSChristoph Hellwig 570*f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 571*f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 572*f461d2dcSChristoph Hellwig p = kbuf = memdup_user_nul(buffer, left); 573*f461d2dcSChristoph Hellwig if (IS_ERR(kbuf)) 574*f461d2dcSChristoph Hellwig return PTR_ERR(kbuf); 575*f461d2dcSChristoph Hellwig } 576*f461d2dcSChristoph Hellwig 577*f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first=0) { 578*f461d2dcSChristoph Hellwig unsigned long lval; 579*f461d2dcSChristoph Hellwig bool neg; 580*f461d2dcSChristoph Hellwig 581*f461d2dcSChristoph Hellwig if (write) { 582*f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 583*f461d2dcSChristoph Hellwig 584*f461d2dcSChristoph Hellwig if (!left) 585*f461d2dcSChristoph Hellwig break; 586*f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 587*f461d2dcSChristoph Hellwig proc_wspace_sep, 588*f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 589*f461d2dcSChristoph Hellwig if (err) 590*f461d2dcSChristoph Hellwig break; 591*f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 1, data)) { 592*f461d2dcSChristoph Hellwig err = -EINVAL; 593*f461d2dcSChristoph Hellwig break; 594*f461d2dcSChristoph Hellwig } 595*f461d2dcSChristoph Hellwig } else { 596*f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 0, data)) { 597*f461d2dcSChristoph Hellwig err = -EINVAL; 598*f461d2dcSChristoph Hellwig break; 599*f461d2dcSChristoph Hellwig } 600*f461d2dcSChristoph Hellwig if (!first) 601*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '\t'); 602*f461d2dcSChristoph Hellwig if (err) 603*f461d2dcSChristoph Hellwig break; 604*f461d2dcSChristoph Hellwig err = proc_put_long(&buffer, &left, lval, neg); 605*f461d2dcSChristoph Hellwig if (err) 606*f461d2dcSChristoph Hellwig break; 607*f461d2dcSChristoph Hellwig } 608*f461d2dcSChristoph Hellwig } 609*f461d2dcSChristoph Hellwig 610*f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 611*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '\n'); 612*f461d2dcSChristoph Hellwig if (write && !err && left) 613*f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 614*f461d2dcSChristoph Hellwig if (write) { 615*f461d2dcSChristoph Hellwig kfree(kbuf); 616*f461d2dcSChristoph Hellwig if (first) 617*f461d2dcSChristoph Hellwig return err ? : -EINVAL; 618*f461d2dcSChristoph Hellwig } 619*f461d2dcSChristoph Hellwig *lenp -= left; 620*f461d2dcSChristoph Hellwig out: 621*f461d2dcSChristoph Hellwig *ppos += *lenp; 622*f461d2dcSChristoph Hellwig return err; 623*f461d2dcSChristoph Hellwig } 624*f461d2dcSChristoph Hellwig 625*f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write, 626*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos, 627*f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 628*f461d2dcSChristoph Hellwig int write, void *data), 629*f461d2dcSChristoph Hellwig void *data) 630*f461d2dcSChristoph Hellwig { 631*f461d2dcSChristoph Hellwig return __do_proc_dointvec(table->data, table, write, 632*f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 633*f461d2dcSChristoph Hellwig } 634*f461d2dcSChristoph Hellwig 635*f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data, 636*f461d2dcSChristoph Hellwig struct ctl_table *table, 637*f461d2dcSChristoph Hellwig void __user *buffer, 638*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 639*f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 640*f461d2dcSChristoph Hellwig unsigned int *valp, 641*f461d2dcSChristoph Hellwig int write, void *data), 642*f461d2dcSChristoph Hellwig void *data) 643*f461d2dcSChristoph Hellwig { 644*f461d2dcSChristoph Hellwig unsigned long lval; 645*f461d2dcSChristoph Hellwig int err = 0; 646*f461d2dcSChristoph Hellwig size_t left; 647*f461d2dcSChristoph Hellwig bool neg; 648*f461d2dcSChristoph Hellwig char *kbuf = NULL, *p; 649*f461d2dcSChristoph Hellwig 650*f461d2dcSChristoph Hellwig left = *lenp; 651*f461d2dcSChristoph Hellwig 652*f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 653*f461d2dcSChristoph Hellwig goto bail_early; 654*f461d2dcSChristoph Hellwig 655*f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 656*f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 657*f461d2dcSChristoph Hellwig 658*f461d2dcSChristoph Hellwig p = kbuf = memdup_user_nul(buffer, left); 659*f461d2dcSChristoph Hellwig if (IS_ERR(kbuf)) 660*f461d2dcSChristoph Hellwig return -EINVAL; 661*f461d2dcSChristoph Hellwig 662*f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 663*f461d2dcSChristoph Hellwig if (!left) { 664*f461d2dcSChristoph Hellwig err = -EINVAL; 665*f461d2dcSChristoph Hellwig goto out_free; 666*f461d2dcSChristoph Hellwig } 667*f461d2dcSChristoph Hellwig 668*f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 669*f461d2dcSChristoph Hellwig proc_wspace_sep, 670*f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 671*f461d2dcSChristoph Hellwig if (err || neg) { 672*f461d2dcSChristoph Hellwig err = -EINVAL; 673*f461d2dcSChristoph Hellwig goto out_free; 674*f461d2dcSChristoph Hellwig } 675*f461d2dcSChristoph Hellwig 676*f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 1, data)) { 677*f461d2dcSChristoph Hellwig err = -EINVAL; 678*f461d2dcSChristoph Hellwig goto out_free; 679*f461d2dcSChristoph Hellwig } 680*f461d2dcSChristoph Hellwig 681*f461d2dcSChristoph Hellwig if (!err && left) 682*f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 683*f461d2dcSChristoph Hellwig 684*f461d2dcSChristoph Hellwig out_free: 685*f461d2dcSChristoph Hellwig kfree(kbuf); 686*f461d2dcSChristoph Hellwig if (err) 687*f461d2dcSChristoph Hellwig return -EINVAL; 688*f461d2dcSChristoph Hellwig 689*f461d2dcSChristoph Hellwig return 0; 690*f461d2dcSChristoph Hellwig 691*f461d2dcSChristoph Hellwig /* This is in keeping with old __do_proc_dointvec() */ 692*f461d2dcSChristoph Hellwig bail_early: 693*f461d2dcSChristoph Hellwig *ppos += *lenp; 694*f461d2dcSChristoph Hellwig return err; 695*f461d2dcSChristoph Hellwig } 696*f461d2dcSChristoph Hellwig 697*f461d2dcSChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer, 698*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 699*f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 700*f461d2dcSChristoph Hellwig unsigned int *valp, 701*f461d2dcSChristoph Hellwig int write, void *data), 702*f461d2dcSChristoph Hellwig void *data) 703*f461d2dcSChristoph Hellwig { 704*f461d2dcSChristoph Hellwig unsigned long lval; 705*f461d2dcSChristoph Hellwig int err = 0; 706*f461d2dcSChristoph Hellwig size_t left; 707*f461d2dcSChristoph Hellwig 708*f461d2dcSChristoph Hellwig left = *lenp; 709*f461d2dcSChristoph Hellwig 710*f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 0, data)) { 711*f461d2dcSChristoph Hellwig err = -EINVAL; 712*f461d2dcSChristoph Hellwig goto out; 713*f461d2dcSChristoph Hellwig } 714*f461d2dcSChristoph Hellwig 715*f461d2dcSChristoph Hellwig err = proc_put_long(&buffer, &left, lval, false); 716*f461d2dcSChristoph Hellwig if (err || !left) 717*f461d2dcSChristoph Hellwig goto out; 718*f461d2dcSChristoph Hellwig 719*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '\n'); 720*f461d2dcSChristoph Hellwig 721*f461d2dcSChristoph Hellwig out: 722*f461d2dcSChristoph Hellwig *lenp -= left; 723*f461d2dcSChristoph Hellwig *ppos += *lenp; 724*f461d2dcSChristoph Hellwig 725*f461d2dcSChristoph Hellwig return err; 726*f461d2dcSChristoph Hellwig } 727*f461d2dcSChristoph Hellwig 728*f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 729*f461d2dcSChristoph Hellwig int write, void __user *buffer, 730*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 731*f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 732*f461d2dcSChristoph Hellwig unsigned int *valp, 733*f461d2dcSChristoph Hellwig int write, void *data), 734*f461d2dcSChristoph Hellwig void *data) 735*f461d2dcSChristoph Hellwig { 736*f461d2dcSChristoph Hellwig unsigned int *i, vleft; 737*f461d2dcSChristoph Hellwig 738*f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 739*f461d2dcSChristoph Hellwig *lenp = 0; 740*f461d2dcSChristoph Hellwig return 0; 741*f461d2dcSChristoph Hellwig } 742*f461d2dcSChristoph Hellwig 743*f461d2dcSChristoph Hellwig i = (unsigned int *) tbl_data; 744*f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 745*f461d2dcSChristoph Hellwig 746*f461d2dcSChristoph Hellwig /* 747*f461d2dcSChristoph Hellwig * Arrays are not supported, keep this simple. *Do not* add 748*f461d2dcSChristoph Hellwig * support for them. 749*f461d2dcSChristoph Hellwig */ 750*f461d2dcSChristoph Hellwig if (vleft != 1) { 751*f461d2dcSChristoph Hellwig *lenp = 0; 752*f461d2dcSChristoph Hellwig return -EINVAL; 753*f461d2dcSChristoph Hellwig } 754*f461d2dcSChristoph Hellwig 755*f461d2dcSChristoph Hellwig if (!conv) 756*f461d2dcSChristoph Hellwig conv = do_proc_douintvec_conv; 757*f461d2dcSChristoph Hellwig 758*f461d2dcSChristoph Hellwig if (write) 759*f461d2dcSChristoph Hellwig return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 760*f461d2dcSChristoph Hellwig conv, data); 761*f461d2dcSChristoph Hellwig return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 762*f461d2dcSChristoph Hellwig } 763*f461d2dcSChristoph Hellwig 764*f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write, 765*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos, 766*f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 767*f461d2dcSChristoph Hellwig unsigned int *valp, 768*f461d2dcSChristoph Hellwig int write, void *data), 769*f461d2dcSChristoph Hellwig void *data) 770*f461d2dcSChristoph Hellwig { 771*f461d2dcSChristoph Hellwig return __do_proc_douintvec(table->data, table, write, 772*f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 773*f461d2dcSChristoph Hellwig } 774*f461d2dcSChristoph Hellwig 775*f461d2dcSChristoph Hellwig /** 776*f461d2dcSChristoph Hellwig * proc_dointvec - read a vector of integers 777*f461d2dcSChristoph Hellwig * @table: the sysctl table 778*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 779*f461d2dcSChristoph Hellwig * @buffer: the user buffer 780*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 781*f461d2dcSChristoph Hellwig * @ppos: file position 782*f461d2dcSChristoph Hellwig * 783*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 784*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 785*f461d2dcSChristoph Hellwig * 786*f461d2dcSChristoph Hellwig * Returns 0 on success. 787*f461d2dcSChristoph Hellwig */ 788*f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, 789*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 790*f461d2dcSChristoph Hellwig { 791*f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 792*f461d2dcSChristoph Hellwig } 793*f461d2dcSChristoph Hellwig 794*f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION 795*f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 796*f461d2dcSChristoph Hellwig int write, void __user *buffer, 797*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos) 798*f461d2dcSChristoph Hellwig { 799*f461d2dcSChristoph Hellwig int ret, old; 800*f461d2dcSChristoph Hellwig 801*f461d2dcSChristoph Hellwig if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 802*f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 803*f461d2dcSChristoph Hellwig 804*f461d2dcSChristoph Hellwig old = *(int *)table->data; 805*f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 806*f461d2dcSChristoph Hellwig if (ret) 807*f461d2dcSChristoph Hellwig return ret; 808*f461d2dcSChristoph Hellwig if (old != *(int *)table->data) 809*f461d2dcSChristoph Hellwig pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 810*f461d2dcSChristoph Hellwig table->procname, current->comm, 811*f461d2dcSChristoph Hellwig task_pid_nr(current)); 812*f461d2dcSChristoph Hellwig return ret; 813*f461d2dcSChristoph Hellwig } 814*f461d2dcSChristoph Hellwig #endif 815*f461d2dcSChristoph Hellwig 816*f461d2dcSChristoph Hellwig /** 817*f461d2dcSChristoph Hellwig * proc_douintvec - read a vector of unsigned integers 818*f461d2dcSChristoph Hellwig * @table: the sysctl table 819*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 820*f461d2dcSChristoph Hellwig * @buffer: the user buffer 821*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 822*f461d2dcSChristoph Hellwig * @ppos: file position 823*f461d2dcSChristoph Hellwig * 824*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 825*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 826*f461d2dcSChristoph Hellwig * 827*f461d2dcSChristoph Hellwig * Returns 0 on success. 828*f461d2dcSChristoph Hellwig */ 829*f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, 830*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 831*f461d2dcSChristoph Hellwig { 832*f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 833*f461d2dcSChristoph Hellwig do_proc_douintvec_conv, NULL); 834*f461d2dcSChristoph Hellwig } 835*f461d2dcSChristoph Hellwig 836*f461d2dcSChristoph Hellwig /* 837*f461d2dcSChristoph Hellwig * Taint values can only be increased 838*f461d2dcSChristoph Hellwig * This means we can safely use a temporary. 839*f461d2dcSChristoph Hellwig */ 840*f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write, 841*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 842*f461d2dcSChristoph Hellwig { 843*f461d2dcSChristoph Hellwig struct ctl_table t; 844*f461d2dcSChristoph Hellwig unsigned long tmptaint = get_taint(); 845*f461d2dcSChristoph Hellwig int err; 846*f461d2dcSChristoph Hellwig 847*f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 848*f461d2dcSChristoph Hellwig return -EPERM; 849*f461d2dcSChristoph Hellwig 850*f461d2dcSChristoph Hellwig t = *table; 851*f461d2dcSChristoph Hellwig t.data = &tmptaint; 852*f461d2dcSChristoph Hellwig err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 853*f461d2dcSChristoph Hellwig if (err < 0) 854*f461d2dcSChristoph Hellwig return err; 855*f461d2dcSChristoph Hellwig 856*f461d2dcSChristoph Hellwig if (write) { 857*f461d2dcSChristoph Hellwig /* 858*f461d2dcSChristoph Hellwig * Poor man's atomic or. Not worth adding a primitive 859*f461d2dcSChristoph Hellwig * to everyone's atomic.h for this 860*f461d2dcSChristoph Hellwig */ 861*f461d2dcSChristoph Hellwig int i; 862*f461d2dcSChristoph Hellwig for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 863*f461d2dcSChristoph Hellwig if ((tmptaint >> i) & 1) 864*f461d2dcSChristoph Hellwig add_taint(i, LOCKDEP_STILL_OK); 865*f461d2dcSChristoph Hellwig } 866*f461d2dcSChristoph Hellwig } 867*f461d2dcSChristoph Hellwig 868*f461d2dcSChristoph Hellwig return err; 869*f461d2dcSChristoph Hellwig } 870*f461d2dcSChristoph Hellwig 871*f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK 872*f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 873*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 874*f461d2dcSChristoph Hellwig { 875*f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 876*f461d2dcSChristoph Hellwig return -EPERM; 877*f461d2dcSChristoph Hellwig 878*f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 879*f461d2dcSChristoph Hellwig } 880*f461d2dcSChristoph Hellwig #endif 881*f461d2dcSChristoph Hellwig 882*f461d2dcSChristoph Hellwig /** 883*f461d2dcSChristoph Hellwig * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 884*f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 885*f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 886*f461d2dcSChristoph Hellwig * 887*f461d2dcSChristoph Hellwig * The do_proc_dointvec_minmax_conv_param structure provides the 888*f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 889*f461d2dcSChristoph Hellwig * parameters that use the proc_dointvec_minmax() handler. 890*f461d2dcSChristoph Hellwig */ 891*f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param { 892*f461d2dcSChristoph Hellwig int *min; 893*f461d2dcSChristoph Hellwig int *max; 894*f461d2dcSChristoph Hellwig }; 895*f461d2dcSChristoph Hellwig 896*f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 897*f461d2dcSChristoph Hellwig int *valp, 898*f461d2dcSChristoph Hellwig int write, void *data) 899*f461d2dcSChristoph Hellwig { 900*f461d2dcSChristoph Hellwig int tmp, ret; 901*f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param *param = data; 902*f461d2dcSChristoph Hellwig /* 903*f461d2dcSChristoph Hellwig * If writing, first do so via a temporary local int so we can 904*f461d2dcSChristoph Hellwig * bounds-check it before touching *valp. 905*f461d2dcSChristoph Hellwig */ 906*f461d2dcSChristoph Hellwig int *ip = write ? &tmp : valp; 907*f461d2dcSChristoph Hellwig 908*f461d2dcSChristoph Hellwig ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 909*f461d2dcSChristoph Hellwig if (ret) 910*f461d2dcSChristoph Hellwig return ret; 911*f461d2dcSChristoph Hellwig 912*f461d2dcSChristoph Hellwig if (write) { 913*f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 914*f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 915*f461d2dcSChristoph Hellwig return -EINVAL; 916*f461d2dcSChristoph Hellwig *valp = tmp; 917*f461d2dcSChristoph Hellwig } 918*f461d2dcSChristoph Hellwig 919*f461d2dcSChristoph Hellwig return 0; 920*f461d2dcSChristoph Hellwig } 921*f461d2dcSChristoph Hellwig 922*f461d2dcSChristoph Hellwig /** 923*f461d2dcSChristoph Hellwig * proc_dointvec_minmax - read a vector of integers with min/max values 924*f461d2dcSChristoph Hellwig * @table: the sysctl table 925*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 926*f461d2dcSChristoph Hellwig * @buffer: the user buffer 927*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 928*f461d2dcSChristoph Hellwig * @ppos: file position 929*f461d2dcSChristoph Hellwig * 930*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 931*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 932*f461d2dcSChristoph Hellwig * 933*f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 934*f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 935*f461d2dcSChristoph Hellwig * 936*f461d2dcSChristoph Hellwig * Returns 0 on success or -EINVAL on write when the range check fails. 937*f461d2dcSChristoph Hellwig */ 938*f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 939*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 940*f461d2dcSChristoph Hellwig { 941*f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param param = { 942*f461d2dcSChristoph Hellwig .min = (int *) table->extra1, 943*f461d2dcSChristoph Hellwig .max = (int *) table->extra2, 944*f461d2dcSChristoph Hellwig }; 945*f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 946*f461d2dcSChristoph Hellwig do_proc_dointvec_minmax_conv, ¶m); 947*f461d2dcSChristoph Hellwig } 948*f461d2dcSChristoph Hellwig 949*f461d2dcSChristoph Hellwig /** 950*f461d2dcSChristoph Hellwig * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 951*f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 952*f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 953*f461d2dcSChristoph Hellwig * 954*f461d2dcSChristoph Hellwig * The do_proc_douintvec_minmax_conv_param structure provides the 955*f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 956*f461d2dcSChristoph Hellwig * parameters that use the proc_douintvec_minmax() handler. 957*f461d2dcSChristoph Hellwig */ 958*f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param { 959*f461d2dcSChristoph Hellwig unsigned int *min; 960*f461d2dcSChristoph Hellwig unsigned int *max; 961*f461d2dcSChristoph Hellwig }; 962*f461d2dcSChristoph Hellwig 963*f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 964*f461d2dcSChristoph Hellwig unsigned int *valp, 965*f461d2dcSChristoph Hellwig int write, void *data) 966*f461d2dcSChristoph Hellwig { 967*f461d2dcSChristoph Hellwig int ret; 968*f461d2dcSChristoph Hellwig unsigned int tmp; 969*f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param *param = data; 970*f461d2dcSChristoph Hellwig /* write via temporary local uint for bounds-checking */ 971*f461d2dcSChristoph Hellwig unsigned int *up = write ? &tmp : valp; 972*f461d2dcSChristoph Hellwig 973*f461d2dcSChristoph Hellwig ret = do_proc_douintvec_conv(lvalp, up, write, data); 974*f461d2dcSChristoph Hellwig if (ret) 975*f461d2dcSChristoph Hellwig return ret; 976*f461d2dcSChristoph Hellwig 977*f461d2dcSChristoph Hellwig if (write) { 978*f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 979*f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 980*f461d2dcSChristoph Hellwig return -ERANGE; 981*f461d2dcSChristoph Hellwig 982*f461d2dcSChristoph Hellwig *valp = tmp; 983*f461d2dcSChristoph Hellwig } 984*f461d2dcSChristoph Hellwig 985*f461d2dcSChristoph Hellwig return 0; 986*f461d2dcSChristoph Hellwig } 987*f461d2dcSChristoph Hellwig 988*f461d2dcSChristoph Hellwig /** 989*f461d2dcSChristoph Hellwig * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 990*f461d2dcSChristoph Hellwig * @table: the sysctl table 991*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 992*f461d2dcSChristoph Hellwig * @buffer: the user buffer 993*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 994*f461d2dcSChristoph Hellwig * @ppos: file position 995*f461d2dcSChristoph Hellwig * 996*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 997*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. Negative 998*f461d2dcSChristoph Hellwig * strings are not allowed. 999*f461d2dcSChristoph Hellwig * 1000*f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1001*f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). There is a final sanity 1002*f461d2dcSChristoph Hellwig * check for UINT_MAX to avoid having to support wrap around uses from 1003*f461d2dcSChristoph Hellwig * userspace. 1004*f461d2dcSChristoph Hellwig * 1005*f461d2dcSChristoph Hellwig * Returns 0 on success or -ERANGE on write when the range check fails. 1006*f461d2dcSChristoph Hellwig */ 1007*f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 1008*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1009*f461d2dcSChristoph Hellwig { 1010*f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param param = { 1011*f461d2dcSChristoph Hellwig .min = (unsigned int *) table->extra1, 1012*f461d2dcSChristoph Hellwig .max = (unsigned int *) table->extra2, 1013*f461d2dcSChristoph Hellwig }; 1014*f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1015*f461d2dcSChristoph Hellwig do_proc_douintvec_minmax_conv, ¶m); 1016*f461d2dcSChristoph Hellwig } 1017*f461d2dcSChristoph Hellwig 1018*f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 1019*f461d2dcSChristoph Hellwig unsigned int *valp, 1020*f461d2dcSChristoph Hellwig int write, void *data) 1021*f461d2dcSChristoph Hellwig { 1022*f461d2dcSChristoph Hellwig if (write) { 1023*f461d2dcSChristoph Hellwig unsigned int val; 1024*f461d2dcSChristoph Hellwig 1025*f461d2dcSChristoph Hellwig val = round_pipe_size(*lvalp); 1026*f461d2dcSChristoph Hellwig if (val == 0) 1027*f461d2dcSChristoph Hellwig return -EINVAL; 1028*f461d2dcSChristoph Hellwig 1029*f461d2dcSChristoph Hellwig *valp = val; 1030*f461d2dcSChristoph Hellwig } else { 1031*f461d2dcSChristoph Hellwig unsigned int val = *valp; 1032*f461d2dcSChristoph Hellwig *lvalp = (unsigned long) val; 1033*f461d2dcSChristoph Hellwig } 1034*f461d2dcSChristoph Hellwig 1035*f461d2dcSChristoph Hellwig return 0; 1036*f461d2dcSChristoph Hellwig } 1037*f461d2dcSChristoph Hellwig 1038*f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write, 1039*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1040*f461d2dcSChristoph Hellwig { 1041*f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1042*f461d2dcSChristoph Hellwig do_proc_dopipe_max_size_conv, NULL); 1043*f461d2dcSChristoph Hellwig } 1044*f461d2dcSChristoph Hellwig 1045*f461d2dcSChristoph Hellwig static void validate_coredump_safety(void) 1046*f461d2dcSChristoph Hellwig { 1047*f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1048*f461d2dcSChristoph Hellwig if (suid_dumpable == SUID_DUMP_ROOT && 1049*f461d2dcSChristoph Hellwig core_pattern[0] != '/' && core_pattern[0] != '|') { 1050*f461d2dcSChristoph Hellwig printk(KERN_WARNING 1051*f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n" 1052*f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n" 1053*f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n" 1054*f461d2dcSChristoph Hellwig ); 1055*f461d2dcSChristoph Hellwig } 1056*f461d2dcSChristoph Hellwig #endif 1057*f461d2dcSChristoph Hellwig } 1058*f461d2dcSChristoph Hellwig 1059*f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 1060*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1061*f461d2dcSChristoph Hellwig { 1062*f461d2dcSChristoph Hellwig int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1063*f461d2dcSChristoph Hellwig if (!error) 1064*f461d2dcSChristoph Hellwig validate_coredump_safety(); 1065*f461d2dcSChristoph Hellwig return error; 1066*f461d2dcSChristoph Hellwig } 1067*f461d2dcSChristoph Hellwig 1068*f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1069*f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write, 1070*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1071*f461d2dcSChristoph Hellwig { 1072*f461d2dcSChristoph Hellwig int error = proc_dostring(table, write, buffer, lenp, ppos); 1073*f461d2dcSChristoph Hellwig if (!error) 1074*f461d2dcSChristoph Hellwig validate_coredump_safety(); 1075*f461d2dcSChristoph Hellwig return error; 1076*f461d2dcSChristoph Hellwig } 1077*f461d2dcSChristoph Hellwig #endif 1078*f461d2dcSChristoph Hellwig 1079*f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ 1080*f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write, 1081*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1082*f461d2dcSChristoph Hellwig { 1083*f461d2dcSChristoph Hellwig int tmp, ret; 1084*f461d2dcSChristoph Hellwig 1085*f461d2dcSChristoph Hellwig tmp = sysrq_mask(); 1086*f461d2dcSChristoph Hellwig 1087*f461d2dcSChristoph Hellwig ret = __do_proc_dointvec(&tmp, table, write, buffer, 1088*f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1089*f461d2dcSChristoph Hellwig if (ret || !write) 1090*f461d2dcSChristoph Hellwig return ret; 1091*f461d2dcSChristoph Hellwig 1092*f461d2dcSChristoph Hellwig if (write) 1093*f461d2dcSChristoph Hellwig sysrq_toggle_support(tmp); 1094*f461d2dcSChristoph Hellwig 1095*f461d2dcSChristoph Hellwig return 0; 1096*f461d2dcSChristoph Hellwig } 1097*f461d2dcSChristoph Hellwig #endif 1098*f461d2dcSChristoph Hellwig 1099*f461d2dcSChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 1100*f461d2dcSChristoph Hellwig void __user *buffer, 1101*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 1102*f461d2dcSChristoph Hellwig unsigned long convmul, 1103*f461d2dcSChristoph Hellwig unsigned long convdiv) 1104*f461d2dcSChristoph Hellwig { 1105*f461d2dcSChristoph Hellwig unsigned long *i, *min, *max; 1106*f461d2dcSChristoph Hellwig int vleft, first = 1, err = 0; 1107*f461d2dcSChristoph Hellwig size_t left; 1108*f461d2dcSChristoph Hellwig char *kbuf = NULL, *p; 1109*f461d2dcSChristoph Hellwig 1110*f461d2dcSChristoph Hellwig if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1111*f461d2dcSChristoph Hellwig *lenp = 0; 1112*f461d2dcSChristoph Hellwig return 0; 1113*f461d2dcSChristoph Hellwig } 1114*f461d2dcSChristoph Hellwig 1115*f461d2dcSChristoph Hellwig i = (unsigned long *) data; 1116*f461d2dcSChristoph Hellwig min = (unsigned long *) table->extra1; 1117*f461d2dcSChristoph Hellwig max = (unsigned long *) table->extra2; 1118*f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(unsigned long); 1119*f461d2dcSChristoph Hellwig left = *lenp; 1120*f461d2dcSChristoph Hellwig 1121*f461d2dcSChristoph Hellwig if (write) { 1122*f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 1123*f461d2dcSChristoph Hellwig goto out; 1124*f461d2dcSChristoph Hellwig 1125*f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 1126*f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1127*f461d2dcSChristoph Hellwig p = kbuf = memdup_user_nul(buffer, left); 1128*f461d2dcSChristoph Hellwig if (IS_ERR(kbuf)) 1129*f461d2dcSChristoph Hellwig return PTR_ERR(kbuf); 1130*f461d2dcSChristoph Hellwig } 1131*f461d2dcSChristoph Hellwig 1132*f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first = 0) { 1133*f461d2dcSChristoph Hellwig unsigned long val; 1134*f461d2dcSChristoph Hellwig 1135*f461d2dcSChristoph Hellwig if (write) { 1136*f461d2dcSChristoph Hellwig bool neg; 1137*f461d2dcSChristoph Hellwig 1138*f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1139*f461d2dcSChristoph Hellwig if (!left) 1140*f461d2dcSChristoph Hellwig break; 1141*f461d2dcSChristoph Hellwig 1142*f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val, &neg, 1143*f461d2dcSChristoph Hellwig proc_wspace_sep, 1144*f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 1145*f461d2dcSChristoph Hellwig if (err) 1146*f461d2dcSChristoph Hellwig break; 1147*f461d2dcSChristoph Hellwig if (neg) 1148*f461d2dcSChristoph Hellwig continue; 1149*f461d2dcSChristoph Hellwig val = convmul * val / convdiv; 1150*f461d2dcSChristoph Hellwig if ((min && val < *min) || (max && val > *max)) { 1151*f461d2dcSChristoph Hellwig err = -EINVAL; 1152*f461d2dcSChristoph Hellwig break; 1153*f461d2dcSChristoph Hellwig } 1154*f461d2dcSChristoph Hellwig *i = val; 1155*f461d2dcSChristoph Hellwig } else { 1156*f461d2dcSChristoph Hellwig val = convdiv * (*i) / convmul; 1157*f461d2dcSChristoph Hellwig if (!first) { 1158*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '\t'); 1159*f461d2dcSChristoph Hellwig if (err) 1160*f461d2dcSChristoph Hellwig break; 1161*f461d2dcSChristoph Hellwig } 1162*f461d2dcSChristoph Hellwig err = proc_put_long(&buffer, &left, val, false); 1163*f461d2dcSChristoph Hellwig if (err) 1164*f461d2dcSChristoph Hellwig break; 1165*f461d2dcSChristoph Hellwig } 1166*f461d2dcSChristoph Hellwig } 1167*f461d2dcSChristoph Hellwig 1168*f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 1169*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '\n'); 1170*f461d2dcSChristoph Hellwig if (write && !err) 1171*f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1172*f461d2dcSChristoph Hellwig if (write) { 1173*f461d2dcSChristoph Hellwig kfree(kbuf); 1174*f461d2dcSChristoph Hellwig if (first) 1175*f461d2dcSChristoph Hellwig return err ? : -EINVAL; 1176*f461d2dcSChristoph Hellwig } 1177*f461d2dcSChristoph Hellwig *lenp -= left; 1178*f461d2dcSChristoph Hellwig out: 1179*f461d2dcSChristoph Hellwig *ppos += *lenp; 1180*f461d2dcSChristoph Hellwig return err; 1181*f461d2dcSChristoph Hellwig } 1182*f461d2dcSChristoph Hellwig 1183*f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 1184*f461d2dcSChristoph Hellwig void __user *buffer, 1185*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 1186*f461d2dcSChristoph Hellwig unsigned long convmul, 1187*f461d2dcSChristoph Hellwig unsigned long convdiv) 1188*f461d2dcSChristoph Hellwig { 1189*f461d2dcSChristoph Hellwig return __do_proc_doulongvec_minmax(table->data, table, write, 1190*f461d2dcSChristoph Hellwig buffer, lenp, ppos, convmul, convdiv); 1191*f461d2dcSChristoph Hellwig } 1192*f461d2dcSChristoph Hellwig 1193*f461d2dcSChristoph Hellwig /** 1194*f461d2dcSChristoph Hellwig * proc_doulongvec_minmax - read a vector of long integers with min/max values 1195*f461d2dcSChristoph Hellwig * @table: the sysctl table 1196*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1197*f461d2dcSChristoph Hellwig * @buffer: the user buffer 1198*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1199*f461d2dcSChristoph Hellwig * @ppos: file position 1200*f461d2dcSChristoph Hellwig * 1201*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1202*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1203*f461d2dcSChristoph Hellwig * 1204*f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1205*f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1206*f461d2dcSChristoph Hellwig * 1207*f461d2dcSChristoph Hellwig * Returns 0 on success. 1208*f461d2dcSChristoph Hellwig */ 1209*f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 1210*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1211*f461d2dcSChristoph Hellwig { 1212*f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1213*f461d2dcSChristoph Hellwig } 1214*f461d2dcSChristoph Hellwig 1215*f461d2dcSChristoph Hellwig /** 1216*f461d2dcSChristoph Hellwig * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1217*f461d2dcSChristoph Hellwig * @table: the sysctl table 1218*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1219*f461d2dcSChristoph Hellwig * @buffer: the user buffer 1220*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1221*f461d2dcSChristoph Hellwig * @ppos: file position 1222*f461d2dcSChristoph Hellwig * 1223*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1224*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. The values 1225*f461d2dcSChristoph Hellwig * are treated as milliseconds, and converted to jiffies when they are stored. 1226*f461d2dcSChristoph Hellwig * 1227*f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1228*f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1229*f461d2dcSChristoph Hellwig * 1230*f461d2dcSChristoph Hellwig * Returns 0 on success. 1231*f461d2dcSChristoph Hellwig */ 1232*f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 1233*f461d2dcSChristoph Hellwig void __user *buffer, 1234*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos) 1235*f461d2dcSChristoph Hellwig { 1236*f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, 1237*f461d2dcSChristoph Hellwig lenp, ppos, HZ, 1000l); 1238*f461d2dcSChristoph Hellwig } 1239*f461d2dcSChristoph Hellwig 1240*f461d2dcSChristoph Hellwig 1241*f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1242*f461d2dcSChristoph Hellwig int *valp, 1243*f461d2dcSChristoph Hellwig int write, void *data) 1244*f461d2dcSChristoph Hellwig { 1245*f461d2dcSChristoph Hellwig if (write) { 1246*f461d2dcSChristoph Hellwig if (*lvalp > INT_MAX / HZ) 1247*f461d2dcSChristoph Hellwig return 1; 1248*f461d2dcSChristoph Hellwig *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1249*f461d2dcSChristoph Hellwig } else { 1250*f461d2dcSChristoph Hellwig int val = *valp; 1251*f461d2dcSChristoph Hellwig unsigned long lval; 1252*f461d2dcSChristoph Hellwig if (val < 0) { 1253*f461d2dcSChristoph Hellwig *negp = true; 1254*f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1255*f461d2dcSChristoph Hellwig } else { 1256*f461d2dcSChristoph Hellwig *negp = false; 1257*f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1258*f461d2dcSChristoph Hellwig } 1259*f461d2dcSChristoph Hellwig *lvalp = lval / HZ; 1260*f461d2dcSChristoph Hellwig } 1261*f461d2dcSChristoph Hellwig return 0; 1262*f461d2dcSChristoph Hellwig } 1263*f461d2dcSChristoph Hellwig 1264*f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1265*f461d2dcSChristoph Hellwig int *valp, 1266*f461d2dcSChristoph Hellwig int write, void *data) 1267*f461d2dcSChristoph Hellwig { 1268*f461d2dcSChristoph Hellwig if (write) { 1269*f461d2dcSChristoph Hellwig if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1270*f461d2dcSChristoph Hellwig return 1; 1271*f461d2dcSChristoph Hellwig *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1272*f461d2dcSChristoph Hellwig } else { 1273*f461d2dcSChristoph Hellwig int val = *valp; 1274*f461d2dcSChristoph Hellwig unsigned long lval; 1275*f461d2dcSChristoph Hellwig if (val < 0) { 1276*f461d2dcSChristoph Hellwig *negp = true; 1277*f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1278*f461d2dcSChristoph Hellwig } else { 1279*f461d2dcSChristoph Hellwig *negp = false; 1280*f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1281*f461d2dcSChristoph Hellwig } 1282*f461d2dcSChristoph Hellwig *lvalp = jiffies_to_clock_t(lval); 1283*f461d2dcSChristoph Hellwig } 1284*f461d2dcSChristoph Hellwig return 0; 1285*f461d2dcSChristoph Hellwig } 1286*f461d2dcSChristoph Hellwig 1287*f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1288*f461d2dcSChristoph Hellwig int *valp, 1289*f461d2dcSChristoph Hellwig int write, void *data) 1290*f461d2dcSChristoph Hellwig { 1291*f461d2dcSChristoph Hellwig if (write) { 1292*f461d2dcSChristoph Hellwig unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1293*f461d2dcSChristoph Hellwig 1294*f461d2dcSChristoph Hellwig if (jif > INT_MAX) 1295*f461d2dcSChristoph Hellwig return 1; 1296*f461d2dcSChristoph Hellwig *valp = (int)jif; 1297*f461d2dcSChristoph Hellwig } else { 1298*f461d2dcSChristoph Hellwig int val = *valp; 1299*f461d2dcSChristoph Hellwig unsigned long lval; 1300*f461d2dcSChristoph Hellwig if (val < 0) { 1301*f461d2dcSChristoph Hellwig *negp = true; 1302*f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1303*f461d2dcSChristoph Hellwig } else { 1304*f461d2dcSChristoph Hellwig *negp = false; 1305*f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1306*f461d2dcSChristoph Hellwig } 1307*f461d2dcSChristoph Hellwig *lvalp = jiffies_to_msecs(lval); 1308*f461d2dcSChristoph Hellwig } 1309*f461d2dcSChristoph Hellwig return 0; 1310*f461d2dcSChristoph Hellwig } 1311*f461d2dcSChristoph Hellwig 1312*f461d2dcSChristoph Hellwig /** 1313*f461d2dcSChristoph Hellwig * proc_dointvec_jiffies - read a vector of integers as seconds 1314*f461d2dcSChristoph Hellwig * @table: the sysctl table 1315*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1316*f461d2dcSChristoph Hellwig * @buffer: the user buffer 1317*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1318*f461d2dcSChristoph Hellwig * @ppos: file position 1319*f461d2dcSChristoph Hellwig * 1320*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1321*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1322*f461d2dcSChristoph Hellwig * The values read are assumed to be in seconds, and are converted into 1323*f461d2dcSChristoph Hellwig * jiffies. 1324*f461d2dcSChristoph Hellwig * 1325*f461d2dcSChristoph Hellwig * Returns 0 on success. 1326*f461d2dcSChristoph Hellwig */ 1327*f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 1328*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1329*f461d2dcSChristoph Hellwig { 1330*f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1331*f461d2dcSChristoph Hellwig do_proc_dointvec_jiffies_conv,NULL); 1332*f461d2dcSChristoph Hellwig } 1333*f461d2dcSChristoph Hellwig 1334*f461d2dcSChristoph Hellwig /** 1335*f461d2dcSChristoph Hellwig * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1336*f461d2dcSChristoph Hellwig * @table: the sysctl table 1337*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1338*f461d2dcSChristoph Hellwig * @buffer: the user buffer 1339*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1340*f461d2dcSChristoph Hellwig * @ppos: pointer to the file position 1341*f461d2dcSChristoph Hellwig * 1342*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1343*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1344*f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/USER_HZ seconds, and 1345*f461d2dcSChristoph Hellwig * are converted into jiffies. 1346*f461d2dcSChristoph Hellwig * 1347*f461d2dcSChristoph Hellwig * Returns 0 on success. 1348*f461d2dcSChristoph Hellwig */ 1349*f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 1350*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1351*f461d2dcSChristoph Hellwig { 1352*f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1353*f461d2dcSChristoph Hellwig do_proc_dointvec_userhz_jiffies_conv,NULL); 1354*f461d2dcSChristoph Hellwig } 1355*f461d2dcSChristoph Hellwig 1356*f461d2dcSChristoph Hellwig /** 1357*f461d2dcSChristoph Hellwig * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1358*f461d2dcSChristoph Hellwig * @table: the sysctl table 1359*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1360*f461d2dcSChristoph Hellwig * @buffer: the user buffer 1361*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1362*f461d2dcSChristoph Hellwig * @ppos: file position 1363*f461d2dcSChristoph Hellwig * @ppos: the current position in the file 1364*f461d2dcSChristoph Hellwig * 1365*f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1366*f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1367*f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/1000 seconds, and 1368*f461d2dcSChristoph Hellwig * are converted into jiffies. 1369*f461d2dcSChristoph Hellwig * 1370*f461d2dcSChristoph Hellwig * Returns 0 on success. 1371*f461d2dcSChristoph Hellwig */ 1372*f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 1373*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1374*f461d2dcSChristoph Hellwig { 1375*f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1376*f461d2dcSChristoph Hellwig do_proc_dointvec_ms_jiffies_conv, NULL); 1377*f461d2dcSChristoph Hellwig } 1378*f461d2dcSChristoph Hellwig 1379*f461d2dcSChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, 1380*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1381*f461d2dcSChristoph Hellwig { 1382*f461d2dcSChristoph Hellwig struct pid *new_pid; 1383*f461d2dcSChristoph Hellwig pid_t tmp; 1384*f461d2dcSChristoph Hellwig int r; 1385*f461d2dcSChristoph Hellwig 1386*f461d2dcSChristoph Hellwig tmp = pid_vnr(cad_pid); 1387*f461d2dcSChristoph Hellwig 1388*f461d2dcSChristoph Hellwig r = __do_proc_dointvec(&tmp, table, write, buffer, 1389*f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1390*f461d2dcSChristoph Hellwig if (r || !write) 1391*f461d2dcSChristoph Hellwig return r; 1392*f461d2dcSChristoph Hellwig 1393*f461d2dcSChristoph Hellwig new_pid = find_get_pid(tmp); 1394*f461d2dcSChristoph Hellwig if (!new_pid) 1395*f461d2dcSChristoph Hellwig return -ESRCH; 1396*f461d2dcSChristoph Hellwig 1397*f461d2dcSChristoph Hellwig put_pid(xchg(&cad_pid, new_pid)); 1398*f461d2dcSChristoph Hellwig return 0; 1399*f461d2dcSChristoph Hellwig } 1400*f461d2dcSChristoph Hellwig 1401*f461d2dcSChristoph Hellwig /** 1402*f461d2dcSChristoph Hellwig * proc_do_large_bitmap - read/write from/to a large bitmap 1403*f461d2dcSChristoph Hellwig * @table: the sysctl table 1404*f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1405*f461d2dcSChristoph Hellwig * @buffer: the user buffer 1406*f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1407*f461d2dcSChristoph Hellwig * @ppos: file position 1408*f461d2dcSChristoph Hellwig * 1409*f461d2dcSChristoph Hellwig * The bitmap is stored at table->data and the bitmap length (in bits) 1410*f461d2dcSChristoph Hellwig * in table->maxlen. 1411*f461d2dcSChristoph Hellwig * 1412*f461d2dcSChristoph Hellwig * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1413*f461d2dcSChristoph Hellwig * large bitmaps may be represented in a compact manner. Writing into 1414*f461d2dcSChristoph Hellwig * the file will clear the bitmap then update it with the given input. 1415*f461d2dcSChristoph Hellwig * 1416*f461d2dcSChristoph Hellwig * Returns 0 on success. 1417*f461d2dcSChristoph Hellwig */ 1418*f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 1419*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1420*f461d2dcSChristoph Hellwig { 1421*f461d2dcSChristoph Hellwig int err = 0; 1422*f461d2dcSChristoph Hellwig bool first = 1; 1423*f461d2dcSChristoph Hellwig size_t left = *lenp; 1424*f461d2dcSChristoph Hellwig unsigned long bitmap_len = table->maxlen; 1425*f461d2dcSChristoph Hellwig unsigned long *bitmap = *(unsigned long **) table->data; 1426*f461d2dcSChristoph Hellwig unsigned long *tmp_bitmap = NULL; 1427*f461d2dcSChristoph Hellwig char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1428*f461d2dcSChristoph Hellwig 1429*f461d2dcSChristoph Hellwig if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1430*f461d2dcSChristoph Hellwig *lenp = 0; 1431*f461d2dcSChristoph Hellwig return 0; 1432*f461d2dcSChristoph Hellwig } 1433*f461d2dcSChristoph Hellwig 1434*f461d2dcSChristoph Hellwig if (write) { 1435*f461d2dcSChristoph Hellwig char *kbuf, *p; 1436*f461d2dcSChristoph Hellwig size_t skipped = 0; 1437*f461d2dcSChristoph Hellwig 1438*f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) { 1439*f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1440*f461d2dcSChristoph Hellwig /* How much of the buffer we'll skip this pass */ 1441*f461d2dcSChristoph Hellwig skipped = *lenp - left; 1442*f461d2dcSChristoph Hellwig } 1443*f461d2dcSChristoph Hellwig 1444*f461d2dcSChristoph Hellwig p = kbuf = memdup_user_nul(buffer, left); 1445*f461d2dcSChristoph Hellwig if (IS_ERR(kbuf)) 1446*f461d2dcSChristoph Hellwig return PTR_ERR(kbuf); 1447*f461d2dcSChristoph Hellwig 1448*f461d2dcSChristoph Hellwig tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 1449*f461d2dcSChristoph Hellwig if (!tmp_bitmap) { 1450*f461d2dcSChristoph Hellwig kfree(kbuf); 1451*f461d2dcSChristoph Hellwig return -ENOMEM; 1452*f461d2dcSChristoph Hellwig } 1453*f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1454*f461d2dcSChristoph Hellwig while (!err && left) { 1455*f461d2dcSChristoph Hellwig unsigned long val_a, val_b; 1456*f461d2dcSChristoph Hellwig bool neg; 1457*f461d2dcSChristoph Hellwig size_t saved_left; 1458*f461d2dcSChristoph Hellwig 1459*f461d2dcSChristoph Hellwig /* In case we stop parsing mid-number, we can reset */ 1460*f461d2dcSChristoph Hellwig saved_left = left; 1461*f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1462*f461d2dcSChristoph Hellwig sizeof(tr_a), &c); 1463*f461d2dcSChristoph Hellwig /* 1464*f461d2dcSChristoph Hellwig * If we consumed the entirety of a truncated buffer or 1465*f461d2dcSChristoph Hellwig * only one char is left (may be a "-"), then stop here, 1466*f461d2dcSChristoph Hellwig * reset, & come back for more. 1467*f461d2dcSChristoph Hellwig */ 1468*f461d2dcSChristoph Hellwig if ((left <= 1) && skipped) { 1469*f461d2dcSChristoph Hellwig left = saved_left; 1470*f461d2dcSChristoph Hellwig break; 1471*f461d2dcSChristoph Hellwig } 1472*f461d2dcSChristoph Hellwig 1473*f461d2dcSChristoph Hellwig if (err) 1474*f461d2dcSChristoph Hellwig break; 1475*f461d2dcSChristoph Hellwig if (val_a >= bitmap_len || neg) { 1476*f461d2dcSChristoph Hellwig err = -EINVAL; 1477*f461d2dcSChristoph Hellwig break; 1478*f461d2dcSChristoph Hellwig } 1479*f461d2dcSChristoph Hellwig 1480*f461d2dcSChristoph Hellwig val_b = val_a; 1481*f461d2dcSChristoph Hellwig if (left) { 1482*f461d2dcSChristoph Hellwig p++; 1483*f461d2dcSChristoph Hellwig left--; 1484*f461d2dcSChristoph Hellwig } 1485*f461d2dcSChristoph Hellwig 1486*f461d2dcSChristoph Hellwig if (c == '-') { 1487*f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_b, 1488*f461d2dcSChristoph Hellwig &neg, tr_b, sizeof(tr_b), 1489*f461d2dcSChristoph Hellwig &c); 1490*f461d2dcSChristoph Hellwig /* 1491*f461d2dcSChristoph Hellwig * If we consumed all of a truncated buffer or 1492*f461d2dcSChristoph Hellwig * then stop here, reset, & come back for more. 1493*f461d2dcSChristoph Hellwig */ 1494*f461d2dcSChristoph Hellwig if (!left && skipped) { 1495*f461d2dcSChristoph Hellwig left = saved_left; 1496*f461d2dcSChristoph Hellwig break; 1497*f461d2dcSChristoph Hellwig } 1498*f461d2dcSChristoph Hellwig 1499*f461d2dcSChristoph Hellwig if (err) 1500*f461d2dcSChristoph Hellwig break; 1501*f461d2dcSChristoph Hellwig if (val_b >= bitmap_len || neg || 1502*f461d2dcSChristoph Hellwig val_a > val_b) { 1503*f461d2dcSChristoph Hellwig err = -EINVAL; 1504*f461d2dcSChristoph Hellwig break; 1505*f461d2dcSChristoph Hellwig } 1506*f461d2dcSChristoph Hellwig if (left) { 1507*f461d2dcSChristoph Hellwig p++; 1508*f461d2dcSChristoph Hellwig left--; 1509*f461d2dcSChristoph Hellwig } 1510*f461d2dcSChristoph Hellwig } 1511*f461d2dcSChristoph Hellwig 1512*f461d2dcSChristoph Hellwig bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1513*f461d2dcSChristoph Hellwig first = 0; 1514*f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1515*f461d2dcSChristoph Hellwig } 1516*f461d2dcSChristoph Hellwig kfree(kbuf); 1517*f461d2dcSChristoph Hellwig left += skipped; 1518*f461d2dcSChristoph Hellwig } else { 1519*f461d2dcSChristoph Hellwig unsigned long bit_a, bit_b = 0; 1520*f461d2dcSChristoph Hellwig 1521*f461d2dcSChristoph Hellwig while (left) { 1522*f461d2dcSChristoph Hellwig bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1523*f461d2dcSChristoph Hellwig if (bit_a >= bitmap_len) 1524*f461d2dcSChristoph Hellwig break; 1525*f461d2dcSChristoph Hellwig bit_b = find_next_zero_bit(bitmap, bitmap_len, 1526*f461d2dcSChristoph Hellwig bit_a + 1) - 1; 1527*f461d2dcSChristoph Hellwig 1528*f461d2dcSChristoph Hellwig if (!first) { 1529*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, ','); 1530*f461d2dcSChristoph Hellwig if (err) 1531*f461d2dcSChristoph Hellwig break; 1532*f461d2dcSChristoph Hellwig } 1533*f461d2dcSChristoph Hellwig err = proc_put_long(&buffer, &left, bit_a, false); 1534*f461d2dcSChristoph Hellwig if (err) 1535*f461d2dcSChristoph Hellwig break; 1536*f461d2dcSChristoph Hellwig if (bit_a != bit_b) { 1537*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '-'); 1538*f461d2dcSChristoph Hellwig if (err) 1539*f461d2dcSChristoph Hellwig break; 1540*f461d2dcSChristoph Hellwig err = proc_put_long(&buffer, &left, bit_b, false); 1541*f461d2dcSChristoph Hellwig if (err) 1542*f461d2dcSChristoph Hellwig break; 1543*f461d2dcSChristoph Hellwig } 1544*f461d2dcSChristoph Hellwig 1545*f461d2dcSChristoph Hellwig first = 0; bit_b++; 1546*f461d2dcSChristoph Hellwig } 1547*f461d2dcSChristoph Hellwig if (!err) 1548*f461d2dcSChristoph Hellwig err = proc_put_char(&buffer, &left, '\n'); 1549*f461d2dcSChristoph Hellwig } 1550*f461d2dcSChristoph Hellwig 1551*f461d2dcSChristoph Hellwig if (!err) { 1552*f461d2dcSChristoph Hellwig if (write) { 1553*f461d2dcSChristoph Hellwig if (*ppos) 1554*f461d2dcSChristoph Hellwig bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1555*f461d2dcSChristoph Hellwig else 1556*f461d2dcSChristoph Hellwig bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1557*f461d2dcSChristoph Hellwig } 1558*f461d2dcSChristoph Hellwig *lenp -= left; 1559*f461d2dcSChristoph Hellwig *ppos += *lenp; 1560*f461d2dcSChristoph Hellwig } 1561*f461d2dcSChristoph Hellwig 1562*f461d2dcSChristoph Hellwig bitmap_free(tmp_bitmap); 1563*f461d2dcSChristoph Hellwig return err; 1564*f461d2dcSChristoph Hellwig } 1565*f461d2dcSChristoph Hellwig 1566*f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */ 1567*f461d2dcSChristoph Hellwig 1568*f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 1569*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1570*f461d2dcSChristoph Hellwig { 1571*f461d2dcSChristoph Hellwig return -ENOSYS; 1572*f461d2dcSChristoph Hellwig } 1573*f461d2dcSChristoph Hellwig 1574*f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, 1575*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1576*f461d2dcSChristoph Hellwig { 1577*f461d2dcSChristoph Hellwig return -ENOSYS; 1578*f461d2dcSChristoph Hellwig } 1579*f461d2dcSChristoph Hellwig 1580*f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, 1581*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1582*f461d2dcSChristoph Hellwig { 1583*f461d2dcSChristoph Hellwig return -ENOSYS; 1584*f461d2dcSChristoph Hellwig } 1585*f461d2dcSChristoph Hellwig 1586*f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 1587*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1588*f461d2dcSChristoph Hellwig { 1589*f461d2dcSChristoph Hellwig return -ENOSYS; 1590*f461d2dcSChristoph Hellwig } 1591*f461d2dcSChristoph Hellwig 1592*f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 1593*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1594*f461d2dcSChristoph Hellwig { 1595*f461d2dcSChristoph Hellwig return -ENOSYS; 1596*f461d2dcSChristoph Hellwig } 1597*f461d2dcSChristoph Hellwig 1598*f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 1599*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1600*f461d2dcSChristoph Hellwig { 1601*f461d2dcSChristoph Hellwig return -ENOSYS; 1602*f461d2dcSChristoph Hellwig } 1603*f461d2dcSChristoph Hellwig 1604*f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 1605*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1606*f461d2dcSChristoph Hellwig { 1607*f461d2dcSChristoph Hellwig return -ENOSYS; 1608*f461d2dcSChristoph Hellwig } 1609*f461d2dcSChristoph Hellwig 1610*f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 1611*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1612*f461d2dcSChristoph Hellwig { 1613*f461d2dcSChristoph Hellwig return -ENOSYS; 1614*f461d2dcSChristoph Hellwig } 1615*f461d2dcSChristoph Hellwig 1616*f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 1617*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1618*f461d2dcSChristoph Hellwig { 1619*f461d2dcSChristoph Hellwig return -ENOSYS; 1620*f461d2dcSChristoph Hellwig } 1621*f461d2dcSChristoph Hellwig 1622*f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 1623*f461d2dcSChristoph Hellwig void __user *buffer, 1624*f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos) 1625*f461d2dcSChristoph Hellwig { 1626*f461d2dcSChristoph Hellwig return -ENOSYS; 1627*f461d2dcSChristoph Hellwig } 1628*f461d2dcSChristoph Hellwig 1629*f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 1630*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, loff_t *ppos) 1631*f461d2dcSChristoph Hellwig { 1632*f461d2dcSChristoph Hellwig return -ENOSYS; 1633*f461d2dcSChristoph Hellwig } 1634*f461d2dcSChristoph Hellwig 1635*f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 1636*f461d2dcSChristoph Hellwig 1637*f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL) 1638*f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write, 1639*f461d2dcSChristoph Hellwig void __user *buffer, size_t *lenp, 1640*f461d2dcSChristoph Hellwig loff_t *ppos) 1641*f461d2dcSChristoph Hellwig { 1642*f461d2dcSChristoph Hellwig struct static_key *key = (struct static_key *)table->data; 1643*f461d2dcSChristoph Hellwig static DEFINE_MUTEX(static_key_mutex); 1644*f461d2dcSChristoph Hellwig int val, ret; 1645*f461d2dcSChristoph Hellwig struct ctl_table tmp = { 1646*f461d2dcSChristoph Hellwig .data = &val, 1647*f461d2dcSChristoph Hellwig .maxlen = sizeof(val), 1648*f461d2dcSChristoph Hellwig .mode = table->mode, 1649*f461d2dcSChristoph Hellwig .extra1 = SYSCTL_ZERO, 1650*f461d2dcSChristoph Hellwig .extra2 = SYSCTL_ONE, 1651*f461d2dcSChristoph Hellwig }; 1652*f461d2dcSChristoph Hellwig 1653*f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 1654*f461d2dcSChristoph Hellwig return -EPERM; 1655*f461d2dcSChristoph Hellwig 1656*f461d2dcSChristoph Hellwig mutex_lock(&static_key_mutex); 1657*f461d2dcSChristoph Hellwig val = static_key_enabled(key); 1658*f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1659*f461d2dcSChristoph Hellwig if (write && !ret) { 1660*f461d2dcSChristoph Hellwig if (val) 1661*f461d2dcSChristoph Hellwig static_key_enable(key); 1662*f461d2dcSChristoph Hellwig else 1663*f461d2dcSChristoph Hellwig static_key_disable(key); 1664*f461d2dcSChristoph Hellwig } 1665*f461d2dcSChristoph Hellwig mutex_unlock(&static_key_mutex); 1666*f461d2dcSChristoph Hellwig return ret; 1667*f461d2dcSChristoph Hellwig } 1668*f461d2dcSChristoph Hellwig 1669d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 16702bba22c5SMike Galbraith { 16712bba22c5SMike Galbraith .procname = "sched_child_runs_first", 16722bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 16732bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 16742bba22c5SMike Galbraith .mode = 0644, 16756d456111SEric W. Biederman .proc_handler = proc_dointvec, 16762bba22c5SMike Galbraith }, 167777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 167877e54a1fSIngo Molnar { 1679b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 1680b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 168177e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 168277e54a1fSIngo Molnar .mode = 0644, 1683702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 1684b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 1685b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 168677e54a1fSIngo Molnar }, 168777e54a1fSIngo Molnar { 168821805085SPeter Zijlstra .procname = "sched_latency_ns", 168921805085SPeter Zijlstra .data = &sysctl_sched_latency, 169021805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 169121805085SPeter Zijlstra .mode = 0644, 1692702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 169321805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 169421805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 169521805085SPeter Zijlstra }, 169621805085SPeter Zijlstra { 169777e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 169877e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 169977e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 170077e54a1fSIngo Molnar .mode = 0644, 1701702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 170277e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 170377e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 170477e54a1fSIngo Molnar }, 1705cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 170677e54a1fSIngo Molnar { 17071983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 17081983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 17091983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 17101983a922SChristian Ehrhardt .mode = 0644, 1711702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 17121983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 17131983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 17142398f2c6SPeter Zijlstra }, 17152398f2c6SPeter Zijlstra { 1716d00535dbSNamhyung Kim .procname = "sched_migration_cost_ns", 1717da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 1718da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 1719da84d961SIngo Molnar .mode = 0644, 17206d456111SEric W. Biederman .proc_handler = proc_dointvec, 1721da84d961SIngo Molnar }, 1722b82d9fddSPeter Zijlstra { 1723b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 1724b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 1725b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 1726fa85ae24SPeter Zijlstra .mode = 0644, 17276d456111SEric W. Biederman .proc_handler = proc_dointvec, 1728fa85ae24SPeter Zijlstra }, 1729cb251765SMel Gorman #ifdef CONFIG_SCHEDSTATS 1730cb251765SMel Gorman { 1731cb251765SMel Gorman .procname = "sched_schedstats", 1732cb251765SMel Gorman .data = NULL, 1733cb251765SMel Gorman .maxlen = sizeof(unsigned int), 1734cb251765SMel Gorman .mode = 0644, 1735cb251765SMel Gorman .proc_handler = sysctl_schedstats, 1736eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1737eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1738cb251765SMel Gorman }, 1739cb251765SMel Gorman #endif /* CONFIG_SCHEDSTATS */ 1740cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 1741cbee9f88SPeter Zijlstra #ifdef CONFIG_NUMA_BALANCING 1742cbee9f88SPeter Zijlstra { 17434b96a29bSPeter Zijlstra .procname = "numa_balancing_scan_delay_ms", 17444b96a29bSPeter Zijlstra .data = &sysctl_numa_balancing_scan_delay, 17454b96a29bSPeter Zijlstra .maxlen = sizeof(unsigned int), 17464b96a29bSPeter Zijlstra .mode = 0644, 17474b96a29bSPeter Zijlstra .proc_handler = proc_dointvec, 17484b96a29bSPeter Zijlstra }, 17494b96a29bSPeter Zijlstra { 1750cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_min_ms", 1751cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_min, 1752cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1753cbee9f88SPeter Zijlstra .mode = 0644, 1754cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1755cbee9f88SPeter Zijlstra }, 1756cbee9f88SPeter Zijlstra { 1757cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_max_ms", 1758cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_max, 1759cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1760cbee9f88SPeter Zijlstra .mode = 0644, 1761cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1762cbee9f88SPeter Zijlstra }, 17636e5fb223SPeter Zijlstra { 17646e5fb223SPeter Zijlstra .procname = "numa_balancing_scan_size_mb", 17656e5fb223SPeter Zijlstra .data = &sysctl_numa_balancing_scan_size, 17666e5fb223SPeter Zijlstra .maxlen = sizeof(unsigned int), 17676e5fb223SPeter Zijlstra .mode = 0644, 176864192658SKirill Tkhai .proc_handler = proc_dointvec_minmax, 1769eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 17706e5fb223SPeter Zijlstra }, 17713a7053b3SMel Gorman { 177254a43d54SAndi Kleen .procname = "numa_balancing", 177354a43d54SAndi Kleen .data = NULL, /* filled in by handler */ 177454a43d54SAndi Kleen .maxlen = sizeof(unsigned int), 177554a43d54SAndi Kleen .mode = 0644, 177654a43d54SAndi Kleen .proc_handler = sysctl_numa_balancing, 1777eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1778eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 177954a43d54SAndi Kleen }, 1780cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */ 1781cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 17821799e35dSIngo Molnar { 17839f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 17849f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 17859f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 17869f0c1e56SPeter Zijlstra .mode = 0644, 17876d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17889f0c1e56SPeter Zijlstra }, 17899f0c1e56SPeter Zijlstra { 17909f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 17919f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 17929f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 17939f0c1e56SPeter Zijlstra .mode = 0644, 17946d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17959f0c1e56SPeter Zijlstra }, 1796ce0dbbbbSClark Williams { 1797ce0dbbbbSClark Williams .procname = "sched_rr_timeslice_ms", 1798975e155eSShile Zhang .data = &sysctl_sched_rr_timeslice, 1799ce0dbbbbSClark Williams .maxlen = sizeof(int), 1800ce0dbbbbSClark Williams .mode = 0644, 1801ce0dbbbbSClark Williams .proc_handler = sched_rr_handler, 1802ce0dbbbbSClark Williams }, 1803e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK 1804e8f14172SPatrick Bellasi { 1805e8f14172SPatrick Bellasi .procname = "sched_util_clamp_min", 1806e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_min, 1807e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1808e8f14172SPatrick Bellasi .mode = 0644, 1809e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1810e8f14172SPatrick Bellasi }, 1811e8f14172SPatrick Bellasi { 1812e8f14172SPatrick Bellasi .procname = "sched_util_clamp_max", 1813e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_max, 1814e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1815e8f14172SPatrick Bellasi .mode = 0644, 1816e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1817e8f14172SPatrick Bellasi }, 1818e8f14172SPatrick Bellasi #endif 18195091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 18205091faa4SMike Galbraith { 18215091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 18225091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 18235091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 18245091faa4SMike Galbraith .mode = 0644, 18251747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 1826eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1827eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18285091faa4SMike Galbraith }, 18295091faa4SMike Galbraith #endif 1830ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 1831ec12cb7fSPaul Turner { 1832ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 1833ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 1834ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 1835ec12cb7fSPaul Turner .mode = 0644, 1836ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 1837eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 1838ec12cb7fSPaul Turner }, 1839ec12cb7fSPaul Turner #endif 18408d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 18418d5d0cfbSQuentin Perret { 18428d5d0cfbSQuentin Perret .procname = "sched_energy_aware", 18438d5d0cfbSQuentin Perret .data = &sysctl_sched_energy_aware, 18448d5d0cfbSQuentin Perret .maxlen = sizeof(unsigned int), 18458d5d0cfbSQuentin Perret .mode = 0644, 18468d5d0cfbSQuentin Perret .proc_handler = sched_energy_aware_handler, 1847eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1848eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18498d5d0cfbSQuentin Perret }, 18508d5d0cfbSQuentin Perret #endif 1851f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 1852f20786ffSPeter Zijlstra { 1853f20786ffSPeter Zijlstra .procname = "prove_locking", 1854f20786ffSPeter Zijlstra .data = &prove_locking, 1855f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1856f20786ffSPeter Zijlstra .mode = 0644, 18576d456111SEric W. Biederman .proc_handler = proc_dointvec, 1858f20786ffSPeter Zijlstra }, 1859f20786ffSPeter Zijlstra #endif 1860f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 1861f20786ffSPeter Zijlstra { 1862f20786ffSPeter Zijlstra .procname = "lock_stat", 1863f20786ffSPeter Zijlstra .data = &lock_stat, 1864f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1865f20786ffSPeter Zijlstra .mode = 0644, 18666d456111SEric W. Biederman .proc_handler = proc_dointvec, 1867f20786ffSPeter Zijlstra }, 1868f20786ffSPeter Zijlstra #endif 186977e54a1fSIngo Molnar { 18701da177e4SLinus Torvalds .procname = "panic", 18711da177e4SLinus Torvalds .data = &panic_timeout, 18721da177e4SLinus Torvalds .maxlen = sizeof(int), 18731da177e4SLinus Torvalds .mode = 0644, 18746d456111SEric W. Biederman .proc_handler = proc_dointvec, 18751da177e4SLinus Torvalds }, 1876046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 18771da177e4SLinus Torvalds { 18781da177e4SLinus Torvalds .procname = "core_uses_pid", 18791da177e4SLinus Torvalds .data = &core_uses_pid, 18801da177e4SLinus Torvalds .maxlen = sizeof(int), 18811da177e4SLinus Torvalds .mode = 0644, 18826d456111SEric W. Biederman .proc_handler = proc_dointvec, 18831da177e4SLinus Torvalds }, 18841da177e4SLinus Torvalds { 18851da177e4SLinus Torvalds .procname = "core_pattern", 18861da177e4SLinus Torvalds .data = core_pattern, 188771ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 18881da177e4SLinus Torvalds .mode = 0644, 188954b50199SKees Cook .proc_handler = proc_dostring_coredump, 18901da177e4SLinus Torvalds }, 1891a293980cSNeil Horman { 1892a293980cSNeil Horman .procname = "core_pipe_limit", 1893a293980cSNeil Horman .data = &core_pipe_limit, 1894a293980cSNeil Horman .maxlen = sizeof(unsigned int), 1895a293980cSNeil Horman .mode = 0644, 18966d456111SEric W. Biederman .proc_handler = proc_dointvec, 1897a293980cSNeil Horman }, 1898046d662fSAlex Kelly #endif 189934f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 19001da177e4SLinus Torvalds { 19011da177e4SLinus Torvalds .procname = "tainted", 190225ddbb18SAndi Kleen .maxlen = sizeof(long), 190334f5a398STheodore Ts'o .mode = 0644, 19046d456111SEric W. Biederman .proc_handler = proc_taint, 19051da177e4SLinus Torvalds }, 1906f4aacea2SKees Cook { 1907f4aacea2SKees Cook .procname = "sysctl_writes_strict", 1908f4aacea2SKees Cook .data = &sysctl_writes_strict, 1909f4aacea2SKees Cook .maxlen = sizeof(int), 1910f4aacea2SKees Cook .mode = 0644, 1911f4aacea2SKees Cook .proc_handler = proc_dointvec_minmax, 1912f4aacea2SKees Cook .extra1 = &neg_one, 1913eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1914f4aacea2SKees Cook }, 191534f5a398STheodore Ts'o #endif 19169745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 19179745512cSArjan van de Ven { 19189745512cSArjan van de Ven .procname = "latencytop", 19199745512cSArjan van de Ven .data = &latencytop_enabled, 19209745512cSArjan van de Ven .maxlen = sizeof(int), 19219745512cSArjan van de Ven .mode = 0644, 1922cb251765SMel Gorman .proc_handler = sysctl_latencytop, 19239745512cSArjan van de Ven }, 19249745512cSArjan van de Ven #endif 19251da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 19261da177e4SLinus Torvalds { 19271da177e4SLinus Torvalds .procname = "real-root-dev", 19281da177e4SLinus Torvalds .data = &real_root_dev, 19291da177e4SLinus Torvalds .maxlen = sizeof(int), 19301da177e4SLinus Torvalds .mode = 0644, 19316d456111SEric W. Biederman .proc_handler = proc_dointvec, 19321da177e4SLinus Torvalds }, 19331da177e4SLinus Torvalds #endif 193445807a1dSIngo Molnar { 193545807a1dSIngo Molnar .procname = "print-fatal-signals", 193645807a1dSIngo Molnar .data = &print_fatal_signals, 193745807a1dSIngo Molnar .maxlen = sizeof(int), 193845807a1dSIngo Molnar .mode = 0644, 19396d456111SEric W. Biederman .proc_handler = proc_dointvec, 194045807a1dSIngo Molnar }, 194172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 19421da177e4SLinus Torvalds { 19431da177e4SLinus Torvalds .procname = "reboot-cmd", 19441da177e4SLinus Torvalds .data = reboot_command, 19451da177e4SLinus Torvalds .maxlen = 256, 19461da177e4SLinus Torvalds .mode = 0644, 19476d456111SEric W. Biederman .proc_handler = proc_dostring, 19481da177e4SLinus Torvalds }, 19491da177e4SLinus Torvalds { 19501da177e4SLinus Torvalds .procname = "stop-a", 19511da177e4SLinus Torvalds .data = &stop_a_enabled, 19521da177e4SLinus Torvalds .maxlen = sizeof (int), 19531da177e4SLinus Torvalds .mode = 0644, 19546d456111SEric W. Biederman .proc_handler = proc_dointvec, 19551da177e4SLinus Torvalds }, 19561da177e4SLinus Torvalds { 19571da177e4SLinus Torvalds .procname = "scons-poweroff", 19581da177e4SLinus Torvalds .data = &scons_pwroff, 19591da177e4SLinus Torvalds .maxlen = sizeof (int), 19601da177e4SLinus Torvalds .mode = 0644, 19616d456111SEric W. Biederman .proc_handler = proc_dointvec, 19621da177e4SLinus Torvalds }, 19631da177e4SLinus Torvalds #endif 19640871420fSDavid S. Miller #ifdef CONFIG_SPARC64 19650871420fSDavid S. Miller { 19660871420fSDavid S. Miller .procname = "tsb-ratio", 19670871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 19680871420fSDavid S. Miller .maxlen = sizeof (int), 19690871420fSDavid S. Miller .mode = 0644, 19706d456111SEric W. Biederman .proc_handler = proc_dointvec, 19710871420fSDavid S. Miller }, 19720871420fSDavid S. Miller #endif 1973b67114dbSHelge Deller #ifdef CONFIG_PARISC 19741da177e4SLinus Torvalds { 19751da177e4SLinus Torvalds .procname = "soft-power", 19761da177e4SLinus Torvalds .data = &pwrsw_enabled, 19771da177e4SLinus Torvalds .maxlen = sizeof (int), 19781da177e4SLinus Torvalds .mode = 0644, 19796d456111SEric W. Biederman .proc_handler = proc_dointvec, 19801da177e4SLinus Torvalds }, 1981bf14e3b9SVineet Gupta #endif 1982bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 19831da177e4SLinus Torvalds { 19841da177e4SLinus Torvalds .procname = "unaligned-trap", 19851da177e4SLinus Torvalds .data = &unaligned_enabled, 19861da177e4SLinus Torvalds .maxlen = sizeof (int), 19871da177e4SLinus Torvalds .mode = 0644, 19886d456111SEric W. Biederman .proc_handler = proc_dointvec, 19891da177e4SLinus Torvalds }, 19901da177e4SLinus Torvalds #endif 19911da177e4SLinus Torvalds { 19921da177e4SLinus Torvalds .procname = "ctrl-alt-del", 19931da177e4SLinus Torvalds .data = &C_A_D, 19941da177e4SLinus Torvalds .maxlen = sizeof(int), 19951da177e4SLinus Torvalds .mode = 0644, 19966d456111SEric W. Biederman .proc_handler = proc_dointvec, 19971da177e4SLinus Torvalds }, 1998606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 1999b0fc494fSSteven Rostedt { 2000b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 2001b0fc494fSSteven Rostedt .data = &ftrace_enabled, 2002b0fc494fSSteven Rostedt .maxlen = sizeof(int), 2003b0fc494fSSteven Rostedt .mode = 0644, 20046d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 2005b0fc494fSSteven Rostedt }, 2006b0fc494fSSteven Rostedt #endif 2007f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 2008f38f1d2aSSteven Rostedt { 2009f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 2010f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 2011f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 2012f38f1d2aSSteven Rostedt .mode = 0644, 20136d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 2014f38f1d2aSSteven Rostedt }, 2015f38f1d2aSSteven Rostedt #endif 2016944ac425SSteven Rostedt #ifdef CONFIG_TRACING 2017944ac425SSteven Rostedt { 20183299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 2019944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 2020944ac425SSteven Rostedt .maxlen = sizeof(int), 2021944ac425SSteven Rostedt .mode = 0644, 20226d456111SEric W. Biederman .proc_handler = proc_dointvec, 2023944ac425SSteven Rostedt }, 2024de7edd31SSteven Rostedt (Red Hat) { 2025de7edd31SSteven Rostedt (Red Hat) .procname = "traceoff_on_warning", 2026de7edd31SSteven Rostedt (Red Hat) .data = &__disable_trace_on_warning, 2027de7edd31SSteven Rostedt (Red Hat) .maxlen = sizeof(__disable_trace_on_warning), 2028de7edd31SSteven Rostedt (Red Hat) .mode = 0644, 2029de7edd31SSteven Rostedt (Red Hat) .proc_handler = proc_dointvec, 2030de7edd31SSteven Rostedt (Red Hat) }, 20310daa2302SSteven Rostedt (Red Hat) { 20320daa2302SSteven Rostedt (Red Hat) .procname = "tracepoint_printk", 20330daa2302SSteven Rostedt (Red Hat) .data = &tracepoint_printk, 20340daa2302SSteven Rostedt (Red Hat) .maxlen = sizeof(tracepoint_printk), 20350daa2302SSteven Rostedt (Red Hat) .mode = 0644, 203642391745SSteven Rostedt (Red Hat) .proc_handler = tracepoint_printk_sysctl, 20370daa2302SSteven Rostedt (Red Hat) }, 2038944ac425SSteven Rostedt #endif 20392965faa5SDave Young #ifdef CONFIG_KEXEC_CORE 20407984754bSKees Cook { 20417984754bSKees Cook .procname = "kexec_load_disabled", 20427984754bSKees Cook .data = &kexec_load_disabled, 20437984754bSKees Cook .maxlen = sizeof(int), 20447984754bSKees Cook .mode = 0644, 20457984754bSKees Cook /* only handle a transition from default "0" to "1" */ 20467984754bSKees Cook .proc_handler = proc_dointvec_minmax, 2047eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2048eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20497984754bSKees Cook }, 20507984754bSKees Cook #endif 2051a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 20521da177e4SLinus Torvalds { 20531da177e4SLinus Torvalds .procname = "modprobe", 20541da177e4SLinus Torvalds .data = &modprobe_path, 20551da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 20561da177e4SLinus Torvalds .mode = 0644, 20576d456111SEric W. Biederman .proc_handler = proc_dostring, 20581da177e4SLinus Torvalds }, 20593d43321bSKees Cook { 20603d43321bSKees Cook .procname = "modules_disabled", 20613d43321bSKees Cook .data = &modules_disabled, 20623d43321bSKees Cook .maxlen = sizeof(int), 20633d43321bSKees Cook .mode = 0644, 20643d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 20656d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2066eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2067eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20683d43321bSKees Cook }, 20691da177e4SLinus Torvalds #endif 207086d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER 20711da177e4SLinus Torvalds { 20721da177e4SLinus Torvalds .procname = "hotplug", 2073312c004dSKay Sievers .data = &uevent_helper, 2074312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 20751da177e4SLinus Torvalds .mode = 0644, 20766d456111SEric W. Biederman .proc_handler = proc_dostring, 20771da177e4SLinus Torvalds }, 207886d56134SMichael Marineau #endif 20791da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 20801da177e4SLinus Torvalds { 20811da177e4SLinus Torvalds .procname = "sg-big-buff", 20821da177e4SLinus Torvalds .data = &sg_big_buff, 20831da177e4SLinus Torvalds .maxlen = sizeof (int), 20841da177e4SLinus Torvalds .mode = 0444, 20856d456111SEric W. Biederman .proc_handler = proc_dointvec, 20861da177e4SLinus Torvalds }, 20871da177e4SLinus Torvalds #endif 20881da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 20891da177e4SLinus Torvalds { 20901da177e4SLinus Torvalds .procname = "acct", 20911da177e4SLinus Torvalds .data = &acct_parm, 20921da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 20931da177e4SLinus Torvalds .mode = 0644, 20946d456111SEric W. Biederman .proc_handler = proc_dointvec, 20951da177e4SLinus Torvalds }, 20961da177e4SLinus Torvalds #endif 20971da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 20981da177e4SLinus Torvalds { 20991da177e4SLinus Torvalds .procname = "sysrq", 2100eaee4172SDmitry Safonov .data = NULL, 21011da177e4SLinus Torvalds .maxlen = sizeof (int), 21021da177e4SLinus Torvalds .mode = 0644, 210397f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 21041da177e4SLinus Torvalds }, 21051da177e4SLinus Torvalds #endif 2106d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 21071da177e4SLinus Torvalds { 21081da177e4SLinus Torvalds .procname = "cad_pid", 21099ec52099SCedric Le Goater .data = NULL, 21101da177e4SLinus Torvalds .maxlen = sizeof (int), 21111da177e4SLinus Torvalds .mode = 0600, 21126d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 21131da177e4SLinus Torvalds }, 2114d6f8ff73SRandy Dunlap #endif 21151da177e4SLinus Torvalds { 21161da177e4SLinus Torvalds .procname = "threads-max", 211716db3d3fSHeinrich Schuchardt .data = NULL, 21181da177e4SLinus Torvalds .maxlen = sizeof(int), 21191da177e4SLinus Torvalds .mode = 0644, 212016db3d3fSHeinrich Schuchardt .proc_handler = sysctl_max_threads, 21211da177e4SLinus Torvalds }, 21221da177e4SLinus Torvalds { 21231da177e4SLinus Torvalds .procname = "random", 21241da177e4SLinus Torvalds .mode = 0555, 21251da177e4SLinus Torvalds .child = random_table, 21261da177e4SLinus Torvalds }, 21271da177e4SLinus Torvalds { 212817f60a7dSEric Paris .procname = "usermodehelper", 212917f60a7dSEric Paris .mode = 0555, 213017f60a7dSEric Paris .child = usermodehelper_table, 213117f60a7dSEric Paris }, 2132ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER 2133ceb18132SLuis R. Rodriguez { 2134ceb18132SLuis R. Rodriguez .procname = "firmware_config", 2135ceb18132SLuis R. Rodriguez .mode = 0555, 2136ceb18132SLuis R. Rodriguez .child = firmware_config_table, 2137ceb18132SLuis R. Rodriguez }, 2138ceb18132SLuis R. Rodriguez #endif 213917f60a7dSEric Paris { 21401da177e4SLinus Torvalds .procname = "overflowuid", 21411da177e4SLinus Torvalds .data = &overflowuid, 21421da177e4SLinus Torvalds .maxlen = sizeof(int), 21431da177e4SLinus Torvalds .mode = 0644, 21446d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21451da177e4SLinus Torvalds .extra1 = &minolduid, 21461da177e4SLinus Torvalds .extra2 = &maxolduid, 21471da177e4SLinus Torvalds }, 21481da177e4SLinus Torvalds { 21491da177e4SLinus Torvalds .procname = "overflowgid", 21501da177e4SLinus Torvalds .data = &overflowgid, 21511da177e4SLinus Torvalds .maxlen = sizeof(int), 21521da177e4SLinus Torvalds .mode = 0644, 21536d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21541da177e4SLinus Torvalds .extra1 = &minolduid, 21551da177e4SLinus Torvalds .extra2 = &maxolduid, 21561da177e4SLinus Torvalds }, 2157347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 21581da177e4SLinus Torvalds { 21591da177e4SLinus Torvalds .procname = "userprocess_debug", 2160ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 21611da177e4SLinus Torvalds .maxlen = sizeof(int), 21621da177e4SLinus Torvalds .mode = 0644, 21636d456111SEric W. Biederman .proc_handler = proc_dointvec, 21641da177e4SLinus Torvalds }, 21651da177e4SLinus Torvalds #endif 21661da177e4SLinus Torvalds { 21671da177e4SLinus Torvalds .procname = "pid_max", 21681da177e4SLinus Torvalds .data = &pid_max, 21691da177e4SLinus Torvalds .maxlen = sizeof (int), 21701da177e4SLinus Torvalds .mode = 0644, 21716d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21721da177e4SLinus Torvalds .extra1 = &pid_max_min, 21731da177e4SLinus Torvalds .extra2 = &pid_max_max, 21741da177e4SLinus Torvalds }, 21751da177e4SLinus Torvalds { 21761da177e4SLinus Torvalds .procname = "panic_on_oops", 21771da177e4SLinus Torvalds .data = &panic_on_oops, 21781da177e4SLinus Torvalds .maxlen = sizeof(int), 21791da177e4SLinus Torvalds .mode = 0644, 21806d456111SEric W. Biederman .proc_handler = proc_dointvec, 21811da177e4SLinus Torvalds }, 218281c9d43fSFeng Tang { 218381c9d43fSFeng Tang .procname = "panic_print", 218481c9d43fSFeng Tang .data = &panic_print, 218581c9d43fSFeng Tang .maxlen = sizeof(unsigned long), 218681c9d43fSFeng Tang .mode = 0644, 218781c9d43fSFeng Tang .proc_handler = proc_doulongvec_minmax, 218881c9d43fSFeng Tang }, 21897ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 21907ef3d2fdSJoe Perches { 21917ef3d2fdSJoe Perches .procname = "printk", 21927ef3d2fdSJoe Perches .data = &console_loglevel, 21937ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 21947ef3d2fdSJoe Perches .mode = 0644, 21956d456111SEric W. Biederman .proc_handler = proc_dointvec, 21967ef3d2fdSJoe Perches }, 21971da177e4SLinus Torvalds { 21981da177e4SLinus Torvalds .procname = "printk_ratelimit", 2199717115e1SDave Young .data = &printk_ratelimit_state.interval, 22001da177e4SLinus Torvalds .maxlen = sizeof(int), 22011da177e4SLinus Torvalds .mode = 0644, 22026d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 22031da177e4SLinus Torvalds }, 22041da177e4SLinus Torvalds { 22051da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 2206717115e1SDave Young .data = &printk_ratelimit_state.burst, 22071da177e4SLinus Torvalds .maxlen = sizeof(int), 22081da177e4SLinus Torvalds .mode = 0644, 22096d456111SEric W. Biederman .proc_handler = proc_dointvec, 22101da177e4SLinus Torvalds }, 2211af91322eSDave Young { 2212af91322eSDave Young .procname = "printk_delay", 2213af91322eSDave Young .data = &printk_delay_msec, 2214af91322eSDave Young .maxlen = sizeof(int), 2215af91322eSDave Young .mode = 0644, 22166d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2217eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2218af91322eSDave Young .extra2 = &ten_thousand, 2219af91322eSDave Young }, 22201da177e4SLinus Torvalds { 2221750afe7bSBorislav Petkov .procname = "printk_devkmsg", 2222750afe7bSBorislav Petkov .data = devkmsg_log_str, 2223750afe7bSBorislav Petkov .maxlen = DEVKMSG_STR_MAX_SIZE, 2224750afe7bSBorislav Petkov .mode = 0644, 2225750afe7bSBorislav Petkov .proc_handler = devkmsg_sysctl_set_loglvl, 2226750afe7bSBorislav Petkov }, 2227750afe7bSBorislav Petkov { 2228eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 2229eaf06b24SDan Rosenberg .data = &dmesg_restrict, 2230eaf06b24SDan Rosenberg .maxlen = sizeof(int), 2231eaf06b24SDan Rosenberg .mode = 0644, 2232620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2233eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2234eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2235eaf06b24SDan Rosenberg }, 2236455cd5abSDan Rosenberg { 2237455cd5abSDan Rosenberg .procname = "kptr_restrict", 2238455cd5abSDan Rosenberg .data = &kptr_restrict, 2239455cd5abSDan Rosenberg .maxlen = sizeof(int), 2240455cd5abSDan Rosenberg .mode = 0644, 2241620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2242eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2243455cd5abSDan Rosenberg .extra2 = &two, 2244455cd5abSDan Rosenberg }, 2245df6e61d4SJoe Perches #endif 2246eaf06b24SDan Rosenberg { 22471da177e4SLinus Torvalds .procname = "ngroups_max", 22481da177e4SLinus Torvalds .data = &ngroups_max, 22491da177e4SLinus Torvalds .maxlen = sizeof (int), 22501da177e4SLinus Torvalds .mode = 0444, 22516d456111SEric W. Biederman .proc_handler = proc_dointvec, 22521da177e4SLinus Torvalds }, 225373efc039SDan Ballard { 225473efc039SDan Ballard .procname = "cap_last_cap", 225573efc039SDan Ballard .data = (void *)&cap_last_cap, 225673efc039SDan Ballard .maxlen = sizeof(int), 225773efc039SDan Ballard .mode = 0444, 225873efc039SDan Ballard .proc_handler = proc_dointvec, 225973efc039SDan Ballard }, 226058687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 2261504d7cf1SDon Zickus { 226258687acbSDon Zickus .procname = "watchdog", 22633c00ea82SFrederic Weisbecker .data = &watchdog_user_enabled, 2264504d7cf1SDon Zickus .maxlen = sizeof(int), 2265504d7cf1SDon Zickus .mode = 0644, 2266195daf66SUlrich Obergfell .proc_handler = proc_watchdog, 2267eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2268eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 226958687acbSDon Zickus }, 227058687acbSDon Zickus { 227158687acbSDon Zickus .procname = "watchdog_thresh", 2272586692a5SMandeep Singh Baines .data = &watchdog_thresh, 227358687acbSDon Zickus .maxlen = sizeof(int), 227458687acbSDon Zickus .mode = 0644, 2275195daf66SUlrich Obergfell .proc_handler = proc_watchdog_thresh, 2276eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 227758687acbSDon Zickus .extra2 = &sixty, 2278504d7cf1SDon Zickus }, 22792508ce18SDon Zickus { 2280195daf66SUlrich Obergfell .procname = "nmi_watchdog", 22817feeb9cdSThomas Gleixner .data = &nmi_watchdog_user_enabled, 2282195daf66SUlrich Obergfell .maxlen = sizeof(int), 228351d4052bSThomas Gleixner .mode = NMI_WATCHDOG_SYSCTL_PERM, 2284195daf66SUlrich Obergfell .proc_handler = proc_nmi_watchdog, 2285eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2286eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2287195daf66SUlrich Obergfell }, 2288195daf66SUlrich Obergfell { 228905a4a952SNicholas Piggin .procname = "watchdog_cpumask", 229005a4a952SNicholas Piggin .data = &watchdog_cpumask_bits, 229105a4a952SNicholas Piggin .maxlen = NR_CPUS, 229205a4a952SNicholas Piggin .mode = 0644, 229305a4a952SNicholas Piggin .proc_handler = proc_watchdog_cpumask, 229405a4a952SNicholas Piggin }, 229505a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR 229605a4a952SNicholas Piggin { 2297195daf66SUlrich Obergfell .procname = "soft_watchdog", 22987feeb9cdSThomas Gleixner .data = &soft_watchdog_user_enabled, 2299195daf66SUlrich Obergfell .maxlen = sizeof(int), 2300195daf66SUlrich Obergfell .mode = 0644, 2301195daf66SUlrich Obergfell .proc_handler = proc_soft_watchdog, 2302eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2303eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2304195daf66SUlrich Obergfell }, 2305195daf66SUlrich Obergfell { 23062508ce18SDon Zickus .procname = "softlockup_panic", 23072508ce18SDon Zickus .data = &softlockup_panic, 23082508ce18SDon Zickus .maxlen = sizeof(int), 23092508ce18SDon Zickus .mode = 0644, 23102508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 2311eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2312eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 23132508ce18SDon Zickus }, 2314ed235875SAaron Tomlin #ifdef CONFIG_SMP 2315ed235875SAaron Tomlin { 2316ed235875SAaron Tomlin .procname = "softlockup_all_cpu_backtrace", 2317ed235875SAaron Tomlin .data = &sysctl_softlockup_all_cpu_backtrace, 2318ed235875SAaron Tomlin .maxlen = sizeof(int), 2319ed235875SAaron Tomlin .mode = 0644, 2320ed235875SAaron Tomlin .proc_handler = proc_dointvec_minmax, 2321eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2322eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2323ed235875SAaron Tomlin }, 232405a4a952SNicholas Piggin #endif /* CONFIG_SMP */ 232505a4a952SNicholas Piggin #endif 232605a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR 232705a4a952SNicholas Piggin { 232805a4a952SNicholas Piggin .procname = "hardlockup_panic", 232905a4a952SNicholas Piggin .data = &hardlockup_panic, 233005a4a952SNicholas Piggin .maxlen = sizeof(int), 233105a4a952SNicholas Piggin .mode = 0644, 233205a4a952SNicholas Piggin .proc_handler = proc_dointvec_minmax, 2333eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2334eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 233505a4a952SNicholas Piggin }, 233605a4a952SNicholas Piggin #ifdef CONFIG_SMP 233755537871SJiri Kosina { 233855537871SJiri Kosina .procname = "hardlockup_all_cpu_backtrace", 233955537871SJiri Kosina .data = &sysctl_hardlockup_all_cpu_backtrace, 234055537871SJiri Kosina .maxlen = sizeof(int), 234155537871SJiri Kosina .mode = 0644, 234255537871SJiri Kosina .proc_handler = proc_dointvec_minmax, 2343eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2344eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 234555537871SJiri Kosina }, 2346ed235875SAaron Tomlin #endif /* CONFIG_SMP */ 23475dc30558SDon Zickus #endif 234805a4a952SNicholas Piggin #endif 234905a4a952SNicholas Piggin 23505dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 23515dc30558SDon Zickus { 23525dc30558SDon Zickus .procname = "unknown_nmi_panic", 23535dc30558SDon Zickus .data = &unknown_nmi_panic, 23545dc30558SDon Zickus .maxlen = sizeof (int), 23555dc30558SDon Zickus .mode = 0644, 23565dc30558SDon Zickus .proc_handler = proc_dointvec, 23575dc30558SDon Zickus }, 2358504d7cf1SDon Zickus #endif 23591da177e4SLinus Torvalds #if defined(CONFIG_X86) 23601da177e4SLinus Torvalds { 23618da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 23628da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 23638da5addaSDon Zickus .maxlen = sizeof(int), 23648da5addaSDon Zickus .mode = 0644, 23656d456111SEric W. Biederman .proc_handler = proc_dointvec, 23668da5addaSDon Zickus }, 23678da5addaSDon Zickus { 23685211a242SKurt Garloff .procname = "panic_on_io_nmi", 23695211a242SKurt Garloff .data = &panic_on_io_nmi, 23705211a242SKurt Garloff .maxlen = sizeof(int), 23715211a242SKurt Garloff .mode = 0644, 23726d456111SEric W. Biederman .proc_handler = proc_dointvec, 23735211a242SKurt Garloff }, 237455af7796SMitsuo Hayasaka #ifdef CONFIG_DEBUG_STACKOVERFLOW 237555af7796SMitsuo Hayasaka { 237655af7796SMitsuo Hayasaka .procname = "panic_on_stackoverflow", 237755af7796SMitsuo Hayasaka .data = &sysctl_panic_on_stackoverflow, 237855af7796SMitsuo Hayasaka .maxlen = sizeof(int), 237955af7796SMitsuo Hayasaka .mode = 0644, 238055af7796SMitsuo Hayasaka .proc_handler = proc_dointvec, 238155af7796SMitsuo Hayasaka }, 238255af7796SMitsuo Hayasaka #endif 23835211a242SKurt Garloff { 23841da177e4SLinus Torvalds .procname = "bootloader_type", 23851da177e4SLinus Torvalds .data = &bootloader_type, 23861da177e4SLinus Torvalds .maxlen = sizeof (int), 23871da177e4SLinus Torvalds .mode = 0444, 23886d456111SEric W. Biederman .proc_handler = proc_dointvec, 23891da177e4SLinus Torvalds }, 23900741f4d2SChuck Ebbert { 23915031296cSH. Peter Anvin .procname = "bootloader_version", 23925031296cSH. Peter Anvin .data = &bootloader_version, 23935031296cSH. Peter Anvin .maxlen = sizeof (int), 23945031296cSH. Peter Anvin .mode = 0444, 23956d456111SEric W. Biederman .proc_handler = proc_dointvec, 23965031296cSH. Peter Anvin }, 23975031296cSH. Peter Anvin { 23986e7c4025SIngo Molnar .procname = "io_delay_type", 23996e7c4025SIngo Molnar .data = &io_delay_type, 24006e7c4025SIngo Molnar .maxlen = sizeof(int), 24016e7c4025SIngo Molnar .mode = 0644, 24026d456111SEric W. Biederman .proc_handler = proc_dointvec, 24036e7c4025SIngo Molnar }, 24041da177e4SLinus Torvalds #endif 24057a9166e3SLuke Yang #if defined(CONFIG_MMU) 24061da177e4SLinus Torvalds { 24071da177e4SLinus Torvalds .procname = "randomize_va_space", 24081da177e4SLinus Torvalds .data = &randomize_va_space, 24091da177e4SLinus Torvalds .maxlen = sizeof(int), 24101da177e4SLinus Torvalds .mode = 0644, 24116d456111SEric W. Biederman .proc_handler = proc_dointvec, 24121da177e4SLinus Torvalds }, 24137a9166e3SLuke Yang #endif 24140152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2415951f22d5SMartin Schwidefsky { 2416951f22d5SMartin Schwidefsky .procname = "spin_retry", 2417951f22d5SMartin Schwidefsky .data = &spin_retry, 2418951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 2419951f22d5SMartin Schwidefsky .mode = 0644, 24206d456111SEric W. Biederman .proc_handler = proc_dointvec, 2421951f22d5SMartin Schwidefsky }, 2422951f22d5SMartin Schwidefsky #endif 2423673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2424c255d844SPavel Machek { 2425c255d844SPavel Machek .procname = "acpi_video_flags", 242677afcf78SPavel Machek .data = &acpi_realmode_flags, 2427c255d844SPavel Machek .maxlen = sizeof (unsigned long), 2428c255d844SPavel Machek .mode = 0644, 24296d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 2430c255d844SPavel Machek }, 2431c255d844SPavel Machek #endif 2432b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2433d2b176edSJes Sorensen { 2434d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 2435d2b176edSJes Sorensen .data = &no_unaligned_warning, 2436d2b176edSJes Sorensen .maxlen = sizeof (int), 2437d2b176edSJes Sorensen .mode = 0644, 24386d456111SEric W. Biederman .proc_handler = proc_dointvec, 2439d2b176edSJes Sorensen }, 2440b6fca725SVineet Gupta #endif 2441b6fca725SVineet Gupta #ifdef CONFIG_IA64 244288fc241fSDoug Chapman { 244388fc241fSDoug Chapman .procname = "unaligned-dump-stack", 244488fc241fSDoug Chapman .data = &unaligned_dump_stack, 244588fc241fSDoug Chapman .maxlen = sizeof (int), 244688fc241fSDoug Chapman .mode = 0644, 24476d456111SEric W. Biederman .proc_handler = proc_dointvec, 244888fc241fSDoug Chapman }, 2449d2b176edSJes Sorensen #endif 2450e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 2451e162b39aSMandeep Singh Baines { 2452e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 2453e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 2454e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 2455e162b39aSMandeep Singh Baines .mode = 0644, 24566d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2457eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2458eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2459e162b39aSMandeep Singh Baines }, 246082a1fcb9SIngo Molnar { 246182a1fcb9SIngo Molnar .procname = "hung_task_check_count", 246282a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 2463cd64647fSLi Zefan .maxlen = sizeof(int), 246482a1fcb9SIngo Molnar .mode = 0644, 2465cd64647fSLi Zefan .proc_handler = proc_dointvec_minmax, 2466eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 246782a1fcb9SIngo Molnar }, 246882a1fcb9SIngo Molnar { 246982a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 247082a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 247190739081SIngo Molnar .maxlen = sizeof(unsigned long), 247282a1fcb9SIngo Molnar .mode = 0644, 24736d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 247480df2847SLiu Hua .extra2 = &hung_task_timeout_max, 247582a1fcb9SIngo Molnar }, 247682a1fcb9SIngo Molnar { 2477a2e51445SDmitry Vyukov .procname = "hung_task_check_interval_secs", 2478a2e51445SDmitry Vyukov .data = &sysctl_hung_task_check_interval_secs, 2479a2e51445SDmitry Vyukov .maxlen = sizeof(unsigned long), 2480a2e51445SDmitry Vyukov .mode = 0644, 2481a2e51445SDmitry Vyukov .proc_handler = proc_dohung_task_timeout_secs, 2482a2e51445SDmitry Vyukov .extra2 = &hung_task_timeout_max, 2483a2e51445SDmitry Vyukov }, 2484a2e51445SDmitry Vyukov { 248582a1fcb9SIngo Molnar .procname = "hung_task_warnings", 248682a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 2487270750dbSAaron Tomlin .maxlen = sizeof(int), 248882a1fcb9SIngo Molnar .mode = 0644, 2489270750dbSAaron Tomlin .proc_handler = proc_dointvec_minmax, 2490270750dbSAaron Tomlin .extra1 = &neg_one, 249182a1fcb9SIngo Molnar }, 2492c4f3b63fSRavikiran G Thirumalai #endif 249323f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 249423f78d4aSIngo Molnar { 249523f78d4aSIngo Molnar .procname = "max_lock_depth", 249623f78d4aSIngo Molnar .data = &max_lock_depth, 249723f78d4aSIngo Molnar .maxlen = sizeof(int), 249823f78d4aSIngo Molnar .mode = 0644, 24996d456111SEric W. Biederman .proc_handler = proc_dointvec, 250023f78d4aSIngo Molnar }, 250123f78d4aSIngo Molnar #endif 250210a0a8d4SJeremy Fitzhardinge { 250310a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 250410a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 250510a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 250610a0a8d4SJeremy Fitzhardinge .mode = 0644, 25076d456111SEric W. Biederman .proc_handler = proc_dostring, 250810a0a8d4SJeremy Fitzhardinge }, 25090b77f5bfSDavid Howells #ifdef CONFIG_KEYS 25100b77f5bfSDavid Howells { 25110b77f5bfSDavid Howells .procname = "keys", 25120b77f5bfSDavid Howells .mode = 0555, 25130b77f5bfSDavid Howells .child = key_sysctls, 25140b77f5bfSDavid Howells }, 25150b77f5bfSDavid Howells #endif 2516cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 2517aa4a2218SVince Weaver /* 2518aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 2519aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 2520aa4a2218SVince Weaver * 2521aa4a2218SVince Weaver * So it's an ABI, do not remove! 2522aa4a2218SVince Weaver */ 25231ccd1549SPeter Zijlstra { 2524cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 2525cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 2526cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 25271ccd1549SPeter Zijlstra .mode = 0644, 25286d456111SEric W. Biederman .proc_handler = proc_dointvec, 25291ccd1549SPeter Zijlstra }, 2530c5078f78SPeter Zijlstra { 2531cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 2532cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 2533cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 2534c5078f78SPeter Zijlstra .mode = 0644, 25356d456111SEric W. Biederman .proc_handler = proc_dointvec, 2536c5078f78SPeter Zijlstra }, 2537a78ac325SPeter Zijlstra { 2538cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 2539cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 2540cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 2541a78ac325SPeter Zijlstra .mode = 0644, 2542163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 2543eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2544a78ac325SPeter Zijlstra }, 254514c63f17SDave Hansen { 254614c63f17SDave Hansen .procname = "perf_cpu_time_max_percent", 254714c63f17SDave Hansen .data = &sysctl_perf_cpu_time_max_percent, 254814c63f17SDave Hansen .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 254914c63f17SDave Hansen .mode = 0644, 255014c63f17SDave Hansen .proc_handler = perf_cpu_time_max_percent_handler, 2551eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 255214c63f17SDave Hansen .extra2 = &one_hundred, 255314c63f17SDave Hansen }, 2554c5dfd78eSArnaldo Carvalho de Melo { 2555c5dfd78eSArnaldo Carvalho de Melo .procname = "perf_event_max_stack", 2556a831100aSArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_stack, 2557c5dfd78eSArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_stack), 2558c5dfd78eSArnaldo Carvalho de Melo .mode = 0644, 2559c5dfd78eSArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2560eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2561c5dfd78eSArnaldo Carvalho de Melo .extra2 = &six_hundred_forty_kb, 2562c5dfd78eSArnaldo Carvalho de Melo }, 2563c85b0334SArnaldo Carvalho de Melo { 2564c85b0334SArnaldo Carvalho de Melo .procname = "perf_event_max_contexts_per_stack", 2565c85b0334SArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_contexts_per_stack, 2566c85b0334SArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2567c85b0334SArnaldo Carvalho de Melo .mode = 0644, 2568c85b0334SArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2569eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2570c85b0334SArnaldo Carvalho de Melo .extra2 = &one_thousand, 2571c85b0334SArnaldo Carvalho de Melo }, 25721ccd1549SPeter Zijlstra #endif 25739e3961a0SPrarit Bhargava { 25749e3961a0SPrarit Bhargava .procname = "panic_on_warn", 25759e3961a0SPrarit Bhargava .data = &panic_on_warn, 25769e3961a0SPrarit Bhargava .maxlen = sizeof(int), 25779e3961a0SPrarit Bhargava .mode = 0644, 25789e3961a0SPrarit Bhargava .proc_handler = proc_dointvec_minmax, 2579eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2580eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 25819e3961a0SPrarit Bhargava }, 2582bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2583bc7a34b8SThomas Gleixner { 2584bc7a34b8SThomas Gleixner .procname = "timer_migration", 2585bc7a34b8SThomas Gleixner .data = &sysctl_timer_migration, 2586bc7a34b8SThomas Gleixner .maxlen = sizeof(unsigned int), 2587bc7a34b8SThomas Gleixner .mode = 0644, 2588bc7a34b8SThomas Gleixner .proc_handler = timer_migration_handler, 2589eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2590eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2591bc7a34b8SThomas Gleixner }, 2592bc7a34b8SThomas Gleixner #endif 25931be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL 25941be7f75dSAlexei Starovoitov { 25951be7f75dSAlexei Starovoitov .procname = "unprivileged_bpf_disabled", 25961be7f75dSAlexei Starovoitov .data = &sysctl_unprivileged_bpf_disabled, 25971be7f75dSAlexei Starovoitov .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 25981be7f75dSAlexei Starovoitov .mode = 0644, 25991be7f75dSAlexei Starovoitov /* only handle a transition from default "0" to "1" */ 26001be7f75dSAlexei Starovoitov .proc_handler = proc_dointvec_minmax, 2601eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2602eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 26031be7f75dSAlexei Starovoitov }, 2604492ecee8SAlexei Starovoitov { 2605492ecee8SAlexei Starovoitov .procname = "bpf_stats_enabled", 2606a8e11e5cSEric Dumazet .data = &bpf_stats_enabled_key.key, 2607a8e11e5cSEric Dumazet .maxlen = sizeof(bpf_stats_enabled_key), 2608492ecee8SAlexei Starovoitov .mode = 0644, 2609a8e11e5cSEric Dumazet .proc_handler = proc_do_static_key, 2610492ecee8SAlexei Starovoitov }, 26113fcc5530SAlexei Starovoitov #endif 2612b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU) 2613088e9d25SDaniel Bristot de Oliveira { 2614088e9d25SDaniel Bristot de Oliveira .procname = "panic_on_rcu_stall", 2615088e9d25SDaniel Bristot de Oliveira .data = &sysctl_panic_on_rcu_stall, 2616088e9d25SDaniel Bristot de Oliveira .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2617088e9d25SDaniel Bristot de Oliveira .mode = 0644, 2618088e9d25SDaniel Bristot de Oliveira .proc_handler = proc_dointvec_minmax, 2619eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2620eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2621088e9d25SDaniel Bristot de Oliveira }, 2622088e9d25SDaniel Bristot de Oliveira #endif 2623964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 2624964c9dffSAlexander Popov { 2625964c9dffSAlexander Popov .procname = "stack_erasing", 2626964c9dffSAlexander Popov .data = NULL, 2627964c9dffSAlexander Popov .maxlen = sizeof(int), 2628964c9dffSAlexander Popov .mode = 0600, 2629964c9dffSAlexander Popov .proc_handler = stack_erasing_sysctl, 2630eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2631eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2632964c9dffSAlexander Popov }, 2633964c9dffSAlexander Popov #endif 26346fce56ecSEric W. Biederman { } 26351da177e4SLinus Torvalds }; 26361da177e4SLinus Torvalds 2637d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 26381da177e4SLinus Torvalds { 26391da177e4SLinus Torvalds .procname = "overcommit_memory", 26401da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 26411da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 26421da177e4SLinus Torvalds .mode = 0644, 2643cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2644eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2645cb16e95fSPetr Holasek .extra2 = &two, 26461da177e4SLinus Torvalds }, 26471da177e4SLinus Torvalds { 2648fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 2649fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 2650fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 2651fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 2652cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2653eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2654cb16e95fSPetr Holasek .extra2 = &two, 2655fadd8fbdSKAMEZAWA Hiroyuki }, 2656fadd8fbdSKAMEZAWA Hiroyuki { 2657fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 2658fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 2659fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2660fe071d7eSDavid Rientjes .mode = 0644, 26616d456111SEric W. Biederman .proc_handler = proc_dointvec, 2662fe071d7eSDavid Rientjes }, 2663fe071d7eSDavid Rientjes { 2664fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 2665fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 2666fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 2667fef1bdd6SDavid Rientjes .mode = 0644, 26686d456111SEric W. Biederman .proc_handler = proc_dointvec, 2669fef1bdd6SDavid Rientjes }, 2670fef1bdd6SDavid Rientjes { 26711da177e4SLinus Torvalds .procname = "overcommit_ratio", 26721da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 26731da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 26741da177e4SLinus Torvalds .mode = 0644, 267549f0ce5fSJerome Marchand .proc_handler = overcommit_ratio_handler, 267649f0ce5fSJerome Marchand }, 267749f0ce5fSJerome Marchand { 267849f0ce5fSJerome Marchand .procname = "overcommit_kbytes", 267949f0ce5fSJerome Marchand .data = &sysctl_overcommit_kbytes, 268049f0ce5fSJerome Marchand .maxlen = sizeof(sysctl_overcommit_kbytes), 268149f0ce5fSJerome Marchand .mode = 0644, 268249f0ce5fSJerome Marchand .proc_handler = overcommit_kbytes_handler, 26831da177e4SLinus Torvalds }, 26841da177e4SLinus Torvalds { 26851da177e4SLinus Torvalds .procname = "page-cluster", 26861da177e4SLinus Torvalds .data = &page_cluster, 26871da177e4SLinus Torvalds .maxlen = sizeof(int), 26881da177e4SLinus Torvalds .mode = 0644, 2689cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2690eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 26911da177e4SLinus Torvalds }, 26921da177e4SLinus Torvalds { 26931da177e4SLinus Torvalds .procname = "dirty_background_ratio", 26941da177e4SLinus Torvalds .data = &dirty_background_ratio, 26951da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 26961da177e4SLinus Torvalds .mode = 0644, 26976d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 2698eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 26991da177e4SLinus Torvalds .extra2 = &one_hundred, 27001da177e4SLinus Torvalds }, 27011da177e4SLinus Torvalds { 27022da02997SDavid Rientjes .procname = "dirty_background_bytes", 27032da02997SDavid Rientjes .data = &dirty_background_bytes, 27042da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 27052da02997SDavid Rientjes .mode = 0644, 27066d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 2707fc3501d4SSven Wegener .extra1 = &one_ul, 27082da02997SDavid Rientjes }, 27092da02997SDavid Rientjes { 27101da177e4SLinus Torvalds .procname = "dirty_ratio", 27111da177e4SLinus Torvalds .data = &vm_dirty_ratio, 27121da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 27131da177e4SLinus Torvalds .mode = 0644, 27146d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 2715eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27161da177e4SLinus Torvalds .extra2 = &one_hundred, 27171da177e4SLinus Torvalds }, 27181da177e4SLinus Torvalds { 27192da02997SDavid Rientjes .procname = "dirty_bytes", 27202da02997SDavid Rientjes .data = &vm_dirty_bytes, 27212da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 27222da02997SDavid Rientjes .mode = 0644, 27236d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 27249e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 27252da02997SDavid Rientjes }, 27262da02997SDavid Rientjes { 27271da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 2728f6ef9438SBart Samwel .data = &dirty_writeback_interval, 2729f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 27301da177e4SLinus Torvalds .mode = 0644, 27316d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 27321da177e4SLinus Torvalds }, 27331da177e4SLinus Torvalds { 27341da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 2735f6ef9438SBart Samwel .data = &dirty_expire_interval, 2736f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 27371da177e4SLinus Torvalds .mode = 0644, 2738cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2739eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27401da177e4SLinus Torvalds }, 27411da177e4SLinus Torvalds { 27421efff914STheodore Ts'o .procname = "dirtytime_expire_seconds", 27431efff914STheodore Ts'o .data = &dirtytime_expire_interval, 27442d87b309SRandy Dunlap .maxlen = sizeof(dirtytime_expire_interval), 27451efff914STheodore Ts'o .mode = 0644, 27461efff914STheodore Ts'o .proc_handler = dirtytime_interval_handler, 2747eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27481efff914STheodore Ts'o }, 27491efff914STheodore Ts'o { 27501da177e4SLinus Torvalds .procname = "swappiness", 27511da177e4SLinus Torvalds .data = &vm_swappiness, 27521da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 27531da177e4SLinus Torvalds .mode = 0644, 27546d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2755eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27561da177e4SLinus Torvalds .extra2 = &one_hundred, 27571da177e4SLinus Torvalds }, 27581da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 27591da177e4SLinus Torvalds { 27601da177e4SLinus Torvalds .procname = "nr_hugepages", 2761e5ff2159SAndi Kleen .data = NULL, 27621da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 27631da177e4SLinus Torvalds .mode = 0644, 27646d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 27651da177e4SLinus Torvalds }, 276606808b08SLee Schermerhorn #ifdef CONFIG_NUMA 276706808b08SLee Schermerhorn { 276806808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 276906808b08SLee Schermerhorn .data = NULL, 277006808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 277106808b08SLee Schermerhorn .mode = 0644, 277206808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 277306808b08SLee Schermerhorn }, 27744518085eSKemi Wang { 27754518085eSKemi Wang .procname = "numa_stat", 27764518085eSKemi Wang .data = &sysctl_vm_numa_stat, 27774518085eSKemi Wang .maxlen = sizeof(int), 27784518085eSKemi Wang .mode = 0644, 27794518085eSKemi Wang .proc_handler = sysctl_vm_numa_stat_handler, 2780eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2781eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 27824518085eSKemi Wang }, 278306808b08SLee Schermerhorn #endif 27841da177e4SLinus Torvalds { 27851da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 27861da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 27871da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 27881da177e4SLinus Torvalds .mode = 0644, 27896d456111SEric W. Biederman .proc_handler = proc_dointvec, 27901da177e4SLinus Torvalds }, 2791396faf03SMel Gorman { 2792d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 2793e5ff2159SAndi Kleen .data = NULL, 2794e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 2795d1c3fb1fSNishanth Aravamudan .mode = 0644, 27966d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 2797d1c3fb1fSNishanth Aravamudan }, 27981da177e4SLinus Torvalds #endif 27991da177e4SLinus Torvalds { 28001da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 28011da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 28021da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 28031da177e4SLinus Torvalds .mode = 0644, 28046d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 28051da177e4SLinus Torvalds }, 28061da177e4SLinus Torvalds { 28079d0243bcSAndrew Morton .procname = "drop_caches", 28089d0243bcSAndrew Morton .data = &sysctl_drop_caches, 28099d0243bcSAndrew Morton .maxlen = sizeof(int), 2810204cb79aSJohannes Weiner .mode = 0200, 28119d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 2812eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 28135509a5d2SDave Hansen .extra2 = &four, 28149d0243bcSAndrew Morton }, 281576ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 281676ab0f53SMel Gorman { 281776ab0f53SMel Gorman .procname = "compact_memory", 281876ab0f53SMel Gorman .data = &sysctl_compact_memory, 281976ab0f53SMel Gorman .maxlen = sizeof(int), 282076ab0f53SMel Gorman .mode = 0200, 282176ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 282276ab0f53SMel Gorman }, 28235e771905SMel Gorman { 28245e771905SMel Gorman .procname = "extfrag_threshold", 28255e771905SMel Gorman .data = &sysctl_extfrag_threshold, 28265e771905SMel Gorman .maxlen = sizeof(int), 28275e771905SMel Gorman .mode = 0644, 28286b7e5cadSMatthew Wilcox .proc_handler = proc_dointvec_minmax, 28295e771905SMel Gorman .extra1 = &min_extfrag_threshold, 28305e771905SMel Gorman .extra2 = &max_extfrag_threshold, 28315e771905SMel Gorman }, 28325bbe3547SEric B Munson { 28335bbe3547SEric B Munson .procname = "compact_unevictable_allowed", 28345bbe3547SEric B Munson .data = &sysctl_compact_unevictable_allowed, 28355bbe3547SEric B Munson .maxlen = sizeof(int), 28365bbe3547SEric B Munson .mode = 0644, 28376923aa0dSSebastian Andrzej Siewior .proc_handler = proc_dointvec_minmax_warn_RT_change, 2838eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2839eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28405bbe3547SEric B Munson }, 28415e771905SMel Gorman 284276ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 28439d0243bcSAndrew Morton { 28441da177e4SLinus Torvalds .procname = "min_free_kbytes", 28451da177e4SLinus Torvalds .data = &min_free_kbytes, 28461da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 28471da177e4SLinus Torvalds .mode = 0644, 28486d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 2849eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28501da177e4SLinus Torvalds }, 28518ad4b1fbSRohit Seth { 28521c30844dSMel Gorman .procname = "watermark_boost_factor", 28531c30844dSMel Gorman .data = &watermark_boost_factor, 28541c30844dSMel Gorman .maxlen = sizeof(watermark_boost_factor), 28551c30844dSMel Gorman .mode = 0644, 285626363af5SChristoph Hellwig .proc_handler = proc_dointvec_minmax, 2857eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28581c30844dSMel Gorman }, 28591c30844dSMel Gorman { 2860795ae7a0SJohannes Weiner .procname = "watermark_scale_factor", 2861795ae7a0SJohannes Weiner .data = &watermark_scale_factor, 2862795ae7a0SJohannes Weiner .maxlen = sizeof(watermark_scale_factor), 2863795ae7a0SJohannes Weiner .mode = 0644, 2864795ae7a0SJohannes Weiner .proc_handler = watermark_scale_factor_sysctl_handler, 2865eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2866795ae7a0SJohannes Weiner .extra2 = &one_thousand, 2867795ae7a0SJohannes Weiner }, 2868795ae7a0SJohannes Weiner { 28698ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 28708ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 28718ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 28728ad4b1fbSRohit Seth .mode = 0644, 28736d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 2874eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28758ad4b1fbSRohit Seth }, 28761da177e4SLinus Torvalds #ifdef CONFIG_MMU 28771da177e4SLinus Torvalds { 28781da177e4SLinus Torvalds .procname = "max_map_count", 28791da177e4SLinus Torvalds .data = &sysctl_max_map_count, 28801da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 28811da177e4SLinus Torvalds .mode = 0644, 28823e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 2883eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28841da177e4SLinus Torvalds }, 2885dd8632a1SPaul Mundt #else 2886dd8632a1SPaul Mundt { 2887dd8632a1SPaul Mundt .procname = "nr_trim_pages", 2888dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 2889dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 2890dd8632a1SPaul Mundt .mode = 0644, 28916d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2892eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2893dd8632a1SPaul Mundt }, 28941da177e4SLinus Torvalds #endif 28951da177e4SLinus Torvalds { 28961da177e4SLinus Torvalds .procname = "laptop_mode", 28971da177e4SLinus Torvalds .data = &laptop_mode, 28981da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 28991da177e4SLinus Torvalds .mode = 0644, 29006d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 29011da177e4SLinus Torvalds }, 29021da177e4SLinus Torvalds { 29031da177e4SLinus Torvalds .procname = "block_dump", 29041da177e4SLinus Torvalds .data = &block_dump, 29051da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 29061da177e4SLinus Torvalds .mode = 0644, 29076d456111SEric W. Biederman .proc_handler = proc_dointvec, 2908eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29091da177e4SLinus Torvalds }, 29101da177e4SLinus Torvalds { 29111da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 29121da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 29131da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 29141da177e4SLinus Torvalds .mode = 0644, 29156d456111SEric W. Biederman .proc_handler = proc_dointvec, 2916eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29171da177e4SLinus Torvalds }, 291867f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 291967f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 29201da177e4SLinus Torvalds { 29211da177e4SLinus Torvalds .procname = "legacy_va_layout", 29221da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 29231da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 29241da177e4SLinus Torvalds .mode = 0644, 29256d456111SEric W. Biederman .proc_handler = proc_dointvec, 2926eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29271da177e4SLinus Torvalds }, 29281da177e4SLinus Torvalds #endif 29291743660bSChristoph Lameter #ifdef CONFIG_NUMA 29301743660bSChristoph Lameter { 29311743660bSChristoph Lameter .procname = "zone_reclaim_mode", 2932a5f5f91dSMel Gorman .data = &node_reclaim_mode, 2933a5f5f91dSMel Gorman .maxlen = sizeof(node_reclaim_mode), 29341743660bSChristoph Lameter .mode = 0644, 29356d456111SEric W. Biederman .proc_handler = proc_dointvec, 2936eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29371743660bSChristoph Lameter }, 29389614634fSChristoph Lameter { 29399614634fSChristoph Lameter .procname = "min_unmapped_ratio", 29409614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 29419614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 29429614634fSChristoph Lameter .mode = 0644, 29436d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 2944eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29459614634fSChristoph Lameter .extra2 = &one_hundred, 29469614634fSChristoph Lameter }, 29470ff38490SChristoph Lameter { 29480ff38490SChristoph Lameter .procname = "min_slab_ratio", 29490ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 29500ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 29510ff38490SChristoph Lameter .mode = 0644, 29526d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 2953eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29540ff38490SChristoph Lameter .extra2 = &one_hundred, 29550ff38490SChristoph Lameter }, 29561743660bSChristoph Lameter #endif 295777461ab3SChristoph Lameter #ifdef CONFIG_SMP 295877461ab3SChristoph Lameter { 295977461ab3SChristoph Lameter .procname = "stat_interval", 296077461ab3SChristoph Lameter .data = &sysctl_stat_interval, 296177461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 296277461ab3SChristoph Lameter .mode = 0644, 29636d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 296477461ab3SChristoph Lameter }, 296552b6f46bSHugh Dickins { 296652b6f46bSHugh Dickins .procname = "stat_refresh", 296752b6f46bSHugh Dickins .data = NULL, 296852b6f46bSHugh Dickins .maxlen = 0, 296952b6f46bSHugh Dickins .mode = 0600, 297052b6f46bSHugh Dickins .proc_handler = vmstat_refresh, 297152b6f46bSHugh Dickins }, 297277461ab3SChristoph Lameter #endif 29736e141546SDavid Howells #ifdef CONFIG_MMU 2974ed032189SEric Paris { 2975ed032189SEric Paris .procname = "mmap_min_addr", 2976788084abSEric Paris .data = &dac_mmap_min_addr, 2977ed032189SEric Paris .maxlen = sizeof(unsigned long), 2978ed032189SEric Paris .mode = 0644, 29796d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 2980ed032189SEric Paris }, 29816e141546SDavid Howells #endif 2982f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 2983f0c0b2b8SKAMEZAWA Hiroyuki { 2984f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 2985f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 2986f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 2987f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 29886d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 2989f0c0b2b8SKAMEZAWA Hiroyuki }, 2990f0c0b2b8SKAMEZAWA Hiroyuki #endif 29912b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 29925c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 2993e6e5494cSIngo Molnar { 2994e6e5494cSIngo Molnar .procname = "vdso_enabled", 29953d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32 29963d7ee969SAndy Lutomirski .data = &vdso32_enabled, 29973d7ee969SAndy Lutomirski .maxlen = sizeof(vdso32_enabled), 29983d7ee969SAndy Lutomirski #else 2999e6e5494cSIngo Molnar .data = &vdso_enabled, 3000e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 30013d7ee969SAndy Lutomirski #endif 3002e6e5494cSIngo Molnar .mode = 0644, 30036d456111SEric W. Biederman .proc_handler = proc_dointvec, 3004eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3005e6e5494cSIngo Molnar }, 3006e6e5494cSIngo Molnar #endif 3007195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 3008195cf453SBron Gondwana { 3009195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 3010195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 3011195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 3012195cf453SBron Gondwana .mode = 0644, 30136d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3014eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3015eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3016195cf453SBron Gondwana }, 3017195cf453SBron Gondwana #endif 30186a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 30196a46079cSAndi Kleen { 30206a46079cSAndi Kleen .procname = "memory_failure_early_kill", 30216a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 30226a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 30236a46079cSAndi Kleen .mode = 0644, 30246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3025eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3026eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30276a46079cSAndi Kleen }, 30286a46079cSAndi Kleen { 30296a46079cSAndi Kleen .procname = "memory_failure_recovery", 30306a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 30316a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 30326a46079cSAndi Kleen .mode = 0644, 30336d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3034eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3035eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30366a46079cSAndi Kleen }, 30376a46079cSAndi Kleen #endif 3038c9b1d098SAndrew Shewmaker { 3039c9b1d098SAndrew Shewmaker .procname = "user_reserve_kbytes", 3040c9b1d098SAndrew Shewmaker .data = &sysctl_user_reserve_kbytes, 3041c9b1d098SAndrew Shewmaker .maxlen = sizeof(sysctl_user_reserve_kbytes), 3042c9b1d098SAndrew Shewmaker .mode = 0644, 3043c9b1d098SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 3044c9b1d098SAndrew Shewmaker }, 30454eeab4f5SAndrew Shewmaker { 30464eeab4f5SAndrew Shewmaker .procname = "admin_reserve_kbytes", 30474eeab4f5SAndrew Shewmaker .data = &sysctl_admin_reserve_kbytes, 30484eeab4f5SAndrew Shewmaker .maxlen = sizeof(sysctl_admin_reserve_kbytes), 30494eeab4f5SAndrew Shewmaker .mode = 0644, 30504eeab4f5SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 30514eeab4f5SAndrew Shewmaker }, 3052d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 3053d07e2259SDaniel Cashman { 3054d07e2259SDaniel Cashman .procname = "mmap_rnd_bits", 3055d07e2259SDaniel Cashman .data = &mmap_rnd_bits, 3056d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_bits), 3057d07e2259SDaniel Cashman .mode = 0600, 3058d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3059d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_bits_min, 3060d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_bits_max, 3061d07e2259SDaniel Cashman }, 3062d07e2259SDaniel Cashman #endif 3063d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 3064d07e2259SDaniel Cashman { 3065d07e2259SDaniel Cashman .procname = "mmap_rnd_compat_bits", 3066d07e2259SDaniel Cashman .data = &mmap_rnd_compat_bits, 3067d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_compat_bits), 3068d07e2259SDaniel Cashman .mode = 0600, 3069d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3070d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_compat_bits_min, 3071d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_compat_bits_max, 3072d07e2259SDaniel Cashman }, 3073d07e2259SDaniel Cashman #endif 3074cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD 3075cefdca0aSPeter Xu { 3076cefdca0aSPeter Xu .procname = "unprivileged_userfaultfd", 3077cefdca0aSPeter Xu .data = &sysctl_unprivileged_userfaultfd, 3078cefdca0aSPeter Xu .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 3079cefdca0aSPeter Xu .mode = 0644, 3080cefdca0aSPeter Xu .proc_handler = proc_dointvec_minmax, 3081eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3082eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3083cefdca0aSPeter Xu }, 3084cefdca0aSPeter Xu #endif 30856fce56ecSEric W. Biederman { } 30861da177e4SLinus Torvalds }; 30871da177e4SLinus Torvalds 3088d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 30891da177e4SLinus Torvalds { 30901da177e4SLinus Torvalds .procname = "inode-nr", 30911da177e4SLinus Torvalds .data = &inodes_stat, 30923942c07cSGlauber Costa .maxlen = 2*sizeof(long), 30931da177e4SLinus Torvalds .mode = 0444, 3094cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 30951da177e4SLinus Torvalds }, 30961da177e4SLinus Torvalds { 30971da177e4SLinus Torvalds .procname = "inode-state", 30981da177e4SLinus Torvalds .data = &inodes_stat, 30993942c07cSGlauber Costa .maxlen = 7*sizeof(long), 31001da177e4SLinus Torvalds .mode = 0444, 3101cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31021da177e4SLinus Torvalds }, 31031da177e4SLinus Torvalds { 31041da177e4SLinus Torvalds .procname = "file-nr", 31051da177e4SLinus Torvalds .data = &files_stat, 3106518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 31071da177e4SLinus Torvalds .mode = 0444, 31086d456111SEric W. Biederman .proc_handler = proc_nr_files, 31091da177e4SLinus Torvalds }, 31101da177e4SLinus Torvalds { 31111da177e4SLinus Torvalds .procname = "file-max", 31121da177e4SLinus Torvalds .data = &files_stat.max_files, 3113518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 31141da177e4SLinus Torvalds .mode = 0644, 3115518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 31169002b214SWill Deacon .extra1 = &zero_ul, 311732a5ad9cSChristian Brauner .extra2 = &long_max, 31181da177e4SLinus Torvalds }, 31191da177e4SLinus Torvalds { 31209cfe015aSEric Dumazet .procname = "nr_open", 31219cfe015aSEric Dumazet .data = &sysctl_nr_open, 31229b80a184SAlexey Dobriyan .maxlen = sizeof(unsigned int), 31239cfe015aSEric Dumazet .mode = 0644, 31246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3125eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 3126eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 31279cfe015aSEric Dumazet }, 31289cfe015aSEric Dumazet { 31291da177e4SLinus Torvalds .procname = "dentry-state", 31301da177e4SLinus Torvalds .data = &dentry_stat, 31313942c07cSGlauber Costa .maxlen = 6*sizeof(long), 31321da177e4SLinus Torvalds .mode = 0444, 3133312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 31341da177e4SLinus Torvalds }, 31351da177e4SLinus Torvalds { 31361da177e4SLinus Torvalds .procname = "overflowuid", 31371da177e4SLinus Torvalds .data = &fs_overflowuid, 31381da177e4SLinus Torvalds .maxlen = sizeof(int), 31391da177e4SLinus Torvalds .mode = 0644, 31406d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31411da177e4SLinus Torvalds .extra1 = &minolduid, 31421da177e4SLinus Torvalds .extra2 = &maxolduid, 31431da177e4SLinus Torvalds }, 31441da177e4SLinus Torvalds { 31451da177e4SLinus Torvalds .procname = "overflowgid", 31461da177e4SLinus Torvalds .data = &fs_overflowgid, 31471da177e4SLinus Torvalds .maxlen = sizeof(int), 31481da177e4SLinus Torvalds .mode = 0644, 31496d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31501da177e4SLinus Torvalds .extra1 = &minolduid, 31511da177e4SLinus Torvalds .extra2 = &maxolduid, 31521da177e4SLinus Torvalds }, 3153bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 31541da177e4SLinus Torvalds { 31551da177e4SLinus Torvalds .procname = "leases-enable", 31561da177e4SLinus Torvalds .data = &leases_enable, 31571da177e4SLinus Torvalds .maxlen = sizeof(int), 31581da177e4SLinus Torvalds .mode = 0644, 31596d456111SEric W. Biederman .proc_handler = proc_dointvec, 31601da177e4SLinus Torvalds }, 3161bfcd17a6SThomas Petazzoni #endif 31621da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 31631da177e4SLinus Torvalds { 31641da177e4SLinus Torvalds .procname = "dir-notify-enable", 31651da177e4SLinus Torvalds .data = &dir_notify_enable, 31661da177e4SLinus Torvalds .maxlen = sizeof(int), 31671da177e4SLinus Torvalds .mode = 0644, 31686d456111SEric W. Biederman .proc_handler = proc_dointvec, 31691da177e4SLinus Torvalds }, 31701da177e4SLinus Torvalds #endif 31711da177e4SLinus Torvalds #ifdef CONFIG_MMU 3172bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 31731da177e4SLinus Torvalds { 31741da177e4SLinus Torvalds .procname = "lease-break-time", 31751da177e4SLinus Torvalds .data = &lease_break_time, 31761da177e4SLinus Torvalds .maxlen = sizeof(int), 31771da177e4SLinus Torvalds .mode = 0644, 31786d456111SEric W. Biederman .proc_handler = proc_dointvec, 31791da177e4SLinus Torvalds }, 3180bfcd17a6SThomas Petazzoni #endif 3181ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 31821da177e4SLinus Torvalds { 31831da177e4SLinus Torvalds .procname = "aio-nr", 31841da177e4SLinus Torvalds .data = &aio_nr, 31851da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 31861da177e4SLinus Torvalds .mode = 0444, 31876d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 31881da177e4SLinus Torvalds }, 31891da177e4SLinus Torvalds { 31901da177e4SLinus Torvalds .procname = "aio-max-nr", 31911da177e4SLinus Torvalds .data = &aio_max_nr, 31921da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 31931da177e4SLinus Torvalds .mode = 0644, 31946d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 31951da177e4SLinus Torvalds }, 3196ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 31972d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 31980399cb08SRobert Love { 31990399cb08SRobert Love .procname = "inotify", 32000399cb08SRobert Love .mode = 0555, 32010399cb08SRobert Love .child = inotify_table, 32020399cb08SRobert Love }, 32030399cb08SRobert Love #endif 32047ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 32057ef9964eSDavide Libenzi { 32067ef9964eSDavide Libenzi .procname = "epoll", 32077ef9964eSDavide Libenzi .mode = 0555, 32087ef9964eSDavide Libenzi .child = epoll_table, 32097ef9964eSDavide Libenzi }, 32107ef9964eSDavide Libenzi #endif 32111da177e4SLinus Torvalds #endif 3212d6e71144SAlan Cox { 3213800179c9SKees Cook .procname = "protected_symlinks", 3214800179c9SKees Cook .data = &sysctl_protected_symlinks, 3215800179c9SKees Cook .maxlen = sizeof(int), 3216800179c9SKees Cook .mode = 0600, 3217800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3218eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3219eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3220800179c9SKees Cook }, 3221800179c9SKees Cook { 3222800179c9SKees Cook .procname = "protected_hardlinks", 3223800179c9SKees Cook .data = &sysctl_protected_hardlinks, 3224800179c9SKees Cook .maxlen = sizeof(int), 3225800179c9SKees Cook .mode = 0600, 3226800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3227eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3228eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3229800179c9SKees Cook }, 3230800179c9SKees Cook { 323130aba665SSalvatore Mesoraca .procname = "protected_fifos", 323230aba665SSalvatore Mesoraca .data = &sysctl_protected_fifos, 323330aba665SSalvatore Mesoraca .maxlen = sizeof(int), 323430aba665SSalvatore Mesoraca .mode = 0600, 323530aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3236eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 323730aba665SSalvatore Mesoraca .extra2 = &two, 323830aba665SSalvatore Mesoraca }, 323930aba665SSalvatore Mesoraca { 324030aba665SSalvatore Mesoraca .procname = "protected_regular", 324130aba665SSalvatore Mesoraca .data = &sysctl_protected_regular, 324230aba665SSalvatore Mesoraca .maxlen = sizeof(int), 324330aba665SSalvatore Mesoraca .mode = 0600, 324430aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3245eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 324630aba665SSalvatore Mesoraca .extra2 = &two, 324730aba665SSalvatore Mesoraca }, 324830aba665SSalvatore Mesoraca { 3249d6e71144SAlan Cox .procname = "suid_dumpable", 3250d6e71144SAlan Cox .data = &suid_dumpable, 3251d6e71144SAlan Cox .maxlen = sizeof(int), 3252d6e71144SAlan Cox .mode = 0644, 325354b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 3254eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 32558e654fbaSMatthew Wilcox .extra2 = &two, 3256d6e71144SAlan Cox }, 32572abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 32582abc26fcSEric W. Biederman { 32592abc26fcSEric W. Biederman .procname = "binfmt_misc", 32602abc26fcSEric W. Biederman .mode = 0555, 3261f9bd6733SEric W. Biederman .child = sysctl_mount_point, 32622abc26fcSEric W. Biederman }, 32632abc26fcSEric W. Biederman #endif 3264b492e95bSJens Axboe { 3265ff9da691SJens Axboe .procname = "pipe-max-size", 3266ff9da691SJens Axboe .data = &pipe_max_size, 326798159d97SJoe Lawrence .maxlen = sizeof(pipe_max_size), 3268b492e95bSJens Axboe .mode = 0644, 3269319e0a21SEric Biggers .proc_handler = proc_dopipe_max_size, 3270b492e95bSJens Axboe }, 3271759c0114SWilly Tarreau { 3272759c0114SWilly Tarreau .procname = "pipe-user-pages-hard", 3273759c0114SWilly Tarreau .data = &pipe_user_pages_hard, 3274759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_hard), 3275759c0114SWilly Tarreau .mode = 0644, 3276759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3277759c0114SWilly Tarreau }, 3278759c0114SWilly Tarreau { 3279759c0114SWilly Tarreau .procname = "pipe-user-pages-soft", 3280759c0114SWilly Tarreau .data = &pipe_user_pages_soft, 3281759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_soft), 3282759c0114SWilly Tarreau .mode = 0644, 3283759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3284759c0114SWilly Tarreau }, 3285d2921684SEric W. Biederman { 3286d2921684SEric W. Biederman .procname = "mount-max", 3287d2921684SEric W. Biederman .data = &sysctl_mount_max, 3288d2921684SEric W. Biederman .maxlen = sizeof(unsigned int), 3289d2921684SEric W. Biederman .mode = 0644, 3290d2921684SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3291eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 3292d2921684SEric W. Biederman }, 32936fce56ecSEric W. Biederman { } 32941da177e4SLinus Torvalds }; 32951da177e4SLinus Torvalds 3296d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 32977ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 3298abd4f750SMasoud Asgharifard Sharbiani { 3299abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 3300abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 3301abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 3302abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 3303abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 3304abd4f750SMasoud Asgharifard Sharbiani }, 3305abd4f750SMasoud Asgharifard Sharbiani #endif 3306b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 3307b2be84dfSMasami Hiramatsu { 3308b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 3309b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 3310b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 3311b2be84dfSMasami Hiramatsu .mode = 0644, 3312b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 3313eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3314eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3315b2be84dfSMasami Hiramatsu }, 3316b2be84dfSMasami Hiramatsu #endif 33176fce56ecSEric W. Biederman { } 33181da177e4SLinus Torvalds }; 33191da177e4SLinus Torvalds 3320d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 33216fce56ecSEric W. Biederman { } 33221da177e4SLinus Torvalds }; 33231da177e4SLinus Torvalds 3324*f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = { 3325*f461d2dcSChristoph Hellwig { 3326*f461d2dcSChristoph Hellwig .procname = "kernel", 3327*f461d2dcSChristoph Hellwig .mode = 0555, 3328*f461d2dcSChristoph Hellwig .child = kern_table, 3329*f461d2dcSChristoph Hellwig }, 3330*f461d2dcSChristoph Hellwig { 3331*f461d2dcSChristoph Hellwig .procname = "vm", 3332*f461d2dcSChristoph Hellwig .mode = 0555, 3333*f461d2dcSChristoph Hellwig .child = vm_table, 3334*f461d2dcSChristoph Hellwig }, 3335*f461d2dcSChristoph Hellwig { 3336*f461d2dcSChristoph Hellwig .procname = "fs", 3337*f461d2dcSChristoph Hellwig .mode = 0555, 3338*f461d2dcSChristoph Hellwig .child = fs_table, 3339*f461d2dcSChristoph Hellwig }, 3340*f461d2dcSChristoph Hellwig { 3341*f461d2dcSChristoph Hellwig .procname = "debug", 3342*f461d2dcSChristoph Hellwig .mode = 0555, 3343*f461d2dcSChristoph Hellwig .child = debug_table, 3344*f461d2dcSChristoph Hellwig }, 3345*f461d2dcSChristoph Hellwig { 3346*f461d2dcSChristoph Hellwig .procname = "dev", 3347*f461d2dcSChristoph Hellwig .mode = 0555, 3348*f461d2dcSChristoph Hellwig .child = dev_table, 3349*f461d2dcSChristoph Hellwig }, 3350*f461d2dcSChristoph Hellwig { } 3351*f461d2dcSChristoph Hellwig }; 3352*f461d2dcSChristoph Hellwig 3353de4e83bdSEric W. Biederman int __init sysctl_init(void) 3354330d57fbSAl Viro { 3355fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 3356fd4b616bSSteven Rostedt 3357fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 3358fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 3359330d57fbSAl Viro return 0; 3360f7e6ced4SAl Viro } 3361b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 33621da177e4SLinus Torvalds /* 33631da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 33641da177e4SLinus Torvalds * exception granted :-) 33651da177e4SLinus Torvalds */ 33661da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 3367e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec); 33681da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 33691da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 337061d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 33711da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 33721da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 33731da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 33741da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 33751da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 33760bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap); 3377