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; 121c843966cSJohannes Weiner static int two_hundred = 200; 122795ae7a0SJohannes Weiner static int one_thousand = 1000; 123af91322eSDave Young #ifdef CONFIG_PRINTK 124af91322eSDave Young static int ten_thousand = 10000; 125af91322eSDave Young #endif 126c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS 127c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024; 128c5dfd78eSArnaldo Carvalho de Melo #endif 129c4f3b63fSRavikiran G Thirumalai 1309e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1319e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1329e4a5bdaSAndrea Righi 1331da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1341da177e4SLinus Torvalds static int maxolduid = 65535; 1351da177e4SLinus Torvalds static int minolduid; 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 13873efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1391da177e4SLinus Torvalds 140a2e51445SDmitry Vyukov /* 141a2e51445SDmitry Vyukov * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs 142a2e51445SDmitry Vyukov * and hung_task_check_interval_secs 143a2e51445SDmitry Vyukov */ 14480df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK 14580df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ); 14680df2847SLiu Hua #endif 14780df2847SLiu Hua 148d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 149d14f1729SDave Young #include <linux/inotify.h> 150d14f1729SDave Young #endif 151b6fca725SVineet Gupta 152d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 153f4aacea2SKees Cook 154a19ac337SLuis R. Rodriguez /** 155a19ac337SLuis R. Rodriguez * enum sysctl_writes_mode - supported sysctl write modes 156a19ac337SLuis R. Rodriguez * 157a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value 158a19ac337SLuis R. Rodriguez * to be written, and multiple writes on the same sysctl file descriptor 159a19ac337SLuis R. Rodriguez * will rewrite the sysctl value, regardless of file position. No warning 160a19ac337SLuis R. Rodriguez * is issued when the initial position is not 0. 161a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is 162a19ac337SLuis R. Rodriguez * not 0. 163a19ac337SLuis R. Rodriguez * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at 164a19ac337SLuis R. Rodriguez * file position 0 and the value must be fully contained in the buffer 165a19ac337SLuis R. Rodriguez * sent to the write syscall. If dealing with strings respect the file 166a19ac337SLuis R. Rodriguez * position, but restrict this to the max length of the buffer, anything 16765f50f25SWeitao Hou * passed the max length will be ignored. Multiple writes will append 168a19ac337SLuis R. Rodriguez * to the buffer. 169a19ac337SLuis R. Rodriguez * 170a19ac337SLuis R. Rodriguez * These write modes control how current file position affects the behavior of 171a19ac337SLuis R. Rodriguez * updating sysctl values through the proc interface on each write. 172a19ac337SLuis R. Rodriguez */ 173a19ac337SLuis R. Rodriguez enum sysctl_writes_mode { 174a19ac337SLuis R. Rodriguez SYSCTL_WRITES_LEGACY = -1, 175a19ac337SLuis R. Rodriguez SYSCTL_WRITES_WARN = 0, 176a19ac337SLuis R. Rodriguez SYSCTL_WRITES_STRICT = 1, 177a19ac337SLuis R. Rodriguez }; 178f4aacea2SKees Cook 179a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; 180f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 181ceb18132SLuis R. Rodriguez 18267f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 18367f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 1841da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1851da177e4SLinus Torvalds #endif 1861da177e4SLinus Torvalds 18777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 18873c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 18973c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 19073c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 19173c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 192cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 1931983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 1941983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 195cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 196cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 19777e54a1fSIngo Molnar 1985e771905SMel Gorman #ifdef CONFIG_COMPACTION 1995e771905SMel Gorman static int min_extfrag_threshold; 2005e771905SMel Gorman static int max_extfrag_threshold = 1000; 2015e771905SMel Gorman #endif 2025e771905SMel Gorman 203f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */ 204f461d2dcSChristoph Hellwig 2055447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL) 206d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write, 207d46edd67SSong Liu void __user *buffer, size_t *lenp, 208d46edd67SSong Liu loff_t *ppos) 209d46edd67SSong Liu { 210d46edd67SSong Liu struct static_key *key = (struct static_key *)table->data; 211d46edd67SSong Liu static int saved_val; 212d46edd67SSong Liu int val, ret; 213d46edd67SSong Liu struct ctl_table tmp = { 214d46edd67SSong Liu .data = &val, 215d46edd67SSong Liu .maxlen = sizeof(val), 216d46edd67SSong Liu .mode = table->mode, 217d46edd67SSong Liu .extra1 = SYSCTL_ZERO, 218d46edd67SSong Liu .extra2 = SYSCTL_ONE, 219d46edd67SSong Liu }; 220d46edd67SSong Liu 221d46edd67SSong Liu if (write && !capable(CAP_SYS_ADMIN)) 222d46edd67SSong Liu return -EPERM; 223d46edd67SSong Liu 224d46edd67SSong Liu mutex_lock(&bpf_stats_enabled_mutex); 225d46edd67SSong Liu val = saved_val; 226d46edd67SSong Liu ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 227d46edd67SSong Liu if (write && !ret && val != saved_val) { 228d46edd67SSong Liu if (val) 229d46edd67SSong Liu static_key_slow_inc(key); 230d46edd67SSong Liu else 231d46edd67SSong Liu static_key_slow_dec(key); 232d46edd67SSong Liu saved_val = val; 233d46edd67SSong Liu } 234d46edd67SSong Liu mutex_unlock(&bpf_stats_enabled_mutex); 235d46edd67SSong Liu return ret; 236d46edd67SSong Liu } 237d46edd67SSong Liu #endif 238d46edd67SSong Liu 239f461d2dcSChristoph Hellwig /* 240f461d2dcSChristoph Hellwig * /proc/sys support 241f461d2dcSChristoph Hellwig */ 242f461d2dcSChristoph Hellwig 243f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL 244f461d2dcSChristoph Hellwig 245f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write, 24632927393SChristoph Hellwig char *buffer, size_t *lenp, loff_t *ppos) 247f461d2dcSChristoph Hellwig { 248f461d2dcSChristoph Hellwig size_t len; 24932927393SChristoph Hellwig char c, *p; 250f461d2dcSChristoph Hellwig 251f461d2dcSChristoph Hellwig if (!data || !maxlen || !*lenp) { 252f461d2dcSChristoph Hellwig *lenp = 0; 253f461d2dcSChristoph Hellwig return 0; 254f461d2dcSChristoph Hellwig } 255f461d2dcSChristoph Hellwig 256f461d2dcSChristoph Hellwig if (write) { 257f461d2dcSChristoph Hellwig if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 258f461d2dcSChristoph Hellwig /* Only continue writes not past the end of buffer. */ 259f461d2dcSChristoph Hellwig len = strlen(data); 260f461d2dcSChristoph Hellwig if (len > maxlen - 1) 261f461d2dcSChristoph Hellwig len = maxlen - 1; 262f461d2dcSChristoph Hellwig 263f461d2dcSChristoph Hellwig if (*ppos > len) 264f461d2dcSChristoph Hellwig return 0; 265f461d2dcSChristoph Hellwig len = *ppos; 266f461d2dcSChristoph Hellwig } else { 267f461d2dcSChristoph Hellwig /* Start writing from beginning of buffer. */ 268f461d2dcSChristoph Hellwig len = 0; 269f461d2dcSChristoph Hellwig } 270f461d2dcSChristoph Hellwig 271f461d2dcSChristoph Hellwig *ppos += *lenp; 272f461d2dcSChristoph Hellwig p = buffer; 273f461d2dcSChristoph Hellwig while ((p - buffer) < *lenp && len < maxlen - 1) { 27432927393SChristoph Hellwig c = *(p++); 275f461d2dcSChristoph Hellwig if (c == 0 || c == '\n') 276f461d2dcSChristoph Hellwig break; 277f461d2dcSChristoph Hellwig data[len++] = c; 278f461d2dcSChristoph Hellwig } 279f461d2dcSChristoph Hellwig data[len] = 0; 280f461d2dcSChristoph Hellwig } else { 281f461d2dcSChristoph Hellwig len = strlen(data); 282f461d2dcSChristoph Hellwig if (len > maxlen) 283f461d2dcSChristoph Hellwig len = maxlen; 284f461d2dcSChristoph Hellwig 285f461d2dcSChristoph Hellwig if (*ppos > len) { 286f461d2dcSChristoph Hellwig *lenp = 0; 287f461d2dcSChristoph Hellwig return 0; 288f461d2dcSChristoph Hellwig } 289f461d2dcSChristoph Hellwig 290f461d2dcSChristoph Hellwig data += *ppos; 291f461d2dcSChristoph Hellwig len -= *ppos; 292f461d2dcSChristoph Hellwig 293f461d2dcSChristoph Hellwig if (len > *lenp) 294f461d2dcSChristoph Hellwig len = *lenp; 295f461d2dcSChristoph Hellwig if (len) 29632927393SChristoph Hellwig memcpy(buffer, data, len); 297f461d2dcSChristoph Hellwig if (len < *lenp) { 29832927393SChristoph Hellwig buffer[len] = '\n'; 299f461d2dcSChristoph Hellwig len++; 300f461d2dcSChristoph Hellwig } 301f461d2dcSChristoph Hellwig *lenp = len; 302f461d2dcSChristoph Hellwig *ppos += len; 303f461d2dcSChristoph Hellwig } 304f461d2dcSChristoph Hellwig return 0; 305f461d2dcSChristoph Hellwig } 306f461d2dcSChristoph Hellwig 307f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table) 308f461d2dcSChristoph Hellwig { 309f461d2dcSChristoph Hellwig pr_warn_once("%s wrote to %s when file position was not 0!\n" 310f461d2dcSChristoph Hellwig "This will not be supported in the future. To silence this\n" 311f461d2dcSChristoph Hellwig "warning, set kernel.sysctl_writes_strict = -1\n", 312f461d2dcSChristoph Hellwig current->comm, table->procname); 313f461d2dcSChristoph Hellwig } 314f461d2dcSChristoph Hellwig 315f461d2dcSChristoph Hellwig /** 316f461d2dcSChristoph Hellwig * proc_first_pos_non_zero_ignore - check if first position is allowed 317f461d2dcSChristoph Hellwig * @ppos: file position 318f461d2dcSChristoph Hellwig * @table: the sysctl table 319f461d2dcSChristoph Hellwig * 320f461d2dcSChristoph Hellwig * Returns true if the first position is non-zero and the sysctl_writes_strict 321f461d2dcSChristoph Hellwig * mode indicates this is not allowed for numeric input types. String proc 322f461d2dcSChristoph Hellwig * handlers can ignore the return value. 323f461d2dcSChristoph Hellwig */ 324f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 325f461d2dcSChristoph Hellwig struct ctl_table *table) 326f461d2dcSChristoph Hellwig { 327f461d2dcSChristoph Hellwig if (!*ppos) 328f461d2dcSChristoph Hellwig return false; 329f461d2dcSChristoph Hellwig 330f461d2dcSChristoph Hellwig switch (sysctl_writes_strict) { 331f461d2dcSChristoph Hellwig case SYSCTL_WRITES_STRICT: 332f461d2dcSChristoph Hellwig return true; 333f461d2dcSChristoph Hellwig case SYSCTL_WRITES_WARN: 334f461d2dcSChristoph Hellwig warn_sysctl_write(table); 335f461d2dcSChristoph Hellwig return false; 336f461d2dcSChristoph Hellwig default: 337f461d2dcSChristoph Hellwig return false; 338f461d2dcSChristoph Hellwig } 339f461d2dcSChristoph Hellwig } 340f461d2dcSChristoph Hellwig 341f461d2dcSChristoph Hellwig /** 342f461d2dcSChristoph Hellwig * proc_dostring - read a string sysctl 343f461d2dcSChristoph Hellwig * @table: the sysctl table 344f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 345f461d2dcSChristoph Hellwig * @buffer: the user buffer 346f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 347f461d2dcSChristoph Hellwig * @ppos: file position 348f461d2dcSChristoph Hellwig * 349f461d2dcSChristoph Hellwig * Reads/writes a string from/to the user buffer. If the kernel 350f461d2dcSChristoph Hellwig * buffer provided is not large enough to hold the string, the 351f461d2dcSChristoph Hellwig * string is truncated. The copied string is %NULL-terminated. 352f461d2dcSChristoph Hellwig * If the string is being read by the user process, it is copied 353f461d2dcSChristoph Hellwig * and a newline '\n' is added. It is truncated if the buffer is 354f461d2dcSChristoph Hellwig * not large enough. 355f461d2dcSChristoph Hellwig * 356f461d2dcSChristoph Hellwig * Returns 0 on success. 357f461d2dcSChristoph Hellwig */ 358f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 35932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 360f461d2dcSChristoph Hellwig { 361f461d2dcSChristoph Hellwig if (write) 362f461d2dcSChristoph Hellwig proc_first_pos_non_zero_ignore(ppos, table); 363f461d2dcSChristoph Hellwig 36432927393SChristoph Hellwig return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 36532927393SChristoph Hellwig ppos); 366f461d2dcSChristoph Hellwig } 367f461d2dcSChristoph Hellwig 368f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf) 369f461d2dcSChristoph Hellwig { 370f461d2dcSChristoph Hellwig size_t ret; 371f461d2dcSChristoph Hellwig char *tmp = skip_spaces(*buf); 372f461d2dcSChristoph Hellwig ret = tmp - *buf; 373f461d2dcSChristoph Hellwig *buf = tmp; 374f461d2dcSChristoph Hellwig return ret; 375f461d2dcSChristoph Hellwig } 376f461d2dcSChristoph Hellwig 377f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v) 378f461d2dcSChristoph Hellwig { 379f461d2dcSChristoph Hellwig while (*size) { 380f461d2dcSChristoph Hellwig if (**buf != v) 381f461d2dcSChristoph Hellwig break; 382f461d2dcSChristoph Hellwig (*size)--; 383f461d2dcSChristoph Hellwig (*buf)++; 384f461d2dcSChristoph Hellwig } 385f461d2dcSChristoph Hellwig } 386f461d2dcSChristoph Hellwig 387f461d2dcSChristoph Hellwig /** 388f461d2dcSChristoph Hellwig * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 389f461d2dcSChristoph Hellwig * fail on overflow 390f461d2dcSChristoph Hellwig * 391f461d2dcSChristoph Hellwig * @cp: kernel buffer containing the string to parse 392f461d2dcSChristoph Hellwig * @endp: pointer to store the trailing characters 393f461d2dcSChristoph Hellwig * @base: the base to use 394f461d2dcSChristoph Hellwig * @res: where the parsed integer will be stored 395f461d2dcSChristoph Hellwig * 396f461d2dcSChristoph Hellwig * In case of success 0 is returned and @res will contain the parsed integer, 397f461d2dcSChristoph Hellwig * @endp will hold any trailing characters. 398f461d2dcSChristoph Hellwig * This function will fail the parse on overflow. If there wasn't an overflow 399f461d2dcSChristoph Hellwig * the function will defer the decision what characters count as invalid to the 400f461d2dcSChristoph Hellwig * caller. 401f461d2dcSChristoph Hellwig */ 402f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 403f461d2dcSChristoph Hellwig unsigned long *res) 404f461d2dcSChristoph Hellwig { 405f461d2dcSChristoph Hellwig unsigned long long result; 406f461d2dcSChristoph Hellwig unsigned int rv; 407f461d2dcSChristoph Hellwig 408f461d2dcSChristoph Hellwig cp = _parse_integer_fixup_radix(cp, &base); 409f461d2dcSChristoph Hellwig rv = _parse_integer(cp, base, &result); 410f461d2dcSChristoph Hellwig if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 411f461d2dcSChristoph Hellwig return -ERANGE; 412f461d2dcSChristoph Hellwig 413f461d2dcSChristoph Hellwig cp += rv; 414f461d2dcSChristoph Hellwig 415f461d2dcSChristoph Hellwig if (endp) 416f461d2dcSChristoph Hellwig *endp = (char *)cp; 417f461d2dcSChristoph Hellwig 418f461d2dcSChristoph Hellwig *res = (unsigned long)result; 419f461d2dcSChristoph Hellwig return 0; 420f461d2dcSChristoph Hellwig } 421f461d2dcSChristoph Hellwig 422f461d2dcSChristoph Hellwig #define TMPBUFLEN 22 423f461d2dcSChristoph Hellwig /** 424f461d2dcSChristoph Hellwig * proc_get_long - reads an ASCII formatted integer from a user buffer 425f461d2dcSChristoph Hellwig * 426f461d2dcSChristoph Hellwig * @buf: a kernel buffer 427f461d2dcSChristoph Hellwig * @size: size of the kernel buffer 428f461d2dcSChristoph Hellwig * @val: this is where the number will be stored 429f461d2dcSChristoph Hellwig * @neg: set to %TRUE if number is negative 430f461d2dcSChristoph Hellwig * @perm_tr: a vector which contains the allowed trailers 431f461d2dcSChristoph Hellwig * @perm_tr_len: size of the perm_tr vector 432f461d2dcSChristoph Hellwig * @tr: pointer to store the trailer character 433f461d2dcSChristoph Hellwig * 434f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 435f461d2dcSChristoph Hellwig * the amount of bytes read. If @tr is non-NULL and a trailing 436f461d2dcSChristoph Hellwig * character exists (size is non-zero after returning from this 437f461d2dcSChristoph Hellwig * function), @tr is updated with the trailing character. 438f461d2dcSChristoph Hellwig */ 439f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size, 440f461d2dcSChristoph Hellwig unsigned long *val, bool *neg, 441f461d2dcSChristoph Hellwig const char *perm_tr, unsigned perm_tr_len, char *tr) 442f461d2dcSChristoph Hellwig { 443f461d2dcSChristoph Hellwig int len; 444f461d2dcSChristoph Hellwig char *p, tmp[TMPBUFLEN]; 445f461d2dcSChristoph Hellwig 446f461d2dcSChristoph Hellwig if (!*size) 447f461d2dcSChristoph Hellwig return -EINVAL; 448f461d2dcSChristoph Hellwig 449f461d2dcSChristoph Hellwig len = *size; 450f461d2dcSChristoph Hellwig if (len > TMPBUFLEN - 1) 451f461d2dcSChristoph Hellwig len = TMPBUFLEN - 1; 452f461d2dcSChristoph Hellwig 453f461d2dcSChristoph Hellwig memcpy(tmp, *buf, len); 454f461d2dcSChristoph Hellwig 455f461d2dcSChristoph Hellwig tmp[len] = 0; 456f461d2dcSChristoph Hellwig p = tmp; 457f461d2dcSChristoph Hellwig if (*p == '-' && *size > 1) { 458f461d2dcSChristoph Hellwig *neg = true; 459f461d2dcSChristoph Hellwig p++; 460f461d2dcSChristoph Hellwig } else 461f461d2dcSChristoph Hellwig *neg = false; 462f461d2dcSChristoph Hellwig if (!isdigit(*p)) 463f461d2dcSChristoph Hellwig return -EINVAL; 464f461d2dcSChristoph Hellwig 465f461d2dcSChristoph Hellwig if (strtoul_lenient(p, &p, 0, val)) 466f461d2dcSChristoph Hellwig return -EINVAL; 467f461d2dcSChristoph Hellwig 468f461d2dcSChristoph Hellwig len = p - tmp; 469f461d2dcSChristoph Hellwig 470f461d2dcSChristoph Hellwig /* We don't know if the next char is whitespace thus we may accept 471f461d2dcSChristoph Hellwig * invalid integers (e.g. 1234...a) or two integers instead of one 472f461d2dcSChristoph Hellwig * (e.g. 123...1). So lets not allow such large numbers. */ 473f461d2dcSChristoph Hellwig if (len == TMPBUFLEN - 1) 474f461d2dcSChristoph Hellwig return -EINVAL; 475f461d2dcSChristoph Hellwig 476f461d2dcSChristoph Hellwig if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 477f461d2dcSChristoph Hellwig return -EINVAL; 478f461d2dcSChristoph Hellwig 479f461d2dcSChristoph Hellwig if (tr && (len < *size)) 480f461d2dcSChristoph Hellwig *tr = *p; 481f461d2dcSChristoph Hellwig 482f461d2dcSChristoph Hellwig *buf += len; 483f461d2dcSChristoph Hellwig *size -= len; 484f461d2dcSChristoph Hellwig 485f461d2dcSChristoph Hellwig return 0; 486f461d2dcSChristoph Hellwig } 487f461d2dcSChristoph Hellwig 488f461d2dcSChristoph Hellwig /** 489f461d2dcSChristoph Hellwig * proc_put_long - converts an integer to a decimal ASCII formatted string 490f461d2dcSChristoph Hellwig * 491f461d2dcSChristoph Hellwig * @buf: the user buffer 492f461d2dcSChristoph Hellwig * @size: the size of the user buffer 493f461d2dcSChristoph Hellwig * @val: the integer to be converted 494f461d2dcSChristoph Hellwig * @neg: sign of the number, %TRUE for negative 495f461d2dcSChristoph Hellwig * 49632927393SChristoph Hellwig * In case of success @buf and @size are updated with the amount of bytes 49732927393SChristoph Hellwig * written. 498f461d2dcSChristoph Hellwig */ 49932927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 500f461d2dcSChristoph Hellwig { 501f461d2dcSChristoph Hellwig int len; 502f461d2dcSChristoph Hellwig char tmp[TMPBUFLEN], *p = tmp; 503f461d2dcSChristoph Hellwig 504f461d2dcSChristoph Hellwig sprintf(p, "%s%lu", neg ? "-" : "", val); 505f461d2dcSChristoph Hellwig len = strlen(tmp); 506f461d2dcSChristoph Hellwig if (len > *size) 507f461d2dcSChristoph Hellwig len = *size; 50832927393SChristoph Hellwig memcpy(*buf, tmp, len); 509f461d2dcSChristoph Hellwig *size -= len; 510f461d2dcSChristoph Hellwig *buf += len; 511f461d2dcSChristoph Hellwig } 512f461d2dcSChristoph Hellwig #undef TMPBUFLEN 513f461d2dcSChristoph Hellwig 51432927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c) 515f461d2dcSChristoph Hellwig { 516f461d2dcSChristoph Hellwig if (*size) { 51732927393SChristoph Hellwig char **buffer = (char **)buf; 51832927393SChristoph Hellwig **buffer = c; 51932927393SChristoph Hellwig 52032927393SChristoph Hellwig (*size)--; 52132927393SChristoph Hellwig (*buffer)++; 522f461d2dcSChristoph Hellwig *buf = *buffer; 523f461d2dcSChristoph Hellwig } 524f461d2dcSChristoph Hellwig } 525f461d2dcSChristoph Hellwig 526f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 527f461d2dcSChristoph Hellwig int *valp, 528f461d2dcSChristoph Hellwig int write, void *data) 529f461d2dcSChristoph Hellwig { 530f461d2dcSChristoph Hellwig if (write) { 531f461d2dcSChristoph Hellwig if (*negp) { 532f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX + 1) 533f461d2dcSChristoph Hellwig return -EINVAL; 534f461d2dcSChristoph Hellwig *valp = -*lvalp; 535f461d2dcSChristoph Hellwig } else { 536f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX) 537f461d2dcSChristoph Hellwig return -EINVAL; 538f461d2dcSChristoph Hellwig *valp = *lvalp; 539f461d2dcSChristoph Hellwig } 540f461d2dcSChristoph Hellwig } else { 541f461d2dcSChristoph Hellwig int val = *valp; 542f461d2dcSChristoph Hellwig if (val < 0) { 543f461d2dcSChristoph Hellwig *negp = true; 544f461d2dcSChristoph Hellwig *lvalp = -(unsigned long)val; 545f461d2dcSChristoph Hellwig } else { 546f461d2dcSChristoph Hellwig *negp = false; 547f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 548f461d2dcSChristoph Hellwig } 549f461d2dcSChristoph Hellwig } 550f461d2dcSChristoph Hellwig return 0; 551f461d2dcSChristoph Hellwig } 552f461d2dcSChristoph Hellwig 553f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp, 554f461d2dcSChristoph Hellwig unsigned int *valp, 555f461d2dcSChristoph Hellwig int write, void *data) 556f461d2dcSChristoph Hellwig { 557f461d2dcSChristoph Hellwig if (write) { 558f461d2dcSChristoph Hellwig if (*lvalp > UINT_MAX) 559f461d2dcSChristoph Hellwig return -EINVAL; 560f461d2dcSChristoph Hellwig *valp = *lvalp; 561f461d2dcSChristoph Hellwig } else { 562f461d2dcSChristoph Hellwig unsigned int val = *valp; 563f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 564f461d2dcSChristoph Hellwig } 565f461d2dcSChristoph Hellwig return 0; 566f461d2dcSChristoph Hellwig } 567f461d2dcSChristoph Hellwig 568f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 569f461d2dcSChristoph Hellwig 570f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 57132927393SChristoph Hellwig int write, void *buffer, 572f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 573f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 574f461d2dcSChristoph Hellwig int write, void *data), 575f461d2dcSChristoph Hellwig void *data) 576f461d2dcSChristoph Hellwig { 577f461d2dcSChristoph Hellwig int *i, vleft, first = 1, err = 0; 578f461d2dcSChristoph Hellwig size_t left; 57932927393SChristoph Hellwig char *p; 580f461d2dcSChristoph Hellwig 581f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 582f461d2dcSChristoph Hellwig *lenp = 0; 583f461d2dcSChristoph Hellwig return 0; 584f461d2dcSChristoph Hellwig } 585f461d2dcSChristoph Hellwig 586f461d2dcSChristoph Hellwig i = (int *) tbl_data; 587f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 588f461d2dcSChristoph Hellwig left = *lenp; 589f461d2dcSChristoph Hellwig 590f461d2dcSChristoph Hellwig if (!conv) 591f461d2dcSChristoph Hellwig conv = do_proc_dointvec_conv; 592f461d2dcSChristoph Hellwig 593f461d2dcSChristoph Hellwig if (write) { 594f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 595f461d2dcSChristoph Hellwig goto out; 596f461d2dcSChristoph Hellwig 597f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 598f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 59932927393SChristoph Hellwig p = buffer; 600f461d2dcSChristoph Hellwig } 601f461d2dcSChristoph Hellwig 602f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first=0) { 603f461d2dcSChristoph Hellwig unsigned long lval; 604f461d2dcSChristoph Hellwig bool neg; 605f461d2dcSChristoph Hellwig 606f461d2dcSChristoph Hellwig if (write) { 607f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 608f461d2dcSChristoph Hellwig 609f461d2dcSChristoph Hellwig if (!left) 610f461d2dcSChristoph Hellwig break; 611f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 612f461d2dcSChristoph Hellwig proc_wspace_sep, 613f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 614f461d2dcSChristoph Hellwig if (err) 615f461d2dcSChristoph Hellwig break; 616f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 1, data)) { 617f461d2dcSChristoph Hellwig err = -EINVAL; 618f461d2dcSChristoph Hellwig break; 619f461d2dcSChristoph Hellwig } 620f461d2dcSChristoph Hellwig } else { 621f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 0, data)) { 622f461d2dcSChristoph Hellwig err = -EINVAL; 623f461d2dcSChristoph Hellwig break; 624f461d2dcSChristoph Hellwig } 625f461d2dcSChristoph Hellwig if (!first) 62632927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 62732927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, neg); 628f461d2dcSChristoph Hellwig } 629f461d2dcSChristoph Hellwig } 630f461d2dcSChristoph Hellwig 631f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 63232927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 633f461d2dcSChristoph Hellwig if (write && !err && left) 634f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 63532927393SChristoph Hellwig if (write && first) 636f461d2dcSChristoph Hellwig return err ? : -EINVAL; 637f461d2dcSChristoph Hellwig *lenp -= left; 638f461d2dcSChristoph Hellwig out: 639f461d2dcSChristoph Hellwig *ppos += *lenp; 640f461d2dcSChristoph Hellwig return err; 641f461d2dcSChristoph Hellwig } 642f461d2dcSChristoph Hellwig 643f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write, 64432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 645f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 646f461d2dcSChristoph Hellwig int write, void *data), 647f461d2dcSChristoph Hellwig void *data) 648f461d2dcSChristoph Hellwig { 649f461d2dcSChristoph Hellwig return __do_proc_dointvec(table->data, table, write, 650f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 651f461d2dcSChristoph Hellwig } 652f461d2dcSChristoph Hellwig 653f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data, 654f461d2dcSChristoph Hellwig struct ctl_table *table, 65532927393SChristoph Hellwig void *buffer, 656f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 657f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 658f461d2dcSChristoph Hellwig unsigned int *valp, 659f461d2dcSChristoph Hellwig int write, void *data), 660f461d2dcSChristoph Hellwig void *data) 661f461d2dcSChristoph Hellwig { 662f461d2dcSChristoph Hellwig unsigned long lval; 663f461d2dcSChristoph Hellwig int err = 0; 664f461d2dcSChristoph Hellwig size_t left; 665f461d2dcSChristoph Hellwig bool neg; 66632927393SChristoph Hellwig char *p = buffer; 667f461d2dcSChristoph Hellwig 668f461d2dcSChristoph Hellwig left = *lenp; 669f461d2dcSChristoph Hellwig 670f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 671f461d2dcSChristoph Hellwig goto bail_early; 672f461d2dcSChristoph Hellwig 673f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 674f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 675f461d2dcSChristoph Hellwig 676f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 677f461d2dcSChristoph Hellwig if (!left) { 678f461d2dcSChristoph Hellwig err = -EINVAL; 679f461d2dcSChristoph Hellwig goto out_free; 680f461d2dcSChristoph Hellwig } 681f461d2dcSChristoph Hellwig 682f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 683f461d2dcSChristoph Hellwig proc_wspace_sep, 684f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 685f461d2dcSChristoph Hellwig if (err || neg) { 686f461d2dcSChristoph Hellwig err = -EINVAL; 687f461d2dcSChristoph Hellwig goto out_free; 688f461d2dcSChristoph Hellwig } 689f461d2dcSChristoph Hellwig 690f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 1, data)) { 691f461d2dcSChristoph Hellwig err = -EINVAL; 692f461d2dcSChristoph Hellwig goto out_free; 693f461d2dcSChristoph Hellwig } 694f461d2dcSChristoph Hellwig 695f461d2dcSChristoph Hellwig if (!err && left) 696f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 697f461d2dcSChristoph Hellwig 698f461d2dcSChristoph Hellwig out_free: 699f461d2dcSChristoph Hellwig if (err) 700f461d2dcSChristoph Hellwig return -EINVAL; 701f461d2dcSChristoph Hellwig 702f461d2dcSChristoph Hellwig return 0; 703f461d2dcSChristoph Hellwig 704f461d2dcSChristoph Hellwig /* This is in keeping with old __do_proc_dointvec() */ 705f461d2dcSChristoph Hellwig bail_early: 706f461d2dcSChristoph Hellwig *ppos += *lenp; 707f461d2dcSChristoph Hellwig return err; 708f461d2dcSChristoph Hellwig } 709f461d2dcSChristoph Hellwig 71032927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 711f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 712f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 713f461d2dcSChristoph Hellwig unsigned int *valp, 714f461d2dcSChristoph Hellwig int write, void *data), 715f461d2dcSChristoph Hellwig void *data) 716f461d2dcSChristoph Hellwig { 717f461d2dcSChristoph Hellwig unsigned long lval; 718f461d2dcSChristoph Hellwig int err = 0; 719f461d2dcSChristoph Hellwig size_t left; 720f461d2dcSChristoph Hellwig 721f461d2dcSChristoph Hellwig left = *lenp; 722f461d2dcSChristoph Hellwig 723f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 0, data)) { 724f461d2dcSChristoph Hellwig err = -EINVAL; 725f461d2dcSChristoph Hellwig goto out; 726f461d2dcSChristoph Hellwig } 727f461d2dcSChristoph Hellwig 72832927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, false); 72932927393SChristoph Hellwig if (!left) 730f461d2dcSChristoph Hellwig goto out; 731f461d2dcSChristoph Hellwig 73232927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 733f461d2dcSChristoph Hellwig 734f461d2dcSChristoph Hellwig out: 735f461d2dcSChristoph Hellwig *lenp -= left; 736f461d2dcSChristoph Hellwig *ppos += *lenp; 737f461d2dcSChristoph Hellwig 738f461d2dcSChristoph Hellwig return err; 739f461d2dcSChristoph Hellwig } 740f461d2dcSChristoph Hellwig 741f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 74232927393SChristoph Hellwig int write, void *buffer, 743f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 744f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 745f461d2dcSChristoph Hellwig unsigned int *valp, 746f461d2dcSChristoph Hellwig int write, void *data), 747f461d2dcSChristoph Hellwig void *data) 748f461d2dcSChristoph Hellwig { 749f461d2dcSChristoph Hellwig unsigned int *i, vleft; 750f461d2dcSChristoph Hellwig 751f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 752f461d2dcSChristoph Hellwig *lenp = 0; 753f461d2dcSChristoph Hellwig return 0; 754f461d2dcSChristoph Hellwig } 755f461d2dcSChristoph Hellwig 756f461d2dcSChristoph Hellwig i = (unsigned int *) tbl_data; 757f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 758f461d2dcSChristoph Hellwig 759f461d2dcSChristoph Hellwig /* 760f461d2dcSChristoph Hellwig * Arrays are not supported, keep this simple. *Do not* add 761f461d2dcSChristoph Hellwig * support for them. 762f461d2dcSChristoph Hellwig */ 763f461d2dcSChristoph Hellwig if (vleft != 1) { 764f461d2dcSChristoph Hellwig *lenp = 0; 765f461d2dcSChristoph Hellwig return -EINVAL; 766f461d2dcSChristoph Hellwig } 767f461d2dcSChristoph Hellwig 768f461d2dcSChristoph Hellwig if (!conv) 769f461d2dcSChristoph Hellwig conv = do_proc_douintvec_conv; 770f461d2dcSChristoph Hellwig 771f461d2dcSChristoph Hellwig if (write) 772f461d2dcSChristoph Hellwig return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 773f461d2dcSChristoph Hellwig conv, data); 774f461d2dcSChristoph Hellwig return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 775f461d2dcSChristoph Hellwig } 776f461d2dcSChristoph Hellwig 777f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write, 77832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 779f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 780f461d2dcSChristoph Hellwig unsigned int *valp, 781f461d2dcSChristoph Hellwig int write, void *data), 782f461d2dcSChristoph Hellwig void *data) 783f461d2dcSChristoph Hellwig { 784f461d2dcSChristoph Hellwig return __do_proc_douintvec(table->data, table, write, 785f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 786f461d2dcSChristoph Hellwig } 787f461d2dcSChristoph Hellwig 788f461d2dcSChristoph Hellwig /** 789f461d2dcSChristoph Hellwig * proc_dointvec - read a vector of integers 790f461d2dcSChristoph Hellwig * @table: the sysctl table 791f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 792f461d2dcSChristoph Hellwig * @buffer: the user buffer 793f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 794f461d2dcSChristoph Hellwig * @ppos: file position 795f461d2dcSChristoph Hellwig * 796f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 797f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 798f461d2dcSChristoph Hellwig * 799f461d2dcSChristoph Hellwig * Returns 0 on success. 800f461d2dcSChristoph Hellwig */ 80132927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer, 80232927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 803f461d2dcSChristoph Hellwig { 804f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 805f461d2dcSChristoph Hellwig } 806f461d2dcSChristoph Hellwig 807f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION 808f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 80932927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos) 810f461d2dcSChristoph Hellwig { 811f461d2dcSChristoph Hellwig int ret, old; 812f461d2dcSChristoph Hellwig 813f461d2dcSChristoph Hellwig if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 814f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 815f461d2dcSChristoph Hellwig 816f461d2dcSChristoph Hellwig old = *(int *)table->data; 817f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 818f461d2dcSChristoph Hellwig if (ret) 819f461d2dcSChristoph Hellwig return ret; 820f461d2dcSChristoph Hellwig if (old != *(int *)table->data) 821f461d2dcSChristoph Hellwig pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 822f461d2dcSChristoph Hellwig table->procname, current->comm, 823f461d2dcSChristoph Hellwig task_pid_nr(current)); 824f461d2dcSChristoph Hellwig return ret; 825f461d2dcSChristoph Hellwig } 826f461d2dcSChristoph Hellwig #endif 827f461d2dcSChristoph Hellwig 828f461d2dcSChristoph Hellwig /** 829f461d2dcSChristoph Hellwig * proc_douintvec - read a vector of unsigned integers 830f461d2dcSChristoph Hellwig * @table: the sysctl table 831f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 832f461d2dcSChristoph Hellwig * @buffer: the user buffer 833f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 834f461d2dcSChristoph Hellwig * @ppos: file position 835f461d2dcSChristoph Hellwig * 836f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 837f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 838f461d2dcSChristoph Hellwig * 839f461d2dcSChristoph Hellwig * Returns 0 on success. 840f461d2dcSChristoph Hellwig */ 84132927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer, 84232927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 843f461d2dcSChristoph Hellwig { 844f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 845f461d2dcSChristoph Hellwig do_proc_douintvec_conv, NULL); 846f461d2dcSChristoph Hellwig } 847f461d2dcSChristoph Hellwig 848f461d2dcSChristoph Hellwig /* 849f461d2dcSChristoph Hellwig * Taint values can only be increased 850f461d2dcSChristoph Hellwig * This means we can safely use a temporary. 851f461d2dcSChristoph Hellwig */ 852f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write, 85332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 854f461d2dcSChristoph Hellwig { 855f461d2dcSChristoph Hellwig struct ctl_table t; 856f461d2dcSChristoph Hellwig unsigned long tmptaint = get_taint(); 857f461d2dcSChristoph Hellwig int err; 858f461d2dcSChristoph Hellwig 859f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 860f461d2dcSChristoph Hellwig return -EPERM; 861f461d2dcSChristoph Hellwig 862f461d2dcSChristoph Hellwig t = *table; 863f461d2dcSChristoph Hellwig t.data = &tmptaint; 864f461d2dcSChristoph Hellwig err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 865f461d2dcSChristoph Hellwig if (err < 0) 866f461d2dcSChristoph Hellwig return err; 867f461d2dcSChristoph Hellwig 868f461d2dcSChristoph Hellwig if (write) { 869db38d5c1SRafael Aquini int i; 870db38d5c1SRafael Aquini 871db38d5c1SRafael Aquini /* 872db38d5c1SRafael Aquini * If we are relying on panic_on_taint not producing 873db38d5c1SRafael Aquini * false positives due to userspace input, bail out 874db38d5c1SRafael Aquini * before setting the requested taint flags. 875db38d5c1SRafael Aquini */ 876db38d5c1SRafael Aquini if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint)) 877db38d5c1SRafael Aquini return -EINVAL; 878db38d5c1SRafael Aquini 879f461d2dcSChristoph Hellwig /* 880f461d2dcSChristoph Hellwig * Poor man's atomic or. Not worth adding a primitive 881f461d2dcSChristoph Hellwig * to everyone's atomic.h for this 882f461d2dcSChristoph Hellwig */ 883*e77132e7SRafael Aquini for (i = 0; i < TAINT_FLAGS_COUNT; i++) 884*e77132e7SRafael Aquini if ((1UL << i) & tmptaint) 885f461d2dcSChristoph Hellwig add_taint(i, LOCKDEP_STILL_OK); 886f461d2dcSChristoph Hellwig } 887f461d2dcSChristoph Hellwig 888f461d2dcSChristoph Hellwig return err; 889f461d2dcSChristoph Hellwig } 890f461d2dcSChristoph Hellwig 891f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK 892f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 89332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 894f461d2dcSChristoph Hellwig { 895f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 896f461d2dcSChristoph Hellwig return -EPERM; 897f461d2dcSChristoph Hellwig 898f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 899f461d2dcSChristoph Hellwig } 900f461d2dcSChristoph Hellwig #endif 901f461d2dcSChristoph Hellwig 902f461d2dcSChristoph Hellwig /** 903f461d2dcSChristoph Hellwig * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 904f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 905f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 906f461d2dcSChristoph Hellwig * 907f461d2dcSChristoph Hellwig * The do_proc_dointvec_minmax_conv_param structure provides the 908f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 909f461d2dcSChristoph Hellwig * parameters that use the proc_dointvec_minmax() handler. 910f461d2dcSChristoph Hellwig */ 911f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param { 912f461d2dcSChristoph Hellwig int *min; 913f461d2dcSChristoph Hellwig int *max; 914f461d2dcSChristoph Hellwig }; 915f461d2dcSChristoph Hellwig 916f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 917f461d2dcSChristoph Hellwig int *valp, 918f461d2dcSChristoph Hellwig int write, void *data) 919f461d2dcSChristoph Hellwig { 920f461d2dcSChristoph Hellwig int tmp, ret; 921f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param *param = data; 922f461d2dcSChristoph Hellwig /* 923f461d2dcSChristoph Hellwig * If writing, first do so via a temporary local int so we can 924f461d2dcSChristoph Hellwig * bounds-check it before touching *valp. 925f461d2dcSChristoph Hellwig */ 926f461d2dcSChristoph Hellwig int *ip = write ? &tmp : valp; 927f461d2dcSChristoph Hellwig 928f461d2dcSChristoph Hellwig ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 929f461d2dcSChristoph Hellwig if (ret) 930f461d2dcSChristoph Hellwig return ret; 931f461d2dcSChristoph Hellwig 932f461d2dcSChristoph Hellwig if (write) { 933f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 934f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 935f461d2dcSChristoph Hellwig return -EINVAL; 936f461d2dcSChristoph Hellwig *valp = tmp; 937f461d2dcSChristoph Hellwig } 938f461d2dcSChristoph Hellwig 939f461d2dcSChristoph Hellwig return 0; 940f461d2dcSChristoph Hellwig } 941f461d2dcSChristoph Hellwig 942f461d2dcSChristoph Hellwig /** 943f461d2dcSChristoph Hellwig * proc_dointvec_minmax - read a vector of integers with min/max values 944f461d2dcSChristoph Hellwig * @table: the sysctl table 945f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 946f461d2dcSChristoph Hellwig * @buffer: the user buffer 947f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 948f461d2dcSChristoph Hellwig * @ppos: file position 949f461d2dcSChristoph Hellwig * 950f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 951f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 952f461d2dcSChristoph Hellwig * 953f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 954f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 955f461d2dcSChristoph Hellwig * 956f461d2dcSChristoph Hellwig * Returns 0 on success or -EINVAL on write when the range check fails. 957f461d2dcSChristoph Hellwig */ 958f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 95932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 960f461d2dcSChristoph Hellwig { 961f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param param = { 962f461d2dcSChristoph Hellwig .min = (int *) table->extra1, 963f461d2dcSChristoph Hellwig .max = (int *) table->extra2, 964f461d2dcSChristoph Hellwig }; 965f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 966f461d2dcSChristoph Hellwig do_proc_dointvec_minmax_conv, ¶m); 967f461d2dcSChristoph Hellwig } 968f461d2dcSChristoph Hellwig 969f461d2dcSChristoph Hellwig /** 970f461d2dcSChristoph Hellwig * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 971f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 972f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 973f461d2dcSChristoph Hellwig * 974f461d2dcSChristoph Hellwig * The do_proc_douintvec_minmax_conv_param structure provides the 975f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 976f461d2dcSChristoph Hellwig * parameters that use the proc_douintvec_minmax() handler. 977f461d2dcSChristoph Hellwig */ 978f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param { 979f461d2dcSChristoph Hellwig unsigned int *min; 980f461d2dcSChristoph Hellwig unsigned int *max; 981f461d2dcSChristoph Hellwig }; 982f461d2dcSChristoph Hellwig 983f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 984f461d2dcSChristoph Hellwig unsigned int *valp, 985f461d2dcSChristoph Hellwig int write, void *data) 986f461d2dcSChristoph Hellwig { 987f461d2dcSChristoph Hellwig int ret; 988f461d2dcSChristoph Hellwig unsigned int tmp; 989f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param *param = data; 990f461d2dcSChristoph Hellwig /* write via temporary local uint for bounds-checking */ 991f461d2dcSChristoph Hellwig unsigned int *up = write ? &tmp : valp; 992f461d2dcSChristoph Hellwig 993f461d2dcSChristoph Hellwig ret = do_proc_douintvec_conv(lvalp, up, write, data); 994f461d2dcSChristoph Hellwig if (ret) 995f461d2dcSChristoph Hellwig return ret; 996f461d2dcSChristoph Hellwig 997f461d2dcSChristoph Hellwig if (write) { 998f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 999f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 1000f461d2dcSChristoph Hellwig return -ERANGE; 1001f461d2dcSChristoph Hellwig 1002f461d2dcSChristoph Hellwig *valp = tmp; 1003f461d2dcSChristoph Hellwig } 1004f461d2dcSChristoph Hellwig 1005f461d2dcSChristoph Hellwig return 0; 1006f461d2dcSChristoph Hellwig } 1007f461d2dcSChristoph Hellwig 1008f461d2dcSChristoph Hellwig /** 1009f461d2dcSChristoph Hellwig * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 1010f461d2dcSChristoph Hellwig * @table: the sysctl table 1011f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1012f461d2dcSChristoph Hellwig * @buffer: the user buffer 1013f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1014f461d2dcSChristoph Hellwig * @ppos: file position 1015f461d2dcSChristoph Hellwig * 1016f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 1017f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. Negative 1018f461d2dcSChristoph Hellwig * strings are not allowed. 1019f461d2dcSChristoph Hellwig * 1020f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1021f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). There is a final sanity 1022f461d2dcSChristoph Hellwig * check for UINT_MAX to avoid having to support wrap around uses from 1023f461d2dcSChristoph Hellwig * userspace. 1024f461d2dcSChristoph Hellwig * 1025f461d2dcSChristoph Hellwig * Returns 0 on success or -ERANGE on write when the range check fails. 1026f461d2dcSChristoph Hellwig */ 1027f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 102832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1029f461d2dcSChristoph Hellwig { 1030f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param param = { 1031f461d2dcSChristoph Hellwig .min = (unsigned int *) table->extra1, 1032f461d2dcSChristoph Hellwig .max = (unsigned int *) table->extra2, 1033f461d2dcSChristoph Hellwig }; 1034f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1035f461d2dcSChristoph Hellwig do_proc_douintvec_minmax_conv, ¶m); 1036f461d2dcSChristoph Hellwig } 1037f461d2dcSChristoph Hellwig 1038f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 1039f461d2dcSChristoph Hellwig unsigned int *valp, 1040f461d2dcSChristoph Hellwig int write, void *data) 1041f461d2dcSChristoph Hellwig { 1042f461d2dcSChristoph Hellwig if (write) { 1043f461d2dcSChristoph Hellwig unsigned int val; 1044f461d2dcSChristoph Hellwig 1045f461d2dcSChristoph Hellwig val = round_pipe_size(*lvalp); 1046f461d2dcSChristoph Hellwig if (val == 0) 1047f461d2dcSChristoph Hellwig return -EINVAL; 1048f461d2dcSChristoph Hellwig 1049f461d2dcSChristoph Hellwig *valp = val; 1050f461d2dcSChristoph Hellwig } else { 1051f461d2dcSChristoph Hellwig unsigned int val = *valp; 1052f461d2dcSChristoph Hellwig *lvalp = (unsigned long) val; 1053f461d2dcSChristoph Hellwig } 1054f461d2dcSChristoph Hellwig 1055f461d2dcSChristoph Hellwig return 0; 1056f461d2dcSChristoph Hellwig } 1057f461d2dcSChristoph Hellwig 1058f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write, 105932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1060f461d2dcSChristoph Hellwig { 1061f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1062f461d2dcSChristoph Hellwig do_proc_dopipe_max_size_conv, NULL); 1063f461d2dcSChristoph Hellwig } 1064f461d2dcSChristoph Hellwig 1065f461d2dcSChristoph Hellwig static void validate_coredump_safety(void) 1066f461d2dcSChristoph Hellwig { 1067f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1068f461d2dcSChristoph Hellwig if (suid_dumpable == SUID_DUMP_ROOT && 1069f461d2dcSChristoph Hellwig core_pattern[0] != '/' && core_pattern[0] != '|') { 1070f461d2dcSChristoph Hellwig printk(KERN_WARNING 1071f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n" 1072f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n" 1073f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n" 1074f461d2dcSChristoph Hellwig ); 1075f461d2dcSChristoph Hellwig } 1076f461d2dcSChristoph Hellwig #endif 1077f461d2dcSChristoph Hellwig } 1078f461d2dcSChristoph Hellwig 1079f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 108032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1081f461d2dcSChristoph Hellwig { 1082f461d2dcSChristoph Hellwig int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1083f461d2dcSChristoph Hellwig if (!error) 1084f461d2dcSChristoph Hellwig validate_coredump_safety(); 1085f461d2dcSChristoph Hellwig return error; 1086f461d2dcSChristoph Hellwig } 1087f461d2dcSChristoph Hellwig 1088f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1089f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write, 109032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1091f461d2dcSChristoph Hellwig { 1092f461d2dcSChristoph Hellwig int error = proc_dostring(table, write, buffer, lenp, ppos); 1093f461d2dcSChristoph Hellwig if (!error) 1094f461d2dcSChristoph Hellwig validate_coredump_safety(); 1095f461d2dcSChristoph Hellwig return error; 1096f461d2dcSChristoph Hellwig } 1097f461d2dcSChristoph Hellwig #endif 1098f461d2dcSChristoph Hellwig 1099f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ 1100f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write, 110132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1102f461d2dcSChristoph Hellwig { 1103f461d2dcSChristoph Hellwig int tmp, ret; 1104f461d2dcSChristoph Hellwig 1105f461d2dcSChristoph Hellwig tmp = sysrq_mask(); 1106f461d2dcSChristoph Hellwig 1107f461d2dcSChristoph Hellwig ret = __do_proc_dointvec(&tmp, table, write, buffer, 1108f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1109f461d2dcSChristoph Hellwig if (ret || !write) 1110f461d2dcSChristoph Hellwig return ret; 1111f461d2dcSChristoph Hellwig 1112f461d2dcSChristoph Hellwig if (write) 1113f461d2dcSChristoph Hellwig sysrq_toggle_support(tmp); 1114f461d2dcSChristoph Hellwig 1115f461d2dcSChristoph Hellwig return 0; 1116f461d2dcSChristoph Hellwig } 1117f461d2dcSChristoph Hellwig #endif 1118f461d2dcSChristoph Hellwig 111932927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, 112032927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos, 112132927393SChristoph Hellwig unsigned long convmul, unsigned long convdiv) 1122f461d2dcSChristoph Hellwig { 1123f461d2dcSChristoph Hellwig unsigned long *i, *min, *max; 1124f461d2dcSChristoph Hellwig int vleft, first = 1, err = 0; 1125f461d2dcSChristoph Hellwig size_t left; 112632927393SChristoph Hellwig char *p; 1127f461d2dcSChristoph Hellwig 1128f461d2dcSChristoph Hellwig if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1129f461d2dcSChristoph Hellwig *lenp = 0; 1130f461d2dcSChristoph Hellwig return 0; 1131f461d2dcSChristoph Hellwig } 1132f461d2dcSChristoph Hellwig 1133f461d2dcSChristoph Hellwig i = (unsigned long *) data; 1134f461d2dcSChristoph Hellwig min = (unsigned long *) table->extra1; 1135f461d2dcSChristoph Hellwig max = (unsigned long *) table->extra2; 1136f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(unsigned long); 1137f461d2dcSChristoph Hellwig left = *lenp; 1138f461d2dcSChristoph Hellwig 1139f461d2dcSChristoph Hellwig if (write) { 1140f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 1141f461d2dcSChristoph Hellwig goto out; 1142f461d2dcSChristoph Hellwig 1143f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 1144f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 114532927393SChristoph Hellwig p = buffer; 1146f461d2dcSChristoph Hellwig } 1147f461d2dcSChristoph Hellwig 1148f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first = 0) { 1149f461d2dcSChristoph Hellwig unsigned long val; 1150f461d2dcSChristoph Hellwig 1151f461d2dcSChristoph Hellwig if (write) { 1152f461d2dcSChristoph Hellwig bool neg; 1153f461d2dcSChristoph Hellwig 1154f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1155f461d2dcSChristoph Hellwig if (!left) 1156f461d2dcSChristoph Hellwig break; 1157f461d2dcSChristoph Hellwig 1158f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val, &neg, 1159f461d2dcSChristoph Hellwig proc_wspace_sep, 1160f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 1161f461d2dcSChristoph Hellwig if (err) 1162f461d2dcSChristoph Hellwig break; 1163f461d2dcSChristoph Hellwig if (neg) 1164f461d2dcSChristoph Hellwig continue; 1165f461d2dcSChristoph Hellwig val = convmul * val / convdiv; 1166f461d2dcSChristoph Hellwig if ((min && val < *min) || (max && val > *max)) { 1167f461d2dcSChristoph Hellwig err = -EINVAL; 1168f461d2dcSChristoph Hellwig break; 1169f461d2dcSChristoph Hellwig } 1170f461d2dcSChristoph Hellwig *i = val; 1171f461d2dcSChristoph Hellwig } else { 1172f461d2dcSChristoph Hellwig val = convdiv * (*i) / convmul; 117332927393SChristoph Hellwig if (!first) 117432927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 117532927393SChristoph Hellwig proc_put_long(&buffer, &left, val, false); 1176f461d2dcSChristoph Hellwig } 1177f461d2dcSChristoph Hellwig } 1178f461d2dcSChristoph Hellwig 1179f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 118032927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1181f461d2dcSChristoph Hellwig if (write && !err) 1182f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 118332927393SChristoph Hellwig if (write && first) 1184f461d2dcSChristoph Hellwig return err ? : -EINVAL; 1185f461d2dcSChristoph Hellwig *lenp -= left; 1186f461d2dcSChristoph Hellwig out: 1187f461d2dcSChristoph Hellwig *ppos += *lenp; 1188f461d2dcSChristoph Hellwig return err; 1189f461d2dcSChristoph Hellwig } 1190f461d2dcSChristoph Hellwig 1191f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 119232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1193f461d2dcSChristoph Hellwig unsigned long convdiv) 1194f461d2dcSChristoph Hellwig { 1195f461d2dcSChristoph Hellwig return __do_proc_doulongvec_minmax(table->data, table, write, 1196f461d2dcSChristoph Hellwig buffer, lenp, ppos, convmul, convdiv); 1197f461d2dcSChristoph Hellwig } 1198f461d2dcSChristoph Hellwig 1199f461d2dcSChristoph Hellwig /** 1200f461d2dcSChristoph Hellwig * proc_doulongvec_minmax - read a vector of long integers with min/max values 1201f461d2dcSChristoph Hellwig * @table: the sysctl table 1202f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1203f461d2dcSChristoph Hellwig * @buffer: the user buffer 1204f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1205f461d2dcSChristoph Hellwig * @ppos: file position 1206f461d2dcSChristoph Hellwig * 1207f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1208f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1209f461d2dcSChristoph Hellwig * 1210f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1211f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1212f461d2dcSChristoph Hellwig * 1213f461d2dcSChristoph Hellwig * Returns 0 on success. 1214f461d2dcSChristoph Hellwig */ 1215f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 121632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1217f461d2dcSChristoph Hellwig { 1218f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1219f461d2dcSChristoph Hellwig } 1220f461d2dcSChristoph Hellwig 1221f461d2dcSChristoph Hellwig /** 1222f461d2dcSChristoph Hellwig * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1223f461d2dcSChristoph Hellwig * @table: the sysctl table 1224f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1225f461d2dcSChristoph Hellwig * @buffer: the user buffer 1226f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1227f461d2dcSChristoph Hellwig * @ppos: file position 1228f461d2dcSChristoph Hellwig * 1229f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1230f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. The values 1231f461d2dcSChristoph Hellwig * are treated as milliseconds, and converted to jiffies when they are stored. 1232f461d2dcSChristoph Hellwig * 1233f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1234f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1235f461d2dcSChristoph Hellwig * 1236f461d2dcSChristoph Hellwig * Returns 0 on success. 1237f461d2dcSChristoph Hellwig */ 1238f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 123932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1240f461d2dcSChristoph Hellwig { 1241f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, 1242f461d2dcSChristoph Hellwig lenp, ppos, HZ, 1000l); 1243f461d2dcSChristoph Hellwig } 1244f461d2dcSChristoph Hellwig 1245f461d2dcSChristoph Hellwig 1246f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1247f461d2dcSChristoph Hellwig int *valp, 1248f461d2dcSChristoph Hellwig int write, void *data) 1249f461d2dcSChristoph Hellwig { 1250f461d2dcSChristoph Hellwig if (write) { 1251f461d2dcSChristoph Hellwig if (*lvalp > INT_MAX / HZ) 1252f461d2dcSChristoph Hellwig return 1; 1253f461d2dcSChristoph Hellwig *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1254f461d2dcSChristoph Hellwig } else { 1255f461d2dcSChristoph Hellwig int val = *valp; 1256f461d2dcSChristoph Hellwig unsigned long lval; 1257f461d2dcSChristoph Hellwig if (val < 0) { 1258f461d2dcSChristoph Hellwig *negp = true; 1259f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1260f461d2dcSChristoph Hellwig } else { 1261f461d2dcSChristoph Hellwig *negp = false; 1262f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1263f461d2dcSChristoph Hellwig } 1264f461d2dcSChristoph Hellwig *lvalp = lval / HZ; 1265f461d2dcSChristoph Hellwig } 1266f461d2dcSChristoph Hellwig return 0; 1267f461d2dcSChristoph Hellwig } 1268f461d2dcSChristoph Hellwig 1269f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1270f461d2dcSChristoph Hellwig int *valp, 1271f461d2dcSChristoph Hellwig int write, void *data) 1272f461d2dcSChristoph Hellwig { 1273f461d2dcSChristoph Hellwig if (write) { 1274f461d2dcSChristoph Hellwig if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1275f461d2dcSChristoph Hellwig return 1; 1276f461d2dcSChristoph Hellwig *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1277f461d2dcSChristoph Hellwig } else { 1278f461d2dcSChristoph Hellwig int val = *valp; 1279f461d2dcSChristoph Hellwig unsigned long lval; 1280f461d2dcSChristoph Hellwig if (val < 0) { 1281f461d2dcSChristoph Hellwig *negp = true; 1282f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1283f461d2dcSChristoph Hellwig } else { 1284f461d2dcSChristoph Hellwig *negp = false; 1285f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1286f461d2dcSChristoph Hellwig } 1287f461d2dcSChristoph Hellwig *lvalp = jiffies_to_clock_t(lval); 1288f461d2dcSChristoph Hellwig } 1289f461d2dcSChristoph Hellwig return 0; 1290f461d2dcSChristoph Hellwig } 1291f461d2dcSChristoph Hellwig 1292f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1293f461d2dcSChristoph Hellwig int *valp, 1294f461d2dcSChristoph Hellwig int write, void *data) 1295f461d2dcSChristoph Hellwig { 1296f461d2dcSChristoph Hellwig if (write) { 1297f461d2dcSChristoph Hellwig unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1298f461d2dcSChristoph Hellwig 1299f461d2dcSChristoph Hellwig if (jif > INT_MAX) 1300f461d2dcSChristoph Hellwig return 1; 1301f461d2dcSChristoph Hellwig *valp = (int)jif; 1302f461d2dcSChristoph Hellwig } else { 1303f461d2dcSChristoph Hellwig int val = *valp; 1304f461d2dcSChristoph Hellwig unsigned long lval; 1305f461d2dcSChristoph Hellwig if (val < 0) { 1306f461d2dcSChristoph Hellwig *negp = true; 1307f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1308f461d2dcSChristoph Hellwig } else { 1309f461d2dcSChristoph Hellwig *negp = false; 1310f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1311f461d2dcSChristoph Hellwig } 1312f461d2dcSChristoph Hellwig *lvalp = jiffies_to_msecs(lval); 1313f461d2dcSChristoph Hellwig } 1314f461d2dcSChristoph Hellwig return 0; 1315f461d2dcSChristoph Hellwig } 1316f461d2dcSChristoph Hellwig 1317f461d2dcSChristoph Hellwig /** 1318f461d2dcSChristoph Hellwig * proc_dointvec_jiffies - read a vector of integers as seconds 1319f461d2dcSChristoph Hellwig * @table: the sysctl table 1320f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1321f461d2dcSChristoph Hellwig * @buffer: the user buffer 1322f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1323f461d2dcSChristoph Hellwig * @ppos: file position 1324f461d2dcSChristoph Hellwig * 1325f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1326f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1327f461d2dcSChristoph Hellwig * The values read are assumed to be in seconds, and are converted into 1328f461d2dcSChristoph Hellwig * jiffies. 1329f461d2dcSChristoph Hellwig * 1330f461d2dcSChristoph Hellwig * Returns 0 on success. 1331f461d2dcSChristoph Hellwig */ 1332f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 133332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1334f461d2dcSChristoph Hellwig { 1335f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1336f461d2dcSChristoph Hellwig do_proc_dointvec_jiffies_conv,NULL); 1337f461d2dcSChristoph Hellwig } 1338f461d2dcSChristoph Hellwig 1339f461d2dcSChristoph Hellwig /** 1340f461d2dcSChristoph Hellwig * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1341f461d2dcSChristoph Hellwig * @table: the sysctl table 1342f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1343f461d2dcSChristoph Hellwig * @buffer: the user buffer 1344f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1345f461d2dcSChristoph Hellwig * @ppos: pointer to the file position 1346f461d2dcSChristoph Hellwig * 1347f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1348f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1349f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/USER_HZ seconds, and 1350f461d2dcSChristoph Hellwig * are converted into jiffies. 1351f461d2dcSChristoph Hellwig * 1352f461d2dcSChristoph Hellwig * Returns 0 on success. 1353f461d2dcSChristoph Hellwig */ 1354f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 135532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1356f461d2dcSChristoph Hellwig { 1357f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1358f461d2dcSChristoph Hellwig do_proc_dointvec_userhz_jiffies_conv,NULL); 1359f461d2dcSChristoph Hellwig } 1360f461d2dcSChristoph Hellwig 1361f461d2dcSChristoph Hellwig /** 1362f461d2dcSChristoph Hellwig * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1363f461d2dcSChristoph Hellwig * @table: the sysctl table 1364f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1365f461d2dcSChristoph Hellwig * @buffer: the user buffer 1366f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1367f461d2dcSChristoph Hellwig * @ppos: file position 1368f461d2dcSChristoph Hellwig * @ppos: the current position in the file 1369f461d2dcSChristoph Hellwig * 1370f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1371f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1372f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/1000 seconds, and 1373f461d2dcSChristoph Hellwig * are converted into jiffies. 1374f461d2dcSChristoph Hellwig * 1375f461d2dcSChristoph Hellwig * Returns 0 on success. 1376f461d2dcSChristoph Hellwig */ 137732927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer, 137832927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1379f461d2dcSChristoph Hellwig { 1380f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1381f461d2dcSChristoph Hellwig do_proc_dointvec_ms_jiffies_conv, NULL); 1382f461d2dcSChristoph Hellwig } 1383f461d2dcSChristoph Hellwig 138432927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, 138532927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1386f461d2dcSChristoph Hellwig { 1387f461d2dcSChristoph Hellwig struct pid *new_pid; 1388f461d2dcSChristoph Hellwig pid_t tmp; 1389f461d2dcSChristoph Hellwig int r; 1390f461d2dcSChristoph Hellwig 1391f461d2dcSChristoph Hellwig tmp = pid_vnr(cad_pid); 1392f461d2dcSChristoph Hellwig 1393f461d2dcSChristoph Hellwig r = __do_proc_dointvec(&tmp, table, write, buffer, 1394f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1395f461d2dcSChristoph Hellwig if (r || !write) 1396f461d2dcSChristoph Hellwig return r; 1397f461d2dcSChristoph Hellwig 1398f461d2dcSChristoph Hellwig new_pid = find_get_pid(tmp); 1399f461d2dcSChristoph Hellwig if (!new_pid) 1400f461d2dcSChristoph Hellwig return -ESRCH; 1401f461d2dcSChristoph Hellwig 1402f461d2dcSChristoph Hellwig put_pid(xchg(&cad_pid, new_pid)); 1403f461d2dcSChristoph Hellwig return 0; 1404f461d2dcSChristoph Hellwig } 1405f461d2dcSChristoph Hellwig 1406f461d2dcSChristoph Hellwig /** 1407f461d2dcSChristoph Hellwig * proc_do_large_bitmap - read/write from/to a large bitmap 1408f461d2dcSChristoph Hellwig * @table: the sysctl table 1409f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1410f461d2dcSChristoph Hellwig * @buffer: the user buffer 1411f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1412f461d2dcSChristoph Hellwig * @ppos: file position 1413f461d2dcSChristoph Hellwig * 1414f461d2dcSChristoph Hellwig * The bitmap is stored at table->data and the bitmap length (in bits) 1415f461d2dcSChristoph Hellwig * in table->maxlen. 1416f461d2dcSChristoph Hellwig * 1417f461d2dcSChristoph Hellwig * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1418f461d2dcSChristoph Hellwig * large bitmaps may be represented in a compact manner. Writing into 1419f461d2dcSChristoph Hellwig * the file will clear the bitmap then update it with the given input. 1420f461d2dcSChristoph Hellwig * 1421f461d2dcSChristoph Hellwig * Returns 0 on success. 1422f461d2dcSChristoph Hellwig */ 1423f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 142432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1425f461d2dcSChristoph Hellwig { 1426f461d2dcSChristoph Hellwig int err = 0; 1427f461d2dcSChristoph Hellwig bool first = 1; 1428f461d2dcSChristoph Hellwig size_t left = *lenp; 1429f461d2dcSChristoph Hellwig unsigned long bitmap_len = table->maxlen; 1430f461d2dcSChristoph Hellwig unsigned long *bitmap = *(unsigned long **) table->data; 1431f461d2dcSChristoph Hellwig unsigned long *tmp_bitmap = NULL; 1432f461d2dcSChristoph Hellwig char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1433f461d2dcSChristoph Hellwig 1434f461d2dcSChristoph Hellwig if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1435f461d2dcSChristoph Hellwig *lenp = 0; 1436f461d2dcSChristoph Hellwig return 0; 1437f461d2dcSChristoph Hellwig } 1438f461d2dcSChristoph Hellwig 1439f461d2dcSChristoph Hellwig if (write) { 144032927393SChristoph Hellwig char *p = buffer; 1441f461d2dcSChristoph Hellwig size_t skipped = 0; 1442f461d2dcSChristoph Hellwig 1443f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) { 1444f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1445f461d2dcSChristoph Hellwig /* How much of the buffer we'll skip this pass */ 1446f461d2dcSChristoph Hellwig skipped = *lenp - left; 1447f461d2dcSChristoph Hellwig } 1448f461d2dcSChristoph Hellwig 1449f461d2dcSChristoph Hellwig tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 145032927393SChristoph Hellwig if (!tmp_bitmap) 1451f461d2dcSChristoph Hellwig return -ENOMEM; 1452f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1453f461d2dcSChristoph Hellwig while (!err && left) { 1454f461d2dcSChristoph Hellwig unsigned long val_a, val_b; 1455f461d2dcSChristoph Hellwig bool neg; 1456f461d2dcSChristoph Hellwig size_t saved_left; 1457f461d2dcSChristoph Hellwig 1458f461d2dcSChristoph Hellwig /* In case we stop parsing mid-number, we can reset */ 1459f461d2dcSChristoph Hellwig saved_left = left; 1460f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1461f461d2dcSChristoph Hellwig sizeof(tr_a), &c); 1462f461d2dcSChristoph Hellwig /* 1463f461d2dcSChristoph Hellwig * If we consumed the entirety of a truncated buffer or 1464f461d2dcSChristoph Hellwig * only one char is left (may be a "-"), then stop here, 1465f461d2dcSChristoph Hellwig * reset, & come back for more. 1466f461d2dcSChristoph Hellwig */ 1467f461d2dcSChristoph Hellwig if ((left <= 1) && skipped) { 1468f461d2dcSChristoph Hellwig left = saved_left; 1469f461d2dcSChristoph Hellwig break; 1470f461d2dcSChristoph Hellwig } 1471f461d2dcSChristoph Hellwig 1472f461d2dcSChristoph Hellwig if (err) 1473f461d2dcSChristoph Hellwig break; 1474f461d2dcSChristoph Hellwig if (val_a >= bitmap_len || neg) { 1475f461d2dcSChristoph Hellwig err = -EINVAL; 1476f461d2dcSChristoph Hellwig break; 1477f461d2dcSChristoph Hellwig } 1478f461d2dcSChristoph Hellwig 1479f461d2dcSChristoph Hellwig val_b = val_a; 1480f461d2dcSChristoph Hellwig if (left) { 1481f461d2dcSChristoph Hellwig p++; 1482f461d2dcSChristoph Hellwig left--; 1483f461d2dcSChristoph Hellwig } 1484f461d2dcSChristoph Hellwig 1485f461d2dcSChristoph Hellwig if (c == '-') { 1486f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_b, 1487f461d2dcSChristoph Hellwig &neg, tr_b, sizeof(tr_b), 1488f461d2dcSChristoph Hellwig &c); 1489f461d2dcSChristoph Hellwig /* 1490f461d2dcSChristoph Hellwig * If we consumed all of a truncated buffer or 1491f461d2dcSChristoph Hellwig * then stop here, reset, & come back for more. 1492f461d2dcSChristoph Hellwig */ 1493f461d2dcSChristoph Hellwig if (!left && skipped) { 1494f461d2dcSChristoph Hellwig left = saved_left; 1495f461d2dcSChristoph Hellwig break; 1496f461d2dcSChristoph Hellwig } 1497f461d2dcSChristoph Hellwig 1498f461d2dcSChristoph Hellwig if (err) 1499f461d2dcSChristoph Hellwig break; 1500f461d2dcSChristoph Hellwig if (val_b >= bitmap_len || neg || 1501f461d2dcSChristoph Hellwig val_a > val_b) { 1502f461d2dcSChristoph Hellwig err = -EINVAL; 1503f461d2dcSChristoph Hellwig break; 1504f461d2dcSChristoph Hellwig } 1505f461d2dcSChristoph Hellwig if (left) { 1506f461d2dcSChristoph Hellwig p++; 1507f461d2dcSChristoph Hellwig left--; 1508f461d2dcSChristoph Hellwig } 1509f461d2dcSChristoph Hellwig } 1510f461d2dcSChristoph Hellwig 1511f461d2dcSChristoph Hellwig bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1512f461d2dcSChristoph Hellwig first = 0; 1513f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1514f461d2dcSChristoph Hellwig } 1515f461d2dcSChristoph Hellwig left += skipped; 1516f461d2dcSChristoph Hellwig } else { 1517f461d2dcSChristoph Hellwig unsigned long bit_a, bit_b = 0; 1518f461d2dcSChristoph Hellwig 1519f461d2dcSChristoph Hellwig while (left) { 1520f461d2dcSChristoph Hellwig bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1521f461d2dcSChristoph Hellwig if (bit_a >= bitmap_len) 1522f461d2dcSChristoph Hellwig break; 1523f461d2dcSChristoph Hellwig bit_b = find_next_zero_bit(bitmap, bitmap_len, 1524f461d2dcSChristoph Hellwig bit_a + 1) - 1; 1525f461d2dcSChristoph Hellwig 152632927393SChristoph Hellwig if (!first) 152732927393SChristoph Hellwig proc_put_char(&buffer, &left, ','); 152832927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_a, false); 1529f461d2dcSChristoph Hellwig if (bit_a != bit_b) { 153032927393SChristoph Hellwig proc_put_char(&buffer, &left, '-'); 153132927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_b, false); 1532f461d2dcSChristoph Hellwig } 1533f461d2dcSChristoph Hellwig 1534f461d2dcSChristoph Hellwig first = 0; bit_b++; 1535f461d2dcSChristoph Hellwig } 153632927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1537f461d2dcSChristoph Hellwig } 1538f461d2dcSChristoph Hellwig 1539f461d2dcSChristoph Hellwig if (!err) { 1540f461d2dcSChristoph Hellwig if (write) { 1541f461d2dcSChristoph Hellwig if (*ppos) 1542f461d2dcSChristoph Hellwig bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1543f461d2dcSChristoph Hellwig else 1544f461d2dcSChristoph Hellwig bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1545f461d2dcSChristoph Hellwig } 1546f461d2dcSChristoph Hellwig *lenp -= left; 1547f461d2dcSChristoph Hellwig *ppos += *lenp; 1548f461d2dcSChristoph Hellwig } 1549f461d2dcSChristoph Hellwig 1550f461d2dcSChristoph Hellwig bitmap_free(tmp_bitmap); 1551f461d2dcSChristoph Hellwig return err; 1552f461d2dcSChristoph Hellwig } 1553f461d2dcSChristoph Hellwig 1554f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */ 1555f461d2dcSChristoph Hellwig 1556f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 155732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1558f461d2dcSChristoph Hellwig { 1559f461d2dcSChristoph Hellwig return -ENOSYS; 1560f461d2dcSChristoph Hellwig } 1561f461d2dcSChristoph Hellwig 1562f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, 156332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1564f461d2dcSChristoph Hellwig { 1565f461d2dcSChristoph Hellwig return -ENOSYS; 1566f461d2dcSChristoph Hellwig } 1567f461d2dcSChristoph Hellwig 1568f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, 156932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1570f461d2dcSChristoph Hellwig { 1571f461d2dcSChristoph Hellwig return -ENOSYS; 1572f461d2dcSChristoph Hellwig } 1573f461d2dcSChristoph Hellwig 1574f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 157532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1576f461d2dcSChristoph Hellwig { 1577f461d2dcSChristoph Hellwig return -ENOSYS; 1578f461d2dcSChristoph Hellwig } 1579f461d2dcSChristoph Hellwig 1580f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 158132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1582f461d2dcSChristoph Hellwig { 1583f461d2dcSChristoph Hellwig return -ENOSYS; 1584f461d2dcSChristoph Hellwig } 1585f461d2dcSChristoph Hellwig 1586f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 158732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1588f461d2dcSChristoph Hellwig { 1589f461d2dcSChristoph Hellwig return -ENOSYS; 1590f461d2dcSChristoph Hellwig } 1591f461d2dcSChristoph Hellwig 1592f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 159332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1594f461d2dcSChristoph Hellwig { 1595f461d2dcSChristoph Hellwig return -ENOSYS; 1596f461d2dcSChristoph Hellwig } 1597f461d2dcSChristoph Hellwig 1598f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 159932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1600f461d2dcSChristoph Hellwig { 1601f461d2dcSChristoph Hellwig return -ENOSYS; 1602f461d2dcSChristoph Hellwig } 1603f461d2dcSChristoph Hellwig 1604f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 160532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1606f461d2dcSChristoph Hellwig { 1607f461d2dcSChristoph Hellwig return -ENOSYS; 1608f461d2dcSChristoph Hellwig } 1609f461d2dcSChristoph Hellwig 1610f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 161132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1612f461d2dcSChristoph Hellwig { 1613f461d2dcSChristoph Hellwig return -ENOSYS; 1614f461d2dcSChristoph Hellwig } 1615f461d2dcSChristoph Hellwig 1616f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 161732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1618f461d2dcSChristoph Hellwig { 1619f461d2dcSChristoph Hellwig return -ENOSYS; 1620f461d2dcSChristoph Hellwig } 1621f461d2dcSChristoph Hellwig 1622f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 1623f461d2dcSChristoph Hellwig 1624f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL) 1625f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write, 162632927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1627f461d2dcSChristoph Hellwig { 1628f461d2dcSChristoph Hellwig struct static_key *key = (struct static_key *)table->data; 1629f461d2dcSChristoph Hellwig static DEFINE_MUTEX(static_key_mutex); 1630f461d2dcSChristoph Hellwig int val, ret; 1631f461d2dcSChristoph Hellwig struct ctl_table tmp = { 1632f461d2dcSChristoph Hellwig .data = &val, 1633f461d2dcSChristoph Hellwig .maxlen = sizeof(val), 1634f461d2dcSChristoph Hellwig .mode = table->mode, 1635f461d2dcSChristoph Hellwig .extra1 = SYSCTL_ZERO, 1636f461d2dcSChristoph Hellwig .extra2 = SYSCTL_ONE, 1637f461d2dcSChristoph Hellwig }; 1638f461d2dcSChristoph Hellwig 1639f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 1640f461d2dcSChristoph Hellwig return -EPERM; 1641f461d2dcSChristoph Hellwig 1642f461d2dcSChristoph Hellwig mutex_lock(&static_key_mutex); 1643f461d2dcSChristoph Hellwig val = static_key_enabled(key); 1644f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1645f461d2dcSChristoph Hellwig if (write && !ret) { 1646f461d2dcSChristoph Hellwig if (val) 1647f461d2dcSChristoph Hellwig static_key_enable(key); 1648f461d2dcSChristoph Hellwig else 1649f461d2dcSChristoph Hellwig static_key_disable(key); 1650f461d2dcSChristoph Hellwig } 1651f461d2dcSChristoph Hellwig mutex_unlock(&static_key_mutex); 1652f461d2dcSChristoph Hellwig return ret; 1653f461d2dcSChristoph Hellwig } 1654f461d2dcSChristoph Hellwig 1655d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 16562bba22c5SMike Galbraith { 16572bba22c5SMike Galbraith .procname = "sched_child_runs_first", 16582bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 16592bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 16602bba22c5SMike Galbraith .mode = 0644, 16616d456111SEric W. Biederman .proc_handler = proc_dointvec, 16622bba22c5SMike Galbraith }, 166377e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 166477e54a1fSIngo Molnar { 1665b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 1666b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 166777e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 166877e54a1fSIngo Molnar .mode = 0644, 1669702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 1670b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 1671b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 167277e54a1fSIngo Molnar }, 167377e54a1fSIngo Molnar { 167421805085SPeter Zijlstra .procname = "sched_latency_ns", 167521805085SPeter Zijlstra .data = &sysctl_sched_latency, 167621805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 167721805085SPeter Zijlstra .mode = 0644, 1678702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 167921805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 168021805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 168121805085SPeter Zijlstra }, 168221805085SPeter Zijlstra { 168377e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 168477e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 168577e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 168677e54a1fSIngo Molnar .mode = 0644, 1687702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 168877e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 168977e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 169077e54a1fSIngo Molnar }, 1691cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 169277e54a1fSIngo Molnar { 16931983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 16941983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 16951983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 16961983a922SChristian Ehrhardt .mode = 0644, 1697702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 16981983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 16991983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 17002398f2c6SPeter Zijlstra }, 17012398f2c6SPeter Zijlstra { 1702d00535dbSNamhyung Kim .procname = "sched_migration_cost_ns", 1703da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 1704da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 1705da84d961SIngo Molnar .mode = 0644, 17066d456111SEric W. Biederman .proc_handler = proc_dointvec, 1707da84d961SIngo Molnar }, 1708b82d9fddSPeter Zijlstra { 1709b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 1710b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 1711b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 1712fa85ae24SPeter Zijlstra .mode = 0644, 17136d456111SEric W. Biederman .proc_handler = proc_dointvec, 1714fa85ae24SPeter Zijlstra }, 1715cb251765SMel Gorman #ifdef CONFIG_SCHEDSTATS 1716cb251765SMel Gorman { 1717cb251765SMel Gorman .procname = "sched_schedstats", 1718cb251765SMel Gorman .data = NULL, 1719cb251765SMel Gorman .maxlen = sizeof(unsigned int), 1720cb251765SMel Gorman .mode = 0644, 1721cb251765SMel Gorman .proc_handler = sysctl_schedstats, 1722eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1723eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1724cb251765SMel Gorman }, 1725cb251765SMel Gorman #endif /* CONFIG_SCHEDSTATS */ 1726cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 1727cbee9f88SPeter Zijlstra #ifdef CONFIG_NUMA_BALANCING 1728cbee9f88SPeter Zijlstra { 17294b96a29bSPeter Zijlstra .procname = "numa_balancing_scan_delay_ms", 17304b96a29bSPeter Zijlstra .data = &sysctl_numa_balancing_scan_delay, 17314b96a29bSPeter Zijlstra .maxlen = sizeof(unsigned int), 17324b96a29bSPeter Zijlstra .mode = 0644, 17334b96a29bSPeter Zijlstra .proc_handler = proc_dointvec, 17344b96a29bSPeter Zijlstra }, 17354b96a29bSPeter Zijlstra { 1736cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_min_ms", 1737cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_min, 1738cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1739cbee9f88SPeter Zijlstra .mode = 0644, 1740cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1741cbee9f88SPeter Zijlstra }, 1742cbee9f88SPeter Zijlstra { 1743cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_max_ms", 1744cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_max, 1745cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1746cbee9f88SPeter Zijlstra .mode = 0644, 1747cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1748cbee9f88SPeter Zijlstra }, 17496e5fb223SPeter Zijlstra { 17506e5fb223SPeter Zijlstra .procname = "numa_balancing_scan_size_mb", 17516e5fb223SPeter Zijlstra .data = &sysctl_numa_balancing_scan_size, 17526e5fb223SPeter Zijlstra .maxlen = sizeof(unsigned int), 17536e5fb223SPeter Zijlstra .mode = 0644, 175464192658SKirill Tkhai .proc_handler = proc_dointvec_minmax, 1755eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 17566e5fb223SPeter Zijlstra }, 17573a7053b3SMel Gorman { 175854a43d54SAndi Kleen .procname = "numa_balancing", 175954a43d54SAndi Kleen .data = NULL, /* filled in by handler */ 176054a43d54SAndi Kleen .maxlen = sizeof(unsigned int), 176154a43d54SAndi Kleen .mode = 0644, 176254a43d54SAndi Kleen .proc_handler = sysctl_numa_balancing, 1763eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1764eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 176554a43d54SAndi Kleen }, 1766cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */ 1767cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 17681799e35dSIngo Molnar { 17699f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 17709f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 17719f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 17729f0c1e56SPeter Zijlstra .mode = 0644, 17736d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17749f0c1e56SPeter Zijlstra }, 17759f0c1e56SPeter Zijlstra { 17769f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 17779f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 17789f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 17799f0c1e56SPeter Zijlstra .mode = 0644, 17806d456111SEric W. Biederman .proc_handler = sched_rt_handler, 17819f0c1e56SPeter Zijlstra }, 1782ce0dbbbbSClark Williams { 1783ce0dbbbbSClark Williams .procname = "sched_rr_timeslice_ms", 1784975e155eSShile Zhang .data = &sysctl_sched_rr_timeslice, 1785ce0dbbbbSClark Williams .maxlen = sizeof(int), 1786ce0dbbbbSClark Williams .mode = 0644, 1787ce0dbbbbSClark Williams .proc_handler = sched_rr_handler, 1788ce0dbbbbSClark Williams }, 1789e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK 1790e8f14172SPatrick Bellasi { 1791e8f14172SPatrick Bellasi .procname = "sched_util_clamp_min", 1792e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_min, 1793e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1794e8f14172SPatrick Bellasi .mode = 0644, 1795e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1796e8f14172SPatrick Bellasi }, 1797e8f14172SPatrick Bellasi { 1798e8f14172SPatrick Bellasi .procname = "sched_util_clamp_max", 1799e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_max, 1800e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1801e8f14172SPatrick Bellasi .mode = 0644, 1802e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1803e8f14172SPatrick Bellasi }, 1804e8f14172SPatrick Bellasi #endif 18055091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 18065091faa4SMike Galbraith { 18075091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 18085091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 18095091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 18105091faa4SMike Galbraith .mode = 0644, 18111747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 1812eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1813eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18145091faa4SMike Galbraith }, 18155091faa4SMike Galbraith #endif 1816ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 1817ec12cb7fSPaul Turner { 1818ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 1819ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 1820ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 1821ec12cb7fSPaul Turner .mode = 0644, 1822ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 1823eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 1824ec12cb7fSPaul Turner }, 1825ec12cb7fSPaul Turner #endif 18268d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 18278d5d0cfbSQuentin Perret { 18288d5d0cfbSQuentin Perret .procname = "sched_energy_aware", 18298d5d0cfbSQuentin Perret .data = &sysctl_sched_energy_aware, 18308d5d0cfbSQuentin Perret .maxlen = sizeof(unsigned int), 18318d5d0cfbSQuentin Perret .mode = 0644, 18328d5d0cfbSQuentin Perret .proc_handler = sched_energy_aware_handler, 1833eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1834eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18358d5d0cfbSQuentin Perret }, 18368d5d0cfbSQuentin Perret #endif 1837f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 1838f20786ffSPeter Zijlstra { 1839f20786ffSPeter Zijlstra .procname = "prove_locking", 1840f20786ffSPeter Zijlstra .data = &prove_locking, 1841f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1842f20786ffSPeter Zijlstra .mode = 0644, 18436d456111SEric W. Biederman .proc_handler = proc_dointvec, 1844f20786ffSPeter Zijlstra }, 1845f20786ffSPeter Zijlstra #endif 1846f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 1847f20786ffSPeter Zijlstra { 1848f20786ffSPeter Zijlstra .procname = "lock_stat", 1849f20786ffSPeter Zijlstra .data = &lock_stat, 1850f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1851f20786ffSPeter Zijlstra .mode = 0644, 18526d456111SEric W. Biederman .proc_handler = proc_dointvec, 1853f20786ffSPeter Zijlstra }, 1854f20786ffSPeter Zijlstra #endif 185577e54a1fSIngo Molnar { 18561da177e4SLinus Torvalds .procname = "panic", 18571da177e4SLinus Torvalds .data = &panic_timeout, 18581da177e4SLinus Torvalds .maxlen = sizeof(int), 18591da177e4SLinus Torvalds .mode = 0644, 18606d456111SEric W. Biederman .proc_handler = proc_dointvec, 18611da177e4SLinus Torvalds }, 1862046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 18631da177e4SLinus Torvalds { 18641da177e4SLinus Torvalds .procname = "core_uses_pid", 18651da177e4SLinus Torvalds .data = &core_uses_pid, 18661da177e4SLinus Torvalds .maxlen = sizeof(int), 18671da177e4SLinus Torvalds .mode = 0644, 18686d456111SEric W. Biederman .proc_handler = proc_dointvec, 18691da177e4SLinus Torvalds }, 18701da177e4SLinus Torvalds { 18711da177e4SLinus Torvalds .procname = "core_pattern", 18721da177e4SLinus Torvalds .data = core_pattern, 187371ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 18741da177e4SLinus Torvalds .mode = 0644, 187554b50199SKees Cook .proc_handler = proc_dostring_coredump, 18761da177e4SLinus Torvalds }, 1877a293980cSNeil Horman { 1878a293980cSNeil Horman .procname = "core_pipe_limit", 1879a293980cSNeil Horman .data = &core_pipe_limit, 1880a293980cSNeil Horman .maxlen = sizeof(unsigned int), 1881a293980cSNeil Horman .mode = 0644, 18826d456111SEric W. Biederman .proc_handler = proc_dointvec, 1883a293980cSNeil Horman }, 1884046d662fSAlex Kelly #endif 188534f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 18861da177e4SLinus Torvalds { 18871da177e4SLinus Torvalds .procname = "tainted", 188825ddbb18SAndi Kleen .maxlen = sizeof(long), 188934f5a398STheodore Ts'o .mode = 0644, 18906d456111SEric W. Biederman .proc_handler = proc_taint, 18911da177e4SLinus Torvalds }, 1892f4aacea2SKees Cook { 1893f4aacea2SKees Cook .procname = "sysctl_writes_strict", 1894f4aacea2SKees Cook .data = &sysctl_writes_strict, 1895f4aacea2SKees Cook .maxlen = sizeof(int), 1896f4aacea2SKees Cook .mode = 0644, 1897f4aacea2SKees Cook .proc_handler = proc_dointvec_minmax, 1898f4aacea2SKees Cook .extra1 = &neg_one, 1899eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1900f4aacea2SKees Cook }, 190134f5a398STheodore Ts'o #endif 19029745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 19039745512cSArjan van de Ven { 19049745512cSArjan van de Ven .procname = "latencytop", 19059745512cSArjan van de Ven .data = &latencytop_enabled, 19069745512cSArjan van de Ven .maxlen = sizeof(int), 19079745512cSArjan van de Ven .mode = 0644, 1908cb251765SMel Gorman .proc_handler = sysctl_latencytop, 19099745512cSArjan van de Ven }, 19109745512cSArjan van de Ven #endif 19111da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 19121da177e4SLinus Torvalds { 19131da177e4SLinus Torvalds .procname = "real-root-dev", 19141da177e4SLinus Torvalds .data = &real_root_dev, 19151da177e4SLinus Torvalds .maxlen = sizeof(int), 19161da177e4SLinus Torvalds .mode = 0644, 19176d456111SEric W. Biederman .proc_handler = proc_dointvec, 19181da177e4SLinus Torvalds }, 19191da177e4SLinus Torvalds #endif 192045807a1dSIngo Molnar { 192145807a1dSIngo Molnar .procname = "print-fatal-signals", 192245807a1dSIngo Molnar .data = &print_fatal_signals, 192345807a1dSIngo Molnar .maxlen = sizeof(int), 192445807a1dSIngo Molnar .mode = 0644, 19256d456111SEric W. Biederman .proc_handler = proc_dointvec, 192645807a1dSIngo Molnar }, 192772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 19281da177e4SLinus Torvalds { 19291da177e4SLinus Torvalds .procname = "reboot-cmd", 19301da177e4SLinus Torvalds .data = reboot_command, 19311da177e4SLinus Torvalds .maxlen = 256, 19321da177e4SLinus Torvalds .mode = 0644, 19336d456111SEric W. Biederman .proc_handler = proc_dostring, 19341da177e4SLinus Torvalds }, 19351da177e4SLinus Torvalds { 19361da177e4SLinus Torvalds .procname = "stop-a", 19371da177e4SLinus Torvalds .data = &stop_a_enabled, 19381da177e4SLinus Torvalds .maxlen = sizeof (int), 19391da177e4SLinus Torvalds .mode = 0644, 19406d456111SEric W. Biederman .proc_handler = proc_dointvec, 19411da177e4SLinus Torvalds }, 19421da177e4SLinus Torvalds { 19431da177e4SLinus Torvalds .procname = "scons-poweroff", 19441da177e4SLinus Torvalds .data = &scons_pwroff, 19451da177e4SLinus Torvalds .maxlen = sizeof (int), 19461da177e4SLinus Torvalds .mode = 0644, 19476d456111SEric W. Biederman .proc_handler = proc_dointvec, 19481da177e4SLinus Torvalds }, 19491da177e4SLinus Torvalds #endif 19500871420fSDavid S. Miller #ifdef CONFIG_SPARC64 19510871420fSDavid S. Miller { 19520871420fSDavid S. Miller .procname = "tsb-ratio", 19530871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 19540871420fSDavid S. Miller .maxlen = sizeof (int), 19550871420fSDavid S. Miller .mode = 0644, 19566d456111SEric W. Biederman .proc_handler = proc_dointvec, 19570871420fSDavid S. Miller }, 19580871420fSDavid S. Miller #endif 1959b67114dbSHelge Deller #ifdef CONFIG_PARISC 19601da177e4SLinus Torvalds { 19611da177e4SLinus Torvalds .procname = "soft-power", 19621da177e4SLinus Torvalds .data = &pwrsw_enabled, 19631da177e4SLinus Torvalds .maxlen = sizeof (int), 19641da177e4SLinus Torvalds .mode = 0644, 19656d456111SEric W. Biederman .proc_handler = proc_dointvec, 19661da177e4SLinus Torvalds }, 1967bf14e3b9SVineet Gupta #endif 1968bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 19691da177e4SLinus Torvalds { 19701da177e4SLinus Torvalds .procname = "unaligned-trap", 19711da177e4SLinus Torvalds .data = &unaligned_enabled, 19721da177e4SLinus Torvalds .maxlen = sizeof (int), 19731da177e4SLinus Torvalds .mode = 0644, 19746d456111SEric W. Biederman .proc_handler = proc_dointvec, 19751da177e4SLinus Torvalds }, 19761da177e4SLinus Torvalds #endif 19771da177e4SLinus Torvalds { 19781da177e4SLinus Torvalds .procname = "ctrl-alt-del", 19791da177e4SLinus Torvalds .data = &C_A_D, 19801da177e4SLinus Torvalds .maxlen = sizeof(int), 19811da177e4SLinus Torvalds .mode = 0644, 19826d456111SEric W. Biederman .proc_handler = proc_dointvec, 19831da177e4SLinus Torvalds }, 1984606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 1985b0fc494fSSteven Rostedt { 1986b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 1987b0fc494fSSteven Rostedt .data = &ftrace_enabled, 1988b0fc494fSSteven Rostedt .maxlen = sizeof(int), 1989b0fc494fSSteven Rostedt .mode = 0644, 19906d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 1991b0fc494fSSteven Rostedt }, 1992b0fc494fSSteven Rostedt #endif 1993f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 1994f38f1d2aSSteven Rostedt { 1995f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 1996f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 1997f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 1998f38f1d2aSSteven Rostedt .mode = 0644, 19996d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 2000f38f1d2aSSteven Rostedt }, 2001f38f1d2aSSteven Rostedt #endif 2002944ac425SSteven Rostedt #ifdef CONFIG_TRACING 2003944ac425SSteven Rostedt { 20043299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 2005944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 2006944ac425SSteven Rostedt .maxlen = sizeof(int), 2007944ac425SSteven Rostedt .mode = 0644, 20086d456111SEric W. Biederman .proc_handler = proc_dointvec, 2009944ac425SSteven Rostedt }, 2010de7edd31SSteven Rostedt (Red Hat) { 2011de7edd31SSteven Rostedt (Red Hat) .procname = "traceoff_on_warning", 2012de7edd31SSteven Rostedt (Red Hat) .data = &__disable_trace_on_warning, 2013de7edd31SSteven Rostedt (Red Hat) .maxlen = sizeof(__disable_trace_on_warning), 2014de7edd31SSteven Rostedt (Red Hat) .mode = 0644, 2015de7edd31SSteven Rostedt (Red Hat) .proc_handler = proc_dointvec, 2016de7edd31SSteven Rostedt (Red Hat) }, 20170daa2302SSteven Rostedt (Red Hat) { 20180daa2302SSteven Rostedt (Red Hat) .procname = "tracepoint_printk", 20190daa2302SSteven Rostedt (Red Hat) .data = &tracepoint_printk, 20200daa2302SSteven Rostedt (Red Hat) .maxlen = sizeof(tracepoint_printk), 20210daa2302SSteven Rostedt (Red Hat) .mode = 0644, 202242391745SSteven Rostedt (Red Hat) .proc_handler = tracepoint_printk_sysctl, 20230daa2302SSteven Rostedt (Red Hat) }, 2024944ac425SSteven Rostedt #endif 20252965faa5SDave Young #ifdef CONFIG_KEXEC_CORE 20267984754bSKees Cook { 20277984754bSKees Cook .procname = "kexec_load_disabled", 20287984754bSKees Cook .data = &kexec_load_disabled, 20297984754bSKees Cook .maxlen = sizeof(int), 20307984754bSKees Cook .mode = 0644, 20317984754bSKees Cook /* only handle a transition from default "0" to "1" */ 20327984754bSKees Cook .proc_handler = proc_dointvec_minmax, 2033eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2034eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20357984754bSKees Cook }, 20367984754bSKees Cook #endif 2037a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 20381da177e4SLinus Torvalds { 20391da177e4SLinus Torvalds .procname = "modprobe", 20401da177e4SLinus Torvalds .data = &modprobe_path, 20411da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 20421da177e4SLinus Torvalds .mode = 0644, 20436d456111SEric W. Biederman .proc_handler = proc_dostring, 20441da177e4SLinus Torvalds }, 20453d43321bSKees Cook { 20463d43321bSKees Cook .procname = "modules_disabled", 20473d43321bSKees Cook .data = &modules_disabled, 20483d43321bSKees Cook .maxlen = sizeof(int), 20493d43321bSKees Cook .mode = 0644, 20503d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 20516d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2052eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2053eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 20543d43321bSKees Cook }, 20551da177e4SLinus Torvalds #endif 205686d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER 20571da177e4SLinus Torvalds { 20581da177e4SLinus Torvalds .procname = "hotplug", 2059312c004dSKay Sievers .data = &uevent_helper, 2060312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 20611da177e4SLinus Torvalds .mode = 0644, 20626d456111SEric W. Biederman .proc_handler = proc_dostring, 20631da177e4SLinus Torvalds }, 206486d56134SMichael Marineau #endif 20651da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 20661da177e4SLinus Torvalds { 20671da177e4SLinus Torvalds .procname = "sg-big-buff", 20681da177e4SLinus Torvalds .data = &sg_big_buff, 20691da177e4SLinus Torvalds .maxlen = sizeof (int), 20701da177e4SLinus Torvalds .mode = 0444, 20716d456111SEric W. Biederman .proc_handler = proc_dointvec, 20721da177e4SLinus Torvalds }, 20731da177e4SLinus Torvalds #endif 20741da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 20751da177e4SLinus Torvalds { 20761da177e4SLinus Torvalds .procname = "acct", 20771da177e4SLinus Torvalds .data = &acct_parm, 20781da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 20791da177e4SLinus Torvalds .mode = 0644, 20806d456111SEric W. Biederman .proc_handler = proc_dointvec, 20811da177e4SLinus Torvalds }, 20821da177e4SLinus Torvalds #endif 20831da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 20841da177e4SLinus Torvalds { 20851da177e4SLinus Torvalds .procname = "sysrq", 2086eaee4172SDmitry Safonov .data = NULL, 20871da177e4SLinus Torvalds .maxlen = sizeof (int), 20881da177e4SLinus Torvalds .mode = 0644, 208997f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 20901da177e4SLinus Torvalds }, 20911da177e4SLinus Torvalds #endif 2092d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 20931da177e4SLinus Torvalds { 20941da177e4SLinus Torvalds .procname = "cad_pid", 20959ec52099SCedric Le Goater .data = NULL, 20961da177e4SLinus Torvalds .maxlen = sizeof (int), 20971da177e4SLinus Torvalds .mode = 0600, 20986d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 20991da177e4SLinus Torvalds }, 2100d6f8ff73SRandy Dunlap #endif 21011da177e4SLinus Torvalds { 21021da177e4SLinus Torvalds .procname = "threads-max", 210316db3d3fSHeinrich Schuchardt .data = NULL, 21041da177e4SLinus Torvalds .maxlen = sizeof(int), 21051da177e4SLinus Torvalds .mode = 0644, 210616db3d3fSHeinrich Schuchardt .proc_handler = sysctl_max_threads, 21071da177e4SLinus Torvalds }, 21081da177e4SLinus Torvalds { 21091da177e4SLinus Torvalds .procname = "random", 21101da177e4SLinus Torvalds .mode = 0555, 21111da177e4SLinus Torvalds .child = random_table, 21121da177e4SLinus Torvalds }, 21131da177e4SLinus Torvalds { 211417f60a7dSEric Paris .procname = "usermodehelper", 211517f60a7dSEric Paris .mode = 0555, 211617f60a7dSEric Paris .child = usermodehelper_table, 211717f60a7dSEric Paris }, 2118ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER 2119ceb18132SLuis R. Rodriguez { 2120ceb18132SLuis R. Rodriguez .procname = "firmware_config", 2121ceb18132SLuis R. Rodriguez .mode = 0555, 2122ceb18132SLuis R. Rodriguez .child = firmware_config_table, 2123ceb18132SLuis R. Rodriguez }, 2124ceb18132SLuis R. Rodriguez #endif 212517f60a7dSEric Paris { 21261da177e4SLinus Torvalds .procname = "overflowuid", 21271da177e4SLinus Torvalds .data = &overflowuid, 21281da177e4SLinus Torvalds .maxlen = sizeof(int), 21291da177e4SLinus Torvalds .mode = 0644, 21306d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21311da177e4SLinus Torvalds .extra1 = &minolduid, 21321da177e4SLinus Torvalds .extra2 = &maxolduid, 21331da177e4SLinus Torvalds }, 21341da177e4SLinus Torvalds { 21351da177e4SLinus Torvalds .procname = "overflowgid", 21361da177e4SLinus Torvalds .data = &overflowgid, 21371da177e4SLinus Torvalds .maxlen = sizeof(int), 21381da177e4SLinus Torvalds .mode = 0644, 21396d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21401da177e4SLinus Torvalds .extra1 = &minolduid, 21411da177e4SLinus Torvalds .extra2 = &maxolduid, 21421da177e4SLinus Torvalds }, 2143347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 21441da177e4SLinus Torvalds { 21451da177e4SLinus Torvalds .procname = "userprocess_debug", 2146ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 21471da177e4SLinus Torvalds .maxlen = sizeof(int), 21481da177e4SLinus Torvalds .mode = 0644, 21496d456111SEric W. Biederman .proc_handler = proc_dointvec, 21501da177e4SLinus Torvalds }, 21511da177e4SLinus Torvalds #endif 215260c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP 215360c958d8SGuilherme G. Piccoli { 215460c958d8SGuilherme G. Piccoli .procname = "oops_all_cpu_backtrace", 215560c958d8SGuilherme G. Piccoli .data = &sysctl_oops_all_cpu_backtrace, 215660c958d8SGuilherme G. Piccoli .maxlen = sizeof(int), 215760c958d8SGuilherme G. Piccoli .mode = 0644, 215860c958d8SGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 215960c958d8SGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 216060c958d8SGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 216160c958d8SGuilherme G. Piccoli }, 216260c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */ 21631da177e4SLinus Torvalds { 21641da177e4SLinus Torvalds .procname = "pid_max", 21651da177e4SLinus Torvalds .data = &pid_max, 21661da177e4SLinus Torvalds .maxlen = sizeof (int), 21671da177e4SLinus Torvalds .mode = 0644, 21686d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 21691da177e4SLinus Torvalds .extra1 = &pid_max_min, 21701da177e4SLinus Torvalds .extra2 = &pid_max_max, 21711da177e4SLinus Torvalds }, 21721da177e4SLinus Torvalds { 21731da177e4SLinus Torvalds .procname = "panic_on_oops", 21741da177e4SLinus Torvalds .data = &panic_on_oops, 21751da177e4SLinus Torvalds .maxlen = sizeof(int), 21761da177e4SLinus Torvalds .mode = 0644, 21776d456111SEric W. Biederman .proc_handler = proc_dointvec, 21781da177e4SLinus Torvalds }, 217981c9d43fSFeng Tang { 218081c9d43fSFeng Tang .procname = "panic_print", 218181c9d43fSFeng Tang .data = &panic_print, 218281c9d43fSFeng Tang .maxlen = sizeof(unsigned long), 218381c9d43fSFeng Tang .mode = 0644, 218481c9d43fSFeng Tang .proc_handler = proc_doulongvec_minmax, 218581c9d43fSFeng Tang }, 21867ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 21877ef3d2fdSJoe Perches { 21887ef3d2fdSJoe Perches .procname = "printk", 21897ef3d2fdSJoe Perches .data = &console_loglevel, 21907ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 21917ef3d2fdSJoe Perches .mode = 0644, 21926d456111SEric W. Biederman .proc_handler = proc_dointvec, 21937ef3d2fdSJoe Perches }, 21941da177e4SLinus Torvalds { 21951da177e4SLinus Torvalds .procname = "printk_ratelimit", 2196717115e1SDave Young .data = &printk_ratelimit_state.interval, 21971da177e4SLinus Torvalds .maxlen = sizeof(int), 21981da177e4SLinus Torvalds .mode = 0644, 21996d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 22001da177e4SLinus Torvalds }, 22011da177e4SLinus Torvalds { 22021da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 2203717115e1SDave Young .data = &printk_ratelimit_state.burst, 22041da177e4SLinus Torvalds .maxlen = sizeof(int), 22051da177e4SLinus Torvalds .mode = 0644, 22066d456111SEric W. Biederman .proc_handler = proc_dointvec, 22071da177e4SLinus Torvalds }, 2208af91322eSDave Young { 2209af91322eSDave Young .procname = "printk_delay", 2210af91322eSDave Young .data = &printk_delay_msec, 2211af91322eSDave Young .maxlen = sizeof(int), 2212af91322eSDave Young .mode = 0644, 22136d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2214eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2215af91322eSDave Young .extra2 = &ten_thousand, 2216af91322eSDave Young }, 22171da177e4SLinus Torvalds { 2218750afe7bSBorislav Petkov .procname = "printk_devkmsg", 2219750afe7bSBorislav Petkov .data = devkmsg_log_str, 2220750afe7bSBorislav Petkov .maxlen = DEVKMSG_STR_MAX_SIZE, 2221750afe7bSBorislav Petkov .mode = 0644, 2222750afe7bSBorislav Petkov .proc_handler = devkmsg_sysctl_set_loglvl, 2223750afe7bSBorislav Petkov }, 2224750afe7bSBorislav Petkov { 2225eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 2226eaf06b24SDan Rosenberg .data = &dmesg_restrict, 2227eaf06b24SDan Rosenberg .maxlen = sizeof(int), 2228eaf06b24SDan Rosenberg .mode = 0644, 2229620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2230eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2231eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2232eaf06b24SDan Rosenberg }, 2233455cd5abSDan Rosenberg { 2234455cd5abSDan Rosenberg .procname = "kptr_restrict", 2235455cd5abSDan Rosenberg .data = &kptr_restrict, 2236455cd5abSDan Rosenberg .maxlen = sizeof(int), 2237455cd5abSDan Rosenberg .mode = 0644, 2238620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2239eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2240455cd5abSDan Rosenberg .extra2 = &two, 2241455cd5abSDan Rosenberg }, 2242df6e61d4SJoe Perches #endif 2243eaf06b24SDan Rosenberg { 22441da177e4SLinus Torvalds .procname = "ngroups_max", 22451da177e4SLinus Torvalds .data = &ngroups_max, 22461da177e4SLinus Torvalds .maxlen = sizeof (int), 22471da177e4SLinus Torvalds .mode = 0444, 22486d456111SEric W. Biederman .proc_handler = proc_dointvec, 22491da177e4SLinus Torvalds }, 225073efc039SDan Ballard { 225173efc039SDan Ballard .procname = "cap_last_cap", 225273efc039SDan Ballard .data = (void *)&cap_last_cap, 225373efc039SDan Ballard .maxlen = sizeof(int), 225473efc039SDan Ballard .mode = 0444, 225573efc039SDan Ballard .proc_handler = proc_dointvec, 225673efc039SDan Ballard }, 225758687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 2258504d7cf1SDon Zickus { 225958687acbSDon Zickus .procname = "watchdog", 22603c00ea82SFrederic Weisbecker .data = &watchdog_user_enabled, 2261504d7cf1SDon Zickus .maxlen = sizeof(int), 2262504d7cf1SDon Zickus .mode = 0644, 2263195daf66SUlrich Obergfell .proc_handler = proc_watchdog, 2264eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2265eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 226658687acbSDon Zickus }, 226758687acbSDon Zickus { 226858687acbSDon Zickus .procname = "watchdog_thresh", 2269586692a5SMandeep Singh Baines .data = &watchdog_thresh, 227058687acbSDon Zickus .maxlen = sizeof(int), 227158687acbSDon Zickus .mode = 0644, 2272195daf66SUlrich Obergfell .proc_handler = proc_watchdog_thresh, 2273eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 227458687acbSDon Zickus .extra2 = &sixty, 2275504d7cf1SDon Zickus }, 22762508ce18SDon Zickus { 2277195daf66SUlrich Obergfell .procname = "nmi_watchdog", 22787feeb9cdSThomas Gleixner .data = &nmi_watchdog_user_enabled, 2279195daf66SUlrich Obergfell .maxlen = sizeof(int), 228051d4052bSThomas Gleixner .mode = NMI_WATCHDOG_SYSCTL_PERM, 2281195daf66SUlrich Obergfell .proc_handler = proc_nmi_watchdog, 2282eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2283eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2284195daf66SUlrich Obergfell }, 2285195daf66SUlrich Obergfell { 228605a4a952SNicholas Piggin .procname = "watchdog_cpumask", 228705a4a952SNicholas Piggin .data = &watchdog_cpumask_bits, 228805a4a952SNicholas Piggin .maxlen = NR_CPUS, 228905a4a952SNicholas Piggin .mode = 0644, 229005a4a952SNicholas Piggin .proc_handler = proc_watchdog_cpumask, 229105a4a952SNicholas Piggin }, 229205a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR 229305a4a952SNicholas Piggin { 2294195daf66SUlrich Obergfell .procname = "soft_watchdog", 22957feeb9cdSThomas Gleixner .data = &soft_watchdog_user_enabled, 2296195daf66SUlrich Obergfell .maxlen = sizeof(int), 2297195daf66SUlrich Obergfell .mode = 0644, 2298195daf66SUlrich Obergfell .proc_handler = proc_soft_watchdog, 2299eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2300eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2301195daf66SUlrich Obergfell }, 2302195daf66SUlrich Obergfell { 23032508ce18SDon Zickus .procname = "softlockup_panic", 23042508ce18SDon Zickus .data = &softlockup_panic, 23052508ce18SDon Zickus .maxlen = sizeof(int), 23062508ce18SDon Zickus .mode = 0644, 23072508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 2308eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2309eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 23102508ce18SDon Zickus }, 2311ed235875SAaron Tomlin #ifdef CONFIG_SMP 2312ed235875SAaron Tomlin { 2313ed235875SAaron Tomlin .procname = "softlockup_all_cpu_backtrace", 2314ed235875SAaron Tomlin .data = &sysctl_softlockup_all_cpu_backtrace, 2315ed235875SAaron Tomlin .maxlen = sizeof(int), 2316ed235875SAaron Tomlin .mode = 0644, 2317ed235875SAaron Tomlin .proc_handler = proc_dointvec_minmax, 2318eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2319eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2320ed235875SAaron Tomlin }, 232105a4a952SNicholas Piggin #endif /* CONFIG_SMP */ 232205a4a952SNicholas Piggin #endif 232305a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR 232405a4a952SNicholas Piggin { 232505a4a952SNicholas Piggin .procname = "hardlockup_panic", 232605a4a952SNicholas Piggin .data = &hardlockup_panic, 232705a4a952SNicholas Piggin .maxlen = sizeof(int), 232805a4a952SNicholas Piggin .mode = 0644, 232905a4a952SNicholas Piggin .proc_handler = proc_dointvec_minmax, 2330eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2331eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 233205a4a952SNicholas Piggin }, 233305a4a952SNicholas Piggin #ifdef CONFIG_SMP 233455537871SJiri Kosina { 233555537871SJiri Kosina .procname = "hardlockup_all_cpu_backtrace", 233655537871SJiri Kosina .data = &sysctl_hardlockup_all_cpu_backtrace, 233755537871SJiri Kosina .maxlen = sizeof(int), 233855537871SJiri Kosina .mode = 0644, 233955537871SJiri Kosina .proc_handler = proc_dointvec_minmax, 2340eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2341eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 234255537871SJiri Kosina }, 2343ed235875SAaron Tomlin #endif /* CONFIG_SMP */ 23445dc30558SDon Zickus #endif 234505a4a952SNicholas Piggin #endif 234605a4a952SNicholas Piggin 23475dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 23485dc30558SDon Zickus { 23495dc30558SDon Zickus .procname = "unknown_nmi_panic", 23505dc30558SDon Zickus .data = &unknown_nmi_panic, 23515dc30558SDon Zickus .maxlen = sizeof (int), 23525dc30558SDon Zickus .mode = 0644, 23535dc30558SDon Zickus .proc_handler = proc_dointvec, 23545dc30558SDon Zickus }, 2355504d7cf1SDon Zickus #endif 2356b6522fa4SXiaoming Ni 2357b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \ 2358b6522fa4SXiaoming Ni defined(CONFIG_DEBUG_STACKOVERFLOW) 2359b6522fa4SXiaoming Ni { 2360b6522fa4SXiaoming Ni .procname = "panic_on_stackoverflow", 2361b6522fa4SXiaoming Ni .data = &sysctl_panic_on_stackoverflow, 2362b6522fa4SXiaoming Ni .maxlen = sizeof(int), 2363b6522fa4SXiaoming Ni .mode = 0644, 2364b6522fa4SXiaoming Ni .proc_handler = proc_dointvec, 2365b6522fa4SXiaoming Ni }, 2366b6522fa4SXiaoming Ni #endif 23671da177e4SLinus Torvalds #if defined(CONFIG_X86) 23681da177e4SLinus Torvalds { 23698da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 23708da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 23718da5addaSDon Zickus .maxlen = sizeof(int), 23728da5addaSDon Zickus .mode = 0644, 23736d456111SEric W. Biederman .proc_handler = proc_dointvec, 23748da5addaSDon Zickus }, 23758da5addaSDon Zickus { 23765211a242SKurt Garloff .procname = "panic_on_io_nmi", 23775211a242SKurt Garloff .data = &panic_on_io_nmi, 23785211a242SKurt Garloff .maxlen = sizeof(int), 23795211a242SKurt Garloff .mode = 0644, 23806d456111SEric W. Biederman .proc_handler = proc_dointvec, 23815211a242SKurt Garloff }, 23825211a242SKurt Garloff { 23831da177e4SLinus Torvalds .procname = "bootloader_type", 23841da177e4SLinus Torvalds .data = &bootloader_type, 23851da177e4SLinus Torvalds .maxlen = sizeof (int), 23861da177e4SLinus Torvalds .mode = 0444, 23876d456111SEric W. Biederman .proc_handler = proc_dointvec, 23881da177e4SLinus Torvalds }, 23890741f4d2SChuck Ebbert { 23905031296cSH. Peter Anvin .procname = "bootloader_version", 23915031296cSH. Peter Anvin .data = &bootloader_version, 23925031296cSH. Peter Anvin .maxlen = sizeof (int), 23935031296cSH. Peter Anvin .mode = 0444, 23946d456111SEric W. Biederman .proc_handler = proc_dointvec, 23955031296cSH. Peter Anvin }, 23965031296cSH. Peter Anvin { 23976e7c4025SIngo Molnar .procname = "io_delay_type", 23986e7c4025SIngo Molnar .data = &io_delay_type, 23996e7c4025SIngo Molnar .maxlen = sizeof(int), 24006e7c4025SIngo Molnar .mode = 0644, 24016d456111SEric W. Biederman .proc_handler = proc_dointvec, 24026e7c4025SIngo Molnar }, 24031da177e4SLinus Torvalds #endif 24047a9166e3SLuke Yang #if defined(CONFIG_MMU) 24051da177e4SLinus Torvalds { 24061da177e4SLinus Torvalds .procname = "randomize_va_space", 24071da177e4SLinus Torvalds .data = &randomize_va_space, 24081da177e4SLinus Torvalds .maxlen = sizeof(int), 24091da177e4SLinus Torvalds .mode = 0644, 24106d456111SEric W. Biederman .proc_handler = proc_dointvec, 24111da177e4SLinus Torvalds }, 24127a9166e3SLuke Yang #endif 24130152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2414951f22d5SMartin Schwidefsky { 2415951f22d5SMartin Schwidefsky .procname = "spin_retry", 2416951f22d5SMartin Schwidefsky .data = &spin_retry, 2417951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 2418951f22d5SMartin Schwidefsky .mode = 0644, 24196d456111SEric W. Biederman .proc_handler = proc_dointvec, 2420951f22d5SMartin Schwidefsky }, 2421951f22d5SMartin Schwidefsky #endif 2422673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2423c255d844SPavel Machek { 2424c255d844SPavel Machek .procname = "acpi_video_flags", 242577afcf78SPavel Machek .data = &acpi_realmode_flags, 2426c255d844SPavel Machek .maxlen = sizeof (unsigned long), 2427c255d844SPavel Machek .mode = 0644, 24286d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 2429c255d844SPavel Machek }, 2430c255d844SPavel Machek #endif 2431b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2432d2b176edSJes Sorensen { 2433d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 2434d2b176edSJes Sorensen .data = &no_unaligned_warning, 2435d2b176edSJes Sorensen .maxlen = sizeof (int), 2436d2b176edSJes Sorensen .mode = 0644, 24376d456111SEric W. Biederman .proc_handler = proc_dointvec, 2438d2b176edSJes Sorensen }, 2439b6fca725SVineet Gupta #endif 2440b6fca725SVineet Gupta #ifdef CONFIG_IA64 244188fc241fSDoug Chapman { 244288fc241fSDoug Chapman .procname = "unaligned-dump-stack", 244388fc241fSDoug Chapman .data = &unaligned_dump_stack, 244488fc241fSDoug Chapman .maxlen = sizeof (int), 244588fc241fSDoug Chapman .mode = 0644, 24466d456111SEric W. Biederman .proc_handler = proc_dointvec, 244788fc241fSDoug Chapman }, 2448d2b176edSJes Sorensen #endif 2449e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 24500ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP 24510ec9dc9bSGuilherme G. Piccoli { 24520ec9dc9bSGuilherme G. Piccoli .procname = "hung_task_all_cpu_backtrace", 24530ec9dc9bSGuilherme G. Piccoli .data = &sysctl_hung_task_all_cpu_backtrace, 24540ec9dc9bSGuilherme G. Piccoli .maxlen = sizeof(int), 24550ec9dc9bSGuilherme G. Piccoli .mode = 0644, 24560ec9dc9bSGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 24570ec9dc9bSGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 24580ec9dc9bSGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 24590ec9dc9bSGuilherme G. Piccoli }, 24600ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */ 2461e162b39aSMandeep Singh Baines { 2462e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 2463e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 2464e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 2465e162b39aSMandeep Singh Baines .mode = 0644, 24666d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2467eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2468eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2469e162b39aSMandeep Singh Baines }, 247082a1fcb9SIngo Molnar { 247182a1fcb9SIngo Molnar .procname = "hung_task_check_count", 247282a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 2473cd64647fSLi Zefan .maxlen = sizeof(int), 247482a1fcb9SIngo Molnar .mode = 0644, 2475cd64647fSLi Zefan .proc_handler = proc_dointvec_minmax, 2476eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 247782a1fcb9SIngo Molnar }, 247882a1fcb9SIngo Molnar { 247982a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 248082a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 248190739081SIngo Molnar .maxlen = sizeof(unsigned long), 248282a1fcb9SIngo Molnar .mode = 0644, 24836d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 248480df2847SLiu Hua .extra2 = &hung_task_timeout_max, 248582a1fcb9SIngo Molnar }, 248682a1fcb9SIngo Molnar { 2487a2e51445SDmitry Vyukov .procname = "hung_task_check_interval_secs", 2488a2e51445SDmitry Vyukov .data = &sysctl_hung_task_check_interval_secs, 2489a2e51445SDmitry Vyukov .maxlen = sizeof(unsigned long), 2490a2e51445SDmitry Vyukov .mode = 0644, 2491a2e51445SDmitry Vyukov .proc_handler = proc_dohung_task_timeout_secs, 2492a2e51445SDmitry Vyukov .extra2 = &hung_task_timeout_max, 2493a2e51445SDmitry Vyukov }, 2494a2e51445SDmitry Vyukov { 249582a1fcb9SIngo Molnar .procname = "hung_task_warnings", 249682a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 2497270750dbSAaron Tomlin .maxlen = sizeof(int), 249882a1fcb9SIngo Molnar .mode = 0644, 2499270750dbSAaron Tomlin .proc_handler = proc_dointvec_minmax, 2500270750dbSAaron Tomlin .extra1 = &neg_one, 250182a1fcb9SIngo Molnar }, 2502c4f3b63fSRavikiran G Thirumalai #endif 250323f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 250423f78d4aSIngo Molnar { 250523f78d4aSIngo Molnar .procname = "max_lock_depth", 250623f78d4aSIngo Molnar .data = &max_lock_depth, 250723f78d4aSIngo Molnar .maxlen = sizeof(int), 250823f78d4aSIngo Molnar .mode = 0644, 25096d456111SEric W. Biederman .proc_handler = proc_dointvec, 251023f78d4aSIngo Molnar }, 251123f78d4aSIngo Molnar #endif 251210a0a8d4SJeremy Fitzhardinge { 251310a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 251410a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 251510a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 251610a0a8d4SJeremy Fitzhardinge .mode = 0644, 25176d456111SEric W. Biederman .proc_handler = proc_dostring, 251810a0a8d4SJeremy Fitzhardinge }, 25190b77f5bfSDavid Howells #ifdef CONFIG_KEYS 25200b77f5bfSDavid Howells { 25210b77f5bfSDavid Howells .procname = "keys", 25220b77f5bfSDavid Howells .mode = 0555, 25230b77f5bfSDavid Howells .child = key_sysctls, 25240b77f5bfSDavid Howells }, 25250b77f5bfSDavid Howells #endif 2526cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 2527aa4a2218SVince Weaver /* 2528aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 2529aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 2530aa4a2218SVince Weaver * 2531aa4a2218SVince Weaver * So it's an ABI, do not remove! 2532aa4a2218SVince Weaver */ 25331ccd1549SPeter Zijlstra { 2534cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 2535cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 2536cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 25371ccd1549SPeter Zijlstra .mode = 0644, 25386d456111SEric W. Biederman .proc_handler = proc_dointvec, 25391ccd1549SPeter Zijlstra }, 2540c5078f78SPeter Zijlstra { 2541cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 2542cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 2543cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 2544c5078f78SPeter Zijlstra .mode = 0644, 25456d456111SEric W. Biederman .proc_handler = proc_dointvec, 2546c5078f78SPeter Zijlstra }, 2547a78ac325SPeter Zijlstra { 2548cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 2549cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 2550cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 2551a78ac325SPeter Zijlstra .mode = 0644, 2552163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 2553eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2554a78ac325SPeter Zijlstra }, 255514c63f17SDave Hansen { 255614c63f17SDave Hansen .procname = "perf_cpu_time_max_percent", 255714c63f17SDave Hansen .data = &sysctl_perf_cpu_time_max_percent, 255814c63f17SDave Hansen .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 255914c63f17SDave Hansen .mode = 0644, 256014c63f17SDave Hansen .proc_handler = perf_cpu_time_max_percent_handler, 2561eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 256214c63f17SDave Hansen .extra2 = &one_hundred, 256314c63f17SDave Hansen }, 2564c5dfd78eSArnaldo Carvalho de Melo { 2565c5dfd78eSArnaldo Carvalho de Melo .procname = "perf_event_max_stack", 2566a831100aSArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_stack, 2567c5dfd78eSArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_stack), 2568c5dfd78eSArnaldo Carvalho de Melo .mode = 0644, 2569c5dfd78eSArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2570eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2571c5dfd78eSArnaldo Carvalho de Melo .extra2 = &six_hundred_forty_kb, 2572c5dfd78eSArnaldo Carvalho de Melo }, 2573c85b0334SArnaldo Carvalho de Melo { 2574c85b0334SArnaldo Carvalho de Melo .procname = "perf_event_max_contexts_per_stack", 2575c85b0334SArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_contexts_per_stack, 2576c85b0334SArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2577c85b0334SArnaldo Carvalho de Melo .mode = 0644, 2578c85b0334SArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2579eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2580c85b0334SArnaldo Carvalho de Melo .extra2 = &one_thousand, 2581c85b0334SArnaldo Carvalho de Melo }, 25821ccd1549SPeter Zijlstra #endif 25839e3961a0SPrarit Bhargava { 25849e3961a0SPrarit Bhargava .procname = "panic_on_warn", 25859e3961a0SPrarit Bhargava .data = &panic_on_warn, 25869e3961a0SPrarit Bhargava .maxlen = sizeof(int), 25879e3961a0SPrarit Bhargava .mode = 0644, 25889e3961a0SPrarit Bhargava .proc_handler = proc_dointvec_minmax, 2589eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2590eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 25919e3961a0SPrarit Bhargava }, 2592bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2593bc7a34b8SThomas Gleixner { 2594bc7a34b8SThomas Gleixner .procname = "timer_migration", 2595bc7a34b8SThomas Gleixner .data = &sysctl_timer_migration, 2596bc7a34b8SThomas Gleixner .maxlen = sizeof(unsigned int), 2597bc7a34b8SThomas Gleixner .mode = 0644, 2598bc7a34b8SThomas Gleixner .proc_handler = timer_migration_handler, 2599eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2600eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2601bc7a34b8SThomas Gleixner }, 2602bc7a34b8SThomas Gleixner #endif 26031be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL 26041be7f75dSAlexei Starovoitov { 26051be7f75dSAlexei Starovoitov .procname = "unprivileged_bpf_disabled", 26061be7f75dSAlexei Starovoitov .data = &sysctl_unprivileged_bpf_disabled, 26071be7f75dSAlexei Starovoitov .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 26081be7f75dSAlexei Starovoitov .mode = 0644, 26091be7f75dSAlexei Starovoitov /* only handle a transition from default "0" to "1" */ 26101be7f75dSAlexei Starovoitov .proc_handler = proc_dointvec_minmax, 2611eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2612eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 26131be7f75dSAlexei Starovoitov }, 2614492ecee8SAlexei Starovoitov { 2615492ecee8SAlexei Starovoitov .procname = "bpf_stats_enabled", 2616a8e11e5cSEric Dumazet .data = &bpf_stats_enabled_key.key, 2617a8e11e5cSEric Dumazet .maxlen = sizeof(bpf_stats_enabled_key), 2618492ecee8SAlexei Starovoitov .mode = 0644, 2619d46edd67SSong Liu .proc_handler = bpf_stats_handler, 2620492ecee8SAlexei Starovoitov }, 26213fcc5530SAlexei Starovoitov #endif 2622b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU) 2623088e9d25SDaniel Bristot de Oliveira { 2624088e9d25SDaniel Bristot de Oliveira .procname = "panic_on_rcu_stall", 2625088e9d25SDaniel Bristot de Oliveira .data = &sysctl_panic_on_rcu_stall, 2626088e9d25SDaniel Bristot de Oliveira .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2627088e9d25SDaniel Bristot de Oliveira .mode = 0644, 2628088e9d25SDaniel Bristot de Oliveira .proc_handler = proc_dointvec_minmax, 2629eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2630eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2631088e9d25SDaniel Bristot de Oliveira }, 2632088e9d25SDaniel Bristot de Oliveira #endif 2633964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 2634964c9dffSAlexander Popov { 2635964c9dffSAlexander Popov .procname = "stack_erasing", 2636964c9dffSAlexander Popov .data = NULL, 2637964c9dffSAlexander Popov .maxlen = sizeof(int), 2638964c9dffSAlexander Popov .mode = 0600, 2639964c9dffSAlexander Popov .proc_handler = stack_erasing_sysctl, 2640eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2641eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2642964c9dffSAlexander Popov }, 2643964c9dffSAlexander Popov #endif 26446fce56ecSEric W. Biederman { } 26451da177e4SLinus Torvalds }; 26461da177e4SLinus Torvalds 2647d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 26481da177e4SLinus Torvalds { 26491da177e4SLinus Torvalds .procname = "overcommit_memory", 26501da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 26511da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 26521da177e4SLinus Torvalds .mode = 0644, 2653cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2654eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2655cb16e95fSPetr Holasek .extra2 = &two, 26561da177e4SLinus Torvalds }, 26571da177e4SLinus Torvalds { 2658fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 2659fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 2660fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 2661fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 2662cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2663eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2664cb16e95fSPetr Holasek .extra2 = &two, 2665fadd8fbdSKAMEZAWA Hiroyuki }, 2666fadd8fbdSKAMEZAWA Hiroyuki { 2667fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 2668fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 2669fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2670fe071d7eSDavid Rientjes .mode = 0644, 26716d456111SEric W. Biederman .proc_handler = proc_dointvec, 2672fe071d7eSDavid Rientjes }, 2673fe071d7eSDavid Rientjes { 2674fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 2675fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 2676fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 2677fef1bdd6SDavid Rientjes .mode = 0644, 26786d456111SEric W. Biederman .proc_handler = proc_dointvec, 2679fef1bdd6SDavid Rientjes }, 2680fef1bdd6SDavid Rientjes { 26811da177e4SLinus Torvalds .procname = "overcommit_ratio", 26821da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 26831da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 26841da177e4SLinus Torvalds .mode = 0644, 268549f0ce5fSJerome Marchand .proc_handler = overcommit_ratio_handler, 268649f0ce5fSJerome Marchand }, 268749f0ce5fSJerome Marchand { 268849f0ce5fSJerome Marchand .procname = "overcommit_kbytes", 268949f0ce5fSJerome Marchand .data = &sysctl_overcommit_kbytes, 269049f0ce5fSJerome Marchand .maxlen = sizeof(sysctl_overcommit_kbytes), 269149f0ce5fSJerome Marchand .mode = 0644, 269249f0ce5fSJerome Marchand .proc_handler = overcommit_kbytes_handler, 26931da177e4SLinus Torvalds }, 26941da177e4SLinus Torvalds { 26951da177e4SLinus Torvalds .procname = "page-cluster", 26961da177e4SLinus Torvalds .data = &page_cluster, 26971da177e4SLinus Torvalds .maxlen = sizeof(int), 26981da177e4SLinus Torvalds .mode = 0644, 2699cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2700eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27011da177e4SLinus Torvalds }, 27021da177e4SLinus Torvalds { 27031da177e4SLinus Torvalds .procname = "dirty_background_ratio", 27041da177e4SLinus Torvalds .data = &dirty_background_ratio, 27051da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 27061da177e4SLinus Torvalds .mode = 0644, 27076d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 2708eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27091da177e4SLinus Torvalds .extra2 = &one_hundred, 27101da177e4SLinus Torvalds }, 27111da177e4SLinus Torvalds { 27122da02997SDavid Rientjes .procname = "dirty_background_bytes", 27132da02997SDavid Rientjes .data = &dirty_background_bytes, 27142da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 27152da02997SDavid Rientjes .mode = 0644, 27166d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 2717fc3501d4SSven Wegener .extra1 = &one_ul, 27182da02997SDavid Rientjes }, 27192da02997SDavid Rientjes { 27201da177e4SLinus Torvalds .procname = "dirty_ratio", 27211da177e4SLinus Torvalds .data = &vm_dirty_ratio, 27221da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 27231da177e4SLinus Torvalds .mode = 0644, 27246d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 2725eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27261da177e4SLinus Torvalds .extra2 = &one_hundred, 27271da177e4SLinus Torvalds }, 27281da177e4SLinus Torvalds { 27292da02997SDavid Rientjes .procname = "dirty_bytes", 27302da02997SDavid Rientjes .data = &vm_dirty_bytes, 27312da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 27322da02997SDavid Rientjes .mode = 0644, 27336d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 27349e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 27352da02997SDavid Rientjes }, 27362da02997SDavid Rientjes { 27371da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 2738f6ef9438SBart Samwel .data = &dirty_writeback_interval, 2739f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 27401da177e4SLinus Torvalds .mode = 0644, 27416d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 27421da177e4SLinus Torvalds }, 27431da177e4SLinus Torvalds { 27441da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 2745f6ef9438SBart Samwel .data = &dirty_expire_interval, 2746f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 27471da177e4SLinus Torvalds .mode = 0644, 2748cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2749eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27501da177e4SLinus Torvalds }, 27511da177e4SLinus Torvalds { 27521efff914STheodore Ts'o .procname = "dirtytime_expire_seconds", 27531efff914STheodore Ts'o .data = &dirtytime_expire_interval, 27542d87b309SRandy Dunlap .maxlen = sizeof(dirtytime_expire_interval), 27551efff914STheodore Ts'o .mode = 0644, 27561efff914STheodore Ts'o .proc_handler = dirtytime_interval_handler, 2757eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27581efff914STheodore Ts'o }, 27591efff914STheodore Ts'o { 27601da177e4SLinus Torvalds .procname = "swappiness", 27611da177e4SLinus Torvalds .data = &vm_swappiness, 27621da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 27631da177e4SLinus Torvalds .mode = 0644, 27646d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2765eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2766c843966cSJohannes Weiner .extra2 = &two_hundred, 27671da177e4SLinus Torvalds }, 27681da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 27691da177e4SLinus Torvalds { 27701da177e4SLinus Torvalds .procname = "nr_hugepages", 2771e5ff2159SAndi Kleen .data = NULL, 27721da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 27731da177e4SLinus Torvalds .mode = 0644, 27746d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 27751da177e4SLinus Torvalds }, 277606808b08SLee Schermerhorn #ifdef CONFIG_NUMA 277706808b08SLee Schermerhorn { 277806808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 277906808b08SLee Schermerhorn .data = NULL, 278006808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 278106808b08SLee Schermerhorn .mode = 0644, 278206808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 278306808b08SLee Schermerhorn }, 27844518085eSKemi Wang { 27854518085eSKemi Wang .procname = "numa_stat", 27864518085eSKemi Wang .data = &sysctl_vm_numa_stat, 27874518085eSKemi Wang .maxlen = sizeof(int), 27884518085eSKemi Wang .mode = 0644, 27894518085eSKemi Wang .proc_handler = sysctl_vm_numa_stat_handler, 2790eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2791eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 27924518085eSKemi Wang }, 279306808b08SLee Schermerhorn #endif 27941da177e4SLinus Torvalds { 27951da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 27961da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 27971da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 27981da177e4SLinus Torvalds .mode = 0644, 27996d456111SEric W. Biederman .proc_handler = proc_dointvec, 28001da177e4SLinus Torvalds }, 2801396faf03SMel Gorman { 2802d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 2803e5ff2159SAndi Kleen .data = NULL, 2804e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 2805d1c3fb1fSNishanth Aravamudan .mode = 0644, 28066d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 2807d1c3fb1fSNishanth Aravamudan }, 28081da177e4SLinus Torvalds #endif 28091da177e4SLinus Torvalds { 28101da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 28111da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 28121da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 28131da177e4SLinus Torvalds .mode = 0644, 28146d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 28151da177e4SLinus Torvalds }, 28161da177e4SLinus Torvalds { 28179d0243bcSAndrew Morton .procname = "drop_caches", 28189d0243bcSAndrew Morton .data = &sysctl_drop_caches, 28199d0243bcSAndrew Morton .maxlen = sizeof(int), 2820204cb79aSJohannes Weiner .mode = 0200, 28219d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 2822eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 28235509a5d2SDave Hansen .extra2 = &four, 28249d0243bcSAndrew Morton }, 282576ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 282676ab0f53SMel Gorman { 282776ab0f53SMel Gorman .procname = "compact_memory", 282876ab0f53SMel Gorman .data = &sysctl_compact_memory, 282976ab0f53SMel Gorman .maxlen = sizeof(int), 283076ab0f53SMel Gorman .mode = 0200, 283176ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 283276ab0f53SMel Gorman }, 28335e771905SMel Gorman { 28345e771905SMel Gorman .procname = "extfrag_threshold", 28355e771905SMel Gorman .data = &sysctl_extfrag_threshold, 28365e771905SMel Gorman .maxlen = sizeof(int), 28375e771905SMel Gorman .mode = 0644, 28386b7e5cadSMatthew Wilcox .proc_handler = proc_dointvec_minmax, 28395e771905SMel Gorman .extra1 = &min_extfrag_threshold, 28405e771905SMel Gorman .extra2 = &max_extfrag_threshold, 28415e771905SMel Gorman }, 28425bbe3547SEric B Munson { 28435bbe3547SEric B Munson .procname = "compact_unevictable_allowed", 28445bbe3547SEric B Munson .data = &sysctl_compact_unevictable_allowed, 28455bbe3547SEric B Munson .maxlen = sizeof(int), 28465bbe3547SEric B Munson .mode = 0644, 28476923aa0dSSebastian Andrzej Siewior .proc_handler = proc_dointvec_minmax_warn_RT_change, 2848eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2849eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28505bbe3547SEric B Munson }, 28515e771905SMel Gorman 285276ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 28539d0243bcSAndrew Morton { 28541da177e4SLinus Torvalds .procname = "min_free_kbytes", 28551da177e4SLinus Torvalds .data = &min_free_kbytes, 28561da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 28571da177e4SLinus Torvalds .mode = 0644, 28586d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 2859eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28601da177e4SLinus Torvalds }, 28618ad4b1fbSRohit Seth { 28621c30844dSMel Gorman .procname = "watermark_boost_factor", 28631c30844dSMel Gorman .data = &watermark_boost_factor, 28641c30844dSMel Gorman .maxlen = sizeof(watermark_boost_factor), 28651c30844dSMel Gorman .mode = 0644, 286626363af5SChristoph Hellwig .proc_handler = proc_dointvec_minmax, 2867eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28681c30844dSMel Gorman }, 28691c30844dSMel Gorman { 2870795ae7a0SJohannes Weiner .procname = "watermark_scale_factor", 2871795ae7a0SJohannes Weiner .data = &watermark_scale_factor, 2872795ae7a0SJohannes Weiner .maxlen = sizeof(watermark_scale_factor), 2873795ae7a0SJohannes Weiner .mode = 0644, 2874795ae7a0SJohannes Weiner .proc_handler = watermark_scale_factor_sysctl_handler, 2875eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2876795ae7a0SJohannes Weiner .extra2 = &one_thousand, 2877795ae7a0SJohannes Weiner }, 2878795ae7a0SJohannes Weiner { 28798ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 28808ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 28818ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 28828ad4b1fbSRohit Seth .mode = 0644, 28836d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 2884eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28858ad4b1fbSRohit Seth }, 28861da177e4SLinus Torvalds #ifdef CONFIG_MMU 28871da177e4SLinus Torvalds { 28881da177e4SLinus Torvalds .procname = "max_map_count", 28891da177e4SLinus Torvalds .data = &sysctl_max_map_count, 28901da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 28911da177e4SLinus Torvalds .mode = 0644, 28923e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 2893eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28941da177e4SLinus Torvalds }, 2895dd8632a1SPaul Mundt #else 2896dd8632a1SPaul Mundt { 2897dd8632a1SPaul Mundt .procname = "nr_trim_pages", 2898dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 2899dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 2900dd8632a1SPaul Mundt .mode = 0644, 29016d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2902eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2903dd8632a1SPaul Mundt }, 29041da177e4SLinus Torvalds #endif 29051da177e4SLinus Torvalds { 29061da177e4SLinus Torvalds .procname = "laptop_mode", 29071da177e4SLinus Torvalds .data = &laptop_mode, 29081da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 29091da177e4SLinus Torvalds .mode = 0644, 29106d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 29111da177e4SLinus Torvalds }, 29121da177e4SLinus Torvalds { 29131da177e4SLinus Torvalds .procname = "block_dump", 29141da177e4SLinus Torvalds .data = &block_dump, 29151da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 29161da177e4SLinus Torvalds .mode = 0644, 29176d456111SEric W. Biederman .proc_handler = proc_dointvec, 2918eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29191da177e4SLinus Torvalds }, 29201da177e4SLinus Torvalds { 29211da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 29221da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 29231da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 29241da177e4SLinus Torvalds .mode = 0644, 29256d456111SEric W. Biederman .proc_handler = proc_dointvec, 2926eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29271da177e4SLinus Torvalds }, 292867f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 292967f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 29301da177e4SLinus Torvalds { 29311da177e4SLinus Torvalds .procname = "legacy_va_layout", 29321da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 29331da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 29341da177e4SLinus Torvalds .mode = 0644, 29356d456111SEric W. Biederman .proc_handler = proc_dointvec, 2936eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29371da177e4SLinus Torvalds }, 29381da177e4SLinus Torvalds #endif 29391743660bSChristoph Lameter #ifdef CONFIG_NUMA 29401743660bSChristoph Lameter { 29411743660bSChristoph Lameter .procname = "zone_reclaim_mode", 2942a5f5f91dSMel Gorman .data = &node_reclaim_mode, 2943a5f5f91dSMel Gorman .maxlen = sizeof(node_reclaim_mode), 29441743660bSChristoph Lameter .mode = 0644, 29456d456111SEric W. Biederman .proc_handler = proc_dointvec, 2946eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29471743660bSChristoph Lameter }, 29489614634fSChristoph Lameter { 29499614634fSChristoph Lameter .procname = "min_unmapped_ratio", 29509614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 29519614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 29529614634fSChristoph Lameter .mode = 0644, 29536d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 2954eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29559614634fSChristoph Lameter .extra2 = &one_hundred, 29569614634fSChristoph Lameter }, 29570ff38490SChristoph Lameter { 29580ff38490SChristoph Lameter .procname = "min_slab_ratio", 29590ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 29600ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 29610ff38490SChristoph Lameter .mode = 0644, 29626d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 2963eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29640ff38490SChristoph Lameter .extra2 = &one_hundred, 29650ff38490SChristoph Lameter }, 29661743660bSChristoph Lameter #endif 296777461ab3SChristoph Lameter #ifdef CONFIG_SMP 296877461ab3SChristoph Lameter { 296977461ab3SChristoph Lameter .procname = "stat_interval", 297077461ab3SChristoph Lameter .data = &sysctl_stat_interval, 297177461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 297277461ab3SChristoph Lameter .mode = 0644, 29736d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 297477461ab3SChristoph Lameter }, 297552b6f46bSHugh Dickins { 297652b6f46bSHugh Dickins .procname = "stat_refresh", 297752b6f46bSHugh Dickins .data = NULL, 297852b6f46bSHugh Dickins .maxlen = 0, 297952b6f46bSHugh Dickins .mode = 0600, 298052b6f46bSHugh Dickins .proc_handler = vmstat_refresh, 298152b6f46bSHugh Dickins }, 298277461ab3SChristoph Lameter #endif 29836e141546SDavid Howells #ifdef CONFIG_MMU 2984ed032189SEric Paris { 2985ed032189SEric Paris .procname = "mmap_min_addr", 2986788084abSEric Paris .data = &dac_mmap_min_addr, 2987ed032189SEric Paris .maxlen = sizeof(unsigned long), 2988ed032189SEric Paris .mode = 0644, 29896d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 2990ed032189SEric Paris }, 29916e141546SDavid Howells #endif 2992f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 2993f0c0b2b8SKAMEZAWA Hiroyuki { 2994f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 2995f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 2996f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 2997f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 29986d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 2999f0c0b2b8SKAMEZAWA Hiroyuki }, 3000f0c0b2b8SKAMEZAWA Hiroyuki #endif 30012b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 30025c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 3003e6e5494cSIngo Molnar { 3004e6e5494cSIngo Molnar .procname = "vdso_enabled", 30053d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32 30063d7ee969SAndy Lutomirski .data = &vdso32_enabled, 30073d7ee969SAndy Lutomirski .maxlen = sizeof(vdso32_enabled), 30083d7ee969SAndy Lutomirski #else 3009e6e5494cSIngo Molnar .data = &vdso_enabled, 3010e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 30113d7ee969SAndy Lutomirski #endif 3012e6e5494cSIngo Molnar .mode = 0644, 30136d456111SEric W. Biederman .proc_handler = proc_dointvec, 3014eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3015e6e5494cSIngo Molnar }, 3016e6e5494cSIngo Molnar #endif 3017195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 3018195cf453SBron Gondwana { 3019195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 3020195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 3021195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 3022195cf453SBron Gondwana .mode = 0644, 30236d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3024eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3025eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3026195cf453SBron Gondwana }, 3027195cf453SBron Gondwana #endif 30286a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 30296a46079cSAndi Kleen { 30306a46079cSAndi Kleen .procname = "memory_failure_early_kill", 30316a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 30326a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 30336a46079cSAndi Kleen .mode = 0644, 30346d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3035eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3036eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30376a46079cSAndi Kleen }, 30386a46079cSAndi Kleen { 30396a46079cSAndi Kleen .procname = "memory_failure_recovery", 30406a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 30416a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 30426a46079cSAndi Kleen .mode = 0644, 30436d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3044eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3045eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 30466a46079cSAndi Kleen }, 30476a46079cSAndi Kleen #endif 3048c9b1d098SAndrew Shewmaker { 3049c9b1d098SAndrew Shewmaker .procname = "user_reserve_kbytes", 3050c9b1d098SAndrew Shewmaker .data = &sysctl_user_reserve_kbytes, 3051c9b1d098SAndrew Shewmaker .maxlen = sizeof(sysctl_user_reserve_kbytes), 3052c9b1d098SAndrew Shewmaker .mode = 0644, 3053c9b1d098SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 3054c9b1d098SAndrew Shewmaker }, 30554eeab4f5SAndrew Shewmaker { 30564eeab4f5SAndrew Shewmaker .procname = "admin_reserve_kbytes", 30574eeab4f5SAndrew Shewmaker .data = &sysctl_admin_reserve_kbytes, 30584eeab4f5SAndrew Shewmaker .maxlen = sizeof(sysctl_admin_reserve_kbytes), 30594eeab4f5SAndrew Shewmaker .mode = 0644, 30604eeab4f5SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 30614eeab4f5SAndrew Shewmaker }, 3062d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 3063d07e2259SDaniel Cashman { 3064d07e2259SDaniel Cashman .procname = "mmap_rnd_bits", 3065d07e2259SDaniel Cashman .data = &mmap_rnd_bits, 3066d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_bits), 3067d07e2259SDaniel Cashman .mode = 0600, 3068d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3069d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_bits_min, 3070d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_bits_max, 3071d07e2259SDaniel Cashman }, 3072d07e2259SDaniel Cashman #endif 3073d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 3074d07e2259SDaniel Cashman { 3075d07e2259SDaniel Cashman .procname = "mmap_rnd_compat_bits", 3076d07e2259SDaniel Cashman .data = &mmap_rnd_compat_bits, 3077d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_compat_bits), 3078d07e2259SDaniel Cashman .mode = 0600, 3079d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3080d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_compat_bits_min, 3081d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_compat_bits_max, 3082d07e2259SDaniel Cashman }, 3083d07e2259SDaniel Cashman #endif 3084cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD 3085cefdca0aSPeter Xu { 3086cefdca0aSPeter Xu .procname = "unprivileged_userfaultfd", 3087cefdca0aSPeter Xu .data = &sysctl_unprivileged_userfaultfd, 3088cefdca0aSPeter Xu .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 3089cefdca0aSPeter Xu .mode = 0644, 3090cefdca0aSPeter Xu .proc_handler = proc_dointvec_minmax, 3091eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3092eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3093cefdca0aSPeter Xu }, 3094cefdca0aSPeter Xu #endif 30956fce56ecSEric W. Biederman { } 30961da177e4SLinus Torvalds }; 30971da177e4SLinus Torvalds 3098d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 30991da177e4SLinus Torvalds { 31001da177e4SLinus Torvalds .procname = "inode-nr", 31011da177e4SLinus Torvalds .data = &inodes_stat, 31023942c07cSGlauber Costa .maxlen = 2*sizeof(long), 31031da177e4SLinus Torvalds .mode = 0444, 3104cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31051da177e4SLinus Torvalds }, 31061da177e4SLinus Torvalds { 31071da177e4SLinus Torvalds .procname = "inode-state", 31081da177e4SLinus Torvalds .data = &inodes_stat, 31093942c07cSGlauber Costa .maxlen = 7*sizeof(long), 31101da177e4SLinus Torvalds .mode = 0444, 3111cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 31121da177e4SLinus Torvalds }, 31131da177e4SLinus Torvalds { 31141da177e4SLinus Torvalds .procname = "file-nr", 31151da177e4SLinus Torvalds .data = &files_stat, 3116518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 31171da177e4SLinus Torvalds .mode = 0444, 31186d456111SEric W. Biederman .proc_handler = proc_nr_files, 31191da177e4SLinus Torvalds }, 31201da177e4SLinus Torvalds { 31211da177e4SLinus Torvalds .procname = "file-max", 31221da177e4SLinus Torvalds .data = &files_stat.max_files, 3123518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 31241da177e4SLinus Torvalds .mode = 0644, 3125518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 31269002b214SWill Deacon .extra1 = &zero_ul, 312732a5ad9cSChristian Brauner .extra2 = &long_max, 31281da177e4SLinus Torvalds }, 31291da177e4SLinus Torvalds { 31309cfe015aSEric Dumazet .procname = "nr_open", 31319cfe015aSEric Dumazet .data = &sysctl_nr_open, 31329b80a184SAlexey Dobriyan .maxlen = sizeof(unsigned int), 31339cfe015aSEric Dumazet .mode = 0644, 31346d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3135eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 3136eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 31379cfe015aSEric Dumazet }, 31389cfe015aSEric Dumazet { 31391da177e4SLinus Torvalds .procname = "dentry-state", 31401da177e4SLinus Torvalds .data = &dentry_stat, 31413942c07cSGlauber Costa .maxlen = 6*sizeof(long), 31421da177e4SLinus Torvalds .mode = 0444, 3143312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 31441da177e4SLinus Torvalds }, 31451da177e4SLinus Torvalds { 31461da177e4SLinus Torvalds .procname = "overflowuid", 31471da177e4SLinus Torvalds .data = &fs_overflowuid, 31481da177e4SLinus Torvalds .maxlen = sizeof(int), 31491da177e4SLinus Torvalds .mode = 0644, 31506d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31511da177e4SLinus Torvalds .extra1 = &minolduid, 31521da177e4SLinus Torvalds .extra2 = &maxolduid, 31531da177e4SLinus Torvalds }, 31541da177e4SLinus Torvalds { 31551da177e4SLinus Torvalds .procname = "overflowgid", 31561da177e4SLinus Torvalds .data = &fs_overflowgid, 31571da177e4SLinus Torvalds .maxlen = sizeof(int), 31581da177e4SLinus Torvalds .mode = 0644, 31596d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 31601da177e4SLinus Torvalds .extra1 = &minolduid, 31611da177e4SLinus Torvalds .extra2 = &maxolduid, 31621da177e4SLinus Torvalds }, 3163bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 31641da177e4SLinus Torvalds { 31651da177e4SLinus Torvalds .procname = "leases-enable", 31661da177e4SLinus Torvalds .data = &leases_enable, 31671da177e4SLinus Torvalds .maxlen = sizeof(int), 31681da177e4SLinus Torvalds .mode = 0644, 31696d456111SEric W. Biederman .proc_handler = proc_dointvec, 31701da177e4SLinus Torvalds }, 3171bfcd17a6SThomas Petazzoni #endif 31721da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 31731da177e4SLinus Torvalds { 31741da177e4SLinus Torvalds .procname = "dir-notify-enable", 31751da177e4SLinus Torvalds .data = &dir_notify_enable, 31761da177e4SLinus Torvalds .maxlen = sizeof(int), 31771da177e4SLinus Torvalds .mode = 0644, 31786d456111SEric W. Biederman .proc_handler = proc_dointvec, 31791da177e4SLinus Torvalds }, 31801da177e4SLinus Torvalds #endif 31811da177e4SLinus Torvalds #ifdef CONFIG_MMU 3182bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 31831da177e4SLinus Torvalds { 31841da177e4SLinus Torvalds .procname = "lease-break-time", 31851da177e4SLinus Torvalds .data = &lease_break_time, 31861da177e4SLinus Torvalds .maxlen = sizeof(int), 31871da177e4SLinus Torvalds .mode = 0644, 31886d456111SEric W. Biederman .proc_handler = proc_dointvec, 31891da177e4SLinus Torvalds }, 3190bfcd17a6SThomas Petazzoni #endif 3191ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 31921da177e4SLinus Torvalds { 31931da177e4SLinus Torvalds .procname = "aio-nr", 31941da177e4SLinus Torvalds .data = &aio_nr, 31951da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 31961da177e4SLinus Torvalds .mode = 0444, 31976d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 31981da177e4SLinus Torvalds }, 31991da177e4SLinus Torvalds { 32001da177e4SLinus Torvalds .procname = "aio-max-nr", 32011da177e4SLinus Torvalds .data = &aio_max_nr, 32021da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 32031da177e4SLinus Torvalds .mode = 0644, 32046d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 32051da177e4SLinus Torvalds }, 3206ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 32072d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 32080399cb08SRobert Love { 32090399cb08SRobert Love .procname = "inotify", 32100399cb08SRobert Love .mode = 0555, 32110399cb08SRobert Love .child = inotify_table, 32120399cb08SRobert Love }, 32130399cb08SRobert Love #endif 32147ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 32157ef9964eSDavide Libenzi { 32167ef9964eSDavide Libenzi .procname = "epoll", 32177ef9964eSDavide Libenzi .mode = 0555, 32187ef9964eSDavide Libenzi .child = epoll_table, 32197ef9964eSDavide Libenzi }, 32207ef9964eSDavide Libenzi #endif 32211da177e4SLinus Torvalds #endif 3222d6e71144SAlan Cox { 3223800179c9SKees Cook .procname = "protected_symlinks", 3224800179c9SKees Cook .data = &sysctl_protected_symlinks, 3225800179c9SKees Cook .maxlen = sizeof(int), 3226800179c9SKees Cook .mode = 0600, 3227800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3228eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3229eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3230800179c9SKees Cook }, 3231800179c9SKees Cook { 3232800179c9SKees Cook .procname = "protected_hardlinks", 3233800179c9SKees Cook .data = &sysctl_protected_hardlinks, 3234800179c9SKees Cook .maxlen = sizeof(int), 3235800179c9SKees Cook .mode = 0600, 3236800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3237eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3238eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3239800179c9SKees Cook }, 3240800179c9SKees Cook { 324130aba665SSalvatore Mesoraca .procname = "protected_fifos", 324230aba665SSalvatore Mesoraca .data = &sysctl_protected_fifos, 324330aba665SSalvatore Mesoraca .maxlen = sizeof(int), 324430aba665SSalvatore Mesoraca .mode = 0600, 324530aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3246eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 324730aba665SSalvatore Mesoraca .extra2 = &two, 324830aba665SSalvatore Mesoraca }, 324930aba665SSalvatore Mesoraca { 325030aba665SSalvatore Mesoraca .procname = "protected_regular", 325130aba665SSalvatore Mesoraca .data = &sysctl_protected_regular, 325230aba665SSalvatore Mesoraca .maxlen = sizeof(int), 325330aba665SSalvatore Mesoraca .mode = 0600, 325430aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3255eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 325630aba665SSalvatore Mesoraca .extra2 = &two, 325730aba665SSalvatore Mesoraca }, 325830aba665SSalvatore Mesoraca { 3259d6e71144SAlan Cox .procname = "suid_dumpable", 3260d6e71144SAlan Cox .data = &suid_dumpable, 3261d6e71144SAlan Cox .maxlen = sizeof(int), 3262d6e71144SAlan Cox .mode = 0644, 326354b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 3264eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 32658e654fbaSMatthew Wilcox .extra2 = &two, 3266d6e71144SAlan Cox }, 32672abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 32682abc26fcSEric W. Biederman { 32692abc26fcSEric W. Biederman .procname = "binfmt_misc", 32702abc26fcSEric W. Biederman .mode = 0555, 3271f9bd6733SEric W. Biederman .child = sysctl_mount_point, 32722abc26fcSEric W. Biederman }, 32732abc26fcSEric W. Biederman #endif 3274b492e95bSJens Axboe { 3275ff9da691SJens Axboe .procname = "pipe-max-size", 3276ff9da691SJens Axboe .data = &pipe_max_size, 327798159d97SJoe Lawrence .maxlen = sizeof(pipe_max_size), 3278b492e95bSJens Axboe .mode = 0644, 3279319e0a21SEric Biggers .proc_handler = proc_dopipe_max_size, 3280b492e95bSJens Axboe }, 3281759c0114SWilly Tarreau { 3282759c0114SWilly Tarreau .procname = "pipe-user-pages-hard", 3283759c0114SWilly Tarreau .data = &pipe_user_pages_hard, 3284759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_hard), 3285759c0114SWilly Tarreau .mode = 0644, 3286759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3287759c0114SWilly Tarreau }, 3288759c0114SWilly Tarreau { 3289759c0114SWilly Tarreau .procname = "pipe-user-pages-soft", 3290759c0114SWilly Tarreau .data = &pipe_user_pages_soft, 3291759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_soft), 3292759c0114SWilly Tarreau .mode = 0644, 3293759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3294759c0114SWilly Tarreau }, 3295d2921684SEric W. Biederman { 3296d2921684SEric W. Biederman .procname = "mount-max", 3297d2921684SEric W. Biederman .data = &sysctl_mount_max, 3298d2921684SEric W. Biederman .maxlen = sizeof(unsigned int), 3299d2921684SEric W. Biederman .mode = 0644, 3300d2921684SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3301eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 3302d2921684SEric W. Biederman }, 33036fce56ecSEric W. Biederman { } 33041da177e4SLinus Torvalds }; 33051da177e4SLinus Torvalds 3306d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 33077ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 3308abd4f750SMasoud Asgharifard Sharbiani { 3309abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 3310abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 3311abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 3312abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 3313abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 3314abd4f750SMasoud Asgharifard Sharbiani }, 3315abd4f750SMasoud Asgharifard Sharbiani #endif 3316b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 3317b2be84dfSMasami Hiramatsu { 3318b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 3319b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 3320b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 3321b2be84dfSMasami Hiramatsu .mode = 0644, 3322b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 3323eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3324eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3325b2be84dfSMasami Hiramatsu }, 3326b2be84dfSMasami Hiramatsu #endif 33276fce56ecSEric W. Biederman { } 33281da177e4SLinus Torvalds }; 33291da177e4SLinus Torvalds 3330d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 33316fce56ecSEric W. Biederman { } 33321da177e4SLinus Torvalds }; 33331da177e4SLinus Torvalds 3334f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = { 3335f461d2dcSChristoph Hellwig { 3336f461d2dcSChristoph Hellwig .procname = "kernel", 3337f461d2dcSChristoph Hellwig .mode = 0555, 3338f461d2dcSChristoph Hellwig .child = kern_table, 3339f461d2dcSChristoph Hellwig }, 3340f461d2dcSChristoph Hellwig { 3341f461d2dcSChristoph Hellwig .procname = "vm", 3342f461d2dcSChristoph Hellwig .mode = 0555, 3343f461d2dcSChristoph Hellwig .child = vm_table, 3344f461d2dcSChristoph Hellwig }, 3345f461d2dcSChristoph Hellwig { 3346f461d2dcSChristoph Hellwig .procname = "fs", 3347f461d2dcSChristoph Hellwig .mode = 0555, 3348f461d2dcSChristoph Hellwig .child = fs_table, 3349f461d2dcSChristoph Hellwig }, 3350f461d2dcSChristoph Hellwig { 3351f461d2dcSChristoph Hellwig .procname = "debug", 3352f461d2dcSChristoph Hellwig .mode = 0555, 3353f461d2dcSChristoph Hellwig .child = debug_table, 3354f461d2dcSChristoph Hellwig }, 3355f461d2dcSChristoph Hellwig { 3356f461d2dcSChristoph Hellwig .procname = "dev", 3357f461d2dcSChristoph Hellwig .mode = 0555, 3358f461d2dcSChristoph Hellwig .child = dev_table, 3359f461d2dcSChristoph Hellwig }, 3360f461d2dcSChristoph Hellwig { } 3361f461d2dcSChristoph Hellwig }; 3362f461d2dcSChristoph Hellwig 3363de4e83bdSEric W. Biederman int __init sysctl_init(void) 3364330d57fbSAl Viro { 3365fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 3366fd4b616bSSteven Rostedt 3367fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 3368fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 3369330d57fbSAl Viro return 0; 3370f7e6ced4SAl Viro } 3371b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 33721da177e4SLinus Torvalds /* 33731da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 33741da177e4SLinus Torvalds * exception granted :-) 33751da177e4SLinus Torvalds */ 33761da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 3377e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec); 33781da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 33791da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 338061d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 33811da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 33821da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 33831da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 33841da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 33851da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 33860bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap); 3387