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, 2077787b6fcSTobias Klauser void *buffer, size_t *lenp, loff_t *ppos) 208d46edd67SSong Liu { 209d46edd67SSong Liu struct static_key *key = (struct static_key *)table->data; 210d46edd67SSong Liu static int saved_val; 211d46edd67SSong Liu int val, ret; 212d46edd67SSong Liu struct ctl_table tmp = { 213d46edd67SSong Liu .data = &val, 214d46edd67SSong Liu .maxlen = sizeof(val), 215d46edd67SSong Liu .mode = table->mode, 216d46edd67SSong Liu .extra1 = SYSCTL_ZERO, 217d46edd67SSong Liu .extra2 = SYSCTL_ONE, 218d46edd67SSong Liu }; 219d46edd67SSong Liu 220d46edd67SSong Liu if (write && !capable(CAP_SYS_ADMIN)) 221d46edd67SSong Liu return -EPERM; 222d46edd67SSong Liu 223d46edd67SSong Liu mutex_lock(&bpf_stats_enabled_mutex); 224d46edd67SSong Liu val = saved_val; 225d46edd67SSong Liu ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 226d46edd67SSong Liu if (write && !ret && val != saved_val) { 227d46edd67SSong Liu if (val) 228d46edd67SSong Liu static_key_slow_inc(key); 229d46edd67SSong Liu else 230d46edd67SSong Liu static_key_slow_dec(key); 231d46edd67SSong Liu saved_val = val; 232d46edd67SSong Liu } 233d46edd67SSong Liu mutex_unlock(&bpf_stats_enabled_mutex); 234d46edd67SSong Liu return ret; 235d46edd67SSong Liu } 236d46edd67SSong Liu #endif 237d46edd67SSong Liu 238f461d2dcSChristoph Hellwig /* 239f461d2dcSChristoph Hellwig * /proc/sys support 240f461d2dcSChristoph Hellwig */ 241f461d2dcSChristoph Hellwig 242f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL 243f461d2dcSChristoph Hellwig 244f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write, 24532927393SChristoph Hellwig char *buffer, size_t *lenp, loff_t *ppos) 246f461d2dcSChristoph Hellwig { 247f461d2dcSChristoph Hellwig size_t len; 24832927393SChristoph Hellwig char c, *p; 249f461d2dcSChristoph Hellwig 250f461d2dcSChristoph Hellwig if (!data || !maxlen || !*lenp) { 251f461d2dcSChristoph Hellwig *lenp = 0; 252f461d2dcSChristoph Hellwig return 0; 253f461d2dcSChristoph Hellwig } 254f461d2dcSChristoph Hellwig 255f461d2dcSChristoph Hellwig if (write) { 256f461d2dcSChristoph Hellwig if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) { 257f461d2dcSChristoph Hellwig /* Only continue writes not past the end of buffer. */ 258f461d2dcSChristoph Hellwig len = strlen(data); 259f461d2dcSChristoph Hellwig if (len > maxlen - 1) 260f461d2dcSChristoph Hellwig len = maxlen - 1; 261f461d2dcSChristoph Hellwig 262f461d2dcSChristoph Hellwig if (*ppos > len) 263f461d2dcSChristoph Hellwig return 0; 264f461d2dcSChristoph Hellwig len = *ppos; 265f461d2dcSChristoph Hellwig } else { 266f461d2dcSChristoph Hellwig /* Start writing from beginning of buffer. */ 267f461d2dcSChristoph Hellwig len = 0; 268f461d2dcSChristoph Hellwig } 269f461d2dcSChristoph Hellwig 270f461d2dcSChristoph Hellwig *ppos += *lenp; 271f461d2dcSChristoph Hellwig p = buffer; 272f461d2dcSChristoph Hellwig while ((p - buffer) < *lenp && len < maxlen - 1) { 27332927393SChristoph Hellwig c = *(p++); 274f461d2dcSChristoph Hellwig if (c == 0 || c == '\n') 275f461d2dcSChristoph Hellwig break; 276f461d2dcSChristoph Hellwig data[len++] = c; 277f461d2dcSChristoph Hellwig } 278f461d2dcSChristoph Hellwig data[len] = 0; 279f461d2dcSChristoph Hellwig } else { 280f461d2dcSChristoph Hellwig len = strlen(data); 281f461d2dcSChristoph Hellwig if (len > maxlen) 282f461d2dcSChristoph Hellwig len = maxlen; 283f461d2dcSChristoph Hellwig 284f461d2dcSChristoph Hellwig if (*ppos > len) { 285f461d2dcSChristoph Hellwig *lenp = 0; 286f461d2dcSChristoph Hellwig return 0; 287f461d2dcSChristoph Hellwig } 288f461d2dcSChristoph Hellwig 289f461d2dcSChristoph Hellwig data += *ppos; 290f461d2dcSChristoph Hellwig len -= *ppos; 291f461d2dcSChristoph Hellwig 292f461d2dcSChristoph Hellwig if (len > *lenp) 293f461d2dcSChristoph Hellwig len = *lenp; 294f461d2dcSChristoph Hellwig if (len) 29532927393SChristoph Hellwig memcpy(buffer, data, len); 296f461d2dcSChristoph Hellwig if (len < *lenp) { 29732927393SChristoph Hellwig buffer[len] = '\n'; 298f461d2dcSChristoph Hellwig len++; 299f461d2dcSChristoph Hellwig } 300f461d2dcSChristoph Hellwig *lenp = len; 301f461d2dcSChristoph Hellwig *ppos += len; 302f461d2dcSChristoph Hellwig } 303f461d2dcSChristoph Hellwig return 0; 304f461d2dcSChristoph Hellwig } 305f461d2dcSChristoph Hellwig 306f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table) 307f461d2dcSChristoph Hellwig { 308f461d2dcSChristoph Hellwig pr_warn_once("%s wrote to %s when file position was not 0!\n" 309f461d2dcSChristoph Hellwig "This will not be supported in the future. To silence this\n" 310f461d2dcSChristoph Hellwig "warning, set kernel.sysctl_writes_strict = -1\n", 311f461d2dcSChristoph Hellwig current->comm, table->procname); 312f461d2dcSChristoph Hellwig } 313f461d2dcSChristoph Hellwig 314f461d2dcSChristoph Hellwig /** 315f461d2dcSChristoph Hellwig * proc_first_pos_non_zero_ignore - check if first position is allowed 316f461d2dcSChristoph Hellwig * @ppos: file position 317f461d2dcSChristoph Hellwig * @table: the sysctl table 318f461d2dcSChristoph Hellwig * 319f461d2dcSChristoph Hellwig * Returns true if the first position is non-zero and the sysctl_writes_strict 320f461d2dcSChristoph Hellwig * mode indicates this is not allowed for numeric input types. String proc 321f461d2dcSChristoph Hellwig * handlers can ignore the return value. 322f461d2dcSChristoph Hellwig */ 323f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos, 324f461d2dcSChristoph Hellwig struct ctl_table *table) 325f461d2dcSChristoph Hellwig { 326f461d2dcSChristoph Hellwig if (!*ppos) 327f461d2dcSChristoph Hellwig return false; 328f461d2dcSChristoph Hellwig 329f461d2dcSChristoph Hellwig switch (sysctl_writes_strict) { 330f461d2dcSChristoph Hellwig case SYSCTL_WRITES_STRICT: 331f461d2dcSChristoph Hellwig return true; 332f461d2dcSChristoph Hellwig case SYSCTL_WRITES_WARN: 333f461d2dcSChristoph Hellwig warn_sysctl_write(table); 334f461d2dcSChristoph Hellwig return false; 335f461d2dcSChristoph Hellwig default: 336f461d2dcSChristoph Hellwig return false; 337f461d2dcSChristoph Hellwig } 338f461d2dcSChristoph Hellwig } 339f461d2dcSChristoph Hellwig 340f461d2dcSChristoph Hellwig /** 341f461d2dcSChristoph Hellwig * proc_dostring - read a string sysctl 342f461d2dcSChristoph Hellwig * @table: the sysctl table 343f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 344f461d2dcSChristoph Hellwig * @buffer: the user buffer 345f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 346f461d2dcSChristoph Hellwig * @ppos: file position 347f461d2dcSChristoph Hellwig * 348f461d2dcSChristoph Hellwig * Reads/writes a string from/to the user buffer. If the kernel 349f461d2dcSChristoph Hellwig * buffer provided is not large enough to hold the string, the 350f461d2dcSChristoph Hellwig * string is truncated. The copied string is %NULL-terminated. 351f461d2dcSChristoph Hellwig * If the string is being read by the user process, it is copied 352f461d2dcSChristoph Hellwig * and a newline '\n' is added. It is truncated if the buffer is 353f461d2dcSChristoph Hellwig * not large enough. 354f461d2dcSChristoph Hellwig * 355f461d2dcSChristoph Hellwig * Returns 0 on success. 356f461d2dcSChristoph Hellwig */ 357f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 35832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 359f461d2dcSChristoph Hellwig { 360f461d2dcSChristoph Hellwig if (write) 361f461d2dcSChristoph Hellwig proc_first_pos_non_zero_ignore(ppos, table); 362f461d2dcSChristoph Hellwig 36332927393SChristoph Hellwig return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, 36432927393SChristoph Hellwig ppos); 365f461d2dcSChristoph Hellwig } 366f461d2dcSChristoph Hellwig 367f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf) 368f461d2dcSChristoph Hellwig { 369f461d2dcSChristoph Hellwig size_t ret; 370f461d2dcSChristoph Hellwig char *tmp = skip_spaces(*buf); 371f461d2dcSChristoph Hellwig ret = tmp - *buf; 372f461d2dcSChristoph Hellwig *buf = tmp; 373f461d2dcSChristoph Hellwig return ret; 374f461d2dcSChristoph Hellwig } 375f461d2dcSChristoph Hellwig 376f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v) 377f461d2dcSChristoph Hellwig { 378f461d2dcSChristoph Hellwig while (*size) { 379f461d2dcSChristoph Hellwig if (**buf != v) 380f461d2dcSChristoph Hellwig break; 381f461d2dcSChristoph Hellwig (*size)--; 382f461d2dcSChristoph Hellwig (*buf)++; 383f461d2dcSChristoph Hellwig } 384f461d2dcSChristoph Hellwig } 385f461d2dcSChristoph Hellwig 386f461d2dcSChristoph Hellwig /** 387f461d2dcSChristoph Hellwig * strtoul_lenient - parse an ASCII formatted integer from a buffer and only 388f461d2dcSChristoph Hellwig * fail on overflow 389f461d2dcSChristoph Hellwig * 390f461d2dcSChristoph Hellwig * @cp: kernel buffer containing the string to parse 391f461d2dcSChristoph Hellwig * @endp: pointer to store the trailing characters 392f461d2dcSChristoph Hellwig * @base: the base to use 393f461d2dcSChristoph Hellwig * @res: where the parsed integer will be stored 394f461d2dcSChristoph Hellwig * 395f461d2dcSChristoph Hellwig * In case of success 0 is returned and @res will contain the parsed integer, 396f461d2dcSChristoph Hellwig * @endp will hold any trailing characters. 397f461d2dcSChristoph Hellwig * This function will fail the parse on overflow. If there wasn't an overflow 398f461d2dcSChristoph Hellwig * the function will defer the decision what characters count as invalid to the 399f461d2dcSChristoph Hellwig * caller. 400f461d2dcSChristoph Hellwig */ 401f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base, 402f461d2dcSChristoph Hellwig unsigned long *res) 403f461d2dcSChristoph Hellwig { 404f461d2dcSChristoph Hellwig unsigned long long result; 405f461d2dcSChristoph Hellwig unsigned int rv; 406f461d2dcSChristoph Hellwig 407f461d2dcSChristoph Hellwig cp = _parse_integer_fixup_radix(cp, &base); 408f461d2dcSChristoph Hellwig rv = _parse_integer(cp, base, &result); 409f461d2dcSChristoph Hellwig if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result)) 410f461d2dcSChristoph Hellwig return -ERANGE; 411f461d2dcSChristoph Hellwig 412f461d2dcSChristoph Hellwig cp += rv; 413f461d2dcSChristoph Hellwig 414f461d2dcSChristoph Hellwig if (endp) 415f461d2dcSChristoph Hellwig *endp = (char *)cp; 416f461d2dcSChristoph Hellwig 417f461d2dcSChristoph Hellwig *res = (unsigned long)result; 418f461d2dcSChristoph Hellwig return 0; 419f461d2dcSChristoph Hellwig } 420f461d2dcSChristoph Hellwig 421f461d2dcSChristoph Hellwig #define TMPBUFLEN 22 422f461d2dcSChristoph Hellwig /** 423f461d2dcSChristoph Hellwig * proc_get_long - reads an ASCII formatted integer from a user buffer 424f461d2dcSChristoph Hellwig * 425f461d2dcSChristoph Hellwig * @buf: a kernel buffer 426f461d2dcSChristoph Hellwig * @size: size of the kernel buffer 427f461d2dcSChristoph Hellwig * @val: this is where the number will be stored 428f461d2dcSChristoph Hellwig * @neg: set to %TRUE if number is negative 429f461d2dcSChristoph Hellwig * @perm_tr: a vector which contains the allowed trailers 430f461d2dcSChristoph Hellwig * @perm_tr_len: size of the perm_tr vector 431f461d2dcSChristoph Hellwig * @tr: pointer to store the trailer character 432f461d2dcSChristoph Hellwig * 433f461d2dcSChristoph Hellwig * In case of success %0 is returned and @buf and @size are updated with 434f461d2dcSChristoph Hellwig * the amount of bytes read. If @tr is non-NULL and a trailing 435f461d2dcSChristoph Hellwig * character exists (size is non-zero after returning from this 436f461d2dcSChristoph Hellwig * function), @tr is updated with the trailing character. 437f461d2dcSChristoph Hellwig */ 438f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size, 439f461d2dcSChristoph Hellwig unsigned long *val, bool *neg, 440f461d2dcSChristoph Hellwig const char *perm_tr, unsigned perm_tr_len, char *tr) 441f461d2dcSChristoph Hellwig { 442f461d2dcSChristoph Hellwig int len; 443f461d2dcSChristoph Hellwig char *p, tmp[TMPBUFLEN]; 444f461d2dcSChristoph Hellwig 445f461d2dcSChristoph Hellwig if (!*size) 446f461d2dcSChristoph Hellwig return -EINVAL; 447f461d2dcSChristoph Hellwig 448f461d2dcSChristoph Hellwig len = *size; 449f461d2dcSChristoph Hellwig if (len > TMPBUFLEN - 1) 450f461d2dcSChristoph Hellwig len = TMPBUFLEN - 1; 451f461d2dcSChristoph Hellwig 452f461d2dcSChristoph Hellwig memcpy(tmp, *buf, len); 453f461d2dcSChristoph Hellwig 454f461d2dcSChristoph Hellwig tmp[len] = 0; 455f461d2dcSChristoph Hellwig p = tmp; 456f461d2dcSChristoph Hellwig if (*p == '-' && *size > 1) { 457f461d2dcSChristoph Hellwig *neg = true; 458f461d2dcSChristoph Hellwig p++; 459f461d2dcSChristoph Hellwig } else 460f461d2dcSChristoph Hellwig *neg = false; 461f461d2dcSChristoph Hellwig if (!isdigit(*p)) 462f461d2dcSChristoph Hellwig return -EINVAL; 463f461d2dcSChristoph Hellwig 464f461d2dcSChristoph Hellwig if (strtoul_lenient(p, &p, 0, val)) 465f461d2dcSChristoph Hellwig return -EINVAL; 466f461d2dcSChristoph Hellwig 467f461d2dcSChristoph Hellwig len = p - tmp; 468f461d2dcSChristoph Hellwig 469f461d2dcSChristoph Hellwig /* We don't know if the next char is whitespace thus we may accept 470f461d2dcSChristoph Hellwig * invalid integers (e.g. 1234...a) or two integers instead of one 471f461d2dcSChristoph Hellwig * (e.g. 123...1). So lets not allow such large numbers. */ 472f461d2dcSChristoph Hellwig if (len == TMPBUFLEN - 1) 473f461d2dcSChristoph Hellwig return -EINVAL; 474f461d2dcSChristoph Hellwig 475f461d2dcSChristoph Hellwig if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 476f461d2dcSChristoph Hellwig return -EINVAL; 477f461d2dcSChristoph Hellwig 478f461d2dcSChristoph Hellwig if (tr && (len < *size)) 479f461d2dcSChristoph Hellwig *tr = *p; 480f461d2dcSChristoph Hellwig 481f461d2dcSChristoph Hellwig *buf += len; 482f461d2dcSChristoph Hellwig *size -= len; 483f461d2dcSChristoph Hellwig 484f461d2dcSChristoph Hellwig return 0; 485f461d2dcSChristoph Hellwig } 486f461d2dcSChristoph Hellwig 487f461d2dcSChristoph Hellwig /** 488f461d2dcSChristoph Hellwig * proc_put_long - converts an integer to a decimal ASCII formatted string 489f461d2dcSChristoph Hellwig * 490f461d2dcSChristoph Hellwig * @buf: the user buffer 491f461d2dcSChristoph Hellwig * @size: the size of the user buffer 492f461d2dcSChristoph Hellwig * @val: the integer to be converted 493f461d2dcSChristoph Hellwig * @neg: sign of the number, %TRUE for negative 494f461d2dcSChristoph Hellwig * 49532927393SChristoph Hellwig * In case of success @buf and @size are updated with the amount of bytes 49632927393SChristoph Hellwig * written. 497f461d2dcSChristoph Hellwig */ 49832927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg) 499f461d2dcSChristoph Hellwig { 500f461d2dcSChristoph Hellwig int len; 501f461d2dcSChristoph Hellwig char tmp[TMPBUFLEN], *p = tmp; 502f461d2dcSChristoph Hellwig 503f461d2dcSChristoph Hellwig sprintf(p, "%s%lu", neg ? "-" : "", val); 504f461d2dcSChristoph Hellwig len = strlen(tmp); 505f461d2dcSChristoph Hellwig if (len > *size) 506f461d2dcSChristoph Hellwig len = *size; 50732927393SChristoph Hellwig memcpy(*buf, tmp, len); 508f461d2dcSChristoph Hellwig *size -= len; 509f461d2dcSChristoph Hellwig *buf += len; 510f461d2dcSChristoph Hellwig } 511f461d2dcSChristoph Hellwig #undef TMPBUFLEN 512f461d2dcSChristoph Hellwig 51332927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c) 514f461d2dcSChristoph Hellwig { 515f461d2dcSChristoph Hellwig if (*size) { 51632927393SChristoph Hellwig char **buffer = (char **)buf; 51732927393SChristoph Hellwig **buffer = c; 51832927393SChristoph Hellwig 51932927393SChristoph Hellwig (*size)--; 52032927393SChristoph Hellwig (*buffer)++; 521f461d2dcSChristoph Hellwig *buf = *buffer; 522f461d2dcSChristoph Hellwig } 523f461d2dcSChristoph Hellwig } 524f461d2dcSChristoph Hellwig 525f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 526f461d2dcSChristoph Hellwig int *valp, 527f461d2dcSChristoph Hellwig int write, void *data) 528f461d2dcSChristoph Hellwig { 529f461d2dcSChristoph Hellwig if (write) { 530f461d2dcSChristoph Hellwig if (*negp) { 531f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX + 1) 532f461d2dcSChristoph Hellwig return -EINVAL; 533f461d2dcSChristoph Hellwig *valp = -*lvalp; 534f461d2dcSChristoph Hellwig } else { 535f461d2dcSChristoph Hellwig if (*lvalp > (unsigned long) INT_MAX) 536f461d2dcSChristoph Hellwig return -EINVAL; 537f461d2dcSChristoph Hellwig *valp = *lvalp; 538f461d2dcSChristoph Hellwig } 539f461d2dcSChristoph Hellwig } else { 540f461d2dcSChristoph Hellwig int val = *valp; 541f461d2dcSChristoph Hellwig if (val < 0) { 542f461d2dcSChristoph Hellwig *negp = true; 543f461d2dcSChristoph Hellwig *lvalp = -(unsigned long)val; 544f461d2dcSChristoph Hellwig } else { 545f461d2dcSChristoph Hellwig *negp = false; 546f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 547f461d2dcSChristoph Hellwig } 548f461d2dcSChristoph Hellwig } 549f461d2dcSChristoph Hellwig return 0; 550f461d2dcSChristoph Hellwig } 551f461d2dcSChristoph Hellwig 552f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp, 553f461d2dcSChristoph Hellwig unsigned int *valp, 554f461d2dcSChristoph Hellwig int write, void *data) 555f461d2dcSChristoph Hellwig { 556f461d2dcSChristoph Hellwig if (write) { 557f461d2dcSChristoph Hellwig if (*lvalp > UINT_MAX) 558f461d2dcSChristoph Hellwig return -EINVAL; 559f461d2dcSChristoph Hellwig *valp = *lvalp; 560f461d2dcSChristoph Hellwig } else { 561f461d2dcSChristoph Hellwig unsigned int val = *valp; 562f461d2dcSChristoph Hellwig *lvalp = (unsigned long)val; 563f461d2dcSChristoph Hellwig } 564f461d2dcSChristoph Hellwig return 0; 565f461d2dcSChristoph Hellwig } 566f461d2dcSChristoph Hellwig 567f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 568f461d2dcSChristoph Hellwig 569f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 57032927393SChristoph Hellwig int write, void *buffer, 571f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 572f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 573f461d2dcSChristoph Hellwig int write, void *data), 574f461d2dcSChristoph Hellwig void *data) 575f461d2dcSChristoph Hellwig { 576f461d2dcSChristoph Hellwig int *i, vleft, first = 1, err = 0; 577f461d2dcSChristoph Hellwig size_t left; 57832927393SChristoph Hellwig char *p; 579f461d2dcSChristoph Hellwig 580f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 581f461d2dcSChristoph Hellwig *lenp = 0; 582f461d2dcSChristoph Hellwig return 0; 583f461d2dcSChristoph Hellwig } 584f461d2dcSChristoph Hellwig 585f461d2dcSChristoph Hellwig i = (int *) tbl_data; 586f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 587f461d2dcSChristoph Hellwig left = *lenp; 588f461d2dcSChristoph Hellwig 589f461d2dcSChristoph Hellwig if (!conv) 590f461d2dcSChristoph Hellwig conv = do_proc_dointvec_conv; 591f461d2dcSChristoph Hellwig 592f461d2dcSChristoph Hellwig if (write) { 593f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 594f461d2dcSChristoph Hellwig goto out; 595f461d2dcSChristoph Hellwig 596f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 597f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 59832927393SChristoph Hellwig p = buffer; 599f461d2dcSChristoph Hellwig } 600f461d2dcSChristoph Hellwig 601f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first=0) { 602f461d2dcSChristoph Hellwig unsigned long lval; 603f461d2dcSChristoph Hellwig bool neg; 604f461d2dcSChristoph Hellwig 605f461d2dcSChristoph Hellwig if (write) { 606f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 607f461d2dcSChristoph Hellwig 608f461d2dcSChristoph Hellwig if (!left) 609f461d2dcSChristoph Hellwig break; 610f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 611f461d2dcSChristoph Hellwig proc_wspace_sep, 612f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 613f461d2dcSChristoph Hellwig if (err) 614f461d2dcSChristoph Hellwig break; 615f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 1, data)) { 616f461d2dcSChristoph Hellwig err = -EINVAL; 617f461d2dcSChristoph Hellwig break; 618f461d2dcSChristoph Hellwig } 619f461d2dcSChristoph Hellwig } else { 620f461d2dcSChristoph Hellwig if (conv(&neg, &lval, i, 0, data)) { 621f461d2dcSChristoph Hellwig err = -EINVAL; 622f461d2dcSChristoph Hellwig break; 623f461d2dcSChristoph Hellwig } 624f461d2dcSChristoph Hellwig if (!first) 62532927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 62632927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, neg); 627f461d2dcSChristoph Hellwig } 628f461d2dcSChristoph Hellwig } 629f461d2dcSChristoph Hellwig 630f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 63132927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 632f461d2dcSChristoph Hellwig if (write && !err && left) 633f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 63432927393SChristoph Hellwig if (write && first) 635f461d2dcSChristoph Hellwig return err ? : -EINVAL; 636f461d2dcSChristoph Hellwig *lenp -= left; 637f461d2dcSChristoph Hellwig out: 638f461d2dcSChristoph Hellwig *ppos += *lenp; 639f461d2dcSChristoph Hellwig return err; 640f461d2dcSChristoph Hellwig } 641f461d2dcSChristoph Hellwig 642f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write, 64332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 644f461d2dcSChristoph Hellwig int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 645f461d2dcSChristoph Hellwig int write, void *data), 646f461d2dcSChristoph Hellwig void *data) 647f461d2dcSChristoph Hellwig { 648f461d2dcSChristoph Hellwig return __do_proc_dointvec(table->data, table, write, 649f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 650f461d2dcSChristoph Hellwig } 651f461d2dcSChristoph Hellwig 652f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data, 653f461d2dcSChristoph Hellwig struct ctl_table *table, 65432927393SChristoph Hellwig void *buffer, 655f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 656f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 657f461d2dcSChristoph Hellwig unsigned int *valp, 658f461d2dcSChristoph Hellwig int write, void *data), 659f461d2dcSChristoph Hellwig void *data) 660f461d2dcSChristoph Hellwig { 661f461d2dcSChristoph Hellwig unsigned long lval; 662f461d2dcSChristoph Hellwig int err = 0; 663f461d2dcSChristoph Hellwig size_t left; 664f461d2dcSChristoph Hellwig bool neg; 66532927393SChristoph Hellwig char *p = buffer; 666f461d2dcSChristoph Hellwig 667f461d2dcSChristoph Hellwig left = *lenp; 668f461d2dcSChristoph Hellwig 669f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 670f461d2dcSChristoph Hellwig goto bail_early; 671f461d2dcSChristoph Hellwig 672f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 673f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 674f461d2dcSChristoph Hellwig 675f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 676f461d2dcSChristoph Hellwig if (!left) { 677f461d2dcSChristoph Hellwig err = -EINVAL; 678f461d2dcSChristoph Hellwig goto out_free; 679f461d2dcSChristoph Hellwig } 680f461d2dcSChristoph Hellwig 681f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &lval, &neg, 682f461d2dcSChristoph Hellwig proc_wspace_sep, 683f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 684f461d2dcSChristoph Hellwig if (err || neg) { 685f461d2dcSChristoph Hellwig err = -EINVAL; 686f461d2dcSChristoph Hellwig goto out_free; 687f461d2dcSChristoph Hellwig } 688f461d2dcSChristoph Hellwig 689f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 1, data)) { 690f461d2dcSChristoph Hellwig err = -EINVAL; 691f461d2dcSChristoph Hellwig goto out_free; 692f461d2dcSChristoph Hellwig } 693f461d2dcSChristoph Hellwig 694f461d2dcSChristoph Hellwig if (!err && left) 695f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 696f461d2dcSChristoph Hellwig 697f461d2dcSChristoph Hellwig out_free: 698f461d2dcSChristoph Hellwig if (err) 699f461d2dcSChristoph Hellwig return -EINVAL; 700f461d2dcSChristoph Hellwig 701f461d2dcSChristoph Hellwig return 0; 702f461d2dcSChristoph Hellwig 703f461d2dcSChristoph Hellwig /* This is in keeping with old __do_proc_dointvec() */ 704f461d2dcSChristoph Hellwig bail_early: 705f461d2dcSChristoph Hellwig *ppos += *lenp; 706f461d2dcSChristoph Hellwig return err; 707f461d2dcSChristoph Hellwig } 708f461d2dcSChristoph Hellwig 70932927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, 710f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 711f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 712f461d2dcSChristoph Hellwig unsigned int *valp, 713f461d2dcSChristoph Hellwig int write, void *data), 714f461d2dcSChristoph Hellwig void *data) 715f461d2dcSChristoph Hellwig { 716f461d2dcSChristoph Hellwig unsigned long lval; 717f461d2dcSChristoph Hellwig int err = 0; 718f461d2dcSChristoph Hellwig size_t left; 719f461d2dcSChristoph Hellwig 720f461d2dcSChristoph Hellwig left = *lenp; 721f461d2dcSChristoph Hellwig 722f461d2dcSChristoph Hellwig if (conv(&lval, tbl_data, 0, data)) { 723f461d2dcSChristoph Hellwig err = -EINVAL; 724f461d2dcSChristoph Hellwig goto out; 725f461d2dcSChristoph Hellwig } 726f461d2dcSChristoph Hellwig 72732927393SChristoph Hellwig proc_put_long(&buffer, &left, lval, false); 72832927393SChristoph Hellwig if (!left) 729f461d2dcSChristoph Hellwig goto out; 730f461d2dcSChristoph Hellwig 73132927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 732f461d2dcSChristoph Hellwig 733f461d2dcSChristoph Hellwig out: 734f461d2dcSChristoph Hellwig *lenp -= left; 735f461d2dcSChristoph Hellwig *ppos += *lenp; 736f461d2dcSChristoph Hellwig 737f461d2dcSChristoph Hellwig return err; 738f461d2dcSChristoph Hellwig } 739f461d2dcSChristoph Hellwig 740f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, 74132927393SChristoph Hellwig int write, void *buffer, 742f461d2dcSChristoph Hellwig size_t *lenp, loff_t *ppos, 743f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 744f461d2dcSChristoph Hellwig unsigned int *valp, 745f461d2dcSChristoph Hellwig int write, void *data), 746f461d2dcSChristoph Hellwig void *data) 747f461d2dcSChristoph Hellwig { 748f461d2dcSChristoph Hellwig unsigned int *i, vleft; 749f461d2dcSChristoph Hellwig 750f461d2dcSChristoph Hellwig if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 751f461d2dcSChristoph Hellwig *lenp = 0; 752f461d2dcSChristoph Hellwig return 0; 753f461d2dcSChristoph Hellwig } 754f461d2dcSChristoph Hellwig 755f461d2dcSChristoph Hellwig i = (unsigned int *) tbl_data; 756f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(*i); 757f461d2dcSChristoph Hellwig 758f461d2dcSChristoph Hellwig /* 759f461d2dcSChristoph Hellwig * Arrays are not supported, keep this simple. *Do not* add 760f461d2dcSChristoph Hellwig * support for them. 761f461d2dcSChristoph Hellwig */ 762f461d2dcSChristoph Hellwig if (vleft != 1) { 763f461d2dcSChristoph Hellwig *lenp = 0; 764f461d2dcSChristoph Hellwig return -EINVAL; 765f461d2dcSChristoph Hellwig } 766f461d2dcSChristoph Hellwig 767f461d2dcSChristoph Hellwig if (!conv) 768f461d2dcSChristoph Hellwig conv = do_proc_douintvec_conv; 769f461d2dcSChristoph Hellwig 770f461d2dcSChristoph Hellwig if (write) 771f461d2dcSChristoph Hellwig return do_proc_douintvec_w(i, table, buffer, lenp, ppos, 772f461d2dcSChristoph Hellwig conv, data); 773f461d2dcSChristoph Hellwig return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); 774f461d2dcSChristoph Hellwig } 775f461d2dcSChristoph Hellwig 776f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write, 77732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, 778f461d2dcSChristoph Hellwig int (*conv)(unsigned long *lvalp, 779f461d2dcSChristoph Hellwig unsigned int *valp, 780f461d2dcSChristoph Hellwig int write, void *data), 781f461d2dcSChristoph Hellwig void *data) 782f461d2dcSChristoph Hellwig { 783f461d2dcSChristoph Hellwig return __do_proc_douintvec(table->data, table, write, 784f461d2dcSChristoph Hellwig buffer, lenp, ppos, conv, data); 785f461d2dcSChristoph Hellwig } 786f461d2dcSChristoph Hellwig 787f461d2dcSChristoph Hellwig /** 788f461d2dcSChristoph Hellwig * proc_dointvec - read a vector of integers 789f461d2dcSChristoph Hellwig * @table: the sysctl table 790f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 791f461d2dcSChristoph Hellwig * @buffer: the user buffer 792f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 793f461d2dcSChristoph Hellwig * @ppos: file position 794f461d2dcSChristoph Hellwig * 795f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 796f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 797f461d2dcSChristoph Hellwig * 798f461d2dcSChristoph Hellwig * Returns 0 on success. 799f461d2dcSChristoph Hellwig */ 80032927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer, 80132927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 802f461d2dcSChristoph Hellwig { 803f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 804f461d2dcSChristoph Hellwig } 805f461d2dcSChristoph Hellwig 806f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION 807f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table, 80832927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos) 809f461d2dcSChristoph Hellwig { 810f461d2dcSChristoph Hellwig int ret, old; 811f461d2dcSChristoph Hellwig 812f461d2dcSChristoph Hellwig if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write) 813f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 814f461d2dcSChristoph Hellwig 815f461d2dcSChristoph Hellwig old = *(int *)table->data; 816f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 817f461d2dcSChristoph Hellwig if (ret) 818f461d2dcSChristoph Hellwig return ret; 819f461d2dcSChristoph Hellwig if (old != *(int *)table->data) 820f461d2dcSChristoph Hellwig pr_warn_once("sysctl attribute %s changed by %s[%d]\n", 821f461d2dcSChristoph Hellwig table->procname, current->comm, 822f461d2dcSChristoph Hellwig task_pid_nr(current)); 823f461d2dcSChristoph Hellwig return ret; 824f461d2dcSChristoph Hellwig } 825f461d2dcSChristoph Hellwig #endif 826f461d2dcSChristoph Hellwig 827f461d2dcSChristoph Hellwig /** 828f461d2dcSChristoph Hellwig * proc_douintvec - read a vector of unsigned integers 829f461d2dcSChristoph Hellwig * @table: the sysctl table 830f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 831f461d2dcSChristoph Hellwig * @buffer: the user buffer 832f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 833f461d2dcSChristoph Hellwig * @ppos: file position 834f461d2dcSChristoph Hellwig * 835f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 836f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 837f461d2dcSChristoph Hellwig * 838f461d2dcSChristoph Hellwig * Returns 0 on success. 839f461d2dcSChristoph Hellwig */ 84032927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer, 84132927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 842f461d2dcSChristoph Hellwig { 843f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 844f461d2dcSChristoph Hellwig do_proc_douintvec_conv, NULL); 845f461d2dcSChristoph Hellwig } 846f461d2dcSChristoph Hellwig 847f461d2dcSChristoph Hellwig /* 848f461d2dcSChristoph Hellwig * Taint values can only be increased 849f461d2dcSChristoph Hellwig * This means we can safely use a temporary. 850f461d2dcSChristoph Hellwig */ 851f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write, 85232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 853f461d2dcSChristoph Hellwig { 854f461d2dcSChristoph Hellwig struct ctl_table t; 855f461d2dcSChristoph Hellwig unsigned long tmptaint = get_taint(); 856f461d2dcSChristoph Hellwig int err; 857f461d2dcSChristoph Hellwig 858f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 859f461d2dcSChristoph Hellwig return -EPERM; 860f461d2dcSChristoph Hellwig 861f461d2dcSChristoph Hellwig t = *table; 862f461d2dcSChristoph Hellwig t.data = &tmptaint; 863f461d2dcSChristoph Hellwig err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 864f461d2dcSChristoph Hellwig if (err < 0) 865f461d2dcSChristoph Hellwig return err; 866f461d2dcSChristoph Hellwig 867f461d2dcSChristoph Hellwig if (write) { 868db38d5c1SRafael Aquini int i; 869db38d5c1SRafael Aquini 870db38d5c1SRafael Aquini /* 871db38d5c1SRafael Aquini * If we are relying on panic_on_taint not producing 872db38d5c1SRafael Aquini * false positives due to userspace input, bail out 873db38d5c1SRafael Aquini * before setting the requested taint flags. 874db38d5c1SRafael Aquini */ 875db38d5c1SRafael Aquini if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint)) 876db38d5c1SRafael Aquini return -EINVAL; 877db38d5c1SRafael Aquini 878f461d2dcSChristoph Hellwig /* 879f461d2dcSChristoph Hellwig * Poor man's atomic or. Not worth adding a primitive 880f461d2dcSChristoph Hellwig * to everyone's atomic.h for this 881f461d2dcSChristoph Hellwig */ 882e77132e7SRafael Aquini for (i = 0; i < TAINT_FLAGS_COUNT; i++) 883e77132e7SRafael Aquini if ((1UL << i) & tmptaint) 884f461d2dcSChristoph Hellwig add_taint(i, LOCKDEP_STILL_OK); 885f461d2dcSChristoph Hellwig } 886f461d2dcSChristoph Hellwig 887f461d2dcSChristoph Hellwig return err; 888f461d2dcSChristoph Hellwig } 889f461d2dcSChristoph Hellwig 890f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK 891f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 89232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 893f461d2dcSChristoph Hellwig { 894f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 895f461d2dcSChristoph Hellwig return -EPERM; 896f461d2dcSChristoph Hellwig 897f461d2dcSChristoph Hellwig return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 898f461d2dcSChristoph Hellwig } 899f461d2dcSChristoph Hellwig #endif 900f461d2dcSChristoph Hellwig 901f461d2dcSChristoph Hellwig /** 902f461d2dcSChristoph Hellwig * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure 903f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 904f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 905f461d2dcSChristoph Hellwig * 906f461d2dcSChristoph Hellwig * The do_proc_dointvec_minmax_conv_param structure provides the 907f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 908f461d2dcSChristoph Hellwig * parameters that use the proc_dointvec_minmax() handler. 909f461d2dcSChristoph Hellwig */ 910f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param { 911f461d2dcSChristoph Hellwig int *min; 912f461d2dcSChristoph Hellwig int *max; 913f461d2dcSChristoph Hellwig }; 914f461d2dcSChristoph Hellwig 915f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 916f461d2dcSChristoph Hellwig int *valp, 917f461d2dcSChristoph Hellwig int write, void *data) 918f461d2dcSChristoph Hellwig { 919f461d2dcSChristoph Hellwig int tmp, ret; 920f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param *param = data; 921f461d2dcSChristoph Hellwig /* 922f461d2dcSChristoph Hellwig * If writing, first do so via a temporary local int so we can 923f461d2dcSChristoph Hellwig * bounds-check it before touching *valp. 924f461d2dcSChristoph Hellwig */ 925f461d2dcSChristoph Hellwig int *ip = write ? &tmp : valp; 926f461d2dcSChristoph Hellwig 927f461d2dcSChristoph Hellwig ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); 928f461d2dcSChristoph Hellwig if (ret) 929f461d2dcSChristoph Hellwig return ret; 930f461d2dcSChristoph Hellwig 931f461d2dcSChristoph Hellwig if (write) { 932f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 933f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 934f461d2dcSChristoph Hellwig return -EINVAL; 935f461d2dcSChristoph Hellwig *valp = tmp; 936f461d2dcSChristoph Hellwig } 937f461d2dcSChristoph Hellwig 938f461d2dcSChristoph Hellwig return 0; 939f461d2dcSChristoph Hellwig } 940f461d2dcSChristoph Hellwig 941f461d2dcSChristoph Hellwig /** 942f461d2dcSChristoph Hellwig * proc_dointvec_minmax - read a vector of integers with min/max values 943f461d2dcSChristoph Hellwig * @table: the sysctl table 944f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 945f461d2dcSChristoph Hellwig * @buffer: the user buffer 946f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 947f461d2dcSChristoph Hellwig * @ppos: file position 948f461d2dcSChristoph Hellwig * 949f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 950f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 951f461d2dcSChristoph Hellwig * 952f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 953f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 954f461d2dcSChristoph Hellwig * 955f461d2dcSChristoph Hellwig * Returns 0 on success or -EINVAL on write when the range check fails. 956f461d2dcSChristoph Hellwig */ 957f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 95832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 959f461d2dcSChristoph Hellwig { 960f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param param = { 961f461d2dcSChristoph Hellwig .min = (int *) table->extra1, 962f461d2dcSChristoph Hellwig .max = (int *) table->extra2, 963f461d2dcSChristoph Hellwig }; 964f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 965f461d2dcSChristoph Hellwig do_proc_dointvec_minmax_conv, ¶m); 966f461d2dcSChristoph Hellwig } 967f461d2dcSChristoph Hellwig 968f461d2dcSChristoph Hellwig /** 969f461d2dcSChristoph Hellwig * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure 970f461d2dcSChristoph Hellwig * @min: pointer to minimum allowable value 971f461d2dcSChristoph Hellwig * @max: pointer to maximum allowable value 972f461d2dcSChristoph Hellwig * 973f461d2dcSChristoph Hellwig * The do_proc_douintvec_minmax_conv_param structure provides the 974f461d2dcSChristoph Hellwig * minimum and maximum values for doing range checking for those sysctl 975f461d2dcSChristoph Hellwig * parameters that use the proc_douintvec_minmax() handler. 976f461d2dcSChristoph Hellwig */ 977f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param { 978f461d2dcSChristoph Hellwig unsigned int *min; 979f461d2dcSChristoph Hellwig unsigned int *max; 980f461d2dcSChristoph Hellwig }; 981f461d2dcSChristoph Hellwig 982f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, 983f461d2dcSChristoph Hellwig unsigned int *valp, 984f461d2dcSChristoph Hellwig int write, void *data) 985f461d2dcSChristoph Hellwig { 986f461d2dcSChristoph Hellwig int ret; 987f461d2dcSChristoph Hellwig unsigned int tmp; 988f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param *param = data; 989f461d2dcSChristoph Hellwig /* write via temporary local uint for bounds-checking */ 990f461d2dcSChristoph Hellwig unsigned int *up = write ? &tmp : valp; 991f461d2dcSChristoph Hellwig 992f461d2dcSChristoph Hellwig ret = do_proc_douintvec_conv(lvalp, up, write, data); 993f461d2dcSChristoph Hellwig if (ret) 994f461d2dcSChristoph Hellwig return ret; 995f461d2dcSChristoph Hellwig 996f461d2dcSChristoph Hellwig if (write) { 997f461d2dcSChristoph Hellwig if ((param->min && *param->min > tmp) || 998f461d2dcSChristoph Hellwig (param->max && *param->max < tmp)) 999f461d2dcSChristoph Hellwig return -ERANGE; 1000f461d2dcSChristoph Hellwig 1001f461d2dcSChristoph Hellwig *valp = tmp; 1002f461d2dcSChristoph Hellwig } 1003f461d2dcSChristoph Hellwig 1004f461d2dcSChristoph Hellwig return 0; 1005f461d2dcSChristoph Hellwig } 1006f461d2dcSChristoph Hellwig 1007f461d2dcSChristoph Hellwig /** 1008f461d2dcSChristoph Hellwig * proc_douintvec_minmax - read a vector of unsigned ints with min/max values 1009f461d2dcSChristoph Hellwig * @table: the sysctl table 1010f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1011f461d2dcSChristoph Hellwig * @buffer: the user buffer 1012f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1013f461d2dcSChristoph Hellwig * @ppos: file position 1014f461d2dcSChristoph Hellwig * 1015f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 1016f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. Negative 1017f461d2dcSChristoph Hellwig * strings are not allowed. 1018f461d2dcSChristoph Hellwig * 1019f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1020f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). There is a final sanity 1021f461d2dcSChristoph Hellwig * check for UINT_MAX to avoid having to support wrap around uses from 1022f461d2dcSChristoph Hellwig * userspace. 1023f461d2dcSChristoph Hellwig * 1024f461d2dcSChristoph Hellwig * Returns 0 on success or -ERANGE on write when the range check fails. 1025f461d2dcSChristoph Hellwig */ 1026f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 102732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1028f461d2dcSChristoph Hellwig { 1029f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param param = { 1030f461d2dcSChristoph Hellwig .min = (unsigned int *) table->extra1, 1031f461d2dcSChristoph Hellwig .max = (unsigned int *) table->extra2, 1032f461d2dcSChristoph Hellwig }; 1033f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1034f461d2dcSChristoph Hellwig do_proc_douintvec_minmax_conv, ¶m); 1035f461d2dcSChristoph Hellwig } 1036f461d2dcSChristoph Hellwig 1037*cb944413SEric Dumazet /** 1038*cb944413SEric Dumazet * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values 1039*cb944413SEric Dumazet * @table: the sysctl table 1040*cb944413SEric Dumazet * @write: %TRUE if this is a write to the sysctl file 1041*cb944413SEric Dumazet * @buffer: the user buffer 1042*cb944413SEric Dumazet * @lenp: the size of the user buffer 1043*cb944413SEric Dumazet * @ppos: file position 1044*cb944413SEric Dumazet * 1045*cb944413SEric Dumazet * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars 1046*cb944413SEric Dumazet * values from/to the user buffer, treated as an ASCII string. Negative 1047*cb944413SEric Dumazet * strings are not allowed. 1048*cb944413SEric Dumazet * 1049*cb944413SEric Dumazet * This routine will ensure the values are within the range specified by 1050*cb944413SEric Dumazet * table->extra1 (min) and table->extra2 (max). 1051*cb944413SEric Dumazet * 1052*cb944413SEric Dumazet * Returns 0 on success or an error on write when the range check fails. 1053*cb944413SEric Dumazet */ 1054*cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write, 1055*cb944413SEric Dumazet void *buffer, size_t *lenp, loff_t *ppos) 1056*cb944413SEric Dumazet { 1057*cb944413SEric Dumazet struct ctl_table tmp; 1058*cb944413SEric Dumazet unsigned int min = 0, max = 255U, val; 1059*cb944413SEric Dumazet u8 *data = table->data; 1060*cb944413SEric Dumazet struct do_proc_douintvec_minmax_conv_param param = { 1061*cb944413SEric Dumazet .min = &min, 1062*cb944413SEric Dumazet .max = &max, 1063*cb944413SEric Dumazet }; 1064*cb944413SEric Dumazet int res; 1065*cb944413SEric Dumazet 1066*cb944413SEric Dumazet /* Do not support arrays yet. */ 1067*cb944413SEric Dumazet if (table->maxlen != sizeof(u8)) 1068*cb944413SEric Dumazet return -EINVAL; 1069*cb944413SEric Dumazet 1070*cb944413SEric Dumazet if (table->extra1) { 1071*cb944413SEric Dumazet min = *(unsigned int *) table->extra1; 1072*cb944413SEric Dumazet if (min > 255U) 1073*cb944413SEric Dumazet return -EINVAL; 1074*cb944413SEric Dumazet } 1075*cb944413SEric Dumazet if (table->extra2) { 1076*cb944413SEric Dumazet max = *(unsigned int *) table->extra2; 1077*cb944413SEric Dumazet if (max > 255U) 1078*cb944413SEric Dumazet return -EINVAL; 1079*cb944413SEric Dumazet } 1080*cb944413SEric Dumazet 1081*cb944413SEric Dumazet tmp = *table; 1082*cb944413SEric Dumazet 1083*cb944413SEric Dumazet tmp.maxlen = sizeof(val); 1084*cb944413SEric Dumazet tmp.data = &val; 1085*cb944413SEric Dumazet val = *data; 1086*cb944413SEric Dumazet res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos, 1087*cb944413SEric Dumazet do_proc_douintvec_minmax_conv, ¶m); 1088*cb944413SEric Dumazet if (res) 1089*cb944413SEric Dumazet return res; 1090*cb944413SEric Dumazet if (write) 1091*cb944413SEric Dumazet *data = val; 1092*cb944413SEric Dumazet return 0; 1093*cb944413SEric Dumazet } 1094*cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax); 1095*cb944413SEric Dumazet 1096f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp, 1097f461d2dcSChristoph Hellwig unsigned int *valp, 1098f461d2dcSChristoph Hellwig int write, void *data) 1099f461d2dcSChristoph Hellwig { 1100f461d2dcSChristoph Hellwig if (write) { 1101f461d2dcSChristoph Hellwig unsigned int val; 1102f461d2dcSChristoph Hellwig 1103f461d2dcSChristoph Hellwig val = round_pipe_size(*lvalp); 1104f461d2dcSChristoph Hellwig if (val == 0) 1105f461d2dcSChristoph Hellwig return -EINVAL; 1106f461d2dcSChristoph Hellwig 1107f461d2dcSChristoph Hellwig *valp = val; 1108f461d2dcSChristoph Hellwig } else { 1109f461d2dcSChristoph Hellwig unsigned int val = *valp; 1110f461d2dcSChristoph Hellwig *lvalp = (unsigned long) val; 1111f461d2dcSChristoph Hellwig } 1112f461d2dcSChristoph Hellwig 1113f461d2dcSChristoph Hellwig return 0; 1114f461d2dcSChristoph Hellwig } 1115f461d2dcSChristoph Hellwig 1116f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write, 111732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1118f461d2dcSChristoph Hellwig { 1119f461d2dcSChristoph Hellwig return do_proc_douintvec(table, write, buffer, lenp, ppos, 1120f461d2dcSChristoph Hellwig do_proc_dopipe_max_size_conv, NULL); 1121f461d2dcSChristoph Hellwig } 1122f461d2dcSChristoph Hellwig 1123f461d2dcSChristoph Hellwig static void validate_coredump_safety(void) 1124f461d2dcSChristoph Hellwig { 1125f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1126f461d2dcSChristoph Hellwig if (suid_dumpable == SUID_DUMP_ROOT && 1127f461d2dcSChristoph Hellwig core_pattern[0] != '/' && core_pattern[0] != '|') { 1128f461d2dcSChristoph Hellwig printk(KERN_WARNING 1129f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n" 1130f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n" 1131f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n" 1132f461d2dcSChristoph Hellwig ); 1133f461d2dcSChristoph Hellwig } 1134f461d2dcSChristoph Hellwig #endif 1135f461d2dcSChristoph Hellwig } 1136f461d2dcSChristoph Hellwig 1137f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 113832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1139f461d2dcSChristoph Hellwig { 1140f461d2dcSChristoph Hellwig int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1141f461d2dcSChristoph Hellwig if (!error) 1142f461d2dcSChristoph Hellwig validate_coredump_safety(); 1143f461d2dcSChristoph Hellwig return error; 1144f461d2dcSChristoph Hellwig } 1145f461d2dcSChristoph Hellwig 1146f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP 1147f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write, 114832927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1149f461d2dcSChristoph Hellwig { 1150f461d2dcSChristoph Hellwig int error = proc_dostring(table, write, buffer, lenp, ppos); 1151f461d2dcSChristoph Hellwig if (!error) 1152f461d2dcSChristoph Hellwig validate_coredump_safety(); 1153f461d2dcSChristoph Hellwig return error; 1154f461d2dcSChristoph Hellwig } 1155f461d2dcSChristoph Hellwig #endif 1156f461d2dcSChristoph Hellwig 1157f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ 1158f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write, 115932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1160f461d2dcSChristoph Hellwig { 1161f461d2dcSChristoph Hellwig int tmp, ret; 1162f461d2dcSChristoph Hellwig 1163f461d2dcSChristoph Hellwig tmp = sysrq_mask(); 1164f461d2dcSChristoph Hellwig 1165f461d2dcSChristoph Hellwig ret = __do_proc_dointvec(&tmp, table, write, buffer, 1166f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1167f461d2dcSChristoph Hellwig if (ret || !write) 1168f461d2dcSChristoph Hellwig return ret; 1169f461d2dcSChristoph Hellwig 1170f461d2dcSChristoph Hellwig if (write) 1171f461d2dcSChristoph Hellwig sysrq_toggle_support(tmp); 1172f461d2dcSChristoph Hellwig 1173f461d2dcSChristoph Hellwig return 0; 1174f461d2dcSChristoph Hellwig } 1175f461d2dcSChristoph Hellwig #endif 1176f461d2dcSChristoph Hellwig 117732927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, 117832927393SChristoph Hellwig int write, void *buffer, size_t *lenp, loff_t *ppos, 117932927393SChristoph Hellwig unsigned long convmul, unsigned long convdiv) 1180f461d2dcSChristoph Hellwig { 1181f461d2dcSChristoph Hellwig unsigned long *i, *min, *max; 1182f461d2dcSChristoph Hellwig int vleft, first = 1, err = 0; 1183f461d2dcSChristoph Hellwig size_t left; 118432927393SChristoph Hellwig char *p; 1185f461d2dcSChristoph Hellwig 1186f461d2dcSChristoph Hellwig if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 1187f461d2dcSChristoph Hellwig *lenp = 0; 1188f461d2dcSChristoph Hellwig return 0; 1189f461d2dcSChristoph Hellwig } 1190f461d2dcSChristoph Hellwig 1191f461d2dcSChristoph Hellwig i = (unsigned long *) data; 1192f461d2dcSChristoph Hellwig min = (unsigned long *) table->extra1; 1193f461d2dcSChristoph Hellwig max = (unsigned long *) table->extra2; 1194f461d2dcSChristoph Hellwig vleft = table->maxlen / sizeof(unsigned long); 1195f461d2dcSChristoph Hellwig left = *lenp; 1196f461d2dcSChristoph Hellwig 1197f461d2dcSChristoph Hellwig if (write) { 1198f461d2dcSChristoph Hellwig if (proc_first_pos_non_zero_ignore(ppos, table)) 1199f461d2dcSChristoph Hellwig goto out; 1200f461d2dcSChristoph Hellwig 1201f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) 1202f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 120332927393SChristoph Hellwig p = buffer; 1204f461d2dcSChristoph Hellwig } 1205f461d2dcSChristoph Hellwig 1206f461d2dcSChristoph Hellwig for (; left && vleft--; i++, first = 0) { 1207f461d2dcSChristoph Hellwig unsigned long val; 1208f461d2dcSChristoph Hellwig 1209f461d2dcSChristoph Hellwig if (write) { 1210f461d2dcSChristoph Hellwig bool neg; 1211f461d2dcSChristoph Hellwig 1212f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 1213f461d2dcSChristoph Hellwig if (!left) 1214f461d2dcSChristoph Hellwig break; 1215f461d2dcSChristoph Hellwig 1216f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val, &neg, 1217f461d2dcSChristoph Hellwig proc_wspace_sep, 1218f461d2dcSChristoph Hellwig sizeof(proc_wspace_sep), NULL); 1219f461d2dcSChristoph Hellwig if (err) 1220f461d2dcSChristoph Hellwig break; 1221f461d2dcSChristoph Hellwig if (neg) 1222f461d2dcSChristoph Hellwig continue; 1223f461d2dcSChristoph Hellwig val = convmul * val / convdiv; 1224f461d2dcSChristoph Hellwig if ((min && val < *min) || (max && val > *max)) { 1225f461d2dcSChristoph Hellwig err = -EINVAL; 1226f461d2dcSChristoph Hellwig break; 1227f461d2dcSChristoph Hellwig } 1228f461d2dcSChristoph Hellwig *i = val; 1229f461d2dcSChristoph Hellwig } else { 1230f461d2dcSChristoph Hellwig val = convdiv * (*i) / convmul; 123132927393SChristoph Hellwig if (!first) 123232927393SChristoph Hellwig proc_put_char(&buffer, &left, '\t'); 123332927393SChristoph Hellwig proc_put_long(&buffer, &left, val, false); 1234f461d2dcSChristoph Hellwig } 1235f461d2dcSChristoph Hellwig } 1236f461d2dcSChristoph Hellwig 1237f461d2dcSChristoph Hellwig if (!write && !first && left && !err) 123832927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1239f461d2dcSChristoph Hellwig if (write && !err) 1240f461d2dcSChristoph Hellwig left -= proc_skip_spaces(&p); 124132927393SChristoph Hellwig if (write && first) 1242f461d2dcSChristoph Hellwig return err ? : -EINVAL; 1243f461d2dcSChristoph Hellwig *lenp -= left; 1244f461d2dcSChristoph Hellwig out: 1245f461d2dcSChristoph Hellwig *ppos += *lenp; 1246f461d2dcSChristoph Hellwig return err; 1247f461d2dcSChristoph Hellwig } 1248f461d2dcSChristoph Hellwig 1249f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 125032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, 1251f461d2dcSChristoph Hellwig unsigned long convdiv) 1252f461d2dcSChristoph Hellwig { 1253f461d2dcSChristoph Hellwig return __do_proc_doulongvec_minmax(table->data, table, write, 1254f461d2dcSChristoph Hellwig buffer, lenp, ppos, convmul, convdiv); 1255f461d2dcSChristoph Hellwig } 1256f461d2dcSChristoph Hellwig 1257f461d2dcSChristoph Hellwig /** 1258f461d2dcSChristoph Hellwig * proc_doulongvec_minmax - read a vector of long integers with min/max values 1259f461d2dcSChristoph Hellwig * @table: the sysctl table 1260f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1261f461d2dcSChristoph Hellwig * @buffer: the user buffer 1262f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1263f461d2dcSChristoph Hellwig * @ppos: file position 1264f461d2dcSChristoph Hellwig * 1265f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1266f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1267f461d2dcSChristoph Hellwig * 1268f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1269f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1270f461d2dcSChristoph Hellwig * 1271f461d2dcSChristoph Hellwig * Returns 0 on success. 1272f461d2dcSChristoph Hellwig */ 1273f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 127432927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1275f461d2dcSChristoph Hellwig { 1276f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 1277f461d2dcSChristoph Hellwig } 1278f461d2dcSChristoph Hellwig 1279f461d2dcSChristoph Hellwig /** 1280f461d2dcSChristoph Hellwig * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 1281f461d2dcSChristoph Hellwig * @table: the sysctl table 1282f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1283f461d2dcSChristoph Hellwig * @buffer: the user buffer 1284f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1285f461d2dcSChristoph Hellwig * @ppos: file position 1286f461d2dcSChristoph Hellwig * 1287f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 1288f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. The values 1289f461d2dcSChristoph Hellwig * are treated as milliseconds, and converted to jiffies when they are stored. 1290f461d2dcSChristoph Hellwig * 1291f461d2dcSChristoph Hellwig * This routine will ensure the values are within the range specified by 1292f461d2dcSChristoph Hellwig * table->extra1 (min) and table->extra2 (max). 1293f461d2dcSChristoph Hellwig * 1294f461d2dcSChristoph Hellwig * Returns 0 on success. 1295f461d2dcSChristoph Hellwig */ 1296f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 129732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1298f461d2dcSChristoph Hellwig { 1299f461d2dcSChristoph Hellwig return do_proc_doulongvec_minmax(table, write, buffer, 1300f461d2dcSChristoph Hellwig lenp, ppos, HZ, 1000l); 1301f461d2dcSChristoph Hellwig } 1302f461d2dcSChristoph Hellwig 1303f461d2dcSChristoph Hellwig 1304f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 1305f461d2dcSChristoph Hellwig int *valp, 1306f461d2dcSChristoph Hellwig int write, void *data) 1307f461d2dcSChristoph Hellwig { 1308f461d2dcSChristoph Hellwig if (write) { 1309f461d2dcSChristoph Hellwig if (*lvalp > INT_MAX / HZ) 1310f461d2dcSChristoph Hellwig return 1; 1311f461d2dcSChristoph Hellwig *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 1312f461d2dcSChristoph Hellwig } else { 1313f461d2dcSChristoph Hellwig int val = *valp; 1314f461d2dcSChristoph Hellwig unsigned long lval; 1315f461d2dcSChristoph Hellwig if (val < 0) { 1316f461d2dcSChristoph Hellwig *negp = true; 1317f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1318f461d2dcSChristoph Hellwig } else { 1319f461d2dcSChristoph Hellwig *negp = false; 1320f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1321f461d2dcSChristoph Hellwig } 1322f461d2dcSChristoph Hellwig *lvalp = lval / HZ; 1323f461d2dcSChristoph Hellwig } 1324f461d2dcSChristoph Hellwig return 0; 1325f461d2dcSChristoph Hellwig } 1326f461d2dcSChristoph Hellwig 1327f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 1328f461d2dcSChristoph Hellwig int *valp, 1329f461d2dcSChristoph Hellwig int write, void *data) 1330f461d2dcSChristoph Hellwig { 1331f461d2dcSChristoph Hellwig if (write) { 1332f461d2dcSChristoph Hellwig if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 1333f461d2dcSChristoph Hellwig return 1; 1334f461d2dcSChristoph Hellwig *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 1335f461d2dcSChristoph Hellwig } else { 1336f461d2dcSChristoph Hellwig int val = *valp; 1337f461d2dcSChristoph Hellwig unsigned long lval; 1338f461d2dcSChristoph Hellwig if (val < 0) { 1339f461d2dcSChristoph Hellwig *negp = true; 1340f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1341f461d2dcSChristoph Hellwig } else { 1342f461d2dcSChristoph Hellwig *negp = false; 1343f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1344f461d2dcSChristoph Hellwig } 1345f461d2dcSChristoph Hellwig *lvalp = jiffies_to_clock_t(lval); 1346f461d2dcSChristoph Hellwig } 1347f461d2dcSChristoph Hellwig return 0; 1348f461d2dcSChristoph Hellwig } 1349f461d2dcSChristoph Hellwig 1350f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 1351f461d2dcSChristoph Hellwig int *valp, 1352f461d2dcSChristoph Hellwig int write, void *data) 1353f461d2dcSChristoph Hellwig { 1354f461d2dcSChristoph Hellwig if (write) { 1355f461d2dcSChristoph Hellwig unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 1356f461d2dcSChristoph Hellwig 1357f461d2dcSChristoph Hellwig if (jif > INT_MAX) 1358f461d2dcSChristoph Hellwig return 1; 1359f461d2dcSChristoph Hellwig *valp = (int)jif; 1360f461d2dcSChristoph Hellwig } else { 1361f461d2dcSChristoph Hellwig int val = *valp; 1362f461d2dcSChristoph Hellwig unsigned long lval; 1363f461d2dcSChristoph Hellwig if (val < 0) { 1364f461d2dcSChristoph Hellwig *negp = true; 1365f461d2dcSChristoph Hellwig lval = -(unsigned long)val; 1366f461d2dcSChristoph Hellwig } else { 1367f461d2dcSChristoph Hellwig *negp = false; 1368f461d2dcSChristoph Hellwig lval = (unsigned long)val; 1369f461d2dcSChristoph Hellwig } 1370f461d2dcSChristoph Hellwig *lvalp = jiffies_to_msecs(lval); 1371f461d2dcSChristoph Hellwig } 1372f461d2dcSChristoph Hellwig return 0; 1373f461d2dcSChristoph Hellwig } 1374f461d2dcSChristoph Hellwig 1375f461d2dcSChristoph Hellwig /** 1376f461d2dcSChristoph Hellwig * proc_dointvec_jiffies - read a vector of integers as seconds 1377f461d2dcSChristoph Hellwig * @table: the sysctl table 1378f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1379f461d2dcSChristoph Hellwig * @buffer: the user buffer 1380f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1381f461d2dcSChristoph Hellwig * @ppos: file position 1382f461d2dcSChristoph Hellwig * 1383f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1384f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1385f461d2dcSChristoph Hellwig * The values read are assumed to be in seconds, and are converted into 1386f461d2dcSChristoph Hellwig * jiffies. 1387f461d2dcSChristoph Hellwig * 1388f461d2dcSChristoph Hellwig * Returns 0 on success. 1389f461d2dcSChristoph Hellwig */ 1390f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 139132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1392f461d2dcSChristoph Hellwig { 1393f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1394f461d2dcSChristoph Hellwig do_proc_dointvec_jiffies_conv,NULL); 1395f461d2dcSChristoph Hellwig } 1396f461d2dcSChristoph Hellwig 1397f461d2dcSChristoph Hellwig /** 1398f461d2dcSChristoph Hellwig * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 1399f461d2dcSChristoph Hellwig * @table: the sysctl table 1400f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1401f461d2dcSChristoph Hellwig * @buffer: the user buffer 1402f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1403f461d2dcSChristoph Hellwig * @ppos: pointer to the file position 1404f461d2dcSChristoph Hellwig * 1405f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1406f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1407f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/USER_HZ seconds, and 1408f461d2dcSChristoph Hellwig * are converted into jiffies. 1409f461d2dcSChristoph Hellwig * 1410f461d2dcSChristoph Hellwig * Returns 0 on success. 1411f461d2dcSChristoph Hellwig */ 1412f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 141332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1414f461d2dcSChristoph Hellwig { 1415f461d2dcSChristoph Hellwig return do_proc_dointvec(table,write,buffer,lenp,ppos, 1416f461d2dcSChristoph Hellwig do_proc_dointvec_userhz_jiffies_conv,NULL); 1417f461d2dcSChristoph Hellwig } 1418f461d2dcSChristoph Hellwig 1419f461d2dcSChristoph Hellwig /** 1420f461d2dcSChristoph Hellwig * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 1421f461d2dcSChristoph Hellwig * @table: the sysctl table 1422f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1423f461d2dcSChristoph Hellwig * @buffer: the user buffer 1424f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1425f461d2dcSChristoph Hellwig * @ppos: file position 1426f461d2dcSChristoph Hellwig * @ppos: the current position in the file 1427f461d2dcSChristoph Hellwig * 1428f461d2dcSChristoph Hellwig * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1429f461d2dcSChristoph Hellwig * values from/to the user buffer, treated as an ASCII string. 1430f461d2dcSChristoph Hellwig * The values read are assumed to be in 1/1000 seconds, and 1431f461d2dcSChristoph Hellwig * are converted into jiffies. 1432f461d2dcSChristoph Hellwig * 1433f461d2dcSChristoph Hellwig * Returns 0 on success. 1434f461d2dcSChristoph Hellwig */ 143532927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer, 143632927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1437f461d2dcSChristoph Hellwig { 1438f461d2dcSChristoph Hellwig return do_proc_dointvec(table, write, buffer, lenp, ppos, 1439f461d2dcSChristoph Hellwig do_proc_dointvec_ms_jiffies_conv, NULL); 1440f461d2dcSChristoph Hellwig } 1441f461d2dcSChristoph Hellwig 144232927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, 144332927393SChristoph Hellwig size_t *lenp, loff_t *ppos) 1444f461d2dcSChristoph Hellwig { 1445f461d2dcSChristoph Hellwig struct pid *new_pid; 1446f461d2dcSChristoph Hellwig pid_t tmp; 1447f461d2dcSChristoph Hellwig int r; 1448f461d2dcSChristoph Hellwig 1449f461d2dcSChristoph Hellwig tmp = pid_vnr(cad_pid); 1450f461d2dcSChristoph Hellwig 1451f461d2dcSChristoph Hellwig r = __do_proc_dointvec(&tmp, table, write, buffer, 1452f461d2dcSChristoph Hellwig lenp, ppos, NULL, NULL); 1453f461d2dcSChristoph Hellwig if (r || !write) 1454f461d2dcSChristoph Hellwig return r; 1455f461d2dcSChristoph Hellwig 1456f461d2dcSChristoph Hellwig new_pid = find_get_pid(tmp); 1457f461d2dcSChristoph Hellwig if (!new_pid) 1458f461d2dcSChristoph Hellwig return -ESRCH; 1459f461d2dcSChristoph Hellwig 1460f461d2dcSChristoph Hellwig put_pid(xchg(&cad_pid, new_pid)); 1461f461d2dcSChristoph Hellwig return 0; 1462f461d2dcSChristoph Hellwig } 1463f461d2dcSChristoph Hellwig 1464f461d2dcSChristoph Hellwig /** 1465f461d2dcSChristoph Hellwig * proc_do_large_bitmap - read/write from/to a large bitmap 1466f461d2dcSChristoph Hellwig * @table: the sysctl table 1467f461d2dcSChristoph Hellwig * @write: %TRUE if this is a write to the sysctl file 1468f461d2dcSChristoph Hellwig * @buffer: the user buffer 1469f461d2dcSChristoph Hellwig * @lenp: the size of the user buffer 1470f461d2dcSChristoph Hellwig * @ppos: file position 1471f461d2dcSChristoph Hellwig * 1472f461d2dcSChristoph Hellwig * The bitmap is stored at table->data and the bitmap length (in bits) 1473f461d2dcSChristoph Hellwig * in table->maxlen. 1474f461d2dcSChristoph Hellwig * 1475f461d2dcSChristoph Hellwig * We use a range comma separated format (e.g. 1,3-4,10-10) so that 1476f461d2dcSChristoph Hellwig * large bitmaps may be represented in a compact manner. Writing into 1477f461d2dcSChristoph Hellwig * the file will clear the bitmap then update it with the given input. 1478f461d2dcSChristoph Hellwig * 1479f461d2dcSChristoph Hellwig * Returns 0 on success. 1480f461d2dcSChristoph Hellwig */ 1481f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 148232927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1483f461d2dcSChristoph Hellwig { 1484f461d2dcSChristoph Hellwig int err = 0; 1485f461d2dcSChristoph Hellwig bool first = 1; 1486f461d2dcSChristoph Hellwig size_t left = *lenp; 1487f461d2dcSChristoph Hellwig unsigned long bitmap_len = table->maxlen; 1488f461d2dcSChristoph Hellwig unsigned long *bitmap = *(unsigned long **) table->data; 1489f461d2dcSChristoph Hellwig unsigned long *tmp_bitmap = NULL; 1490f461d2dcSChristoph Hellwig char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1491f461d2dcSChristoph Hellwig 1492f461d2dcSChristoph Hellwig if (!bitmap || !bitmap_len || !left || (*ppos && !write)) { 1493f461d2dcSChristoph Hellwig *lenp = 0; 1494f461d2dcSChristoph Hellwig return 0; 1495f461d2dcSChristoph Hellwig } 1496f461d2dcSChristoph Hellwig 1497f461d2dcSChristoph Hellwig if (write) { 149832927393SChristoph Hellwig char *p = buffer; 1499f461d2dcSChristoph Hellwig size_t skipped = 0; 1500f461d2dcSChristoph Hellwig 1501f461d2dcSChristoph Hellwig if (left > PAGE_SIZE - 1) { 1502f461d2dcSChristoph Hellwig left = PAGE_SIZE - 1; 1503f461d2dcSChristoph Hellwig /* How much of the buffer we'll skip this pass */ 1504f461d2dcSChristoph Hellwig skipped = *lenp - left; 1505f461d2dcSChristoph Hellwig } 1506f461d2dcSChristoph Hellwig 1507f461d2dcSChristoph Hellwig tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); 150832927393SChristoph Hellwig if (!tmp_bitmap) 1509f461d2dcSChristoph Hellwig return -ENOMEM; 1510f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1511f461d2dcSChristoph Hellwig while (!err && left) { 1512f461d2dcSChristoph Hellwig unsigned long val_a, val_b; 1513f461d2dcSChristoph Hellwig bool neg; 1514f461d2dcSChristoph Hellwig size_t saved_left; 1515f461d2dcSChristoph Hellwig 1516f461d2dcSChristoph Hellwig /* In case we stop parsing mid-number, we can reset */ 1517f461d2dcSChristoph Hellwig saved_left = left; 1518f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_a, &neg, tr_a, 1519f461d2dcSChristoph Hellwig sizeof(tr_a), &c); 1520f461d2dcSChristoph Hellwig /* 1521f461d2dcSChristoph Hellwig * If we consumed the entirety of a truncated buffer or 1522f461d2dcSChristoph Hellwig * only one char is left (may be a "-"), then stop here, 1523f461d2dcSChristoph Hellwig * reset, & come back for more. 1524f461d2dcSChristoph Hellwig */ 1525f461d2dcSChristoph Hellwig if ((left <= 1) && skipped) { 1526f461d2dcSChristoph Hellwig left = saved_left; 1527f461d2dcSChristoph Hellwig break; 1528f461d2dcSChristoph Hellwig } 1529f461d2dcSChristoph Hellwig 1530f461d2dcSChristoph Hellwig if (err) 1531f461d2dcSChristoph Hellwig break; 1532f461d2dcSChristoph Hellwig if (val_a >= bitmap_len || neg) { 1533f461d2dcSChristoph Hellwig err = -EINVAL; 1534f461d2dcSChristoph Hellwig break; 1535f461d2dcSChristoph Hellwig } 1536f461d2dcSChristoph Hellwig 1537f461d2dcSChristoph Hellwig val_b = val_a; 1538f461d2dcSChristoph Hellwig if (left) { 1539f461d2dcSChristoph Hellwig p++; 1540f461d2dcSChristoph Hellwig left--; 1541f461d2dcSChristoph Hellwig } 1542f461d2dcSChristoph Hellwig 1543f461d2dcSChristoph Hellwig if (c == '-') { 1544f461d2dcSChristoph Hellwig err = proc_get_long(&p, &left, &val_b, 1545f461d2dcSChristoph Hellwig &neg, tr_b, sizeof(tr_b), 1546f461d2dcSChristoph Hellwig &c); 1547f461d2dcSChristoph Hellwig /* 1548f461d2dcSChristoph Hellwig * If we consumed all of a truncated buffer or 1549f461d2dcSChristoph Hellwig * then stop here, reset, & come back for more. 1550f461d2dcSChristoph Hellwig */ 1551f461d2dcSChristoph Hellwig if (!left && skipped) { 1552f461d2dcSChristoph Hellwig left = saved_left; 1553f461d2dcSChristoph Hellwig break; 1554f461d2dcSChristoph Hellwig } 1555f461d2dcSChristoph Hellwig 1556f461d2dcSChristoph Hellwig if (err) 1557f461d2dcSChristoph Hellwig break; 1558f461d2dcSChristoph Hellwig if (val_b >= bitmap_len || neg || 1559f461d2dcSChristoph Hellwig val_a > val_b) { 1560f461d2dcSChristoph Hellwig err = -EINVAL; 1561f461d2dcSChristoph Hellwig break; 1562f461d2dcSChristoph Hellwig } 1563f461d2dcSChristoph Hellwig if (left) { 1564f461d2dcSChristoph Hellwig p++; 1565f461d2dcSChristoph Hellwig left--; 1566f461d2dcSChristoph Hellwig } 1567f461d2dcSChristoph Hellwig } 1568f461d2dcSChristoph Hellwig 1569f461d2dcSChristoph Hellwig bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 1570f461d2dcSChristoph Hellwig first = 0; 1571f461d2dcSChristoph Hellwig proc_skip_char(&p, &left, '\n'); 1572f461d2dcSChristoph Hellwig } 1573f461d2dcSChristoph Hellwig left += skipped; 1574f461d2dcSChristoph Hellwig } else { 1575f461d2dcSChristoph Hellwig unsigned long bit_a, bit_b = 0; 1576f461d2dcSChristoph Hellwig 1577f461d2dcSChristoph Hellwig while (left) { 1578f461d2dcSChristoph Hellwig bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 1579f461d2dcSChristoph Hellwig if (bit_a >= bitmap_len) 1580f461d2dcSChristoph Hellwig break; 1581f461d2dcSChristoph Hellwig bit_b = find_next_zero_bit(bitmap, bitmap_len, 1582f461d2dcSChristoph Hellwig bit_a + 1) - 1; 1583f461d2dcSChristoph Hellwig 158432927393SChristoph Hellwig if (!first) 158532927393SChristoph Hellwig proc_put_char(&buffer, &left, ','); 158632927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_a, false); 1587f461d2dcSChristoph Hellwig if (bit_a != bit_b) { 158832927393SChristoph Hellwig proc_put_char(&buffer, &left, '-'); 158932927393SChristoph Hellwig proc_put_long(&buffer, &left, bit_b, false); 1590f461d2dcSChristoph Hellwig } 1591f461d2dcSChristoph Hellwig 1592f461d2dcSChristoph Hellwig first = 0; bit_b++; 1593f461d2dcSChristoph Hellwig } 159432927393SChristoph Hellwig proc_put_char(&buffer, &left, '\n'); 1595f461d2dcSChristoph Hellwig } 1596f461d2dcSChristoph Hellwig 1597f461d2dcSChristoph Hellwig if (!err) { 1598f461d2dcSChristoph Hellwig if (write) { 1599f461d2dcSChristoph Hellwig if (*ppos) 1600f461d2dcSChristoph Hellwig bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 1601f461d2dcSChristoph Hellwig else 1602f461d2dcSChristoph Hellwig bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 1603f461d2dcSChristoph Hellwig } 1604f461d2dcSChristoph Hellwig *lenp -= left; 1605f461d2dcSChristoph Hellwig *ppos += *lenp; 1606f461d2dcSChristoph Hellwig } 1607f461d2dcSChristoph Hellwig 1608f461d2dcSChristoph Hellwig bitmap_free(tmp_bitmap); 1609f461d2dcSChristoph Hellwig return err; 1610f461d2dcSChristoph Hellwig } 1611f461d2dcSChristoph Hellwig 1612f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */ 1613f461d2dcSChristoph Hellwig 1614f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write, 161532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1616f461d2dcSChristoph Hellwig { 1617f461d2dcSChristoph Hellwig return -ENOSYS; 1618f461d2dcSChristoph Hellwig } 1619f461d2dcSChristoph Hellwig 1620f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, 162132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1622f461d2dcSChristoph Hellwig { 1623f461d2dcSChristoph Hellwig return -ENOSYS; 1624f461d2dcSChristoph Hellwig } 1625f461d2dcSChristoph Hellwig 1626f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, 162732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1628f461d2dcSChristoph Hellwig { 1629f461d2dcSChristoph Hellwig return -ENOSYS; 1630f461d2dcSChristoph Hellwig } 1631f461d2dcSChristoph Hellwig 1632f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write, 163332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1634f461d2dcSChristoph Hellwig { 1635f461d2dcSChristoph Hellwig return -ENOSYS; 1636f461d2dcSChristoph Hellwig } 1637f461d2dcSChristoph Hellwig 1638f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write, 163932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1640f461d2dcSChristoph Hellwig { 1641f461d2dcSChristoph Hellwig return -ENOSYS; 1642f461d2dcSChristoph Hellwig } 1643f461d2dcSChristoph Hellwig 1644*cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write, 1645*cb944413SEric Dumazet void *buffer, size_t *lenp, loff_t *ppos) 1646*cb944413SEric Dumazet { 1647*cb944413SEric Dumazet return -ENOSYS; 1648*cb944413SEric Dumazet } 1649*cb944413SEric Dumazet 1650f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write, 165132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1652f461d2dcSChristoph Hellwig { 1653f461d2dcSChristoph Hellwig return -ENOSYS; 1654f461d2dcSChristoph Hellwig } 1655f461d2dcSChristoph Hellwig 1656f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 165732927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1658f461d2dcSChristoph Hellwig { 1659f461d2dcSChristoph Hellwig return -ENOSYS; 1660f461d2dcSChristoph Hellwig } 1661f461d2dcSChristoph Hellwig 1662f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 166332927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1664f461d2dcSChristoph Hellwig { 1665f461d2dcSChristoph Hellwig return -ENOSYS; 1666f461d2dcSChristoph Hellwig } 1667f461d2dcSChristoph Hellwig 1668f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write, 166932927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1670f461d2dcSChristoph Hellwig { 1671f461d2dcSChristoph Hellwig return -ENOSYS; 1672f461d2dcSChristoph Hellwig } 1673f461d2dcSChristoph Hellwig 1674f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 167532927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1676f461d2dcSChristoph Hellwig { 1677f461d2dcSChristoph Hellwig return -ENOSYS; 1678f461d2dcSChristoph Hellwig } 1679f461d2dcSChristoph Hellwig 1680f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write, 168132927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1682f461d2dcSChristoph Hellwig { 1683f461d2dcSChristoph Hellwig return -ENOSYS; 1684f461d2dcSChristoph Hellwig } 1685f461d2dcSChristoph Hellwig 1686f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */ 1687f461d2dcSChristoph Hellwig 1688f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL) 1689f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write, 169032927393SChristoph Hellwig void *buffer, size_t *lenp, loff_t *ppos) 1691f461d2dcSChristoph Hellwig { 1692f461d2dcSChristoph Hellwig struct static_key *key = (struct static_key *)table->data; 1693f461d2dcSChristoph Hellwig static DEFINE_MUTEX(static_key_mutex); 1694f461d2dcSChristoph Hellwig int val, ret; 1695f461d2dcSChristoph Hellwig struct ctl_table tmp = { 1696f461d2dcSChristoph Hellwig .data = &val, 1697f461d2dcSChristoph Hellwig .maxlen = sizeof(val), 1698f461d2dcSChristoph Hellwig .mode = table->mode, 1699f461d2dcSChristoph Hellwig .extra1 = SYSCTL_ZERO, 1700f461d2dcSChristoph Hellwig .extra2 = SYSCTL_ONE, 1701f461d2dcSChristoph Hellwig }; 1702f461d2dcSChristoph Hellwig 1703f461d2dcSChristoph Hellwig if (write && !capable(CAP_SYS_ADMIN)) 1704f461d2dcSChristoph Hellwig return -EPERM; 1705f461d2dcSChristoph Hellwig 1706f461d2dcSChristoph Hellwig mutex_lock(&static_key_mutex); 1707f461d2dcSChristoph Hellwig val = static_key_enabled(key); 1708f461d2dcSChristoph Hellwig ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); 1709f461d2dcSChristoph Hellwig if (write && !ret) { 1710f461d2dcSChristoph Hellwig if (val) 1711f461d2dcSChristoph Hellwig static_key_enable(key); 1712f461d2dcSChristoph Hellwig else 1713f461d2dcSChristoph Hellwig static_key_disable(key); 1714f461d2dcSChristoph Hellwig } 1715f461d2dcSChristoph Hellwig mutex_unlock(&static_key_mutex); 1716f461d2dcSChristoph Hellwig return ret; 1717f461d2dcSChristoph Hellwig } 1718f461d2dcSChristoph Hellwig 1719d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 17202bba22c5SMike Galbraith { 17212bba22c5SMike Galbraith .procname = "sched_child_runs_first", 17222bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 17232bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 17242bba22c5SMike Galbraith .mode = 0644, 17256d456111SEric W. Biederman .proc_handler = proc_dointvec, 17262bba22c5SMike Galbraith }, 172777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 172877e54a1fSIngo Molnar { 1729b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 1730b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 173177e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 173277e54a1fSIngo Molnar .mode = 0644, 1733702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 1734b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 1735b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 173677e54a1fSIngo Molnar }, 173777e54a1fSIngo Molnar { 173821805085SPeter Zijlstra .procname = "sched_latency_ns", 173921805085SPeter Zijlstra .data = &sysctl_sched_latency, 174021805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 174121805085SPeter Zijlstra .mode = 0644, 1742702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 174321805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 174421805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 174521805085SPeter Zijlstra }, 174621805085SPeter Zijlstra { 174777e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 174877e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 174977e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 175077e54a1fSIngo Molnar .mode = 0644, 1751702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 175277e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 175377e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 175477e54a1fSIngo Molnar }, 1755cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP 175677e54a1fSIngo Molnar { 17571983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 17581983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 17591983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 17601983a922SChristian Ehrhardt .mode = 0644, 1761702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 17621983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 17631983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 17642398f2c6SPeter Zijlstra }, 17652398f2c6SPeter Zijlstra { 1766d00535dbSNamhyung Kim .procname = "sched_migration_cost_ns", 1767da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 1768da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 1769da84d961SIngo Molnar .mode = 0644, 17706d456111SEric W. Biederman .proc_handler = proc_dointvec, 1771da84d961SIngo Molnar }, 1772b82d9fddSPeter Zijlstra { 1773b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 1774b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 1775b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 1776fa85ae24SPeter Zijlstra .mode = 0644, 17776d456111SEric W. Biederman .proc_handler = proc_dointvec, 1778fa85ae24SPeter Zijlstra }, 1779cb251765SMel Gorman #ifdef CONFIG_SCHEDSTATS 1780cb251765SMel Gorman { 1781cb251765SMel Gorman .procname = "sched_schedstats", 1782cb251765SMel Gorman .data = NULL, 1783cb251765SMel Gorman .maxlen = sizeof(unsigned int), 1784cb251765SMel Gorman .mode = 0644, 1785cb251765SMel Gorman .proc_handler = sysctl_schedstats, 1786eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1787eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1788cb251765SMel Gorman }, 1789cb251765SMel Gorman #endif /* CONFIG_SCHEDSTATS */ 1790cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */ 1791cbee9f88SPeter Zijlstra #ifdef CONFIG_NUMA_BALANCING 1792cbee9f88SPeter Zijlstra { 17934b96a29bSPeter Zijlstra .procname = "numa_balancing_scan_delay_ms", 17944b96a29bSPeter Zijlstra .data = &sysctl_numa_balancing_scan_delay, 17954b96a29bSPeter Zijlstra .maxlen = sizeof(unsigned int), 17964b96a29bSPeter Zijlstra .mode = 0644, 17974b96a29bSPeter Zijlstra .proc_handler = proc_dointvec, 17984b96a29bSPeter Zijlstra }, 17994b96a29bSPeter Zijlstra { 1800cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_min_ms", 1801cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_min, 1802cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1803cbee9f88SPeter Zijlstra .mode = 0644, 1804cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1805cbee9f88SPeter Zijlstra }, 1806cbee9f88SPeter Zijlstra { 1807cbee9f88SPeter Zijlstra .procname = "numa_balancing_scan_period_max_ms", 1808cbee9f88SPeter Zijlstra .data = &sysctl_numa_balancing_scan_period_max, 1809cbee9f88SPeter Zijlstra .maxlen = sizeof(unsigned int), 1810cbee9f88SPeter Zijlstra .mode = 0644, 1811cbee9f88SPeter Zijlstra .proc_handler = proc_dointvec, 1812cbee9f88SPeter Zijlstra }, 18136e5fb223SPeter Zijlstra { 18146e5fb223SPeter Zijlstra .procname = "numa_balancing_scan_size_mb", 18156e5fb223SPeter Zijlstra .data = &sysctl_numa_balancing_scan_size, 18166e5fb223SPeter Zijlstra .maxlen = sizeof(unsigned int), 18176e5fb223SPeter Zijlstra .mode = 0644, 181864192658SKirill Tkhai .proc_handler = proc_dointvec_minmax, 1819eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 18206e5fb223SPeter Zijlstra }, 18213a7053b3SMel Gorman { 182254a43d54SAndi Kleen .procname = "numa_balancing", 182354a43d54SAndi Kleen .data = NULL, /* filled in by handler */ 182454a43d54SAndi Kleen .maxlen = sizeof(unsigned int), 182554a43d54SAndi Kleen .mode = 0644, 182654a43d54SAndi Kleen .proc_handler = sysctl_numa_balancing, 1827eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1828eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 182954a43d54SAndi Kleen }, 1830cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */ 1831cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */ 18321799e35dSIngo Molnar { 18339f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 18349f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 18359f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 18369f0c1e56SPeter Zijlstra .mode = 0644, 18376d456111SEric W. Biederman .proc_handler = sched_rt_handler, 18389f0c1e56SPeter Zijlstra }, 18399f0c1e56SPeter Zijlstra { 18409f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 18419f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 18429f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 18439f0c1e56SPeter Zijlstra .mode = 0644, 18446d456111SEric W. Biederman .proc_handler = sched_rt_handler, 18459f0c1e56SPeter Zijlstra }, 1846ce0dbbbbSClark Williams { 1847b4098bfcSPeter Zijlstra .procname = "sched_deadline_period_max_us", 1848b4098bfcSPeter Zijlstra .data = &sysctl_sched_dl_period_max, 1849b4098bfcSPeter Zijlstra .maxlen = sizeof(unsigned int), 1850b4098bfcSPeter Zijlstra .mode = 0644, 1851b4098bfcSPeter Zijlstra .proc_handler = proc_dointvec, 1852b4098bfcSPeter Zijlstra }, 1853b4098bfcSPeter Zijlstra { 1854b4098bfcSPeter Zijlstra .procname = "sched_deadline_period_min_us", 1855b4098bfcSPeter Zijlstra .data = &sysctl_sched_dl_period_min, 1856b4098bfcSPeter Zijlstra .maxlen = sizeof(unsigned int), 1857b4098bfcSPeter Zijlstra .mode = 0644, 1858b4098bfcSPeter Zijlstra .proc_handler = proc_dointvec, 1859b4098bfcSPeter Zijlstra }, 1860b4098bfcSPeter Zijlstra { 1861ce0dbbbbSClark Williams .procname = "sched_rr_timeslice_ms", 1862975e155eSShile Zhang .data = &sysctl_sched_rr_timeslice, 1863ce0dbbbbSClark Williams .maxlen = sizeof(int), 1864ce0dbbbbSClark Williams .mode = 0644, 1865ce0dbbbbSClark Williams .proc_handler = sched_rr_handler, 1866ce0dbbbbSClark Williams }, 1867e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK 1868e8f14172SPatrick Bellasi { 1869e8f14172SPatrick Bellasi .procname = "sched_util_clamp_min", 1870e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_min, 1871e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1872e8f14172SPatrick Bellasi .mode = 0644, 1873e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1874e8f14172SPatrick Bellasi }, 1875e8f14172SPatrick Bellasi { 1876e8f14172SPatrick Bellasi .procname = "sched_util_clamp_max", 1877e8f14172SPatrick Bellasi .data = &sysctl_sched_uclamp_util_max, 1878e8f14172SPatrick Bellasi .maxlen = sizeof(unsigned int), 1879e8f14172SPatrick Bellasi .mode = 0644, 1880e8f14172SPatrick Bellasi .proc_handler = sysctl_sched_uclamp_handler, 1881e8f14172SPatrick Bellasi }, 188213685c4aSQais Yousef { 188313685c4aSQais Yousef .procname = "sched_util_clamp_min_rt_default", 188413685c4aSQais Yousef .data = &sysctl_sched_uclamp_util_min_rt_default, 188513685c4aSQais Yousef .maxlen = sizeof(unsigned int), 188613685c4aSQais Yousef .mode = 0644, 188713685c4aSQais Yousef .proc_handler = sysctl_sched_uclamp_handler, 188813685c4aSQais Yousef }, 1889e8f14172SPatrick Bellasi #endif 18905091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 18915091faa4SMike Galbraith { 18925091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 18935091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 18945091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 18955091faa4SMike Galbraith .mode = 0644, 18961747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 1897eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1898eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 18995091faa4SMike Galbraith }, 19005091faa4SMike Galbraith #endif 1901ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 1902ec12cb7fSPaul Turner { 1903ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 1904ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 1905ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 1906ec12cb7fSPaul Turner .mode = 0644, 1907ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 1908eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 1909ec12cb7fSPaul Turner }, 1910ec12cb7fSPaul Turner #endif 19118d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) 19128d5d0cfbSQuentin Perret { 19138d5d0cfbSQuentin Perret .procname = "sched_energy_aware", 19148d5d0cfbSQuentin Perret .data = &sysctl_sched_energy_aware, 19158d5d0cfbSQuentin Perret .maxlen = sizeof(unsigned int), 19168d5d0cfbSQuentin Perret .mode = 0644, 19178d5d0cfbSQuentin Perret .proc_handler = sched_energy_aware_handler, 1918eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 1919eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 19208d5d0cfbSQuentin Perret }, 19218d5d0cfbSQuentin Perret #endif 1922f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 1923f20786ffSPeter Zijlstra { 1924f20786ffSPeter Zijlstra .procname = "prove_locking", 1925f20786ffSPeter Zijlstra .data = &prove_locking, 1926f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1927f20786ffSPeter Zijlstra .mode = 0644, 19286d456111SEric W. Biederman .proc_handler = proc_dointvec, 1929f20786ffSPeter Zijlstra }, 1930f20786ffSPeter Zijlstra #endif 1931f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 1932f20786ffSPeter Zijlstra { 1933f20786ffSPeter Zijlstra .procname = "lock_stat", 1934f20786ffSPeter Zijlstra .data = &lock_stat, 1935f20786ffSPeter Zijlstra .maxlen = sizeof(int), 1936f20786ffSPeter Zijlstra .mode = 0644, 19376d456111SEric W. Biederman .proc_handler = proc_dointvec, 1938f20786ffSPeter Zijlstra }, 1939f20786ffSPeter Zijlstra #endif 194077e54a1fSIngo Molnar { 19411da177e4SLinus Torvalds .procname = "panic", 19421da177e4SLinus Torvalds .data = &panic_timeout, 19431da177e4SLinus Torvalds .maxlen = sizeof(int), 19441da177e4SLinus Torvalds .mode = 0644, 19456d456111SEric W. Biederman .proc_handler = proc_dointvec, 19461da177e4SLinus Torvalds }, 1947046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 19481da177e4SLinus Torvalds { 19491da177e4SLinus Torvalds .procname = "core_uses_pid", 19501da177e4SLinus Torvalds .data = &core_uses_pid, 19511da177e4SLinus Torvalds .maxlen = sizeof(int), 19521da177e4SLinus Torvalds .mode = 0644, 19536d456111SEric W. Biederman .proc_handler = proc_dointvec, 19541da177e4SLinus Torvalds }, 19551da177e4SLinus Torvalds { 19561da177e4SLinus Torvalds .procname = "core_pattern", 19571da177e4SLinus Torvalds .data = core_pattern, 195871ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 19591da177e4SLinus Torvalds .mode = 0644, 196054b50199SKees Cook .proc_handler = proc_dostring_coredump, 19611da177e4SLinus Torvalds }, 1962a293980cSNeil Horman { 1963a293980cSNeil Horman .procname = "core_pipe_limit", 1964a293980cSNeil Horman .data = &core_pipe_limit, 1965a293980cSNeil Horman .maxlen = sizeof(unsigned int), 1966a293980cSNeil Horman .mode = 0644, 19676d456111SEric W. Biederman .proc_handler = proc_dointvec, 1968a293980cSNeil Horman }, 1969046d662fSAlex Kelly #endif 197034f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 19711da177e4SLinus Torvalds { 19721da177e4SLinus Torvalds .procname = "tainted", 197325ddbb18SAndi Kleen .maxlen = sizeof(long), 197434f5a398STheodore Ts'o .mode = 0644, 19756d456111SEric W. Biederman .proc_handler = proc_taint, 19761da177e4SLinus Torvalds }, 1977f4aacea2SKees Cook { 1978f4aacea2SKees Cook .procname = "sysctl_writes_strict", 1979f4aacea2SKees Cook .data = &sysctl_writes_strict, 1980f4aacea2SKees Cook .maxlen = sizeof(int), 1981f4aacea2SKees Cook .mode = 0644, 1982f4aacea2SKees Cook .proc_handler = proc_dointvec_minmax, 1983f4aacea2SKees Cook .extra1 = &neg_one, 1984eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 1985f4aacea2SKees Cook }, 198634f5a398STheodore Ts'o #endif 19879745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 19889745512cSArjan van de Ven { 19899745512cSArjan van de Ven .procname = "latencytop", 19909745512cSArjan van de Ven .data = &latencytop_enabled, 19919745512cSArjan van de Ven .maxlen = sizeof(int), 19929745512cSArjan van de Ven .mode = 0644, 1993cb251765SMel Gorman .proc_handler = sysctl_latencytop, 19949745512cSArjan van de Ven }, 19959745512cSArjan van de Ven #endif 19961da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 19971da177e4SLinus Torvalds { 19981da177e4SLinus Torvalds .procname = "real-root-dev", 19991da177e4SLinus Torvalds .data = &real_root_dev, 20001da177e4SLinus Torvalds .maxlen = sizeof(int), 20011da177e4SLinus Torvalds .mode = 0644, 20026d456111SEric W. Biederman .proc_handler = proc_dointvec, 20031da177e4SLinus Torvalds }, 20041da177e4SLinus Torvalds #endif 200545807a1dSIngo Molnar { 200645807a1dSIngo Molnar .procname = "print-fatal-signals", 200745807a1dSIngo Molnar .data = &print_fatal_signals, 200845807a1dSIngo Molnar .maxlen = sizeof(int), 200945807a1dSIngo Molnar .mode = 0644, 20106d456111SEric W. Biederman .proc_handler = proc_dointvec, 201145807a1dSIngo Molnar }, 201272c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 20131da177e4SLinus Torvalds { 20141da177e4SLinus Torvalds .procname = "reboot-cmd", 20151da177e4SLinus Torvalds .data = reboot_command, 20161da177e4SLinus Torvalds .maxlen = 256, 20171da177e4SLinus Torvalds .mode = 0644, 20186d456111SEric W. Biederman .proc_handler = proc_dostring, 20191da177e4SLinus Torvalds }, 20201da177e4SLinus Torvalds { 20211da177e4SLinus Torvalds .procname = "stop-a", 20221da177e4SLinus Torvalds .data = &stop_a_enabled, 20231da177e4SLinus Torvalds .maxlen = sizeof (int), 20241da177e4SLinus Torvalds .mode = 0644, 20256d456111SEric W. Biederman .proc_handler = proc_dointvec, 20261da177e4SLinus Torvalds }, 20271da177e4SLinus Torvalds { 20281da177e4SLinus Torvalds .procname = "scons-poweroff", 20291da177e4SLinus Torvalds .data = &scons_pwroff, 20301da177e4SLinus Torvalds .maxlen = sizeof (int), 20311da177e4SLinus Torvalds .mode = 0644, 20326d456111SEric W. Biederman .proc_handler = proc_dointvec, 20331da177e4SLinus Torvalds }, 20341da177e4SLinus Torvalds #endif 20350871420fSDavid S. Miller #ifdef CONFIG_SPARC64 20360871420fSDavid S. Miller { 20370871420fSDavid S. Miller .procname = "tsb-ratio", 20380871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 20390871420fSDavid S. Miller .maxlen = sizeof (int), 20400871420fSDavid S. Miller .mode = 0644, 20416d456111SEric W. Biederman .proc_handler = proc_dointvec, 20420871420fSDavid S. Miller }, 20430871420fSDavid S. Miller #endif 2044b67114dbSHelge Deller #ifdef CONFIG_PARISC 20451da177e4SLinus Torvalds { 20461da177e4SLinus Torvalds .procname = "soft-power", 20471da177e4SLinus Torvalds .data = &pwrsw_enabled, 20481da177e4SLinus Torvalds .maxlen = sizeof (int), 20491da177e4SLinus Torvalds .mode = 0644, 20506d456111SEric W. Biederman .proc_handler = proc_dointvec, 20511da177e4SLinus Torvalds }, 2052bf14e3b9SVineet Gupta #endif 2053bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW 20541da177e4SLinus Torvalds { 20551da177e4SLinus Torvalds .procname = "unaligned-trap", 20561da177e4SLinus Torvalds .data = &unaligned_enabled, 20571da177e4SLinus Torvalds .maxlen = sizeof (int), 20581da177e4SLinus Torvalds .mode = 0644, 20596d456111SEric W. Biederman .proc_handler = proc_dointvec, 20601da177e4SLinus Torvalds }, 20611da177e4SLinus Torvalds #endif 20621da177e4SLinus Torvalds { 20631da177e4SLinus Torvalds .procname = "ctrl-alt-del", 20641da177e4SLinus Torvalds .data = &C_A_D, 20651da177e4SLinus Torvalds .maxlen = sizeof(int), 20661da177e4SLinus Torvalds .mode = 0644, 20676d456111SEric W. Biederman .proc_handler = proc_dointvec, 20681da177e4SLinus Torvalds }, 2069606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 2070b0fc494fSSteven Rostedt { 2071b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 2072b0fc494fSSteven Rostedt .data = &ftrace_enabled, 2073b0fc494fSSteven Rostedt .maxlen = sizeof(int), 2074b0fc494fSSteven Rostedt .mode = 0644, 20756d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 2076b0fc494fSSteven Rostedt }, 2077b0fc494fSSteven Rostedt #endif 2078f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 2079f38f1d2aSSteven Rostedt { 2080f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 2081f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 2082f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 2083f38f1d2aSSteven Rostedt .mode = 0644, 20846d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 2085f38f1d2aSSteven Rostedt }, 2086f38f1d2aSSteven Rostedt #endif 2087944ac425SSteven Rostedt #ifdef CONFIG_TRACING 2088944ac425SSteven Rostedt { 20893299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 2090944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 2091944ac425SSteven Rostedt .maxlen = sizeof(int), 2092944ac425SSteven Rostedt .mode = 0644, 20936d456111SEric W. Biederman .proc_handler = proc_dointvec, 2094944ac425SSteven Rostedt }, 2095de7edd31SSteven Rostedt (Red Hat) { 2096de7edd31SSteven Rostedt (Red Hat) .procname = "traceoff_on_warning", 2097de7edd31SSteven Rostedt (Red Hat) .data = &__disable_trace_on_warning, 2098de7edd31SSteven Rostedt (Red Hat) .maxlen = sizeof(__disable_trace_on_warning), 2099de7edd31SSteven Rostedt (Red Hat) .mode = 0644, 2100de7edd31SSteven Rostedt (Red Hat) .proc_handler = proc_dointvec, 2101de7edd31SSteven Rostedt (Red Hat) }, 21020daa2302SSteven Rostedt (Red Hat) { 21030daa2302SSteven Rostedt (Red Hat) .procname = "tracepoint_printk", 21040daa2302SSteven Rostedt (Red Hat) .data = &tracepoint_printk, 21050daa2302SSteven Rostedt (Red Hat) .maxlen = sizeof(tracepoint_printk), 21060daa2302SSteven Rostedt (Red Hat) .mode = 0644, 210742391745SSteven Rostedt (Red Hat) .proc_handler = tracepoint_printk_sysctl, 21080daa2302SSteven Rostedt (Red Hat) }, 2109944ac425SSteven Rostedt #endif 21102965faa5SDave Young #ifdef CONFIG_KEXEC_CORE 21117984754bSKees Cook { 21127984754bSKees Cook .procname = "kexec_load_disabled", 21137984754bSKees Cook .data = &kexec_load_disabled, 21147984754bSKees Cook .maxlen = sizeof(int), 21157984754bSKees Cook .mode = 0644, 21167984754bSKees Cook /* only handle a transition from default "0" to "1" */ 21177984754bSKees Cook .proc_handler = proc_dointvec_minmax, 2118eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2119eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 21207984754bSKees Cook }, 21217984754bSKees Cook #endif 2122a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 21231da177e4SLinus Torvalds { 21241da177e4SLinus Torvalds .procname = "modprobe", 21251da177e4SLinus Torvalds .data = &modprobe_path, 21261da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 21271da177e4SLinus Torvalds .mode = 0644, 21286d456111SEric W. Biederman .proc_handler = proc_dostring, 21291da177e4SLinus Torvalds }, 21303d43321bSKees Cook { 21313d43321bSKees Cook .procname = "modules_disabled", 21323d43321bSKees Cook .data = &modules_disabled, 21333d43321bSKees Cook .maxlen = sizeof(int), 21343d43321bSKees Cook .mode = 0644, 21353d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 21366d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2137eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2138eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 21393d43321bSKees Cook }, 21401da177e4SLinus Torvalds #endif 214186d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER 21421da177e4SLinus Torvalds { 21431da177e4SLinus Torvalds .procname = "hotplug", 2144312c004dSKay Sievers .data = &uevent_helper, 2145312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 21461da177e4SLinus Torvalds .mode = 0644, 21476d456111SEric W. Biederman .proc_handler = proc_dostring, 21481da177e4SLinus Torvalds }, 214986d56134SMichael Marineau #endif 21501da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 21511da177e4SLinus Torvalds { 21521da177e4SLinus Torvalds .procname = "sg-big-buff", 21531da177e4SLinus Torvalds .data = &sg_big_buff, 21541da177e4SLinus Torvalds .maxlen = sizeof (int), 21551da177e4SLinus Torvalds .mode = 0444, 21566d456111SEric W. Biederman .proc_handler = proc_dointvec, 21571da177e4SLinus Torvalds }, 21581da177e4SLinus Torvalds #endif 21591da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 21601da177e4SLinus Torvalds { 21611da177e4SLinus Torvalds .procname = "acct", 21621da177e4SLinus Torvalds .data = &acct_parm, 21631da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 21641da177e4SLinus Torvalds .mode = 0644, 21656d456111SEric W. Biederman .proc_handler = proc_dointvec, 21661da177e4SLinus Torvalds }, 21671da177e4SLinus Torvalds #endif 21681da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 21691da177e4SLinus Torvalds { 21701da177e4SLinus Torvalds .procname = "sysrq", 2171eaee4172SDmitry Safonov .data = NULL, 21721da177e4SLinus Torvalds .maxlen = sizeof (int), 21731da177e4SLinus Torvalds .mode = 0644, 217497f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 21751da177e4SLinus Torvalds }, 21761da177e4SLinus Torvalds #endif 2177d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 21781da177e4SLinus Torvalds { 21791da177e4SLinus Torvalds .procname = "cad_pid", 21809ec52099SCedric Le Goater .data = NULL, 21811da177e4SLinus Torvalds .maxlen = sizeof (int), 21821da177e4SLinus Torvalds .mode = 0600, 21836d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 21841da177e4SLinus Torvalds }, 2185d6f8ff73SRandy Dunlap #endif 21861da177e4SLinus Torvalds { 21871da177e4SLinus Torvalds .procname = "threads-max", 218816db3d3fSHeinrich Schuchardt .data = NULL, 21891da177e4SLinus Torvalds .maxlen = sizeof(int), 21901da177e4SLinus Torvalds .mode = 0644, 219116db3d3fSHeinrich Schuchardt .proc_handler = sysctl_max_threads, 21921da177e4SLinus Torvalds }, 21931da177e4SLinus Torvalds { 21941da177e4SLinus Torvalds .procname = "random", 21951da177e4SLinus Torvalds .mode = 0555, 21961da177e4SLinus Torvalds .child = random_table, 21971da177e4SLinus Torvalds }, 21981da177e4SLinus Torvalds { 219917f60a7dSEric Paris .procname = "usermodehelper", 220017f60a7dSEric Paris .mode = 0555, 220117f60a7dSEric Paris .child = usermodehelper_table, 220217f60a7dSEric Paris }, 2203ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER 2204ceb18132SLuis R. Rodriguez { 2205ceb18132SLuis R. Rodriguez .procname = "firmware_config", 2206ceb18132SLuis R. Rodriguez .mode = 0555, 2207ceb18132SLuis R. Rodriguez .child = firmware_config_table, 2208ceb18132SLuis R. Rodriguez }, 2209ceb18132SLuis R. Rodriguez #endif 221017f60a7dSEric Paris { 22111da177e4SLinus Torvalds .procname = "overflowuid", 22121da177e4SLinus Torvalds .data = &overflowuid, 22131da177e4SLinus Torvalds .maxlen = sizeof(int), 22141da177e4SLinus Torvalds .mode = 0644, 22156d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 22161da177e4SLinus Torvalds .extra1 = &minolduid, 22171da177e4SLinus Torvalds .extra2 = &maxolduid, 22181da177e4SLinus Torvalds }, 22191da177e4SLinus Torvalds { 22201da177e4SLinus Torvalds .procname = "overflowgid", 22211da177e4SLinus Torvalds .data = &overflowgid, 22221da177e4SLinus Torvalds .maxlen = sizeof(int), 22231da177e4SLinus Torvalds .mode = 0644, 22246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 22251da177e4SLinus Torvalds .extra1 = &minolduid, 22261da177e4SLinus Torvalds .extra2 = &maxolduid, 22271da177e4SLinus Torvalds }, 2228347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 22291da177e4SLinus Torvalds { 22301da177e4SLinus Torvalds .procname = "userprocess_debug", 2231ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 22321da177e4SLinus Torvalds .maxlen = sizeof(int), 22331da177e4SLinus Torvalds .mode = 0644, 22346d456111SEric W. Biederman .proc_handler = proc_dointvec, 22351da177e4SLinus Torvalds }, 22361da177e4SLinus Torvalds #endif 223760c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP 223860c958d8SGuilherme G. Piccoli { 223960c958d8SGuilherme G. Piccoli .procname = "oops_all_cpu_backtrace", 224060c958d8SGuilherme G. Piccoli .data = &sysctl_oops_all_cpu_backtrace, 224160c958d8SGuilherme G. Piccoli .maxlen = sizeof(int), 224260c958d8SGuilherme G. Piccoli .mode = 0644, 224360c958d8SGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 224460c958d8SGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 224560c958d8SGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 224660c958d8SGuilherme G. Piccoli }, 224760c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */ 22481da177e4SLinus Torvalds { 22491da177e4SLinus Torvalds .procname = "pid_max", 22501da177e4SLinus Torvalds .data = &pid_max, 22511da177e4SLinus Torvalds .maxlen = sizeof (int), 22521da177e4SLinus Torvalds .mode = 0644, 22536d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 22541da177e4SLinus Torvalds .extra1 = &pid_max_min, 22551da177e4SLinus Torvalds .extra2 = &pid_max_max, 22561da177e4SLinus Torvalds }, 22571da177e4SLinus Torvalds { 22581da177e4SLinus Torvalds .procname = "panic_on_oops", 22591da177e4SLinus Torvalds .data = &panic_on_oops, 22601da177e4SLinus Torvalds .maxlen = sizeof(int), 22611da177e4SLinus Torvalds .mode = 0644, 22626d456111SEric W. Biederman .proc_handler = proc_dointvec, 22631da177e4SLinus Torvalds }, 226481c9d43fSFeng Tang { 226581c9d43fSFeng Tang .procname = "panic_print", 226681c9d43fSFeng Tang .data = &panic_print, 226781c9d43fSFeng Tang .maxlen = sizeof(unsigned long), 226881c9d43fSFeng Tang .mode = 0644, 226981c9d43fSFeng Tang .proc_handler = proc_doulongvec_minmax, 227081c9d43fSFeng Tang }, 22717ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 22727ef3d2fdSJoe Perches { 22737ef3d2fdSJoe Perches .procname = "printk", 22747ef3d2fdSJoe Perches .data = &console_loglevel, 22757ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 22767ef3d2fdSJoe Perches .mode = 0644, 22776d456111SEric W. Biederman .proc_handler = proc_dointvec, 22787ef3d2fdSJoe Perches }, 22791da177e4SLinus Torvalds { 22801da177e4SLinus Torvalds .procname = "printk_ratelimit", 2281717115e1SDave Young .data = &printk_ratelimit_state.interval, 22821da177e4SLinus Torvalds .maxlen = sizeof(int), 22831da177e4SLinus Torvalds .mode = 0644, 22846d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 22851da177e4SLinus Torvalds }, 22861da177e4SLinus Torvalds { 22871da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 2288717115e1SDave Young .data = &printk_ratelimit_state.burst, 22891da177e4SLinus Torvalds .maxlen = sizeof(int), 22901da177e4SLinus Torvalds .mode = 0644, 22916d456111SEric W. Biederman .proc_handler = proc_dointvec, 22921da177e4SLinus Torvalds }, 2293af91322eSDave Young { 2294af91322eSDave Young .procname = "printk_delay", 2295af91322eSDave Young .data = &printk_delay_msec, 2296af91322eSDave Young .maxlen = sizeof(int), 2297af91322eSDave Young .mode = 0644, 22986d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2299eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2300af91322eSDave Young .extra2 = &ten_thousand, 2301af91322eSDave Young }, 23021da177e4SLinus Torvalds { 2303750afe7bSBorislav Petkov .procname = "printk_devkmsg", 2304750afe7bSBorislav Petkov .data = devkmsg_log_str, 2305750afe7bSBorislav Petkov .maxlen = DEVKMSG_STR_MAX_SIZE, 2306750afe7bSBorislav Petkov .mode = 0644, 2307750afe7bSBorislav Petkov .proc_handler = devkmsg_sysctl_set_loglvl, 2308750afe7bSBorislav Petkov }, 2309750afe7bSBorislav Petkov { 2310eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 2311eaf06b24SDan Rosenberg .data = &dmesg_restrict, 2312eaf06b24SDan Rosenberg .maxlen = sizeof(int), 2313eaf06b24SDan Rosenberg .mode = 0644, 2314620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2315eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2316eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2317eaf06b24SDan Rosenberg }, 2318455cd5abSDan Rosenberg { 2319455cd5abSDan Rosenberg .procname = "kptr_restrict", 2320455cd5abSDan Rosenberg .data = &kptr_restrict, 2321455cd5abSDan Rosenberg .maxlen = sizeof(int), 2322455cd5abSDan Rosenberg .mode = 0644, 2323620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 2324eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2325455cd5abSDan Rosenberg .extra2 = &two, 2326455cd5abSDan Rosenberg }, 2327df6e61d4SJoe Perches #endif 2328eaf06b24SDan Rosenberg { 23291da177e4SLinus Torvalds .procname = "ngroups_max", 23301da177e4SLinus Torvalds .data = &ngroups_max, 23311da177e4SLinus Torvalds .maxlen = sizeof (int), 23321da177e4SLinus Torvalds .mode = 0444, 23336d456111SEric W. Biederman .proc_handler = proc_dointvec, 23341da177e4SLinus Torvalds }, 233573efc039SDan Ballard { 233673efc039SDan Ballard .procname = "cap_last_cap", 233773efc039SDan Ballard .data = (void *)&cap_last_cap, 233873efc039SDan Ballard .maxlen = sizeof(int), 233973efc039SDan Ballard .mode = 0444, 234073efc039SDan Ballard .proc_handler = proc_dointvec, 234173efc039SDan Ballard }, 234258687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 2343504d7cf1SDon Zickus { 234458687acbSDon Zickus .procname = "watchdog", 23453c00ea82SFrederic Weisbecker .data = &watchdog_user_enabled, 2346504d7cf1SDon Zickus .maxlen = sizeof(int), 2347504d7cf1SDon Zickus .mode = 0644, 2348195daf66SUlrich Obergfell .proc_handler = proc_watchdog, 2349eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2350eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 235158687acbSDon Zickus }, 235258687acbSDon Zickus { 235358687acbSDon Zickus .procname = "watchdog_thresh", 2354586692a5SMandeep Singh Baines .data = &watchdog_thresh, 235558687acbSDon Zickus .maxlen = sizeof(int), 235658687acbSDon Zickus .mode = 0644, 2357195daf66SUlrich Obergfell .proc_handler = proc_watchdog_thresh, 2358eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 235958687acbSDon Zickus .extra2 = &sixty, 2360504d7cf1SDon Zickus }, 23612508ce18SDon Zickus { 2362195daf66SUlrich Obergfell .procname = "nmi_watchdog", 23637feeb9cdSThomas Gleixner .data = &nmi_watchdog_user_enabled, 2364195daf66SUlrich Obergfell .maxlen = sizeof(int), 236551d4052bSThomas Gleixner .mode = NMI_WATCHDOG_SYSCTL_PERM, 2366195daf66SUlrich Obergfell .proc_handler = proc_nmi_watchdog, 2367eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2368eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2369195daf66SUlrich Obergfell }, 2370195daf66SUlrich Obergfell { 237105a4a952SNicholas Piggin .procname = "watchdog_cpumask", 237205a4a952SNicholas Piggin .data = &watchdog_cpumask_bits, 237305a4a952SNicholas Piggin .maxlen = NR_CPUS, 237405a4a952SNicholas Piggin .mode = 0644, 237505a4a952SNicholas Piggin .proc_handler = proc_watchdog_cpumask, 237605a4a952SNicholas Piggin }, 237705a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR 237805a4a952SNicholas Piggin { 2379195daf66SUlrich Obergfell .procname = "soft_watchdog", 23807feeb9cdSThomas Gleixner .data = &soft_watchdog_user_enabled, 2381195daf66SUlrich Obergfell .maxlen = sizeof(int), 2382195daf66SUlrich Obergfell .mode = 0644, 2383195daf66SUlrich Obergfell .proc_handler = proc_soft_watchdog, 2384eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2385eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2386195daf66SUlrich Obergfell }, 2387195daf66SUlrich Obergfell { 23882508ce18SDon Zickus .procname = "softlockup_panic", 23892508ce18SDon Zickus .data = &softlockup_panic, 23902508ce18SDon Zickus .maxlen = sizeof(int), 23912508ce18SDon Zickus .mode = 0644, 23922508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 2393eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2394eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 23952508ce18SDon Zickus }, 2396ed235875SAaron Tomlin #ifdef CONFIG_SMP 2397ed235875SAaron Tomlin { 2398ed235875SAaron Tomlin .procname = "softlockup_all_cpu_backtrace", 2399ed235875SAaron Tomlin .data = &sysctl_softlockup_all_cpu_backtrace, 2400ed235875SAaron Tomlin .maxlen = sizeof(int), 2401ed235875SAaron Tomlin .mode = 0644, 2402ed235875SAaron Tomlin .proc_handler = proc_dointvec_minmax, 2403eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2404eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2405ed235875SAaron Tomlin }, 240605a4a952SNicholas Piggin #endif /* CONFIG_SMP */ 240705a4a952SNicholas Piggin #endif 240805a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR 240905a4a952SNicholas Piggin { 241005a4a952SNicholas Piggin .procname = "hardlockup_panic", 241105a4a952SNicholas Piggin .data = &hardlockup_panic, 241205a4a952SNicholas Piggin .maxlen = sizeof(int), 241305a4a952SNicholas Piggin .mode = 0644, 241405a4a952SNicholas Piggin .proc_handler = proc_dointvec_minmax, 2415eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2416eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 241705a4a952SNicholas Piggin }, 241805a4a952SNicholas Piggin #ifdef CONFIG_SMP 241955537871SJiri Kosina { 242055537871SJiri Kosina .procname = "hardlockup_all_cpu_backtrace", 242155537871SJiri Kosina .data = &sysctl_hardlockup_all_cpu_backtrace, 242255537871SJiri Kosina .maxlen = sizeof(int), 242355537871SJiri Kosina .mode = 0644, 242455537871SJiri Kosina .proc_handler = proc_dointvec_minmax, 2425eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2426eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 242755537871SJiri Kosina }, 2428ed235875SAaron Tomlin #endif /* CONFIG_SMP */ 24295dc30558SDon Zickus #endif 243005a4a952SNicholas Piggin #endif 243105a4a952SNicholas Piggin 24325dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 24335dc30558SDon Zickus { 24345dc30558SDon Zickus .procname = "unknown_nmi_panic", 24355dc30558SDon Zickus .data = &unknown_nmi_panic, 24365dc30558SDon Zickus .maxlen = sizeof (int), 24375dc30558SDon Zickus .mode = 0644, 24385dc30558SDon Zickus .proc_handler = proc_dointvec, 24395dc30558SDon Zickus }, 2440504d7cf1SDon Zickus #endif 2441b6522fa4SXiaoming Ni 2442b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \ 2443b6522fa4SXiaoming Ni defined(CONFIG_DEBUG_STACKOVERFLOW) 2444b6522fa4SXiaoming Ni { 2445b6522fa4SXiaoming Ni .procname = "panic_on_stackoverflow", 2446b6522fa4SXiaoming Ni .data = &sysctl_panic_on_stackoverflow, 2447b6522fa4SXiaoming Ni .maxlen = sizeof(int), 2448b6522fa4SXiaoming Ni .mode = 0644, 2449b6522fa4SXiaoming Ni .proc_handler = proc_dointvec, 2450b6522fa4SXiaoming Ni }, 2451b6522fa4SXiaoming Ni #endif 24521da177e4SLinus Torvalds #if defined(CONFIG_X86) 24531da177e4SLinus Torvalds { 24548da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 24558da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 24568da5addaSDon Zickus .maxlen = sizeof(int), 24578da5addaSDon Zickus .mode = 0644, 24586d456111SEric W. Biederman .proc_handler = proc_dointvec, 24598da5addaSDon Zickus }, 24608da5addaSDon Zickus { 24615211a242SKurt Garloff .procname = "panic_on_io_nmi", 24625211a242SKurt Garloff .data = &panic_on_io_nmi, 24635211a242SKurt Garloff .maxlen = sizeof(int), 24645211a242SKurt Garloff .mode = 0644, 24656d456111SEric W. Biederman .proc_handler = proc_dointvec, 24665211a242SKurt Garloff }, 24675211a242SKurt Garloff { 24681da177e4SLinus Torvalds .procname = "bootloader_type", 24691da177e4SLinus Torvalds .data = &bootloader_type, 24701da177e4SLinus Torvalds .maxlen = sizeof (int), 24711da177e4SLinus Torvalds .mode = 0444, 24726d456111SEric W. Biederman .proc_handler = proc_dointvec, 24731da177e4SLinus Torvalds }, 24740741f4d2SChuck Ebbert { 24755031296cSH. Peter Anvin .procname = "bootloader_version", 24765031296cSH. Peter Anvin .data = &bootloader_version, 24775031296cSH. Peter Anvin .maxlen = sizeof (int), 24785031296cSH. Peter Anvin .mode = 0444, 24796d456111SEric W. Biederman .proc_handler = proc_dointvec, 24805031296cSH. Peter Anvin }, 24815031296cSH. Peter Anvin { 24826e7c4025SIngo Molnar .procname = "io_delay_type", 24836e7c4025SIngo Molnar .data = &io_delay_type, 24846e7c4025SIngo Molnar .maxlen = sizeof(int), 24856e7c4025SIngo Molnar .mode = 0644, 24866d456111SEric W. Biederman .proc_handler = proc_dointvec, 24876e7c4025SIngo Molnar }, 24881da177e4SLinus Torvalds #endif 24897a9166e3SLuke Yang #if defined(CONFIG_MMU) 24901da177e4SLinus Torvalds { 24911da177e4SLinus Torvalds .procname = "randomize_va_space", 24921da177e4SLinus Torvalds .data = &randomize_va_space, 24931da177e4SLinus Torvalds .maxlen = sizeof(int), 24941da177e4SLinus Torvalds .mode = 0644, 24956d456111SEric W. Biederman .proc_handler = proc_dointvec, 24961da177e4SLinus Torvalds }, 24977a9166e3SLuke Yang #endif 24980152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 2499951f22d5SMartin Schwidefsky { 2500951f22d5SMartin Schwidefsky .procname = "spin_retry", 2501951f22d5SMartin Schwidefsky .data = &spin_retry, 2502951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 2503951f22d5SMartin Schwidefsky .mode = 0644, 25046d456111SEric W. Biederman .proc_handler = proc_dointvec, 2505951f22d5SMartin Schwidefsky }, 2506951f22d5SMartin Schwidefsky #endif 2507673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 2508c255d844SPavel Machek { 2509c255d844SPavel Machek .procname = "acpi_video_flags", 251077afcf78SPavel Machek .data = &acpi_realmode_flags, 2511c255d844SPavel Machek .maxlen = sizeof (unsigned long), 2512c255d844SPavel Machek .mode = 0644, 25136d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 2514c255d844SPavel Machek }, 2515c255d844SPavel Machek #endif 2516b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN 2517d2b176edSJes Sorensen { 2518d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 2519d2b176edSJes Sorensen .data = &no_unaligned_warning, 2520d2b176edSJes Sorensen .maxlen = sizeof (int), 2521d2b176edSJes Sorensen .mode = 0644, 25226d456111SEric W. Biederman .proc_handler = proc_dointvec, 2523d2b176edSJes Sorensen }, 2524b6fca725SVineet Gupta #endif 2525b6fca725SVineet Gupta #ifdef CONFIG_IA64 252688fc241fSDoug Chapman { 252788fc241fSDoug Chapman .procname = "unaligned-dump-stack", 252888fc241fSDoug Chapman .data = &unaligned_dump_stack, 252988fc241fSDoug Chapman .maxlen = sizeof (int), 253088fc241fSDoug Chapman .mode = 0644, 25316d456111SEric W. Biederman .proc_handler = proc_dointvec, 253288fc241fSDoug Chapman }, 2533d2b176edSJes Sorensen #endif 2534e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 25350ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP 25360ec9dc9bSGuilherme G. Piccoli { 25370ec9dc9bSGuilherme G. Piccoli .procname = "hung_task_all_cpu_backtrace", 25380ec9dc9bSGuilherme G. Piccoli .data = &sysctl_hung_task_all_cpu_backtrace, 25390ec9dc9bSGuilherme G. Piccoli .maxlen = sizeof(int), 25400ec9dc9bSGuilherme G. Piccoli .mode = 0644, 25410ec9dc9bSGuilherme G. Piccoli .proc_handler = proc_dointvec_minmax, 25420ec9dc9bSGuilherme G. Piccoli .extra1 = SYSCTL_ZERO, 25430ec9dc9bSGuilherme G. Piccoli .extra2 = SYSCTL_ONE, 25440ec9dc9bSGuilherme G. Piccoli }, 25450ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */ 2546e162b39aSMandeep Singh Baines { 2547e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 2548e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 2549e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 2550e162b39aSMandeep Singh Baines .mode = 0644, 25516d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2552eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2553eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2554e162b39aSMandeep Singh Baines }, 255582a1fcb9SIngo Molnar { 255682a1fcb9SIngo Molnar .procname = "hung_task_check_count", 255782a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 2558cd64647fSLi Zefan .maxlen = sizeof(int), 255982a1fcb9SIngo Molnar .mode = 0644, 2560cd64647fSLi Zefan .proc_handler = proc_dointvec_minmax, 2561eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 256282a1fcb9SIngo Molnar }, 256382a1fcb9SIngo Molnar { 256482a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 256582a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 256690739081SIngo Molnar .maxlen = sizeof(unsigned long), 256782a1fcb9SIngo Molnar .mode = 0644, 25686d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 256980df2847SLiu Hua .extra2 = &hung_task_timeout_max, 257082a1fcb9SIngo Molnar }, 257182a1fcb9SIngo Molnar { 2572a2e51445SDmitry Vyukov .procname = "hung_task_check_interval_secs", 2573a2e51445SDmitry Vyukov .data = &sysctl_hung_task_check_interval_secs, 2574a2e51445SDmitry Vyukov .maxlen = sizeof(unsigned long), 2575a2e51445SDmitry Vyukov .mode = 0644, 2576a2e51445SDmitry Vyukov .proc_handler = proc_dohung_task_timeout_secs, 2577a2e51445SDmitry Vyukov .extra2 = &hung_task_timeout_max, 2578a2e51445SDmitry Vyukov }, 2579a2e51445SDmitry Vyukov { 258082a1fcb9SIngo Molnar .procname = "hung_task_warnings", 258182a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 2582270750dbSAaron Tomlin .maxlen = sizeof(int), 258382a1fcb9SIngo Molnar .mode = 0644, 2584270750dbSAaron Tomlin .proc_handler = proc_dointvec_minmax, 2585270750dbSAaron Tomlin .extra1 = &neg_one, 258682a1fcb9SIngo Molnar }, 2587c4f3b63fSRavikiran G Thirumalai #endif 258823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 258923f78d4aSIngo Molnar { 259023f78d4aSIngo Molnar .procname = "max_lock_depth", 259123f78d4aSIngo Molnar .data = &max_lock_depth, 259223f78d4aSIngo Molnar .maxlen = sizeof(int), 259323f78d4aSIngo Molnar .mode = 0644, 25946d456111SEric W. Biederman .proc_handler = proc_dointvec, 259523f78d4aSIngo Molnar }, 259623f78d4aSIngo Molnar #endif 259710a0a8d4SJeremy Fitzhardinge { 259810a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 259910a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 260010a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 260110a0a8d4SJeremy Fitzhardinge .mode = 0644, 26026d456111SEric W. Biederman .proc_handler = proc_dostring, 260310a0a8d4SJeremy Fitzhardinge }, 26040b77f5bfSDavid Howells #ifdef CONFIG_KEYS 26050b77f5bfSDavid Howells { 26060b77f5bfSDavid Howells .procname = "keys", 26070b77f5bfSDavid Howells .mode = 0555, 26080b77f5bfSDavid Howells .child = key_sysctls, 26090b77f5bfSDavid Howells }, 26100b77f5bfSDavid Howells #endif 2611cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 2612aa4a2218SVince Weaver /* 2613aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 2614aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 2615aa4a2218SVince Weaver * 2616aa4a2218SVince Weaver * So it's an ABI, do not remove! 2617aa4a2218SVince Weaver */ 26181ccd1549SPeter Zijlstra { 2619cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 2620cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 2621cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 26221ccd1549SPeter Zijlstra .mode = 0644, 26236d456111SEric W. Biederman .proc_handler = proc_dointvec, 26241ccd1549SPeter Zijlstra }, 2625c5078f78SPeter Zijlstra { 2626cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 2627cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 2628cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 2629c5078f78SPeter Zijlstra .mode = 0644, 26306d456111SEric W. Biederman .proc_handler = proc_dointvec, 2631c5078f78SPeter Zijlstra }, 2632a78ac325SPeter Zijlstra { 2633cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 2634cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 2635cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 2636a78ac325SPeter Zijlstra .mode = 0644, 2637163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 2638eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2639a78ac325SPeter Zijlstra }, 264014c63f17SDave Hansen { 264114c63f17SDave Hansen .procname = "perf_cpu_time_max_percent", 264214c63f17SDave Hansen .data = &sysctl_perf_cpu_time_max_percent, 264314c63f17SDave Hansen .maxlen = sizeof(sysctl_perf_cpu_time_max_percent), 264414c63f17SDave Hansen .mode = 0644, 264514c63f17SDave Hansen .proc_handler = perf_cpu_time_max_percent_handler, 2646eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 264714c63f17SDave Hansen .extra2 = &one_hundred, 264814c63f17SDave Hansen }, 2649c5dfd78eSArnaldo Carvalho de Melo { 2650c5dfd78eSArnaldo Carvalho de Melo .procname = "perf_event_max_stack", 2651a831100aSArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_stack, 2652c5dfd78eSArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_stack), 2653c5dfd78eSArnaldo Carvalho de Melo .mode = 0644, 2654c5dfd78eSArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2655eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2656c5dfd78eSArnaldo Carvalho de Melo .extra2 = &six_hundred_forty_kb, 2657c5dfd78eSArnaldo Carvalho de Melo }, 2658c85b0334SArnaldo Carvalho de Melo { 2659c85b0334SArnaldo Carvalho de Melo .procname = "perf_event_max_contexts_per_stack", 2660c85b0334SArnaldo Carvalho de Melo .data = &sysctl_perf_event_max_contexts_per_stack, 2661c85b0334SArnaldo Carvalho de Melo .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack), 2662c85b0334SArnaldo Carvalho de Melo .mode = 0644, 2663c85b0334SArnaldo Carvalho de Melo .proc_handler = perf_event_max_stack_handler, 2664eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2665c85b0334SArnaldo Carvalho de Melo .extra2 = &one_thousand, 2666c85b0334SArnaldo Carvalho de Melo }, 26671ccd1549SPeter Zijlstra #endif 26689e3961a0SPrarit Bhargava { 26699e3961a0SPrarit Bhargava .procname = "panic_on_warn", 26709e3961a0SPrarit Bhargava .data = &panic_on_warn, 26719e3961a0SPrarit Bhargava .maxlen = sizeof(int), 26729e3961a0SPrarit Bhargava .mode = 0644, 26739e3961a0SPrarit Bhargava .proc_handler = proc_dointvec_minmax, 2674eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2675eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 26769e3961a0SPrarit Bhargava }, 2677bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2678bc7a34b8SThomas Gleixner { 2679bc7a34b8SThomas Gleixner .procname = "timer_migration", 2680bc7a34b8SThomas Gleixner .data = &sysctl_timer_migration, 2681bc7a34b8SThomas Gleixner .maxlen = sizeof(unsigned int), 2682bc7a34b8SThomas Gleixner .mode = 0644, 2683bc7a34b8SThomas Gleixner .proc_handler = timer_migration_handler, 2684eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2685eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2686bc7a34b8SThomas Gleixner }, 2687bc7a34b8SThomas Gleixner #endif 26881be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL 26891be7f75dSAlexei Starovoitov { 26901be7f75dSAlexei Starovoitov .procname = "unprivileged_bpf_disabled", 26911be7f75dSAlexei Starovoitov .data = &sysctl_unprivileged_bpf_disabled, 26921be7f75dSAlexei Starovoitov .maxlen = sizeof(sysctl_unprivileged_bpf_disabled), 26931be7f75dSAlexei Starovoitov .mode = 0644, 26941be7f75dSAlexei Starovoitov /* only handle a transition from default "0" to "1" */ 26951be7f75dSAlexei Starovoitov .proc_handler = proc_dointvec_minmax, 2696eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2697eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 26981be7f75dSAlexei Starovoitov }, 2699492ecee8SAlexei Starovoitov { 2700492ecee8SAlexei Starovoitov .procname = "bpf_stats_enabled", 2701a8e11e5cSEric Dumazet .data = &bpf_stats_enabled_key.key, 2702a8e11e5cSEric Dumazet .maxlen = sizeof(bpf_stats_enabled_key), 2703492ecee8SAlexei Starovoitov .mode = 0644, 2704d46edd67SSong Liu .proc_handler = bpf_stats_handler, 2705492ecee8SAlexei Starovoitov }, 27063fcc5530SAlexei Starovoitov #endif 2707b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU) 2708088e9d25SDaniel Bristot de Oliveira { 2709088e9d25SDaniel Bristot de Oliveira .procname = "panic_on_rcu_stall", 2710088e9d25SDaniel Bristot de Oliveira .data = &sysctl_panic_on_rcu_stall, 2711088e9d25SDaniel Bristot de Oliveira .maxlen = sizeof(sysctl_panic_on_rcu_stall), 2712088e9d25SDaniel Bristot de Oliveira .mode = 0644, 2713088e9d25SDaniel Bristot de Oliveira .proc_handler = proc_dointvec_minmax, 2714eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2715eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2716088e9d25SDaniel Bristot de Oliveira }, 2717088e9d25SDaniel Bristot de Oliveira #endif 2718dfe56404Schao #if defined(CONFIG_TREE_RCU) 2719dfe56404Schao { 2720dfe56404Schao .procname = "max_rcu_stall_to_panic", 2721dfe56404Schao .data = &sysctl_max_rcu_stall_to_panic, 2722dfe56404Schao .maxlen = sizeof(sysctl_max_rcu_stall_to_panic), 2723dfe56404Schao .mode = 0644, 2724dfe56404Schao .proc_handler = proc_dointvec_minmax, 2725dfe56404Schao .extra1 = SYSCTL_ONE, 2726dfe56404Schao .extra2 = SYSCTL_INT_MAX, 2727dfe56404Schao }, 2728dfe56404Schao #endif 2729964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE 2730964c9dffSAlexander Popov { 2731964c9dffSAlexander Popov .procname = "stack_erasing", 2732964c9dffSAlexander Popov .data = NULL, 2733964c9dffSAlexander Popov .maxlen = sizeof(int), 2734964c9dffSAlexander Popov .mode = 0600, 2735964c9dffSAlexander Popov .proc_handler = stack_erasing_sysctl, 2736eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2737eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 2738964c9dffSAlexander Popov }, 2739964c9dffSAlexander Popov #endif 27406fce56ecSEric W. Biederman { } 27411da177e4SLinus Torvalds }; 27421da177e4SLinus Torvalds 2743d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 27441da177e4SLinus Torvalds { 27451da177e4SLinus Torvalds .procname = "overcommit_memory", 27461da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 27471da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 27481da177e4SLinus Torvalds .mode = 0644, 274956f3547bSFeng Tang .proc_handler = overcommit_policy_handler, 2750eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2751cb16e95fSPetr Holasek .extra2 = &two, 27521da177e4SLinus Torvalds }, 27531da177e4SLinus Torvalds { 2754fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 2755fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 2756fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 2757fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 2758cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2759eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2760cb16e95fSPetr Holasek .extra2 = &two, 2761fadd8fbdSKAMEZAWA Hiroyuki }, 2762fadd8fbdSKAMEZAWA Hiroyuki { 2763fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 2764fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 2765fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 2766fe071d7eSDavid Rientjes .mode = 0644, 27676d456111SEric W. Biederman .proc_handler = proc_dointvec, 2768fe071d7eSDavid Rientjes }, 2769fe071d7eSDavid Rientjes { 2770fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 2771fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 2772fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 2773fef1bdd6SDavid Rientjes .mode = 0644, 27746d456111SEric W. Biederman .proc_handler = proc_dointvec, 2775fef1bdd6SDavid Rientjes }, 2776fef1bdd6SDavid Rientjes { 27771da177e4SLinus Torvalds .procname = "overcommit_ratio", 27781da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 27791da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 27801da177e4SLinus Torvalds .mode = 0644, 278149f0ce5fSJerome Marchand .proc_handler = overcommit_ratio_handler, 278249f0ce5fSJerome Marchand }, 278349f0ce5fSJerome Marchand { 278449f0ce5fSJerome Marchand .procname = "overcommit_kbytes", 278549f0ce5fSJerome Marchand .data = &sysctl_overcommit_kbytes, 278649f0ce5fSJerome Marchand .maxlen = sizeof(sysctl_overcommit_kbytes), 278749f0ce5fSJerome Marchand .mode = 0644, 278849f0ce5fSJerome Marchand .proc_handler = overcommit_kbytes_handler, 27891da177e4SLinus Torvalds }, 27901da177e4SLinus Torvalds { 27911da177e4SLinus Torvalds .procname = "page-cluster", 27921da177e4SLinus Torvalds .data = &page_cluster, 27931da177e4SLinus Torvalds .maxlen = sizeof(int), 27941da177e4SLinus Torvalds .mode = 0644, 2795cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2796eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 27971da177e4SLinus Torvalds }, 27981da177e4SLinus Torvalds { 27991da177e4SLinus Torvalds .procname = "dirty_background_ratio", 28001da177e4SLinus Torvalds .data = &dirty_background_ratio, 28011da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 28021da177e4SLinus Torvalds .mode = 0644, 28036d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 2804eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28051da177e4SLinus Torvalds .extra2 = &one_hundred, 28061da177e4SLinus Torvalds }, 28071da177e4SLinus Torvalds { 28082da02997SDavid Rientjes .procname = "dirty_background_bytes", 28092da02997SDavid Rientjes .data = &dirty_background_bytes, 28102da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 28112da02997SDavid Rientjes .mode = 0644, 28126d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 2813fc3501d4SSven Wegener .extra1 = &one_ul, 28142da02997SDavid Rientjes }, 28152da02997SDavid Rientjes { 28161da177e4SLinus Torvalds .procname = "dirty_ratio", 28171da177e4SLinus Torvalds .data = &vm_dirty_ratio, 28181da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 28191da177e4SLinus Torvalds .mode = 0644, 28206d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 2821eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28221da177e4SLinus Torvalds .extra2 = &one_hundred, 28231da177e4SLinus Torvalds }, 28241da177e4SLinus Torvalds { 28252da02997SDavid Rientjes .procname = "dirty_bytes", 28262da02997SDavid Rientjes .data = &vm_dirty_bytes, 28272da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 28282da02997SDavid Rientjes .mode = 0644, 28296d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 28309e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 28312da02997SDavid Rientjes }, 28322da02997SDavid Rientjes { 28331da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 2834f6ef9438SBart Samwel .data = &dirty_writeback_interval, 2835f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 28361da177e4SLinus Torvalds .mode = 0644, 28376d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 28381da177e4SLinus Torvalds }, 28391da177e4SLinus Torvalds { 28401da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 2841f6ef9438SBart Samwel .data = &dirty_expire_interval, 2842f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 28431da177e4SLinus Torvalds .mode = 0644, 2844cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 2845eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28461da177e4SLinus Torvalds }, 28471da177e4SLinus Torvalds { 28481efff914STheodore Ts'o .procname = "dirtytime_expire_seconds", 28491efff914STheodore Ts'o .data = &dirtytime_expire_interval, 28502d87b309SRandy Dunlap .maxlen = sizeof(dirtytime_expire_interval), 28511efff914STheodore Ts'o .mode = 0644, 28521efff914STheodore Ts'o .proc_handler = dirtytime_interval_handler, 2853eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 28541efff914STheodore Ts'o }, 28551efff914STheodore Ts'o { 28561da177e4SLinus Torvalds .procname = "swappiness", 28571da177e4SLinus Torvalds .data = &vm_swappiness, 28581da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 28591da177e4SLinus Torvalds .mode = 0644, 28606d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 2861eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2862c843966cSJohannes Weiner .extra2 = &two_hundred, 28631da177e4SLinus Torvalds }, 28641da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 28651da177e4SLinus Torvalds { 28661da177e4SLinus Torvalds .procname = "nr_hugepages", 2867e5ff2159SAndi Kleen .data = NULL, 28681da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 28691da177e4SLinus Torvalds .mode = 0644, 28706d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 28711da177e4SLinus Torvalds }, 287206808b08SLee Schermerhorn #ifdef CONFIG_NUMA 287306808b08SLee Schermerhorn { 287406808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 287506808b08SLee Schermerhorn .data = NULL, 287606808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 287706808b08SLee Schermerhorn .mode = 0644, 287806808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 287906808b08SLee Schermerhorn }, 28804518085eSKemi Wang { 28814518085eSKemi Wang .procname = "numa_stat", 28824518085eSKemi Wang .data = &sysctl_vm_numa_stat, 28834518085eSKemi Wang .maxlen = sizeof(int), 28844518085eSKemi Wang .mode = 0644, 28854518085eSKemi Wang .proc_handler = sysctl_vm_numa_stat_handler, 2886eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2887eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 28884518085eSKemi Wang }, 288906808b08SLee Schermerhorn #endif 28901da177e4SLinus Torvalds { 28911da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 28921da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 28931da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 28941da177e4SLinus Torvalds .mode = 0644, 28956d456111SEric W. Biederman .proc_handler = proc_dointvec, 28961da177e4SLinus Torvalds }, 2897396faf03SMel Gorman { 2898d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 2899e5ff2159SAndi Kleen .data = NULL, 2900e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 2901d1c3fb1fSNishanth Aravamudan .mode = 0644, 29026d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 2903d1c3fb1fSNishanth Aravamudan }, 29041da177e4SLinus Torvalds #endif 29051da177e4SLinus Torvalds { 29061da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 29071da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 29081da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 29091da177e4SLinus Torvalds .mode = 0644, 29106d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 29111da177e4SLinus Torvalds }, 29121da177e4SLinus Torvalds { 29139d0243bcSAndrew Morton .procname = "drop_caches", 29149d0243bcSAndrew Morton .data = &sysctl_drop_caches, 29159d0243bcSAndrew Morton .maxlen = sizeof(int), 2916204cb79aSJohannes Weiner .mode = 0200, 29179d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 2918eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 29195509a5d2SDave Hansen .extra2 = &four, 29209d0243bcSAndrew Morton }, 292176ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 292276ab0f53SMel Gorman { 292376ab0f53SMel Gorman .procname = "compact_memory", 292476ab0f53SMel Gorman .data = &sysctl_compact_memory, 292576ab0f53SMel Gorman .maxlen = sizeof(int), 292676ab0f53SMel Gorman .mode = 0200, 292776ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 292876ab0f53SMel Gorman }, 29295e771905SMel Gorman { 2930facdaa91SNitin Gupta .procname = "compaction_proactiveness", 2931facdaa91SNitin Gupta .data = &sysctl_compaction_proactiveness, 2932d34c0a75SNitin Gupta .maxlen = sizeof(sysctl_compaction_proactiveness), 2933facdaa91SNitin Gupta .mode = 0644, 2934facdaa91SNitin Gupta .proc_handler = proc_dointvec_minmax, 2935facdaa91SNitin Gupta .extra1 = SYSCTL_ZERO, 2936facdaa91SNitin Gupta .extra2 = &one_hundred, 2937facdaa91SNitin Gupta }, 2938facdaa91SNitin Gupta { 29395e771905SMel Gorman .procname = "extfrag_threshold", 29405e771905SMel Gorman .data = &sysctl_extfrag_threshold, 29415e771905SMel Gorman .maxlen = sizeof(int), 29425e771905SMel Gorman .mode = 0644, 29436b7e5cadSMatthew Wilcox .proc_handler = proc_dointvec_minmax, 29445e771905SMel Gorman .extra1 = &min_extfrag_threshold, 29455e771905SMel Gorman .extra2 = &max_extfrag_threshold, 29465e771905SMel Gorman }, 29475bbe3547SEric B Munson { 29485bbe3547SEric B Munson .procname = "compact_unevictable_allowed", 29495bbe3547SEric B Munson .data = &sysctl_compact_unevictable_allowed, 29505bbe3547SEric B Munson .maxlen = sizeof(int), 29515bbe3547SEric B Munson .mode = 0644, 29526923aa0dSSebastian Andrzej Siewior .proc_handler = proc_dointvec_minmax_warn_RT_change, 2953eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 2954eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 29555bbe3547SEric B Munson }, 29565e771905SMel Gorman 295776ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 29589d0243bcSAndrew Morton { 29591da177e4SLinus Torvalds .procname = "min_free_kbytes", 29601da177e4SLinus Torvalds .data = &min_free_kbytes, 29611da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 29621da177e4SLinus Torvalds .mode = 0644, 29636d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 2964eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29651da177e4SLinus Torvalds }, 29668ad4b1fbSRohit Seth { 29671c30844dSMel Gorman .procname = "watermark_boost_factor", 29681c30844dSMel Gorman .data = &watermark_boost_factor, 29691c30844dSMel Gorman .maxlen = sizeof(watermark_boost_factor), 29701c30844dSMel Gorman .mode = 0644, 297126363af5SChristoph Hellwig .proc_handler = proc_dointvec_minmax, 2972eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29731c30844dSMel Gorman }, 29741c30844dSMel Gorman { 2975795ae7a0SJohannes Weiner .procname = "watermark_scale_factor", 2976795ae7a0SJohannes Weiner .data = &watermark_scale_factor, 2977795ae7a0SJohannes Weiner .maxlen = sizeof(watermark_scale_factor), 2978795ae7a0SJohannes Weiner .mode = 0644, 2979795ae7a0SJohannes Weiner .proc_handler = watermark_scale_factor_sysctl_handler, 2980eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 2981795ae7a0SJohannes Weiner .extra2 = &one_thousand, 2982795ae7a0SJohannes Weiner }, 2983795ae7a0SJohannes Weiner { 29848ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 29858ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 29868ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 29878ad4b1fbSRohit Seth .mode = 0644, 29886d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 2989eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 29908ad4b1fbSRohit Seth }, 29915ef64cc8SLinus Torvalds { 29925ef64cc8SLinus Torvalds .procname = "page_lock_unfairness", 29935ef64cc8SLinus Torvalds .data = &sysctl_page_lock_unfairness, 29945ef64cc8SLinus Torvalds .maxlen = sizeof(sysctl_page_lock_unfairness), 29955ef64cc8SLinus Torvalds .mode = 0644, 29965ef64cc8SLinus Torvalds .proc_handler = proc_dointvec_minmax, 29975ef64cc8SLinus Torvalds .extra1 = SYSCTL_ZERO, 29985ef64cc8SLinus Torvalds }, 29991da177e4SLinus Torvalds #ifdef CONFIG_MMU 30001da177e4SLinus Torvalds { 30011da177e4SLinus Torvalds .procname = "max_map_count", 30021da177e4SLinus Torvalds .data = &sysctl_max_map_count, 30031da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 30041da177e4SLinus Torvalds .mode = 0644, 30053e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 3006eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30071da177e4SLinus Torvalds }, 3008dd8632a1SPaul Mundt #else 3009dd8632a1SPaul Mundt { 3010dd8632a1SPaul Mundt .procname = "nr_trim_pages", 3011dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 3012dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 3013dd8632a1SPaul Mundt .mode = 0644, 30146d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3015eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3016dd8632a1SPaul Mundt }, 30171da177e4SLinus Torvalds #endif 30181da177e4SLinus Torvalds { 30191da177e4SLinus Torvalds .procname = "laptop_mode", 30201da177e4SLinus Torvalds .data = &laptop_mode, 30211da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 30221da177e4SLinus Torvalds .mode = 0644, 30236d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 30241da177e4SLinus Torvalds }, 30251da177e4SLinus Torvalds { 30261da177e4SLinus Torvalds .procname = "block_dump", 30271da177e4SLinus Torvalds .data = &block_dump, 30281da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 30291da177e4SLinus Torvalds .mode = 0644, 30303b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3031eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30321da177e4SLinus Torvalds }, 30331da177e4SLinus Torvalds { 30341da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 30351da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 30361da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 30371da177e4SLinus Torvalds .mode = 0644, 30383b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3039eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30401da177e4SLinus Torvalds }, 304167f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ 304267f3977fSAlexandre Ghiti defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) 30431da177e4SLinus Torvalds { 30441da177e4SLinus Torvalds .procname = "legacy_va_layout", 30451da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 30461da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 30471da177e4SLinus Torvalds .mode = 0644, 30483b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3049eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30501da177e4SLinus Torvalds }, 30511da177e4SLinus Torvalds #endif 30521743660bSChristoph Lameter #ifdef CONFIG_NUMA 30531743660bSChristoph Lameter { 30541743660bSChristoph Lameter .procname = "zone_reclaim_mode", 3055a5f5f91dSMel Gorman .data = &node_reclaim_mode, 3056a5f5f91dSMel Gorman .maxlen = sizeof(node_reclaim_mode), 30571743660bSChristoph Lameter .mode = 0644, 30583b3376f2SLin Feng .proc_handler = proc_dointvec_minmax, 3059eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30601743660bSChristoph Lameter }, 30619614634fSChristoph Lameter { 30629614634fSChristoph Lameter .procname = "min_unmapped_ratio", 30639614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 30649614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 30659614634fSChristoph Lameter .mode = 0644, 30666d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 3067eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30689614634fSChristoph Lameter .extra2 = &one_hundred, 30699614634fSChristoph Lameter }, 30700ff38490SChristoph Lameter { 30710ff38490SChristoph Lameter .procname = "min_slab_ratio", 30720ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 30730ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 30740ff38490SChristoph Lameter .mode = 0644, 30756d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 3076eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 30770ff38490SChristoph Lameter .extra2 = &one_hundred, 30780ff38490SChristoph Lameter }, 30791743660bSChristoph Lameter #endif 308077461ab3SChristoph Lameter #ifdef CONFIG_SMP 308177461ab3SChristoph Lameter { 308277461ab3SChristoph Lameter .procname = "stat_interval", 308377461ab3SChristoph Lameter .data = &sysctl_stat_interval, 308477461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 308577461ab3SChristoph Lameter .mode = 0644, 30866d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 308777461ab3SChristoph Lameter }, 308852b6f46bSHugh Dickins { 308952b6f46bSHugh Dickins .procname = "stat_refresh", 309052b6f46bSHugh Dickins .data = NULL, 309152b6f46bSHugh Dickins .maxlen = 0, 309252b6f46bSHugh Dickins .mode = 0600, 309352b6f46bSHugh Dickins .proc_handler = vmstat_refresh, 309452b6f46bSHugh Dickins }, 309577461ab3SChristoph Lameter #endif 30966e141546SDavid Howells #ifdef CONFIG_MMU 3097ed032189SEric Paris { 3098ed032189SEric Paris .procname = "mmap_min_addr", 3099788084abSEric Paris .data = &dac_mmap_min_addr, 3100ed032189SEric Paris .maxlen = sizeof(unsigned long), 3101ed032189SEric Paris .mode = 0644, 31026d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 3103ed032189SEric Paris }, 31046e141546SDavid Howells #endif 3105f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 3106f0c0b2b8SKAMEZAWA Hiroyuki { 3107f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 3108f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 3109f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 3110f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 31116d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 3112f0c0b2b8SKAMEZAWA Hiroyuki }, 3113f0c0b2b8SKAMEZAWA Hiroyuki #endif 31142b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 31155c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 3116e6e5494cSIngo Molnar { 3117e6e5494cSIngo Molnar .procname = "vdso_enabled", 31183d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32 31193d7ee969SAndy Lutomirski .data = &vdso32_enabled, 31203d7ee969SAndy Lutomirski .maxlen = sizeof(vdso32_enabled), 31213d7ee969SAndy Lutomirski #else 3122e6e5494cSIngo Molnar .data = &vdso_enabled, 3123e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 31243d7ee969SAndy Lutomirski #endif 3125e6e5494cSIngo Molnar .mode = 0644, 31266d456111SEric W. Biederman .proc_handler = proc_dointvec, 3127eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3128e6e5494cSIngo Molnar }, 3129e6e5494cSIngo Molnar #endif 3130195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 3131195cf453SBron Gondwana { 3132195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 3133195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 3134195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 3135195cf453SBron Gondwana .mode = 0644, 31366d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3137eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3138eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3139195cf453SBron Gondwana }, 3140195cf453SBron Gondwana #endif 31416a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 31426a46079cSAndi Kleen { 31436a46079cSAndi Kleen .procname = "memory_failure_early_kill", 31446a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 31456a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 31466a46079cSAndi Kleen .mode = 0644, 31476d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3148eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3149eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 31506a46079cSAndi Kleen }, 31516a46079cSAndi Kleen { 31526a46079cSAndi Kleen .procname = "memory_failure_recovery", 31536a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 31546a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 31556a46079cSAndi Kleen .mode = 0644, 31566d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3157eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3158eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 31596a46079cSAndi Kleen }, 31606a46079cSAndi Kleen #endif 3161c9b1d098SAndrew Shewmaker { 3162c9b1d098SAndrew Shewmaker .procname = "user_reserve_kbytes", 3163c9b1d098SAndrew Shewmaker .data = &sysctl_user_reserve_kbytes, 3164c9b1d098SAndrew Shewmaker .maxlen = sizeof(sysctl_user_reserve_kbytes), 3165c9b1d098SAndrew Shewmaker .mode = 0644, 3166c9b1d098SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 3167c9b1d098SAndrew Shewmaker }, 31684eeab4f5SAndrew Shewmaker { 31694eeab4f5SAndrew Shewmaker .procname = "admin_reserve_kbytes", 31704eeab4f5SAndrew Shewmaker .data = &sysctl_admin_reserve_kbytes, 31714eeab4f5SAndrew Shewmaker .maxlen = sizeof(sysctl_admin_reserve_kbytes), 31724eeab4f5SAndrew Shewmaker .mode = 0644, 31734eeab4f5SAndrew Shewmaker .proc_handler = proc_doulongvec_minmax, 31744eeab4f5SAndrew Shewmaker }, 3175d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS 3176d07e2259SDaniel Cashman { 3177d07e2259SDaniel Cashman .procname = "mmap_rnd_bits", 3178d07e2259SDaniel Cashman .data = &mmap_rnd_bits, 3179d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_bits), 3180d07e2259SDaniel Cashman .mode = 0600, 3181d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3182d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_bits_min, 3183d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_bits_max, 3184d07e2259SDaniel Cashman }, 3185d07e2259SDaniel Cashman #endif 3186d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS 3187d07e2259SDaniel Cashman { 3188d07e2259SDaniel Cashman .procname = "mmap_rnd_compat_bits", 3189d07e2259SDaniel Cashman .data = &mmap_rnd_compat_bits, 3190d07e2259SDaniel Cashman .maxlen = sizeof(mmap_rnd_compat_bits), 3191d07e2259SDaniel Cashman .mode = 0600, 3192d07e2259SDaniel Cashman .proc_handler = proc_dointvec_minmax, 3193d07e2259SDaniel Cashman .extra1 = (void *)&mmap_rnd_compat_bits_min, 3194d07e2259SDaniel Cashman .extra2 = (void *)&mmap_rnd_compat_bits_max, 3195d07e2259SDaniel Cashman }, 3196d07e2259SDaniel Cashman #endif 3197cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD 3198cefdca0aSPeter Xu { 3199cefdca0aSPeter Xu .procname = "unprivileged_userfaultfd", 3200cefdca0aSPeter Xu .data = &sysctl_unprivileged_userfaultfd, 3201cefdca0aSPeter Xu .maxlen = sizeof(sysctl_unprivileged_userfaultfd), 3202cefdca0aSPeter Xu .mode = 0644, 3203cefdca0aSPeter Xu .proc_handler = proc_dointvec_minmax, 3204eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3205eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3206cefdca0aSPeter Xu }, 3207cefdca0aSPeter Xu #endif 32086fce56ecSEric W. Biederman { } 32091da177e4SLinus Torvalds }; 32101da177e4SLinus Torvalds 3211d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 32121da177e4SLinus Torvalds { 32131da177e4SLinus Torvalds .procname = "inode-nr", 32141da177e4SLinus Torvalds .data = &inodes_stat, 32153942c07cSGlauber Costa .maxlen = 2*sizeof(long), 32161da177e4SLinus Torvalds .mode = 0444, 3217cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 32181da177e4SLinus Torvalds }, 32191da177e4SLinus Torvalds { 32201da177e4SLinus Torvalds .procname = "inode-state", 32211da177e4SLinus Torvalds .data = &inodes_stat, 32223942c07cSGlauber Costa .maxlen = 7*sizeof(long), 32231da177e4SLinus Torvalds .mode = 0444, 3224cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 32251da177e4SLinus Torvalds }, 32261da177e4SLinus Torvalds { 32271da177e4SLinus Torvalds .procname = "file-nr", 32281da177e4SLinus Torvalds .data = &files_stat, 3229518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 32301da177e4SLinus Torvalds .mode = 0444, 32316d456111SEric W. Biederman .proc_handler = proc_nr_files, 32321da177e4SLinus Torvalds }, 32331da177e4SLinus Torvalds { 32341da177e4SLinus Torvalds .procname = "file-max", 32351da177e4SLinus Torvalds .data = &files_stat.max_files, 3236518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 32371da177e4SLinus Torvalds .mode = 0644, 3238518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 32399002b214SWill Deacon .extra1 = &zero_ul, 324032a5ad9cSChristian Brauner .extra2 = &long_max, 32411da177e4SLinus Torvalds }, 32421da177e4SLinus Torvalds { 32439cfe015aSEric Dumazet .procname = "nr_open", 32449cfe015aSEric Dumazet .data = &sysctl_nr_open, 32459b80a184SAlexey Dobriyan .maxlen = sizeof(unsigned int), 32469cfe015aSEric Dumazet .mode = 0644, 32476d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3248eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 3249eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 32509cfe015aSEric Dumazet }, 32519cfe015aSEric Dumazet { 32521da177e4SLinus Torvalds .procname = "dentry-state", 32531da177e4SLinus Torvalds .data = &dentry_stat, 32543942c07cSGlauber Costa .maxlen = 6*sizeof(long), 32551da177e4SLinus Torvalds .mode = 0444, 3256312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 32571da177e4SLinus Torvalds }, 32581da177e4SLinus Torvalds { 32591da177e4SLinus Torvalds .procname = "overflowuid", 32601da177e4SLinus Torvalds .data = &fs_overflowuid, 32611da177e4SLinus Torvalds .maxlen = sizeof(int), 32621da177e4SLinus Torvalds .mode = 0644, 32636d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 32641da177e4SLinus Torvalds .extra1 = &minolduid, 32651da177e4SLinus Torvalds .extra2 = &maxolduid, 32661da177e4SLinus Torvalds }, 32671da177e4SLinus Torvalds { 32681da177e4SLinus Torvalds .procname = "overflowgid", 32691da177e4SLinus Torvalds .data = &fs_overflowgid, 32701da177e4SLinus Torvalds .maxlen = sizeof(int), 32711da177e4SLinus Torvalds .mode = 0644, 32726d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 32731da177e4SLinus Torvalds .extra1 = &minolduid, 32741da177e4SLinus Torvalds .extra2 = &maxolduid, 32751da177e4SLinus Torvalds }, 3276bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 32771da177e4SLinus Torvalds { 32781da177e4SLinus Torvalds .procname = "leases-enable", 32791da177e4SLinus Torvalds .data = &leases_enable, 32801da177e4SLinus Torvalds .maxlen = sizeof(int), 32811da177e4SLinus Torvalds .mode = 0644, 32826d456111SEric W. Biederman .proc_handler = proc_dointvec, 32831da177e4SLinus Torvalds }, 3284bfcd17a6SThomas Petazzoni #endif 32851da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 32861da177e4SLinus Torvalds { 32871da177e4SLinus Torvalds .procname = "dir-notify-enable", 32881da177e4SLinus Torvalds .data = &dir_notify_enable, 32891da177e4SLinus Torvalds .maxlen = sizeof(int), 32901da177e4SLinus Torvalds .mode = 0644, 32916d456111SEric W. Biederman .proc_handler = proc_dointvec, 32921da177e4SLinus Torvalds }, 32931da177e4SLinus Torvalds #endif 32941da177e4SLinus Torvalds #ifdef CONFIG_MMU 3295bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 32961da177e4SLinus Torvalds { 32971da177e4SLinus Torvalds .procname = "lease-break-time", 32981da177e4SLinus Torvalds .data = &lease_break_time, 32991da177e4SLinus Torvalds .maxlen = sizeof(int), 33001da177e4SLinus Torvalds .mode = 0644, 33016d456111SEric W. Biederman .proc_handler = proc_dointvec, 33021da177e4SLinus Torvalds }, 3303bfcd17a6SThomas Petazzoni #endif 3304ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 33051da177e4SLinus Torvalds { 33061da177e4SLinus Torvalds .procname = "aio-nr", 33071da177e4SLinus Torvalds .data = &aio_nr, 33081da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 33091da177e4SLinus Torvalds .mode = 0444, 33106d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 33111da177e4SLinus Torvalds }, 33121da177e4SLinus Torvalds { 33131da177e4SLinus Torvalds .procname = "aio-max-nr", 33141da177e4SLinus Torvalds .data = &aio_max_nr, 33151da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 33161da177e4SLinus Torvalds .mode = 0644, 33176d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 33181da177e4SLinus Torvalds }, 3319ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 33202d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 33210399cb08SRobert Love { 33220399cb08SRobert Love .procname = "inotify", 33230399cb08SRobert Love .mode = 0555, 33240399cb08SRobert Love .child = inotify_table, 33250399cb08SRobert Love }, 33260399cb08SRobert Love #endif 33277ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 33287ef9964eSDavide Libenzi { 33297ef9964eSDavide Libenzi .procname = "epoll", 33307ef9964eSDavide Libenzi .mode = 0555, 33317ef9964eSDavide Libenzi .child = epoll_table, 33327ef9964eSDavide Libenzi }, 33337ef9964eSDavide Libenzi #endif 33341da177e4SLinus Torvalds #endif 3335d6e71144SAlan Cox { 3336800179c9SKees Cook .procname = "protected_symlinks", 3337800179c9SKees Cook .data = &sysctl_protected_symlinks, 3338800179c9SKees Cook .maxlen = sizeof(int), 3339800179c9SKees Cook .mode = 0600, 3340800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3341eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3342eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3343800179c9SKees Cook }, 3344800179c9SKees Cook { 3345800179c9SKees Cook .procname = "protected_hardlinks", 3346800179c9SKees Cook .data = &sysctl_protected_hardlinks, 3347800179c9SKees Cook .maxlen = sizeof(int), 3348800179c9SKees Cook .mode = 0600, 3349800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 3350eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3351eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3352800179c9SKees Cook }, 3353800179c9SKees Cook { 335430aba665SSalvatore Mesoraca .procname = "protected_fifos", 335530aba665SSalvatore Mesoraca .data = &sysctl_protected_fifos, 335630aba665SSalvatore Mesoraca .maxlen = sizeof(int), 335730aba665SSalvatore Mesoraca .mode = 0600, 335830aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3359eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 336030aba665SSalvatore Mesoraca .extra2 = &two, 336130aba665SSalvatore Mesoraca }, 336230aba665SSalvatore Mesoraca { 336330aba665SSalvatore Mesoraca .procname = "protected_regular", 336430aba665SSalvatore Mesoraca .data = &sysctl_protected_regular, 336530aba665SSalvatore Mesoraca .maxlen = sizeof(int), 336630aba665SSalvatore Mesoraca .mode = 0600, 336730aba665SSalvatore Mesoraca .proc_handler = proc_dointvec_minmax, 3368eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 336930aba665SSalvatore Mesoraca .extra2 = &two, 337030aba665SSalvatore Mesoraca }, 337130aba665SSalvatore Mesoraca { 3372d6e71144SAlan Cox .procname = "suid_dumpable", 3373d6e71144SAlan Cox .data = &suid_dumpable, 3374d6e71144SAlan Cox .maxlen = sizeof(int), 3375d6e71144SAlan Cox .mode = 0644, 337654b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 3377eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 33788e654fbaSMatthew Wilcox .extra2 = &two, 3379d6e71144SAlan Cox }, 33802abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 33812abc26fcSEric W. Biederman { 33822abc26fcSEric W. Biederman .procname = "binfmt_misc", 33832abc26fcSEric W. Biederman .mode = 0555, 3384f9bd6733SEric W. Biederman .child = sysctl_mount_point, 33852abc26fcSEric W. Biederman }, 33862abc26fcSEric W. Biederman #endif 3387b492e95bSJens Axboe { 3388ff9da691SJens Axboe .procname = "pipe-max-size", 3389ff9da691SJens Axboe .data = &pipe_max_size, 339098159d97SJoe Lawrence .maxlen = sizeof(pipe_max_size), 3391b492e95bSJens Axboe .mode = 0644, 3392319e0a21SEric Biggers .proc_handler = proc_dopipe_max_size, 3393b492e95bSJens Axboe }, 3394759c0114SWilly Tarreau { 3395759c0114SWilly Tarreau .procname = "pipe-user-pages-hard", 3396759c0114SWilly Tarreau .data = &pipe_user_pages_hard, 3397759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_hard), 3398759c0114SWilly Tarreau .mode = 0644, 3399759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3400759c0114SWilly Tarreau }, 3401759c0114SWilly Tarreau { 3402759c0114SWilly Tarreau .procname = "pipe-user-pages-soft", 3403759c0114SWilly Tarreau .data = &pipe_user_pages_soft, 3404759c0114SWilly Tarreau .maxlen = sizeof(pipe_user_pages_soft), 3405759c0114SWilly Tarreau .mode = 0644, 3406759c0114SWilly Tarreau .proc_handler = proc_doulongvec_minmax, 3407759c0114SWilly Tarreau }, 3408d2921684SEric W. Biederman { 3409d2921684SEric W. Biederman .procname = "mount-max", 3410d2921684SEric W. Biederman .data = &sysctl_mount_max, 3411d2921684SEric W. Biederman .maxlen = sizeof(unsigned int), 3412d2921684SEric W. Biederman .mode = 0644, 3413d2921684SEric W. Biederman .proc_handler = proc_dointvec_minmax, 3414eec4844fSMatteo Croce .extra1 = SYSCTL_ONE, 3415d2921684SEric W. Biederman }, 34166fce56ecSEric W. Biederman { } 34171da177e4SLinus Torvalds }; 34181da177e4SLinus Torvalds 3419d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 34207ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 3421abd4f750SMasoud Asgharifard Sharbiani { 3422abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 3423abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 3424abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 3425abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 3426abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 3427abd4f750SMasoud Asgharifard Sharbiani }, 3428abd4f750SMasoud Asgharifard Sharbiani #endif 3429b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 3430b2be84dfSMasami Hiramatsu { 3431b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 3432b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 3433b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 3434b2be84dfSMasami Hiramatsu .mode = 0644, 3435b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 3436eec4844fSMatteo Croce .extra1 = SYSCTL_ZERO, 3437eec4844fSMatteo Croce .extra2 = SYSCTL_ONE, 3438b2be84dfSMasami Hiramatsu }, 3439b2be84dfSMasami Hiramatsu #endif 34406fce56ecSEric W. Biederman { } 34411da177e4SLinus Torvalds }; 34421da177e4SLinus Torvalds 3443d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 34446fce56ecSEric W. Biederman { } 34451da177e4SLinus Torvalds }; 34461da177e4SLinus Torvalds 3447f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = { 3448f461d2dcSChristoph Hellwig { 3449f461d2dcSChristoph Hellwig .procname = "kernel", 3450f461d2dcSChristoph Hellwig .mode = 0555, 3451f461d2dcSChristoph Hellwig .child = kern_table, 3452f461d2dcSChristoph Hellwig }, 3453f461d2dcSChristoph Hellwig { 3454f461d2dcSChristoph Hellwig .procname = "vm", 3455f461d2dcSChristoph Hellwig .mode = 0555, 3456f461d2dcSChristoph Hellwig .child = vm_table, 3457f461d2dcSChristoph Hellwig }, 3458f461d2dcSChristoph Hellwig { 3459f461d2dcSChristoph Hellwig .procname = "fs", 3460f461d2dcSChristoph Hellwig .mode = 0555, 3461f461d2dcSChristoph Hellwig .child = fs_table, 3462f461d2dcSChristoph Hellwig }, 3463f461d2dcSChristoph Hellwig { 3464f461d2dcSChristoph Hellwig .procname = "debug", 3465f461d2dcSChristoph Hellwig .mode = 0555, 3466f461d2dcSChristoph Hellwig .child = debug_table, 3467f461d2dcSChristoph Hellwig }, 3468f461d2dcSChristoph Hellwig { 3469f461d2dcSChristoph Hellwig .procname = "dev", 3470f461d2dcSChristoph Hellwig .mode = 0555, 3471f461d2dcSChristoph Hellwig .child = dev_table, 3472f461d2dcSChristoph Hellwig }, 3473f461d2dcSChristoph Hellwig { } 3474f461d2dcSChristoph Hellwig }; 3475f461d2dcSChristoph Hellwig 3476de4e83bdSEric W. Biederman int __init sysctl_init(void) 3477330d57fbSAl Viro { 3478fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 3479fd4b616bSSteven Rostedt 3480fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 3481fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 3482330d57fbSAl Viro return 0; 3483f7e6ced4SAl Viro } 3484b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 34851da177e4SLinus Torvalds /* 34861da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 34871da177e4SLinus Torvalds * exception granted :-) 34881da177e4SLinus Torvalds */ 34891da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 3490e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec); 34911da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 34921da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 349361d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 34941da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 34951da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 34961da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 34971da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 34981da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 34990bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap); 3500