11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * sysctl.c: General linux system control interface 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Begun 24 March 1995, Stephen Tweedie 51da177e4SLinus Torvalds * Added /proc support, Dec 1995 61da177e4SLinus Torvalds * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 71da177e4SLinus Torvalds * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. 81da177e4SLinus Torvalds * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. 91da177e4SLinus Torvalds * Dynamic registration fixes, Stephen Tweedie. 101da177e4SLinus Torvalds * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. 111da177e4SLinus Torvalds * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris 121da177e4SLinus Torvalds * Horn. 131da177e4SLinus Torvalds * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. 141da177e4SLinus Torvalds * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. 151da177e4SLinus Torvalds * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill 161da177e4SLinus Torvalds * Wendling. 171da177e4SLinus Torvalds * The list_for_each() macro wasn't appropriate for the sysctl loop. 181da177e4SLinus Torvalds * Removed it and replaced it with older style, 03/23/00, Bill Wendling 191da177e4SLinus Torvalds */ 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds #include <linux/module.h> 221da177e4SLinus Torvalds #include <linux/mm.h> 231da177e4SLinus Torvalds #include <linux/swap.h> 241da177e4SLinus Torvalds #include <linux/slab.h> 251da177e4SLinus Torvalds #include <linux/sysctl.h> 261da177e4SLinus Torvalds #include <linux/proc_fs.h> 2772c2d582SAndrew Morgan #include <linux/security.h> 281da177e4SLinus Torvalds #include <linux/ctype.h> 29dfec072eSVegard Nossum #include <linux/kmemcheck.h> 3062239ac2SAdrian Bunk #include <linux/fs.h> 311da177e4SLinus Torvalds #include <linux/init.h> 321da177e4SLinus Torvalds #include <linux/kernel.h> 330296b228SKay Sievers #include <linux/kobject.h> 3420380731SArnaldo Carvalho de Melo #include <linux/net.h> 351da177e4SLinus Torvalds #include <linux/sysrq.h> 361da177e4SLinus Torvalds #include <linux/highuid.h> 371da177e4SLinus Torvalds #include <linux/writeback.h> 383fff4c42SIngo Molnar #include <linux/ratelimit.h> 391da177e4SLinus Torvalds #include <linux/hugetlb.h> 401da177e4SLinus Torvalds #include <linux/initrd.h> 410b77f5bfSDavid Howells #include <linux/key.h> 421da177e4SLinus Torvalds #include <linux/times.h> 431da177e4SLinus Torvalds #include <linux/limits.h> 441da177e4SLinus Torvalds #include <linux/dcache.h> 451da177e4SLinus Torvalds #include <linux/syscalls.h> 46c748e134SAdrian Bunk #include <linux/vmstat.h> 47c255d844SPavel Machek #include <linux/nfs_fs.h> 48c255d844SPavel Machek #include <linux/acpi.h> 4910a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 50b0fc494fSSteven Rostedt #include <linux/ftrace.h> 5112e22c5eSDavid Howells #include <linux/slow-work.h> 52cdd6c482SIngo Molnar #include <linux/perf_event.h> 53*b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds #include <asm/uaccess.h> 561da177e4SLinus Torvalds #include <asm/processor.h> 571da177e4SLinus Torvalds 5829cbc78bSAndi Kleen #ifdef CONFIG_X86 5929cbc78bSAndi Kleen #include <asm/nmi.h> 600741f4d2SChuck Ebbert #include <asm/stacktrace.h> 616e7c4025SIngo Molnar #include <asm/io.h> 6229cbc78bSAndi Kleen #endif 6329cbc78bSAndi Kleen 647058cb02SEric W. Biederman 651da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 661da177e4SLinus Torvalds 671da177e4SLinus Torvalds /* External variables not in a header file. */ 681da177e4SLinus Torvalds extern int C_A_D; 6945807a1dSIngo Molnar extern int print_fatal_signals; 701da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 711da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 72fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom; 73fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task; 74fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks; 751da177e4SLinus Torvalds extern int max_threads; 761da177e4SLinus Torvalds extern int core_uses_pid; 77d6e71144SAlan Cox extern int suid_dumpable; 781da177e4SLinus Torvalds extern char core_pattern[]; 79a293980cSNeil Horman extern unsigned int core_pipe_limit; 801da177e4SLinus Torvalds extern int pid_max; 811da177e4SLinus Torvalds extern int min_free_kbytes; 821da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 839d0243bcSAndrew Morton extern int sysctl_drop_caches; 848ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 85bebfa101SAndi Kleen extern int compat_log; 869745512cSArjan van de Ven extern int latencytop_enabled; 87eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 88dd8632a1SPaul Mundt #ifndef CONFIG_MMU 89dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 90dd8632a1SPaul Mundt #endif 9131a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 9231a72bceSPaul E. McKenney extern int rcutorture_runnable; 9331a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 94cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 955e605b64SJens Axboe extern int blk_iopoll_enabled; 96cb684b5bSJens Axboe #endif 971da177e4SLinus Torvalds 98c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 99195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 100c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1019383d967SDimitri Sivanich static int neg_one = -1; 102c4f3b63fSRavikiran G Thirumalai #endif 103c4f3b63fSRavikiran G Thirumalai 104c4f3b63fSRavikiran G Thirumalai static int zero; 105cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 106cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 107fc3501d4SSven Wegener static unsigned long one_ul = 1; 108c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 109af91322eSDave Young #ifdef CONFIG_PRINTK 110af91322eSDave Young static int ten_thousand = 10000; 111af91322eSDave Young #endif 112c4f3b63fSRavikiran G Thirumalai 1139e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1149e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1159e4a5bdaSAndrea Righi 1161da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1171da177e4SLinus Torvalds static int maxolduid = 65535; 1181da177e4SLinus Torvalds static int minolduid; 1198ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1221da177e4SLinus Torvalds 123a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 1241da177e4SLinus Torvalds extern char modprobe_path[]; 1253d43321bSKees Cook extern int modules_disabled; 1261da177e4SLinus Torvalds #endif 1271da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 1281da177e4SLinus Torvalds extern int sg_big_buff; 1291da177e4SLinus Torvalds #endif 1301da177e4SLinus Torvalds 13172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 13217f04fbbSDavid S. Miller #include <asm/system.h> 1331da177e4SLinus Torvalds #endif 1341da177e4SLinus Torvalds 1350871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1360871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1370871420fSDavid S. Miller #endif 1380871420fSDavid S. Miller 1391da177e4SLinus Torvalds #ifdef __hppa__ 1401da177e4SLinus Torvalds extern int pwrsw_enabled; 1411da177e4SLinus Torvalds extern int unaligned_enabled; 1421da177e4SLinus Torvalds #endif 1431da177e4SLinus Torvalds 144347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1451da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1461da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1471da177e4SLinus Torvalds #endif 1481da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 149951f22d5SMartin Schwidefsky extern int spin_retry; 1501da177e4SLinus Torvalds #endif 1511da177e4SLinus Torvalds 1521da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1531da177e4SLinus Torvalds extern int acct_parm[]; 1541da177e4SLinus Torvalds #endif 1551da177e4SLinus Torvalds 156d2b176edSJes Sorensen #ifdef CONFIG_IA64 157d2b176edSJes Sorensen extern int no_unaligned_warning; 15888fc241fSDoug Chapman extern int unaligned_dump_stack; 159d2b176edSJes Sorensen #endif 160d2b176edSJes Sorensen 1613fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state; 1623fff4c42SIngo Molnar 16323f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 16423f78d4aSIngo Molnar extern int max_lock_depth; 16523f78d4aSIngo Molnar #endif 16623f78d4aSIngo Molnar 167d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1688d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1699ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1708d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 17134f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 172d6f8ff73SRandy Dunlap #endif 1739ec52099SCedric Le Goater 174d8217f07SEric W. Biederman static struct ctl_table root_table[]; 175e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 176e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 177b380b0d4SAl Viro .count = 1, 178e51b6ba0SEric W. Biederman .ctl_table = root_table, 17973455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 180e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 18173455092SAl Viro .set = &sysctl_table_root.default_set, 182e51b6ba0SEric W. Biederman }; 183e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 184e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 18573455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 186e51b6ba0SEric W. Biederman }; 1871da177e4SLinus Torvalds 188d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 189d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 190d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 191d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 192d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 193d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1942d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 195d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1960399cb08SRobert Love #endif 1977ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 1987ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 1997ef9964eSDavide Libenzi #endif 2001da177e4SLinus Torvalds 2011da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2021da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2031da177e4SLinus Torvalds #endif 2041da177e4SLinus Torvalds 205f20786ffSPeter Zijlstra extern int prove_locking; 206f20786ffSPeter Zijlstra extern int lock_stat; 2079bc9a6bdSEric W. Biederman 2081da177e4SLinus Torvalds /* The default sysctl tables: */ 2091da177e4SLinus Torvalds 210d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2111da177e4SLinus Torvalds { 2121da177e4SLinus Torvalds .procname = "kernel", 2131da177e4SLinus Torvalds .mode = 0555, 2141da177e4SLinus Torvalds .child = kern_table, 2151da177e4SLinus Torvalds }, 2161da177e4SLinus Torvalds { 2171da177e4SLinus Torvalds .procname = "vm", 2181da177e4SLinus Torvalds .mode = 0555, 2191da177e4SLinus Torvalds .child = vm_table, 2201da177e4SLinus Torvalds }, 2211da177e4SLinus Torvalds { 2221da177e4SLinus Torvalds .procname = "fs", 2231da177e4SLinus Torvalds .mode = 0555, 2241da177e4SLinus Torvalds .child = fs_table, 2251da177e4SLinus Torvalds }, 2261da177e4SLinus Torvalds { 2271da177e4SLinus Torvalds .procname = "debug", 2281da177e4SLinus Torvalds .mode = 0555, 2291da177e4SLinus Torvalds .child = debug_table, 2301da177e4SLinus Torvalds }, 2311da177e4SLinus Torvalds { 2321da177e4SLinus Torvalds .procname = "dev", 2331da177e4SLinus Torvalds .mode = 0555, 2341da177e4SLinus Torvalds .child = dev_table, 2351da177e4SLinus Torvalds }, 2362be7fe07SAndrew Morton /* 2372be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2382be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2392be7fe07SAndrew Morton */ 2406fce56ecSEric W. Biederman { } 2411da177e4SLinus Torvalds }; 2421da177e4SLinus Torvalds 24377e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 24473c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 24573c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 24673c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 24773c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2481983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2491983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 250acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */ 251acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */ 25277e54a1fSIngo Molnar #endif 25377e54a1fSIngo Molnar 254d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2552bba22c5SMike Galbraith { 2562bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2572bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2582bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2592bba22c5SMike Galbraith .mode = 0644, 2606d456111SEric W. Biederman .proc_handler = proc_dointvec, 2612bba22c5SMike Galbraith }, 26277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 26377e54a1fSIngo Molnar { 264b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 265b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 26677e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 26777e54a1fSIngo Molnar .mode = 0644, 268702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 269b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 270b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 27177e54a1fSIngo Molnar }, 27277e54a1fSIngo Molnar { 27321805085SPeter Zijlstra .procname = "sched_latency_ns", 27421805085SPeter Zijlstra .data = &sysctl_sched_latency, 27521805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 27621805085SPeter Zijlstra .mode = 0644, 277702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 27821805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 27921805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28021805085SPeter Zijlstra }, 28121805085SPeter Zijlstra { 28277e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 28377e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 28477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28577e54a1fSIngo Molnar .mode = 0644, 286702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 28777e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 28877e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 28977e54a1fSIngo Molnar }, 29077e54a1fSIngo Molnar { 2912398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 2922398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 2932398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 2942398f2c6SPeter Zijlstra .mode = 0644, 295702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 296acb4a848SChristian Ehrhardt .extra1 = &min_sched_shares_ratelimit, 297acb4a848SChristian Ehrhardt .extra2 = &max_sched_shares_ratelimit, 2982398f2c6SPeter Zijlstra }, 2992398f2c6SPeter Zijlstra { 3001983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3011983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3021983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3031983a922SChristian Ehrhardt .mode = 0644, 304702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3051983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3061983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3072398f2c6SPeter Zijlstra }, 3082398f2c6SPeter Zijlstra { 309ffda12a1SPeter Zijlstra .procname = "sched_shares_thresh", 310ffda12a1SPeter Zijlstra .data = &sysctl_sched_shares_thresh, 311ffda12a1SPeter Zijlstra .maxlen = sizeof(unsigned int), 312ffda12a1SPeter Zijlstra .mode = 0644, 3136d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 314ffda12a1SPeter Zijlstra .extra1 = &zero, 315ffda12a1SPeter Zijlstra }, 316ffda12a1SPeter Zijlstra { 317da84d961SIngo Molnar .procname = "sched_migration_cost", 318da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 319da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 320da84d961SIngo Molnar .mode = 0644, 3216d456111SEric W. Biederman .proc_handler = proc_dointvec, 322da84d961SIngo Molnar }, 323b82d9fddSPeter Zijlstra { 324b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 325b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 326b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 327fa85ae24SPeter Zijlstra .mode = 0644, 3286d456111SEric W. Biederman .proc_handler = proc_dointvec, 329fa85ae24SPeter Zijlstra }, 330cd1bb94bSArun R Bharadwaj { 331e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 332e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 333e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 334e9e9250bSPeter Zijlstra .mode = 0644, 3356d456111SEric W. Biederman .proc_handler = proc_dointvec, 336e9e9250bSPeter Zijlstra }, 337e9e9250bSPeter Zijlstra { 338cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 339cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 340cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 341cd1bb94bSArun R Bharadwaj .mode = 0644, 3426d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 343bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 344bfdb4d9fSArun R Bharadwaj .extra2 = &one, 345cd1bb94bSArun R Bharadwaj }, 3461fc84aaaSPeter Zijlstra #endif 3471799e35dSIngo Molnar { 3489f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3499f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3509f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3519f0c1e56SPeter Zijlstra .mode = 0644, 3526d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3539f0c1e56SPeter Zijlstra }, 3549f0c1e56SPeter Zijlstra { 3559f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3569f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3579f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3589f0c1e56SPeter Zijlstra .mode = 0644, 3596d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3609f0c1e56SPeter Zijlstra }, 3619f0c1e56SPeter Zijlstra { 3621799e35dSIngo Molnar .procname = "sched_compat_yield", 3631799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3641799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3651799e35dSIngo Molnar .mode = 0644, 3666d456111SEric W. Biederman .proc_handler = proc_dointvec, 3671799e35dSIngo Molnar }, 368f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 369f20786ffSPeter Zijlstra { 370f20786ffSPeter Zijlstra .procname = "prove_locking", 371f20786ffSPeter Zijlstra .data = &prove_locking, 372f20786ffSPeter Zijlstra .maxlen = sizeof(int), 373f20786ffSPeter Zijlstra .mode = 0644, 3746d456111SEric W. Biederman .proc_handler = proc_dointvec, 375f20786ffSPeter Zijlstra }, 376f20786ffSPeter Zijlstra #endif 377f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 378f20786ffSPeter Zijlstra { 379f20786ffSPeter Zijlstra .procname = "lock_stat", 380f20786ffSPeter Zijlstra .data = &lock_stat, 381f20786ffSPeter Zijlstra .maxlen = sizeof(int), 382f20786ffSPeter Zijlstra .mode = 0644, 3836d456111SEric W. Biederman .proc_handler = proc_dointvec, 384f20786ffSPeter Zijlstra }, 385f20786ffSPeter Zijlstra #endif 38677e54a1fSIngo Molnar { 3871da177e4SLinus Torvalds .procname = "panic", 3881da177e4SLinus Torvalds .data = &panic_timeout, 3891da177e4SLinus Torvalds .maxlen = sizeof(int), 3901da177e4SLinus Torvalds .mode = 0644, 3916d456111SEric W. Biederman .proc_handler = proc_dointvec, 3921da177e4SLinus Torvalds }, 3931da177e4SLinus Torvalds { 3941da177e4SLinus Torvalds .procname = "core_uses_pid", 3951da177e4SLinus Torvalds .data = &core_uses_pid, 3961da177e4SLinus Torvalds .maxlen = sizeof(int), 3971da177e4SLinus Torvalds .mode = 0644, 3986d456111SEric W. Biederman .proc_handler = proc_dointvec, 3991da177e4SLinus Torvalds }, 4001da177e4SLinus Torvalds { 4011da177e4SLinus Torvalds .procname = "core_pattern", 4021da177e4SLinus Torvalds .data = core_pattern, 40371ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4041da177e4SLinus Torvalds .mode = 0644, 4056d456111SEric W. Biederman .proc_handler = proc_dostring, 4061da177e4SLinus Torvalds }, 407a293980cSNeil Horman { 408a293980cSNeil Horman .procname = "core_pipe_limit", 409a293980cSNeil Horman .data = &core_pipe_limit, 410a293980cSNeil Horman .maxlen = sizeof(unsigned int), 411a293980cSNeil Horman .mode = 0644, 4126d456111SEric W. Biederman .proc_handler = proc_dointvec, 413a293980cSNeil Horman }, 41434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4151da177e4SLinus Torvalds { 4161da177e4SLinus Torvalds .procname = "tainted", 41725ddbb18SAndi Kleen .maxlen = sizeof(long), 41834f5a398STheodore Ts'o .mode = 0644, 4196d456111SEric W. Biederman .proc_handler = proc_taint, 4201da177e4SLinus Torvalds }, 42134f5a398STheodore Ts'o #endif 4229745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4239745512cSArjan van de Ven { 4249745512cSArjan van de Ven .procname = "latencytop", 4259745512cSArjan van de Ven .data = &latencytop_enabled, 4269745512cSArjan van de Ven .maxlen = sizeof(int), 4279745512cSArjan van de Ven .mode = 0644, 4286d456111SEric W. Biederman .proc_handler = proc_dointvec, 4299745512cSArjan van de Ven }, 4309745512cSArjan van de Ven #endif 4311da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4321da177e4SLinus Torvalds { 4331da177e4SLinus Torvalds .procname = "real-root-dev", 4341da177e4SLinus Torvalds .data = &real_root_dev, 4351da177e4SLinus Torvalds .maxlen = sizeof(int), 4361da177e4SLinus Torvalds .mode = 0644, 4376d456111SEric W. Biederman .proc_handler = proc_dointvec, 4381da177e4SLinus Torvalds }, 4391da177e4SLinus Torvalds #endif 44045807a1dSIngo Molnar { 44145807a1dSIngo Molnar .procname = "print-fatal-signals", 44245807a1dSIngo Molnar .data = &print_fatal_signals, 44345807a1dSIngo Molnar .maxlen = sizeof(int), 44445807a1dSIngo Molnar .mode = 0644, 4456d456111SEric W. Biederman .proc_handler = proc_dointvec, 44645807a1dSIngo Molnar }, 44772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4481da177e4SLinus Torvalds { 4491da177e4SLinus Torvalds .procname = "reboot-cmd", 4501da177e4SLinus Torvalds .data = reboot_command, 4511da177e4SLinus Torvalds .maxlen = 256, 4521da177e4SLinus Torvalds .mode = 0644, 4536d456111SEric W. Biederman .proc_handler = proc_dostring, 4541da177e4SLinus Torvalds }, 4551da177e4SLinus Torvalds { 4561da177e4SLinus Torvalds .procname = "stop-a", 4571da177e4SLinus Torvalds .data = &stop_a_enabled, 4581da177e4SLinus Torvalds .maxlen = sizeof (int), 4591da177e4SLinus Torvalds .mode = 0644, 4606d456111SEric W. Biederman .proc_handler = proc_dointvec, 4611da177e4SLinus Torvalds }, 4621da177e4SLinus Torvalds { 4631da177e4SLinus Torvalds .procname = "scons-poweroff", 4641da177e4SLinus Torvalds .data = &scons_pwroff, 4651da177e4SLinus Torvalds .maxlen = sizeof (int), 4661da177e4SLinus Torvalds .mode = 0644, 4676d456111SEric W. Biederman .proc_handler = proc_dointvec, 4681da177e4SLinus Torvalds }, 4691da177e4SLinus Torvalds #endif 4700871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4710871420fSDavid S. Miller { 4720871420fSDavid S. Miller .procname = "tsb-ratio", 4730871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4740871420fSDavid S. Miller .maxlen = sizeof (int), 4750871420fSDavid S. Miller .mode = 0644, 4766d456111SEric W. Biederman .proc_handler = proc_dointvec, 4770871420fSDavid S. Miller }, 4780871420fSDavid S. Miller #endif 4791da177e4SLinus Torvalds #ifdef __hppa__ 4801da177e4SLinus Torvalds { 4811da177e4SLinus Torvalds .procname = "soft-power", 4821da177e4SLinus Torvalds .data = &pwrsw_enabled, 4831da177e4SLinus Torvalds .maxlen = sizeof (int), 4841da177e4SLinus Torvalds .mode = 0644, 4856d456111SEric W. Biederman .proc_handler = proc_dointvec, 4861da177e4SLinus Torvalds }, 4871da177e4SLinus Torvalds { 4881da177e4SLinus Torvalds .procname = "unaligned-trap", 4891da177e4SLinus Torvalds .data = &unaligned_enabled, 4901da177e4SLinus Torvalds .maxlen = sizeof (int), 4911da177e4SLinus Torvalds .mode = 0644, 4926d456111SEric W. Biederman .proc_handler = proc_dointvec, 4931da177e4SLinus Torvalds }, 4941da177e4SLinus Torvalds #endif 4951da177e4SLinus Torvalds { 4961da177e4SLinus Torvalds .procname = "ctrl-alt-del", 4971da177e4SLinus Torvalds .data = &C_A_D, 4981da177e4SLinus Torvalds .maxlen = sizeof(int), 4991da177e4SLinus Torvalds .mode = 0644, 5006d456111SEric W. Biederman .proc_handler = proc_dointvec, 5011da177e4SLinus Torvalds }, 502606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 503b0fc494fSSteven Rostedt { 504b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 505b0fc494fSSteven Rostedt .data = &ftrace_enabled, 506b0fc494fSSteven Rostedt .maxlen = sizeof(int), 507b0fc494fSSteven Rostedt .mode = 0644, 5086d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 509b0fc494fSSteven Rostedt }, 510b0fc494fSSteven Rostedt #endif 511f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 512f38f1d2aSSteven Rostedt { 513f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 514f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 515f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 516f38f1d2aSSteven Rostedt .mode = 0644, 5176d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 518f38f1d2aSSteven Rostedt }, 519f38f1d2aSSteven Rostedt #endif 520944ac425SSteven Rostedt #ifdef CONFIG_TRACING 521944ac425SSteven Rostedt { 5223299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 523944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 524944ac425SSteven Rostedt .maxlen = sizeof(int), 525944ac425SSteven Rostedt .mode = 0644, 5266d456111SEric W. Biederman .proc_handler = proc_dointvec, 527944ac425SSteven Rostedt }, 528944ac425SSteven Rostedt #endif 529a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5301da177e4SLinus Torvalds { 5311da177e4SLinus Torvalds .procname = "modprobe", 5321da177e4SLinus Torvalds .data = &modprobe_path, 5331da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5341da177e4SLinus Torvalds .mode = 0644, 5356d456111SEric W. Biederman .proc_handler = proc_dostring, 5361da177e4SLinus Torvalds }, 5373d43321bSKees Cook { 5383d43321bSKees Cook .procname = "modules_disabled", 5393d43321bSKees Cook .data = &modules_disabled, 5403d43321bSKees Cook .maxlen = sizeof(int), 5413d43321bSKees Cook .mode = 0644, 5423d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5436d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5443d43321bSKees Cook .extra1 = &one, 5453d43321bSKees Cook .extra2 = &one, 5463d43321bSKees Cook }, 5471da177e4SLinus Torvalds #endif 54857ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 5491da177e4SLinus Torvalds { 5501da177e4SLinus Torvalds .procname = "hotplug", 551312c004dSKay Sievers .data = &uevent_helper, 552312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5531da177e4SLinus Torvalds .mode = 0644, 5546d456111SEric W. Biederman .proc_handler = proc_dostring, 5551da177e4SLinus Torvalds }, 5561da177e4SLinus Torvalds #endif 5571da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5581da177e4SLinus Torvalds { 5591da177e4SLinus Torvalds .procname = "sg-big-buff", 5601da177e4SLinus Torvalds .data = &sg_big_buff, 5611da177e4SLinus Torvalds .maxlen = sizeof (int), 5621da177e4SLinus Torvalds .mode = 0444, 5636d456111SEric W. Biederman .proc_handler = proc_dointvec, 5641da177e4SLinus Torvalds }, 5651da177e4SLinus Torvalds #endif 5661da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5671da177e4SLinus Torvalds { 5681da177e4SLinus Torvalds .procname = "acct", 5691da177e4SLinus Torvalds .data = &acct_parm, 5701da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5711da177e4SLinus Torvalds .mode = 0644, 5726d456111SEric W. Biederman .proc_handler = proc_dointvec, 5731da177e4SLinus Torvalds }, 5741da177e4SLinus Torvalds #endif 5751da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5761da177e4SLinus Torvalds { 5771da177e4SLinus Torvalds .procname = "sysrq", 5785d6f647fSIngo Molnar .data = &__sysrq_enabled, 5791da177e4SLinus Torvalds .maxlen = sizeof (int), 5801da177e4SLinus Torvalds .mode = 0644, 5816d456111SEric W. Biederman .proc_handler = proc_dointvec, 5821da177e4SLinus Torvalds }, 5831da177e4SLinus Torvalds #endif 584d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5851da177e4SLinus Torvalds { 5861da177e4SLinus Torvalds .procname = "cad_pid", 5879ec52099SCedric Le Goater .data = NULL, 5881da177e4SLinus Torvalds .maxlen = sizeof (int), 5891da177e4SLinus Torvalds .mode = 0600, 5906d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 5911da177e4SLinus Torvalds }, 592d6f8ff73SRandy Dunlap #endif 5931da177e4SLinus Torvalds { 5941da177e4SLinus Torvalds .procname = "threads-max", 5951da177e4SLinus Torvalds .data = &max_threads, 5961da177e4SLinus Torvalds .maxlen = sizeof(int), 5971da177e4SLinus Torvalds .mode = 0644, 5986d456111SEric W. Biederman .proc_handler = proc_dointvec, 5991da177e4SLinus Torvalds }, 6001da177e4SLinus Torvalds { 6011da177e4SLinus Torvalds .procname = "random", 6021da177e4SLinus Torvalds .mode = 0555, 6031da177e4SLinus Torvalds .child = random_table, 6041da177e4SLinus Torvalds }, 6051da177e4SLinus Torvalds { 6061da177e4SLinus Torvalds .procname = "overflowuid", 6071da177e4SLinus Torvalds .data = &overflowuid, 6081da177e4SLinus Torvalds .maxlen = sizeof(int), 6091da177e4SLinus Torvalds .mode = 0644, 6106d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6111da177e4SLinus Torvalds .extra1 = &minolduid, 6121da177e4SLinus Torvalds .extra2 = &maxolduid, 6131da177e4SLinus Torvalds }, 6141da177e4SLinus Torvalds { 6151da177e4SLinus Torvalds .procname = "overflowgid", 6161da177e4SLinus Torvalds .data = &overflowgid, 6171da177e4SLinus Torvalds .maxlen = sizeof(int), 6181da177e4SLinus Torvalds .mode = 0644, 6196d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6201da177e4SLinus Torvalds .extra1 = &minolduid, 6211da177e4SLinus Torvalds .extra2 = &maxolduid, 6221da177e4SLinus Torvalds }, 623347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6241da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6251da177e4SLinus Torvalds { 6261da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6271da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6281da177e4SLinus Torvalds .maxlen = sizeof(int), 6291da177e4SLinus Torvalds .mode = 0644, 6306d456111SEric W. Biederman .proc_handler = proc_dointvec, 6311da177e4SLinus Torvalds }, 6321da177e4SLinus Torvalds #endif 6331da177e4SLinus Torvalds { 6341da177e4SLinus Torvalds .procname = "userprocess_debug", 6351da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 6361da177e4SLinus Torvalds .maxlen = sizeof(int), 6371da177e4SLinus Torvalds .mode = 0644, 6386d456111SEric W. Biederman .proc_handler = proc_dointvec, 6391da177e4SLinus Torvalds }, 6401da177e4SLinus Torvalds #endif 6411da177e4SLinus Torvalds { 6421da177e4SLinus Torvalds .procname = "pid_max", 6431da177e4SLinus Torvalds .data = &pid_max, 6441da177e4SLinus Torvalds .maxlen = sizeof (int), 6451da177e4SLinus Torvalds .mode = 0644, 6466d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6471da177e4SLinus Torvalds .extra1 = &pid_max_min, 6481da177e4SLinus Torvalds .extra2 = &pid_max_max, 6491da177e4SLinus Torvalds }, 6501da177e4SLinus Torvalds { 6511da177e4SLinus Torvalds .procname = "panic_on_oops", 6521da177e4SLinus Torvalds .data = &panic_on_oops, 6531da177e4SLinus Torvalds .maxlen = sizeof(int), 6541da177e4SLinus Torvalds .mode = 0644, 6556d456111SEric W. Biederman .proc_handler = proc_dointvec, 6561da177e4SLinus Torvalds }, 6577ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6587ef3d2fdSJoe Perches { 6597ef3d2fdSJoe Perches .procname = "printk", 6607ef3d2fdSJoe Perches .data = &console_loglevel, 6617ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6627ef3d2fdSJoe Perches .mode = 0644, 6636d456111SEric W. Biederman .proc_handler = proc_dointvec, 6647ef3d2fdSJoe Perches }, 6651da177e4SLinus Torvalds { 6661da177e4SLinus Torvalds .procname = "printk_ratelimit", 667717115e1SDave Young .data = &printk_ratelimit_state.interval, 6681da177e4SLinus Torvalds .maxlen = sizeof(int), 6691da177e4SLinus Torvalds .mode = 0644, 6706d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6711da177e4SLinus Torvalds }, 6721da177e4SLinus Torvalds { 6731da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 674717115e1SDave Young .data = &printk_ratelimit_state.burst, 6751da177e4SLinus Torvalds .maxlen = sizeof(int), 6761da177e4SLinus Torvalds .mode = 0644, 6776d456111SEric W. Biederman .proc_handler = proc_dointvec, 6781da177e4SLinus Torvalds }, 679af91322eSDave Young { 680af91322eSDave Young .procname = "printk_delay", 681af91322eSDave Young .data = &printk_delay_msec, 682af91322eSDave Young .maxlen = sizeof(int), 683af91322eSDave Young .mode = 0644, 6846d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 685af91322eSDave Young .extra1 = &zero, 686af91322eSDave Young .extra2 = &ten_thousand, 687af91322eSDave Young }, 6887ef3d2fdSJoe Perches #endif 6891da177e4SLinus Torvalds { 6901da177e4SLinus Torvalds .procname = "ngroups_max", 6911da177e4SLinus Torvalds .data = &ngroups_max, 6921da177e4SLinus Torvalds .maxlen = sizeof (int), 6931da177e4SLinus Torvalds .mode = 0444, 6946d456111SEric W. Biederman .proc_handler = proc_dointvec, 6951da177e4SLinus Torvalds }, 6961da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 6971da177e4SLinus Torvalds { 6981da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 6991da177e4SLinus Torvalds .data = &unknown_nmi_panic, 7001da177e4SLinus Torvalds .maxlen = sizeof (int), 7011da177e4SLinus Torvalds .mode = 0644, 7026d456111SEric W. Biederman .proc_handler = proc_dointvec, 7031da177e4SLinus Torvalds }, 704407984f1SDon Zickus { 705407984f1SDon Zickus .procname = "nmi_watchdog", 706407984f1SDon Zickus .data = &nmi_watchdog_enabled, 707407984f1SDon Zickus .maxlen = sizeof (int), 708407984f1SDon Zickus .mode = 0644, 7096d456111SEric W. Biederman .proc_handler = proc_nmi_enabled, 7101da177e4SLinus Torvalds }, 7111da177e4SLinus Torvalds #endif 7121da177e4SLinus Torvalds #if defined(CONFIG_X86) 7131da177e4SLinus Torvalds { 7148da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7158da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7168da5addaSDon Zickus .maxlen = sizeof(int), 7178da5addaSDon Zickus .mode = 0644, 7186d456111SEric W. Biederman .proc_handler = proc_dointvec, 7198da5addaSDon Zickus }, 7208da5addaSDon Zickus { 7215211a242SKurt Garloff .procname = "panic_on_io_nmi", 7225211a242SKurt Garloff .data = &panic_on_io_nmi, 7235211a242SKurt Garloff .maxlen = sizeof(int), 7245211a242SKurt Garloff .mode = 0644, 7256d456111SEric W. Biederman .proc_handler = proc_dointvec, 7265211a242SKurt Garloff }, 7275211a242SKurt Garloff { 7281da177e4SLinus Torvalds .procname = "bootloader_type", 7291da177e4SLinus Torvalds .data = &bootloader_type, 7301da177e4SLinus Torvalds .maxlen = sizeof (int), 7311da177e4SLinus Torvalds .mode = 0444, 7326d456111SEric W. Biederman .proc_handler = proc_dointvec, 7331da177e4SLinus Torvalds }, 7340741f4d2SChuck Ebbert { 7355031296cSH. Peter Anvin .procname = "bootloader_version", 7365031296cSH. Peter Anvin .data = &bootloader_version, 7375031296cSH. Peter Anvin .maxlen = sizeof (int), 7385031296cSH. Peter Anvin .mode = 0444, 7396d456111SEric W. Biederman .proc_handler = proc_dointvec, 7405031296cSH. Peter Anvin }, 7415031296cSH. Peter Anvin { 7420741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 7430741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 7440741f4d2SChuck Ebbert .maxlen = sizeof(int), 7450741f4d2SChuck Ebbert .mode = 0644, 7466d456111SEric W. Biederman .proc_handler = proc_dointvec, 7470741f4d2SChuck Ebbert }, 7486e7c4025SIngo Molnar { 7496e7c4025SIngo Molnar .procname = "io_delay_type", 7506e7c4025SIngo Molnar .data = &io_delay_type, 7516e7c4025SIngo Molnar .maxlen = sizeof(int), 7526e7c4025SIngo Molnar .mode = 0644, 7536d456111SEric W. Biederman .proc_handler = proc_dointvec, 7546e7c4025SIngo Molnar }, 7551da177e4SLinus Torvalds #endif 7567a9166e3SLuke Yang #if defined(CONFIG_MMU) 7571da177e4SLinus Torvalds { 7581da177e4SLinus Torvalds .procname = "randomize_va_space", 7591da177e4SLinus Torvalds .data = &randomize_va_space, 7601da177e4SLinus Torvalds .maxlen = sizeof(int), 7611da177e4SLinus Torvalds .mode = 0644, 7626d456111SEric W. Biederman .proc_handler = proc_dointvec, 7631da177e4SLinus Torvalds }, 7647a9166e3SLuke Yang #endif 7650152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 766951f22d5SMartin Schwidefsky { 767951f22d5SMartin Schwidefsky .procname = "spin_retry", 768951f22d5SMartin Schwidefsky .data = &spin_retry, 769951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 770951f22d5SMartin Schwidefsky .mode = 0644, 7716d456111SEric W. Biederman .proc_handler = proc_dointvec, 772951f22d5SMartin Schwidefsky }, 773951f22d5SMartin Schwidefsky #endif 774673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 775c255d844SPavel Machek { 776c255d844SPavel Machek .procname = "acpi_video_flags", 77777afcf78SPavel Machek .data = &acpi_realmode_flags, 778c255d844SPavel Machek .maxlen = sizeof (unsigned long), 779c255d844SPavel Machek .mode = 0644, 7806d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 781c255d844SPavel Machek }, 782c255d844SPavel Machek #endif 783d2b176edSJes Sorensen #ifdef CONFIG_IA64 784d2b176edSJes Sorensen { 785d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 786d2b176edSJes Sorensen .data = &no_unaligned_warning, 787d2b176edSJes Sorensen .maxlen = sizeof (int), 788d2b176edSJes Sorensen .mode = 0644, 7896d456111SEric W. Biederman .proc_handler = proc_dointvec, 790d2b176edSJes Sorensen }, 79188fc241fSDoug Chapman { 79288fc241fSDoug Chapman .procname = "unaligned-dump-stack", 79388fc241fSDoug Chapman .data = &unaligned_dump_stack, 79488fc241fSDoug Chapman .maxlen = sizeof (int), 79588fc241fSDoug Chapman .mode = 0644, 7966d456111SEric W. Biederman .proc_handler = proc_dointvec, 79788fc241fSDoug Chapman }, 798d2b176edSJes Sorensen #endif 799c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 800c4f3b63fSRavikiran G Thirumalai { 8019c44bc03SIngo Molnar .procname = "softlockup_panic", 8029c44bc03SIngo Molnar .data = &softlockup_panic, 8039c44bc03SIngo Molnar .maxlen = sizeof(int), 8049c44bc03SIngo Molnar .mode = 0644, 8056d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 8069c44bc03SIngo Molnar .extra1 = &zero, 8079c44bc03SIngo Molnar .extra2 = &one, 8089c44bc03SIngo Molnar }, 8099c44bc03SIngo Molnar { 810c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 811c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 8129383d967SDimitri Sivanich .maxlen = sizeof(int), 813c4f3b63fSRavikiran G Thirumalai .mode = 0644, 8146d456111SEric W. Biederman .proc_handler = proc_dosoftlockup_thresh, 8159383d967SDimitri Sivanich .extra1 = &neg_one, 816c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 817c4f3b63fSRavikiran G Thirumalai }, 818e162b39aSMandeep Singh Baines #endif 819e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 820e162b39aSMandeep Singh Baines { 821e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 822e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 823e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 824e162b39aSMandeep Singh Baines .mode = 0644, 8256d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 826e162b39aSMandeep Singh Baines .extra1 = &zero, 827e162b39aSMandeep Singh Baines .extra2 = &one, 828e162b39aSMandeep Singh Baines }, 82982a1fcb9SIngo Molnar { 83082a1fcb9SIngo Molnar .procname = "hung_task_check_count", 83182a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 83290739081SIngo Molnar .maxlen = sizeof(unsigned long), 83382a1fcb9SIngo Molnar .mode = 0644, 8346d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 83582a1fcb9SIngo Molnar }, 83682a1fcb9SIngo Molnar { 83782a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 83882a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 83990739081SIngo Molnar .maxlen = sizeof(unsigned long), 84082a1fcb9SIngo Molnar .mode = 0644, 8416d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 84282a1fcb9SIngo Molnar }, 84382a1fcb9SIngo Molnar { 84482a1fcb9SIngo Molnar .procname = "hung_task_warnings", 84582a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 84690739081SIngo Molnar .maxlen = sizeof(unsigned long), 84782a1fcb9SIngo Molnar .mode = 0644, 8486d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 84982a1fcb9SIngo Molnar }, 850c4f3b63fSRavikiran G Thirumalai #endif 851bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 852bebfa101SAndi Kleen { 853bebfa101SAndi Kleen .procname = "compat-log", 854bebfa101SAndi Kleen .data = &compat_log, 855bebfa101SAndi Kleen .maxlen = sizeof (int), 856bebfa101SAndi Kleen .mode = 0644, 8576d456111SEric W. Biederman .proc_handler = proc_dointvec, 858bebfa101SAndi Kleen }, 859bebfa101SAndi Kleen #endif 86023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 86123f78d4aSIngo Molnar { 86223f78d4aSIngo Molnar .procname = "max_lock_depth", 86323f78d4aSIngo Molnar .data = &max_lock_depth, 86423f78d4aSIngo Molnar .maxlen = sizeof(int), 86523f78d4aSIngo Molnar .mode = 0644, 8666d456111SEric W. Biederman .proc_handler = proc_dointvec, 86723f78d4aSIngo Molnar }, 86823f78d4aSIngo Molnar #endif 86910a0a8d4SJeremy Fitzhardinge { 87010a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 87110a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 87210a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 87310a0a8d4SJeremy Fitzhardinge .mode = 0644, 8746d456111SEric W. Biederman .proc_handler = proc_dostring, 87510a0a8d4SJeremy Fitzhardinge }, 8760b77f5bfSDavid Howells #ifdef CONFIG_KEYS 8770b77f5bfSDavid Howells { 8780b77f5bfSDavid Howells .procname = "keys", 8790b77f5bfSDavid Howells .mode = 0555, 8800b77f5bfSDavid Howells .child = key_sysctls, 8810b77f5bfSDavid Howells }, 8820b77f5bfSDavid Howells #endif 88331a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 88431a72bceSPaul E. McKenney { 88531a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 88631a72bceSPaul E. McKenney .data = &rcutorture_runnable, 88731a72bceSPaul E. McKenney .maxlen = sizeof(int), 88831a72bceSPaul E. McKenney .mode = 0644, 8896d456111SEric W. Biederman .proc_handler = proc_dointvec, 89031a72bceSPaul E. McKenney }, 89131a72bceSPaul E. McKenney #endif 89212e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK 89312e22c5eSDavid Howells { 89412e22c5eSDavid Howells .procname = "slow-work", 89512e22c5eSDavid Howells .mode = 0555, 89612e22c5eSDavid Howells .child = slow_work_sysctls, 89712e22c5eSDavid Howells }, 89812e22c5eSDavid Howells #endif 899cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 9001ccd1549SPeter Zijlstra { 901cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 902cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 903cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9041ccd1549SPeter Zijlstra .mode = 0644, 9056d456111SEric W. Biederman .proc_handler = proc_dointvec, 9061ccd1549SPeter Zijlstra }, 907c5078f78SPeter Zijlstra { 908cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 909cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 910cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 911c5078f78SPeter Zijlstra .mode = 0644, 9126d456111SEric W. Biederman .proc_handler = proc_dointvec, 913c5078f78SPeter Zijlstra }, 914a78ac325SPeter Zijlstra { 915cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 916cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 917cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 918a78ac325SPeter Zijlstra .mode = 0644, 9196d456111SEric W. Biederman .proc_handler = proc_dointvec, 920a78ac325SPeter Zijlstra }, 9211ccd1549SPeter Zijlstra #endif 922dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 923dfec072eSVegard Nossum { 924dfec072eSVegard Nossum .procname = "kmemcheck", 925dfec072eSVegard Nossum .data = &kmemcheck_enabled, 926dfec072eSVegard Nossum .maxlen = sizeof(int), 927dfec072eSVegard Nossum .mode = 0644, 9286d456111SEric W. Biederman .proc_handler = proc_dointvec, 929dfec072eSVegard Nossum }, 930dfec072eSVegard Nossum #endif 931cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9325e605b64SJens Axboe { 9335e605b64SJens Axboe .procname = "blk_iopoll", 9345e605b64SJens Axboe .data = &blk_iopoll_enabled, 9355e605b64SJens Axboe .maxlen = sizeof(int), 9365e605b64SJens Axboe .mode = 0644, 9376d456111SEric W. Biederman .proc_handler = proc_dointvec, 9385e605b64SJens Axboe }, 939cb684b5bSJens Axboe #endif 940ed2c12f3SAndrew Morton /* 941ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 942ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 943ed2c12f3SAndrew Morton */ 9446fce56ecSEric W. Biederman { } 9451da177e4SLinus Torvalds }; 9461da177e4SLinus Torvalds 947d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 9481da177e4SLinus Torvalds { 9491da177e4SLinus Torvalds .procname = "overcommit_memory", 9501da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 9511da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 9521da177e4SLinus Torvalds .mode = 0644, 9536d456111SEric W. Biederman .proc_handler = proc_dointvec, 9541da177e4SLinus Torvalds }, 9551da177e4SLinus Torvalds { 956fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 957fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 958fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 959fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 9606d456111SEric W. Biederman .proc_handler = proc_dointvec, 961fadd8fbdSKAMEZAWA Hiroyuki }, 962fadd8fbdSKAMEZAWA Hiroyuki { 963fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 964fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 965fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 966fe071d7eSDavid Rientjes .mode = 0644, 9676d456111SEric W. Biederman .proc_handler = proc_dointvec, 968fe071d7eSDavid Rientjes }, 969fe071d7eSDavid Rientjes { 970fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 971fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 972fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 973fef1bdd6SDavid Rientjes .mode = 0644, 9746d456111SEric W. Biederman .proc_handler = proc_dointvec, 975fef1bdd6SDavid Rientjes }, 976fef1bdd6SDavid Rientjes { 9771da177e4SLinus Torvalds .procname = "overcommit_ratio", 9781da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 9791da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 9801da177e4SLinus Torvalds .mode = 0644, 9816d456111SEric W. Biederman .proc_handler = proc_dointvec, 9821da177e4SLinus Torvalds }, 9831da177e4SLinus Torvalds { 9841da177e4SLinus Torvalds .procname = "page-cluster", 9851da177e4SLinus Torvalds .data = &page_cluster, 9861da177e4SLinus Torvalds .maxlen = sizeof(int), 9871da177e4SLinus Torvalds .mode = 0644, 9886d456111SEric W. Biederman .proc_handler = proc_dointvec, 9891da177e4SLinus Torvalds }, 9901da177e4SLinus Torvalds { 9911da177e4SLinus Torvalds .procname = "dirty_background_ratio", 9921da177e4SLinus Torvalds .data = &dirty_background_ratio, 9931da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 9941da177e4SLinus Torvalds .mode = 0644, 9956d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 9961da177e4SLinus Torvalds .extra1 = &zero, 9971da177e4SLinus Torvalds .extra2 = &one_hundred, 9981da177e4SLinus Torvalds }, 9991da177e4SLinus Torvalds { 10002da02997SDavid Rientjes .procname = "dirty_background_bytes", 10012da02997SDavid Rientjes .data = &dirty_background_bytes, 10022da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10032da02997SDavid Rientjes .mode = 0644, 10046d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1005fc3501d4SSven Wegener .extra1 = &one_ul, 10062da02997SDavid Rientjes }, 10072da02997SDavid Rientjes { 10081da177e4SLinus Torvalds .procname = "dirty_ratio", 10091da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10101da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10111da177e4SLinus Torvalds .mode = 0644, 10126d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10131da177e4SLinus Torvalds .extra1 = &zero, 10141da177e4SLinus Torvalds .extra2 = &one_hundred, 10151da177e4SLinus Torvalds }, 10161da177e4SLinus Torvalds { 10172da02997SDavid Rientjes .procname = "dirty_bytes", 10182da02997SDavid Rientjes .data = &vm_dirty_bytes, 10192da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10202da02997SDavid Rientjes .mode = 0644, 10216d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10229e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10232da02997SDavid Rientjes }, 10242da02997SDavid Rientjes { 10251da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1026f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1027f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10281da177e4SLinus Torvalds .mode = 0644, 10296d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10301da177e4SLinus Torvalds }, 10311da177e4SLinus Torvalds { 10321da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1033f6ef9438SBart Samwel .data = &dirty_expire_interval, 1034f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10351da177e4SLinus Torvalds .mode = 0644, 10366d456111SEric W. Biederman .proc_handler = proc_dointvec, 10371da177e4SLinus Torvalds }, 10381da177e4SLinus Torvalds { 10391da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10401da177e4SLinus Torvalds .data = &nr_pdflush_threads, 10411da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 10421da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 10436d456111SEric W. Biederman .proc_handler = proc_dointvec, 10441da177e4SLinus Torvalds }, 10451da177e4SLinus Torvalds { 10461da177e4SLinus Torvalds .procname = "swappiness", 10471da177e4SLinus Torvalds .data = &vm_swappiness, 10481da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 10491da177e4SLinus Torvalds .mode = 0644, 10506d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 10511da177e4SLinus Torvalds .extra1 = &zero, 10521da177e4SLinus Torvalds .extra2 = &one_hundred, 10531da177e4SLinus Torvalds }, 10541da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 10551da177e4SLinus Torvalds { 10561da177e4SLinus Torvalds .procname = "nr_hugepages", 1057e5ff2159SAndi Kleen .data = NULL, 10581da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 10591da177e4SLinus Torvalds .mode = 0644, 10606d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 10611da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 10621da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 10631da177e4SLinus Torvalds }, 106406808b08SLee Schermerhorn #ifdef CONFIG_NUMA 106506808b08SLee Schermerhorn { 106606808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 106706808b08SLee Schermerhorn .data = NULL, 106806808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 106906808b08SLee Schermerhorn .mode = 0644, 107006808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 107106808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 107206808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 107306808b08SLee Schermerhorn }, 107406808b08SLee Schermerhorn #endif 10751da177e4SLinus Torvalds { 10761da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 10771da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 10781da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 10791da177e4SLinus Torvalds .mode = 0644, 10806d456111SEric W. Biederman .proc_handler = proc_dointvec, 10811da177e4SLinus Torvalds }, 1082396faf03SMel Gorman { 1083396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1084396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1085396faf03SMel Gorman .maxlen = sizeof(int), 1086396faf03SMel Gorman .mode = 0644, 10876d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1088396faf03SMel Gorman }, 108954f9f80dSAdam Litke { 1090d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1091e5ff2159SAndi Kleen .data = NULL, 1092e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1093d1c3fb1fSNishanth Aravamudan .mode = 0644, 10946d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1095e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1096e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1097d1c3fb1fSNishanth Aravamudan }, 10981da177e4SLinus Torvalds #endif 10991da177e4SLinus Torvalds { 11001da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11011da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11021da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11031da177e4SLinus Torvalds .mode = 0644, 11046d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11051da177e4SLinus Torvalds }, 11061da177e4SLinus Torvalds { 11079d0243bcSAndrew Morton .procname = "drop_caches", 11089d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11099d0243bcSAndrew Morton .maxlen = sizeof(int), 11109d0243bcSAndrew Morton .mode = 0644, 11119d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 11129d0243bcSAndrew Morton }, 11139d0243bcSAndrew Morton { 11141da177e4SLinus Torvalds .procname = "min_free_kbytes", 11151da177e4SLinus Torvalds .data = &min_free_kbytes, 11161da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11171da177e4SLinus Torvalds .mode = 0644, 11186d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 11191da177e4SLinus Torvalds .extra1 = &zero, 11201da177e4SLinus Torvalds }, 11218ad4b1fbSRohit Seth { 11228ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 11238ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 11248ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 11258ad4b1fbSRohit Seth .mode = 0644, 11266d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 11278ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 11288ad4b1fbSRohit Seth }, 11291da177e4SLinus Torvalds #ifdef CONFIG_MMU 11301da177e4SLinus Torvalds { 11311da177e4SLinus Torvalds .procname = "max_map_count", 11321da177e4SLinus Torvalds .data = &sysctl_max_map_count, 11331da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 11341da177e4SLinus Torvalds .mode = 0644, 11353e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 113670da2340SAmerigo Wang .extra1 = &zero, 11371da177e4SLinus Torvalds }, 1138dd8632a1SPaul Mundt #else 1139dd8632a1SPaul Mundt { 1140dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1141dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1142dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1143dd8632a1SPaul Mundt .mode = 0644, 11446d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1145dd8632a1SPaul Mundt .extra1 = &zero, 1146dd8632a1SPaul Mundt }, 11471da177e4SLinus Torvalds #endif 11481da177e4SLinus Torvalds { 11491da177e4SLinus Torvalds .procname = "laptop_mode", 11501da177e4SLinus Torvalds .data = &laptop_mode, 11511da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 11521da177e4SLinus Torvalds .mode = 0644, 11536d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 11541da177e4SLinus Torvalds }, 11551da177e4SLinus Torvalds { 11561da177e4SLinus Torvalds .procname = "block_dump", 11571da177e4SLinus Torvalds .data = &block_dump, 11581da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 11591da177e4SLinus Torvalds .mode = 0644, 11606d456111SEric W. Biederman .proc_handler = proc_dointvec, 11611da177e4SLinus Torvalds .extra1 = &zero, 11621da177e4SLinus Torvalds }, 11631da177e4SLinus Torvalds { 11641da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 11651da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 11661da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 11671da177e4SLinus Torvalds .mode = 0644, 11686d456111SEric W. Biederman .proc_handler = proc_dointvec, 11691da177e4SLinus Torvalds .extra1 = &zero, 11701da177e4SLinus Torvalds }, 11711da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 11721da177e4SLinus Torvalds { 11731da177e4SLinus Torvalds .procname = "legacy_va_layout", 11741da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 11751da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 11761da177e4SLinus Torvalds .mode = 0644, 11776d456111SEric W. Biederman .proc_handler = proc_dointvec, 11781da177e4SLinus Torvalds .extra1 = &zero, 11791da177e4SLinus Torvalds }, 11801da177e4SLinus Torvalds #endif 11811743660bSChristoph Lameter #ifdef CONFIG_NUMA 11821743660bSChristoph Lameter { 11831743660bSChristoph Lameter .procname = "zone_reclaim_mode", 11841743660bSChristoph Lameter .data = &zone_reclaim_mode, 11851743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 11861743660bSChristoph Lameter .mode = 0644, 11876d456111SEric W. Biederman .proc_handler = proc_dointvec, 1188c84db23cSChristoph Lameter .extra1 = &zero, 11891743660bSChristoph Lameter }, 11909614634fSChristoph Lameter { 11919614634fSChristoph Lameter .procname = "min_unmapped_ratio", 11929614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 11939614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 11949614634fSChristoph Lameter .mode = 0644, 11956d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 11969614634fSChristoph Lameter .extra1 = &zero, 11979614634fSChristoph Lameter .extra2 = &one_hundred, 11989614634fSChristoph Lameter }, 11990ff38490SChristoph Lameter { 12000ff38490SChristoph Lameter .procname = "min_slab_ratio", 12010ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12020ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12030ff38490SChristoph Lameter .mode = 0644, 12046d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12050ff38490SChristoph Lameter .extra1 = &zero, 12060ff38490SChristoph Lameter .extra2 = &one_hundred, 12070ff38490SChristoph Lameter }, 12081743660bSChristoph Lameter #endif 120977461ab3SChristoph Lameter #ifdef CONFIG_SMP 121077461ab3SChristoph Lameter { 121177461ab3SChristoph Lameter .procname = "stat_interval", 121277461ab3SChristoph Lameter .data = &sysctl_stat_interval, 121377461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 121477461ab3SChristoph Lameter .mode = 0644, 12156d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 121677461ab3SChristoph Lameter }, 121777461ab3SChristoph Lameter #endif 12186e141546SDavid Howells #ifdef CONFIG_MMU 1219ed032189SEric Paris { 1220ed032189SEric Paris .procname = "mmap_min_addr", 1221788084abSEric Paris .data = &dac_mmap_min_addr, 1222ed032189SEric Paris .maxlen = sizeof(unsigned long), 1223ed032189SEric Paris .mode = 0644, 12246d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1225ed032189SEric Paris }, 12266e141546SDavid Howells #endif 1227f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1228f0c0b2b8SKAMEZAWA Hiroyuki { 1229f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1230f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1231f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1232f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 12336d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1234f0c0b2b8SKAMEZAWA Hiroyuki }, 1235f0c0b2b8SKAMEZAWA Hiroyuki #endif 12362b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 12375c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1238e6e5494cSIngo Molnar { 1239e6e5494cSIngo Molnar .procname = "vdso_enabled", 1240e6e5494cSIngo Molnar .data = &vdso_enabled, 1241e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1242e6e5494cSIngo Molnar .mode = 0644, 12436d456111SEric W. Biederman .proc_handler = proc_dointvec, 1244e6e5494cSIngo Molnar .extra1 = &zero, 1245e6e5494cSIngo Molnar }, 1246e6e5494cSIngo Molnar #endif 1247195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1248195cf453SBron Gondwana { 1249195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1250195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1251195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1252195cf453SBron Gondwana .mode = 0644, 12536d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1254195cf453SBron Gondwana .extra1 = &zero, 1255195cf453SBron Gondwana .extra2 = &one, 1256195cf453SBron Gondwana }, 1257195cf453SBron Gondwana #endif 12584be6f6bbSPeter Zijlstra { 12594be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 12604be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 12614be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 12624be6f6bbSPeter Zijlstra .mode = 0644, 12636d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 12644be6f6bbSPeter Zijlstra }, 12656a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 12666a46079cSAndi Kleen { 12676a46079cSAndi Kleen .procname = "memory_failure_early_kill", 12686a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 12696a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 12706a46079cSAndi Kleen .mode = 0644, 12716d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12726a46079cSAndi Kleen .extra1 = &zero, 12736a46079cSAndi Kleen .extra2 = &one, 12746a46079cSAndi Kleen }, 12756a46079cSAndi Kleen { 12766a46079cSAndi Kleen .procname = "memory_failure_recovery", 12776a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 12786a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 12796a46079cSAndi Kleen .mode = 0644, 12806d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12816a46079cSAndi Kleen .extra1 = &zero, 12826a46079cSAndi Kleen .extra2 = &one, 12836a46079cSAndi Kleen }, 12846a46079cSAndi Kleen #endif 12856a46079cSAndi Kleen 12862be7fe07SAndrew Morton /* 12872be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 12882be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 12892be7fe07SAndrew Morton */ 12906fce56ecSEric W. Biederman { } 12911da177e4SLinus Torvalds }; 12921da177e4SLinus Torvalds 12932abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1294d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 12956fce56ecSEric W. Biederman { } 12962abc26fcSEric W. Biederman }; 12972abc26fcSEric W. Biederman #endif 12982abc26fcSEric W. Biederman 1299d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13001da177e4SLinus Torvalds { 13011da177e4SLinus Torvalds .procname = "inode-nr", 13021da177e4SLinus Torvalds .data = &inodes_stat, 13031da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13041da177e4SLinus Torvalds .mode = 0444, 13056d456111SEric W. Biederman .proc_handler = proc_dointvec, 13061da177e4SLinus Torvalds }, 13071da177e4SLinus Torvalds { 13081da177e4SLinus Torvalds .procname = "inode-state", 13091da177e4SLinus Torvalds .data = &inodes_stat, 13101da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13111da177e4SLinus Torvalds .mode = 0444, 13126d456111SEric W. Biederman .proc_handler = proc_dointvec, 13131da177e4SLinus Torvalds }, 13141da177e4SLinus Torvalds { 13151da177e4SLinus Torvalds .procname = "file-nr", 13161da177e4SLinus Torvalds .data = &files_stat, 13171da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 13181da177e4SLinus Torvalds .mode = 0444, 13196d456111SEric W. Biederman .proc_handler = proc_nr_files, 13201da177e4SLinus Torvalds }, 13211da177e4SLinus Torvalds { 13221da177e4SLinus Torvalds .procname = "file-max", 13231da177e4SLinus Torvalds .data = &files_stat.max_files, 13241da177e4SLinus Torvalds .maxlen = sizeof(int), 13251da177e4SLinus Torvalds .mode = 0644, 13266d456111SEric W. Biederman .proc_handler = proc_dointvec, 13271da177e4SLinus Torvalds }, 13281da177e4SLinus Torvalds { 13299cfe015aSEric Dumazet .procname = "nr_open", 13309cfe015aSEric Dumazet .data = &sysctl_nr_open, 13319cfe015aSEric Dumazet .maxlen = sizeof(int), 13329cfe015aSEric Dumazet .mode = 0644, 13336d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1334eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1335eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 13369cfe015aSEric Dumazet }, 13379cfe015aSEric Dumazet { 13381da177e4SLinus Torvalds .procname = "dentry-state", 13391da177e4SLinus Torvalds .data = &dentry_stat, 13401da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 13411da177e4SLinus Torvalds .mode = 0444, 13426d456111SEric W. Biederman .proc_handler = proc_dointvec, 13431da177e4SLinus Torvalds }, 13441da177e4SLinus Torvalds { 13451da177e4SLinus Torvalds .procname = "overflowuid", 13461da177e4SLinus Torvalds .data = &fs_overflowuid, 13471da177e4SLinus Torvalds .maxlen = sizeof(int), 13481da177e4SLinus Torvalds .mode = 0644, 13496d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13501da177e4SLinus Torvalds .extra1 = &minolduid, 13511da177e4SLinus Torvalds .extra2 = &maxolduid, 13521da177e4SLinus Torvalds }, 13531da177e4SLinus Torvalds { 13541da177e4SLinus Torvalds .procname = "overflowgid", 13551da177e4SLinus Torvalds .data = &fs_overflowgid, 13561da177e4SLinus Torvalds .maxlen = sizeof(int), 13571da177e4SLinus Torvalds .mode = 0644, 13586d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13591da177e4SLinus Torvalds .extra1 = &minolduid, 13601da177e4SLinus Torvalds .extra2 = &maxolduid, 13611da177e4SLinus Torvalds }, 1362bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13631da177e4SLinus Torvalds { 13641da177e4SLinus Torvalds .procname = "leases-enable", 13651da177e4SLinus Torvalds .data = &leases_enable, 13661da177e4SLinus Torvalds .maxlen = sizeof(int), 13671da177e4SLinus Torvalds .mode = 0644, 13686d456111SEric W. Biederman .proc_handler = proc_dointvec, 13691da177e4SLinus Torvalds }, 1370bfcd17a6SThomas Petazzoni #endif 13711da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 13721da177e4SLinus Torvalds { 13731da177e4SLinus Torvalds .procname = "dir-notify-enable", 13741da177e4SLinus Torvalds .data = &dir_notify_enable, 13751da177e4SLinus Torvalds .maxlen = sizeof(int), 13761da177e4SLinus Torvalds .mode = 0644, 13776d456111SEric W. Biederman .proc_handler = proc_dointvec, 13781da177e4SLinus Torvalds }, 13791da177e4SLinus Torvalds #endif 13801da177e4SLinus Torvalds #ifdef CONFIG_MMU 1381bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13821da177e4SLinus Torvalds { 13831da177e4SLinus Torvalds .procname = "lease-break-time", 13841da177e4SLinus Torvalds .data = &lease_break_time, 13851da177e4SLinus Torvalds .maxlen = sizeof(int), 13861da177e4SLinus Torvalds .mode = 0644, 13876d456111SEric W. Biederman .proc_handler = proc_dointvec, 13881da177e4SLinus Torvalds }, 1389bfcd17a6SThomas Petazzoni #endif 1390ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 13911da177e4SLinus Torvalds { 13921da177e4SLinus Torvalds .procname = "aio-nr", 13931da177e4SLinus Torvalds .data = &aio_nr, 13941da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 13951da177e4SLinus Torvalds .mode = 0444, 13966d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 13971da177e4SLinus Torvalds }, 13981da177e4SLinus Torvalds { 13991da177e4SLinus Torvalds .procname = "aio-max-nr", 14001da177e4SLinus Torvalds .data = &aio_max_nr, 14011da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14021da177e4SLinus Torvalds .mode = 0644, 14036d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14041da177e4SLinus Torvalds }, 1405ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14062d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14070399cb08SRobert Love { 14080399cb08SRobert Love .procname = "inotify", 14090399cb08SRobert Love .mode = 0555, 14100399cb08SRobert Love .child = inotify_table, 14110399cb08SRobert Love }, 14120399cb08SRobert Love #endif 14137ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14147ef9964eSDavide Libenzi { 14157ef9964eSDavide Libenzi .procname = "epoll", 14167ef9964eSDavide Libenzi .mode = 0555, 14177ef9964eSDavide Libenzi .child = epoll_table, 14187ef9964eSDavide Libenzi }, 14197ef9964eSDavide Libenzi #endif 14201da177e4SLinus Torvalds #endif 1421d6e71144SAlan Cox { 1422d6e71144SAlan Cox .procname = "suid_dumpable", 1423d6e71144SAlan Cox .data = &suid_dumpable, 1424d6e71144SAlan Cox .maxlen = sizeof(int), 1425d6e71144SAlan Cox .mode = 0644, 14266d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14278e654fbaSMatthew Wilcox .extra1 = &zero, 14288e654fbaSMatthew Wilcox .extra2 = &two, 1429d6e71144SAlan Cox }, 14302abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14312abc26fcSEric W. Biederman { 14322abc26fcSEric W. Biederman .procname = "binfmt_misc", 14332abc26fcSEric W. Biederman .mode = 0555, 14342abc26fcSEric W. Biederman .child = binfmt_misc_table, 14352abc26fcSEric W. Biederman }, 14362abc26fcSEric W. Biederman #endif 14372be7fe07SAndrew Morton /* 14382be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14392be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14402be7fe07SAndrew Morton */ 14416fce56ecSEric W. Biederman { } 14421da177e4SLinus Torvalds }; 14431da177e4SLinus Torvalds 1444d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1445d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC) 1446abd4f750SMasoud Asgharifard Sharbiani { 1447abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1448abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1449abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1450abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1451abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1452abd4f750SMasoud Asgharifard Sharbiani }, 1453abd4f750SMasoud Asgharifard Sharbiani #endif 1454*b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1455*b2be84dfSMasami Hiramatsu { 1456*b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1457*b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1458*b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1459*b2be84dfSMasami Hiramatsu .mode = 0644, 1460*b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1461*b2be84dfSMasami Hiramatsu .extra1 = &zero, 1462*b2be84dfSMasami Hiramatsu .extra2 = &one, 1463*b2be84dfSMasami Hiramatsu }, 1464*b2be84dfSMasami Hiramatsu #endif 14656fce56ecSEric W. Biederman { } 14661da177e4SLinus Torvalds }; 14671da177e4SLinus Torvalds 1468d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 14696fce56ecSEric W. Biederman { } 14701da177e4SLinus Torvalds }; 14711da177e4SLinus Torvalds 1472330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1473330d57fbSAl Viro 1474330d57fbSAl Viro /* called under sysctl_lock */ 1475330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1476330d57fbSAl Viro { 1477330d57fbSAl Viro if (unlikely(p->unregistering)) 1478330d57fbSAl Viro return 0; 1479330d57fbSAl Viro p->used++; 1480330d57fbSAl Viro return 1; 1481330d57fbSAl Viro } 1482330d57fbSAl Viro 1483330d57fbSAl Viro /* called under sysctl_lock */ 1484330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1485330d57fbSAl Viro { 1486330d57fbSAl Viro if (!--p->used) 1487330d57fbSAl Viro if (unlikely(p->unregistering)) 1488330d57fbSAl Viro complete(p->unregistering); 1489330d57fbSAl Viro } 1490330d57fbSAl Viro 1491330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1492330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1493330d57fbSAl Viro { 1494330d57fbSAl Viro /* 1495330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1496330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1497330d57fbSAl Viro */ 1498330d57fbSAl Viro if (unlikely(p->used)) { 1499330d57fbSAl Viro struct completion wait; 1500330d57fbSAl Viro init_completion(&wait); 1501330d57fbSAl Viro p->unregistering = &wait; 1502330d57fbSAl Viro spin_unlock(&sysctl_lock); 1503330d57fbSAl Viro wait_for_completion(&wait); 1504330d57fbSAl Viro spin_lock(&sysctl_lock); 1505f7e6ced4SAl Viro } else { 1506f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1507f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1508330d57fbSAl Viro } 1509330d57fbSAl Viro /* 1510330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1511330d57fbSAl Viro * list in do_sysctl() relies on that. 1512330d57fbSAl Viro */ 1513330d57fbSAl Viro list_del_init(&p->ctl_entry); 1514330d57fbSAl Viro } 1515330d57fbSAl Viro 1516f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1517f7e6ced4SAl Viro { 1518f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1519f7e6ced4SAl Viro head->count++; 1520f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1521f7e6ced4SAl Viro } 1522f7e6ced4SAl Viro 1523f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1524f7e6ced4SAl Viro { 1525f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1526f7e6ced4SAl Viro if (!--head->count) 1527f7e6ced4SAl Viro kfree(head); 1528f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1529f7e6ced4SAl Viro } 1530f7e6ced4SAl Viro 1531f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1532f7e6ced4SAl Viro { 1533f7e6ced4SAl Viro if (!head) 1534f7e6ced4SAl Viro BUG(); 1535f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1536f7e6ced4SAl Viro if (!use_table(head)) 1537f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1538f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1539f7e6ced4SAl Viro return head; 1540f7e6ced4SAl Viro } 1541f7e6ced4SAl Viro 1542805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1543805b5d5eSEric W. Biederman { 1544805b5d5eSEric W. Biederman if (!head) 1545805b5d5eSEric W. Biederman return; 1546805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1547805b5d5eSEric W. Biederman unuse_table(head); 1548805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1549805b5d5eSEric W. Biederman } 1550805b5d5eSEric W. Biederman 155173455092SAl Viro static struct ctl_table_set * 155273455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 155373455092SAl Viro { 155473455092SAl Viro struct ctl_table_set *set = &root->default_set; 155573455092SAl Viro if (root->lookup) 155673455092SAl Viro set = root->lookup(root, namespaces); 155773455092SAl Viro return set; 155873455092SAl Viro } 155973455092SAl Viro 1560e51b6ba0SEric W. Biederman static struct list_head * 1561e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1562805b5d5eSEric W. Biederman { 156373455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 156473455092SAl Viro return &set->list; 1565e51b6ba0SEric W. Biederman } 1566e51b6ba0SEric W. Biederman 1567e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1568e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1569e51b6ba0SEric W. Biederman { 1570e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1571e51b6ba0SEric W. Biederman struct list_head *header_list; 1572805b5d5eSEric W. Biederman struct ctl_table_header *head; 1573805b5d5eSEric W. Biederman struct list_head *tmp; 1574e51b6ba0SEric W. Biederman 1575805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1576805b5d5eSEric W. Biederman if (prev) { 1577e51b6ba0SEric W. Biederman head = prev; 1578805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1579805b5d5eSEric W. Biederman unuse_table(prev); 1580805b5d5eSEric W. Biederman goto next; 1581805b5d5eSEric W. Biederman } 1582805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1583805b5d5eSEric W. Biederman for (;;) { 1584805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1585805b5d5eSEric W. Biederman 1586805b5d5eSEric W. Biederman if (!use_table(head)) 1587805b5d5eSEric W. Biederman goto next; 1588805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1589805b5d5eSEric W. Biederman return head; 1590805b5d5eSEric W. Biederman next: 1591e51b6ba0SEric W. Biederman root = head->root; 1592805b5d5eSEric W. Biederman tmp = tmp->next; 1593e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1594e51b6ba0SEric W. Biederman if (tmp != header_list) 1595e51b6ba0SEric W. Biederman continue; 1596e51b6ba0SEric W. Biederman 1597e51b6ba0SEric W. Biederman do { 1598e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1599e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1600e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1601e51b6ba0SEric W. Biederman goto out; 1602e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1603e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1604e51b6ba0SEric W. Biederman tmp = header_list->next; 1605805b5d5eSEric W. Biederman } 1606e51b6ba0SEric W. Biederman out: 1607805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1608805b5d5eSEric W. Biederman return NULL; 1609805b5d5eSEric W. Biederman } 1610805b5d5eSEric W. Biederman 1611e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1612e51b6ba0SEric W. Biederman { 1613e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1614e51b6ba0SEric W. Biederman } 1615e51b6ba0SEric W. Biederman 1616e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1617e51b6ba0SEric W. Biederman { 1618e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1619e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1620e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1621e51b6ba0SEric W. Biederman } 1622e51b6ba0SEric W. Biederman 16231da177e4SLinus Torvalds /* 16241ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 16251da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 16261da177e4SLinus Torvalds */ 16271da177e4SLinus Torvalds 16281da177e4SLinus Torvalds static int test_perm(int mode, int op) 16291da177e4SLinus Torvalds { 163076aac0e9SDavid Howells if (!current_euid()) 16311da177e4SLinus Torvalds mode >>= 6; 16321da177e4SLinus Torvalds else if (in_egroup_p(0)) 16331da177e4SLinus Torvalds mode >>= 3; 1634e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 16351da177e4SLinus Torvalds return 0; 16361da177e4SLinus Torvalds return -EACCES; 16371da177e4SLinus Torvalds } 16381da177e4SLinus Torvalds 1639d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 16401da177e4SLinus Torvalds { 16411da177e4SLinus Torvalds int error; 1642d7321cd6SPavel Emelyanov int mode; 1643d7321cd6SPavel Emelyanov 1644e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 16451da177e4SLinus Torvalds if (error) 16461da177e4SLinus Torvalds return error; 1647d7321cd6SPavel Emelyanov 1648d7321cd6SPavel Emelyanov if (root->permissions) 1649d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1650d7321cd6SPavel Emelyanov else 1651d7321cd6SPavel Emelyanov mode = table->mode; 1652d7321cd6SPavel Emelyanov 1653d7321cd6SPavel Emelyanov return test_perm(mode, op); 16541da177e4SLinus Torvalds } 16551da177e4SLinus Torvalds 1656d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1657d912b0ccSEric W. Biederman { 16582315ffa0SEric W. Biederman for (; table->procname; table++) { 1659d912b0ccSEric W. Biederman table->parent = parent; 1660d912b0ccSEric W. Biederman if (table->child) 1661d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1662d912b0ccSEric W. Biederman } 1663d912b0ccSEric W. Biederman } 1664d912b0ccSEric W. Biederman 1665d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1666d912b0ccSEric W. Biederman { 1667d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 166888f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 166988f458e4SHolger Schurig { 167088f458e4SHolger Schurig int err; 1671e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 167288f458e4SHolger Schurig } 167388f458e4SHolger Schurig #endif 1674d912b0ccSEric W. Biederman return 0; 1675d912b0ccSEric W. Biederman } 1676d912b0ccSEric W. Biederman 1677d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1678d912b0ccSEric W. Biederman 1679bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1680bfbcf034SAl Viro struct ctl_table *table) 1681ae7edeccSAl Viro { 1682ae7edeccSAl Viro struct ctl_table *p; 1683ae7edeccSAl Viro const char *s = branch->procname; 1684ae7edeccSAl Viro 1685ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1686ae7edeccSAl Viro if (!s || !branch->child) 1687bfbcf034SAl Viro return NULL; 1688ae7edeccSAl Viro 1689ae7edeccSAl Viro /* ... and nothing else */ 16902315ffa0SEric W. Biederman if (branch[1].procname) 1691bfbcf034SAl Viro return NULL; 1692ae7edeccSAl Viro 1693ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 16942315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1695ae7edeccSAl Viro if (!p->child) 1696ae7edeccSAl Viro continue; 1697ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1698bfbcf034SAl Viro return p; 1699ae7edeccSAl Viro } 1700bfbcf034SAl Viro return NULL; 1701ae7edeccSAl Viro } 1702ae7edeccSAl Viro 1703ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1704ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1705ae7edeccSAl Viro { 1706ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1707bfbcf034SAl Viro struct ctl_table *next; 1708ae7edeccSAl Viro int is_better = 0; 1709ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1710ae7edeccSAl Viro 1711bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1712ae7edeccSAl Viro if (by == q->attached_by) 1713ae7edeccSAl Viro is_better = 1; 1714ae7edeccSAl Viro if (to == p->attached_by) 1715ae7edeccSAl Viro not_in_parent = 1; 1716ae7edeccSAl Viro by = by->child; 1717bfbcf034SAl Viro to = next->child; 1718ae7edeccSAl Viro } 1719ae7edeccSAl Viro 1720ae7edeccSAl Viro if (is_better && not_in_parent) { 1721ae7edeccSAl Viro q->attached_by = by; 1722ae7edeccSAl Viro q->attached_to = to; 1723ae7edeccSAl Viro q->parent = p; 1724ae7edeccSAl Viro } 1725ae7edeccSAl Viro } 1726ae7edeccSAl Viro 17271da177e4SLinus Torvalds /** 1728e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1729e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1730e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 173129e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 17321da177e4SLinus Torvalds * @table: the top-level table structure 17331da177e4SLinus Torvalds * 17341da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 173529e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 17361da177e4SLinus Torvalds * 1737d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 17381da177e4SLinus Torvalds * 17391da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 17401da177e4SLinus Torvalds * enter a sysctl file 17411da177e4SLinus Torvalds * 17421da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 17431da177e4SLinus Torvalds * 17441da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 17451da177e4SLinus Torvalds * 17461da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 17471da177e4SLinus Torvalds * 17481da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 17491da177e4SLinus Torvalds * %NULL. 17501da177e4SLinus Torvalds * 17511da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 17521da177e4SLinus Torvalds * 17531da177e4SLinus Torvalds * de - for internal use by the sysctl routines 17541da177e4SLinus Torvalds * 17551da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 17561da177e4SLinus Torvalds * 17571da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 17581da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 17591da177e4SLinus Torvalds * 17601da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 17611da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 17621da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 17631da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 17641da177e4SLinus Torvalds * 17651da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 17661da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 17671da177e4SLinus Torvalds * directory handler). Several default handlers are available to 17681da177e4SLinus Torvalds * cover common cases - 17691da177e4SLinus Torvalds * 17701da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 17711da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 17721da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 17731da177e4SLinus Torvalds * 17741da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 17751da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 17761da177e4SLinus Torvalds * 17771da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 17781da177e4SLinus Torvalds * to the table header on success. 17791da177e4SLinus Torvalds */ 1780e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1781e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1782e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1783e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 17841da177e4SLinus Torvalds { 178529e796fdSEric W. Biederman struct ctl_table_header *header; 178629e796fdSEric W. Biederman struct ctl_table *new, **prevp; 178729e796fdSEric W. Biederman unsigned int n, npath; 1788ae7edeccSAl Viro struct ctl_table_set *set; 178929e796fdSEric W. Biederman 179029e796fdSEric W. Biederman /* Count the path components */ 17912315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 179229e796fdSEric W. Biederman ; 179329e796fdSEric W. Biederman 179429e796fdSEric W. Biederman /* 179529e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 179629e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 17972315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 179829e796fdSEric W. Biederman * 179929e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 180029e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 180129e796fdSEric W. Biederman */ 180229e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 180329e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 180429e796fdSEric W. Biederman if (!header) 18051da177e4SLinus Torvalds return NULL; 180629e796fdSEric W. Biederman 180729e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 180829e796fdSEric W. Biederman 180929e796fdSEric W. Biederman /* Now connect the dots */ 181029e796fdSEric W. Biederman prevp = &header->ctl_table; 181129e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 181229e796fdSEric W. Biederman /* Copy the procname */ 181329e796fdSEric W. Biederman new->procname = path->procname; 181429e796fdSEric W. Biederman new->mode = 0555; 181529e796fdSEric W. Biederman 181629e796fdSEric W. Biederman *prevp = new; 181729e796fdSEric W. Biederman prevp = &new->child; 181829e796fdSEric W. Biederman 181929e796fdSEric W. Biederman new += 2; 182029e796fdSEric W. Biederman } 182129e796fdSEric W. Biederman *prevp = table; 182223eb06deSEric W. Biederman header->ctl_table_arg = table; 182329e796fdSEric W. Biederman 182429e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 182529e796fdSEric W. Biederman header->used = 0; 182629e796fdSEric W. Biederman header->unregistering = NULL; 1827e51b6ba0SEric W. Biederman header->root = root; 182829e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1829f7e6ced4SAl Viro header->count = 1; 183088f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1831e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 183229e796fdSEric W. Biederman kfree(header); 1833fc6cd25bSEric W. Biederman return NULL; 1834fc6cd25bSEric W. Biederman } 183588f458e4SHolger Schurig #endif 1836330d57fbSAl Viro spin_lock(&sysctl_lock); 183773455092SAl Viro header->set = lookup_header_set(root, namespaces); 1838ae7edeccSAl Viro header->attached_by = header->ctl_table; 1839ae7edeccSAl Viro header->attached_to = root_table; 1840ae7edeccSAl Viro header->parent = &root_table_header; 1841ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1842ae7edeccSAl Viro struct ctl_table_header *p; 1843ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1844ae7edeccSAl Viro if (p->unregistering) 1845ae7edeccSAl Viro continue; 1846ae7edeccSAl Viro try_attach(p, header); 1847ae7edeccSAl Viro } 1848ae7edeccSAl Viro } 1849ae7edeccSAl Viro header->parent->count++; 185073455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1851330d57fbSAl Viro spin_unlock(&sysctl_lock); 185229e796fdSEric W. Biederman 185329e796fdSEric W. Biederman return header; 185429e796fdSEric W. Biederman } 185529e796fdSEric W. Biederman 185629e796fdSEric W. Biederman /** 1857e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1858e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1859e51b6ba0SEric W. Biederman * @table: the top-level table structure 1860e51b6ba0SEric W. Biederman * 1861e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1862e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1863e51b6ba0SEric W. Biederman * 1864e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1865e51b6ba0SEric W. Biederman */ 1866e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1867e51b6ba0SEric W. Biederman struct ctl_table *table) 1868e51b6ba0SEric W. Biederman { 1869e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1870e51b6ba0SEric W. Biederman path, table); 1871e51b6ba0SEric W. Biederman } 1872e51b6ba0SEric W. Biederman 1873e51b6ba0SEric W. Biederman /** 187429e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 187529e796fdSEric W. Biederman * @table: the top-level table structure 187629e796fdSEric W. Biederman * 187729e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 187829e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 187929e796fdSEric W. Biederman * 188029e796fdSEric W. Biederman * See register_sysctl_paths for more details. 188129e796fdSEric W. Biederman */ 188229e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 188329e796fdSEric W. Biederman { 188429e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 188529e796fdSEric W. Biederman 188629e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 18871da177e4SLinus Torvalds } 18881da177e4SLinus Torvalds 18891da177e4SLinus Torvalds /** 18901da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 18911da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 18921da177e4SLinus Torvalds * 18931da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 18941da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 18951da177e4SLinus Torvalds */ 18961da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 18971da177e4SLinus Torvalds { 1898330d57fbSAl Viro might_sleep(); 1899f1dad166SPavel Emelyanov 1900f1dad166SPavel Emelyanov if (header == NULL) 1901f1dad166SPavel Emelyanov return; 1902f1dad166SPavel Emelyanov 1903330d57fbSAl Viro spin_lock(&sysctl_lock); 1904330d57fbSAl Viro start_unregistering(header); 1905ae7edeccSAl Viro if (!--header->parent->count) { 1906ae7edeccSAl Viro WARN_ON(1); 1907ae7edeccSAl Viro kfree(header->parent); 1908ae7edeccSAl Viro } 1909f7e6ced4SAl Viro if (!--header->count) 19101da177e4SLinus Torvalds kfree(header); 1911f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19121da177e4SLinus Torvalds } 19131da177e4SLinus Torvalds 19149043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19159043476fSAl Viro { 19169043476fSAl Viro struct ctl_table_set *set = p->set; 19179043476fSAl Viro int res; 19189043476fSAl Viro spin_lock(&sysctl_lock); 19199043476fSAl Viro if (p->unregistering) 19209043476fSAl Viro res = 0; 19219043476fSAl Viro else if (!set->is_seen) 19229043476fSAl Viro res = 1; 19239043476fSAl Viro else 19249043476fSAl Viro res = set->is_seen(set); 19259043476fSAl Viro spin_unlock(&sysctl_lock); 19269043476fSAl Viro return res; 19279043476fSAl Viro } 19289043476fSAl Viro 192973455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 193073455092SAl Viro struct ctl_table_set *parent, 193173455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 193273455092SAl Viro { 193373455092SAl Viro INIT_LIST_HEAD(&p->list); 193473455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 193573455092SAl Viro p->is_seen = is_seen; 193673455092SAl Viro } 193773455092SAl Viro 1938b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 1939d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1940b89a8171SEric W. Biederman { 1941b89a8171SEric W. Biederman return NULL; 1942b89a8171SEric W. Biederman } 1943b89a8171SEric W. Biederman 194429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 194529e796fdSEric W. Biederman struct ctl_table *table) 194629e796fdSEric W. Biederman { 194729e796fdSEric W. Biederman return NULL; 194829e796fdSEric W. Biederman } 194929e796fdSEric W. Biederman 1950b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 1951b89a8171SEric W. Biederman { 1952b89a8171SEric W. Biederman } 1953b89a8171SEric W. Biederman 195473455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 195573455092SAl Viro struct ctl_table_set *parent, 195673455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 195773455092SAl Viro { 195873455092SAl Viro } 195973455092SAl Viro 1960f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1961f7e6ced4SAl Viro { 1962f7e6ced4SAl Viro } 1963f7e6ced4SAl Viro 1964b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1965b89a8171SEric W. Biederman 19661da177e4SLinus Torvalds /* 19671da177e4SLinus Torvalds * /proc/sys support 19681da177e4SLinus Torvalds */ 19691da177e4SLinus Torvalds 1970b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 19711da177e4SLinus Torvalds 1972b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 19738d65af78SAlexey Dobriyan void __user *buffer, 1974b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1975f5dd3d6fSSam Vilain { 1976f5dd3d6fSSam Vilain size_t len; 1977f5dd3d6fSSam Vilain char __user *p; 1978f5dd3d6fSSam Vilain char c; 1979f5dd3d6fSSam Vilain 19808d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1981f5dd3d6fSSam Vilain *lenp = 0; 1982f5dd3d6fSSam Vilain return 0; 1983f5dd3d6fSSam Vilain } 1984f5dd3d6fSSam Vilain 1985f5dd3d6fSSam Vilain if (write) { 1986f5dd3d6fSSam Vilain len = 0; 1987f5dd3d6fSSam Vilain p = buffer; 1988f5dd3d6fSSam Vilain while (len < *lenp) { 1989f5dd3d6fSSam Vilain if (get_user(c, p++)) 1990f5dd3d6fSSam Vilain return -EFAULT; 1991f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1992f5dd3d6fSSam Vilain break; 1993f5dd3d6fSSam Vilain len++; 1994f5dd3d6fSSam Vilain } 1995f5dd3d6fSSam Vilain if (len >= maxlen) 1996f5dd3d6fSSam Vilain len = maxlen-1; 1997f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1998f5dd3d6fSSam Vilain return -EFAULT; 1999f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2000f5dd3d6fSSam Vilain *ppos += *lenp; 2001f5dd3d6fSSam Vilain } else { 2002f5dd3d6fSSam Vilain len = strlen(data); 2003f5dd3d6fSSam Vilain if (len > maxlen) 2004f5dd3d6fSSam Vilain len = maxlen; 20058d060877SOleg Nesterov 20068d060877SOleg Nesterov if (*ppos > len) { 20078d060877SOleg Nesterov *lenp = 0; 20088d060877SOleg Nesterov return 0; 20098d060877SOleg Nesterov } 20108d060877SOleg Nesterov 20118d060877SOleg Nesterov data += *ppos; 20128d060877SOleg Nesterov len -= *ppos; 20138d060877SOleg Nesterov 2014f5dd3d6fSSam Vilain if (len > *lenp) 2015f5dd3d6fSSam Vilain len = *lenp; 2016f5dd3d6fSSam Vilain if (len) 2017f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2018f5dd3d6fSSam Vilain return -EFAULT; 2019f5dd3d6fSSam Vilain if (len < *lenp) { 2020f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2021f5dd3d6fSSam Vilain return -EFAULT; 2022f5dd3d6fSSam Vilain len++; 2023f5dd3d6fSSam Vilain } 2024f5dd3d6fSSam Vilain *lenp = len; 2025f5dd3d6fSSam Vilain *ppos += len; 2026f5dd3d6fSSam Vilain } 2027f5dd3d6fSSam Vilain return 0; 2028f5dd3d6fSSam Vilain } 2029f5dd3d6fSSam Vilain 20301da177e4SLinus Torvalds /** 20311da177e4SLinus Torvalds * proc_dostring - read a string sysctl 20321da177e4SLinus Torvalds * @table: the sysctl table 20331da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20341da177e4SLinus Torvalds * @buffer: the user buffer 20351da177e4SLinus Torvalds * @lenp: the size of the user buffer 20361da177e4SLinus Torvalds * @ppos: file position 20371da177e4SLinus Torvalds * 20381da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 20391da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 20401da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 20411da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 20421da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 20431da177e4SLinus Torvalds * not large enough. 20441da177e4SLinus Torvalds * 20451da177e4SLinus Torvalds * Returns 0 on success. 20461da177e4SLinus Torvalds */ 20478d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 20481da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20491da177e4SLinus Torvalds { 20508d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2051f5dd3d6fSSam Vilain buffer, lenp, ppos); 20521da177e4SLinus Torvalds } 20531da177e4SLinus Torvalds 20541da177e4SLinus Torvalds 20551da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 20561da177e4SLinus Torvalds int *valp, 20571da177e4SLinus Torvalds int write, void *data) 20581da177e4SLinus Torvalds { 20591da177e4SLinus Torvalds if (write) { 20601da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 20611da177e4SLinus Torvalds } else { 20621da177e4SLinus Torvalds int val = *valp; 20631da177e4SLinus Torvalds if (val < 0) { 20641da177e4SLinus Torvalds *negp = -1; 20651da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 20661da177e4SLinus Torvalds } else { 20671da177e4SLinus Torvalds *negp = 0; 20681da177e4SLinus Torvalds *lvalp = (unsigned long)val; 20691da177e4SLinus Torvalds } 20701da177e4SLinus Torvalds } 20711da177e4SLinus Torvalds return 0; 20721da177e4SLinus Torvalds } 20731da177e4SLinus Torvalds 2074d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 20758d65af78SAlexey Dobriyan int write, void __user *buffer, 2076fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 20771da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 20781da177e4SLinus Torvalds int write, void *data), 20791da177e4SLinus Torvalds void *data) 20801da177e4SLinus Torvalds { 20811da177e4SLinus Torvalds #define TMPBUFLEN 21 20827338f299SSukanto Ghosh int *i, vleft, first = 1, neg; 20831da177e4SLinus Torvalds unsigned long lval; 20841da177e4SLinus Torvalds size_t left, len; 20851da177e4SLinus Torvalds 20861da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 20871da177e4SLinus Torvalds char __user *s = buffer; 20881da177e4SLinus Torvalds 2089fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 20901da177e4SLinus Torvalds (*ppos && !write)) { 20911da177e4SLinus Torvalds *lenp = 0; 20921da177e4SLinus Torvalds return 0; 20931da177e4SLinus Torvalds } 20941da177e4SLinus Torvalds 2095fcfbd547SKirill Korotaev i = (int *) tbl_data; 20961da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 20971da177e4SLinus Torvalds left = *lenp; 20981da177e4SLinus Torvalds 20991da177e4SLinus Torvalds if (!conv) 21001da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 21011da177e4SLinus Torvalds 21021da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 21031da177e4SLinus Torvalds if (write) { 21041da177e4SLinus Torvalds while (left) { 21051da177e4SLinus Torvalds char c; 21061da177e4SLinus Torvalds if (get_user(c, s)) 21071da177e4SLinus Torvalds return -EFAULT; 21081da177e4SLinus Torvalds if (!isspace(c)) 21091da177e4SLinus Torvalds break; 21101da177e4SLinus Torvalds left--; 21111da177e4SLinus Torvalds s++; 21121da177e4SLinus Torvalds } 21131da177e4SLinus Torvalds if (!left) 21141da177e4SLinus Torvalds break; 21151da177e4SLinus Torvalds neg = 0; 21161da177e4SLinus Torvalds len = left; 21171da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 21181da177e4SLinus Torvalds len = sizeof(buf) - 1; 21191da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 21201da177e4SLinus Torvalds return -EFAULT; 21211da177e4SLinus Torvalds buf[len] = 0; 21221da177e4SLinus Torvalds p = buf; 21231da177e4SLinus Torvalds if (*p == '-' && left > 1) { 21241da177e4SLinus Torvalds neg = 1; 2125bd9b0bacSBP, Praveen p++; 21261da177e4SLinus Torvalds } 21271da177e4SLinus Torvalds if (*p < '0' || *p > '9') 21281da177e4SLinus Torvalds break; 21291da177e4SLinus Torvalds 21301da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 21311da177e4SLinus Torvalds 21321da177e4SLinus Torvalds len = p-buf; 21331da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 21341da177e4SLinus Torvalds break; 21351da177e4SLinus Torvalds s += len; 21361da177e4SLinus Torvalds left -= len; 21371da177e4SLinus Torvalds 21381da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 21391da177e4SLinus Torvalds break; 21401da177e4SLinus Torvalds } else { 21411da177e4SLinus Torvalds p = buf; 21421da177e4SLinus Torvalds if (!first) 21431da177e4SLinus Torvalds *p++ = '\t'; 21441da177e4SLinus Torvalds 21451da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 21461da177e4SLinus Torvalds break; 21471da177e4SLinus Torvalds 21481da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 21491da177e4SLinus Torvalds len = strlen(buf); 21501da177e4SLinus Torvalds if (len > left) 21511da177e4SLinus Torvalds len = left; 21521da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 21531da177e4SLinus Torvalds return -EFAULT; 21541da177e4SLinus Torvalds left -= len; 21551da177e4SLinus Torvalds s += len; 21561da177e4SLinus Torvalds } 21571da177e4SLinus Torvalds } 21581da177e4SLinus Torvalds 21591da177e4SLinus Torvalds if (!write && !first && left) { 21601da177e4SLinus Torvalds if(put_user('\n', s)) 21611da177e4SLinus Torvalds return -EFAULT; 21621da177e4SLinus Torvalds left--, s++; 21631da177e4SLinus Torvalds } 21641da177e4SLinus Torvalds if (write) { 21651da177e4SLinus Torvalds while (left) { 21661da177e4SLinus Torvalds char c; 21671da177e4SLinus Torvalds if (get_user(c, s++)) 21681da177e4SLinus Torvalds return -EFAULT; 21691da177e4SLinus Torvalds if (!isspace(c)) 21701da177e4SLinus Torvalds break; 21711da177e4SLinus Torvalds left--; 21721da177e4SLinus Torvalds } 21731da177e4SLinus Torvalds } 21741da177e4SLinus Torvalds if (write && first) 21751da177e4SLinus Torvalds return -EINVAL; 21761da177e4SLinus Torvalds *lenp -= left; 21771da177e4SLinus Torvalds *ppos += *lenp; 21781da177e4SLinus Torvalds return 0; 21791da177e4SLinus Torvalds #undef TMPBUFLEN 21801da177e4SLinus Torvalds } 21811da177e4SLinus Torvalds 21828d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2183fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2184fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2185fcfbd547SKirill Korotaev int write, void *data), 2186fcfbd547SKirill Korotaev void *data) 2187fcfbd547SKirill Korotaev { 21888d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2189fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2190fcfbd547SKirill Korotaev } 2191fcfbd547SKirill Korotaev 21921da177e4SLinus Torvalds /** 21931da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 21941da177e4SLinus Torvalds * @table: the sysctl table 21951da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21961da177e4SLinus Torvalds * @buffer: the user buffer 21971da177e4SLinus Torvalds * @lenp: the size of the user buffer 21981da177e4SLinus Torvalds * @ppos: file position 21991da177e4SLinus Torvalds * 22001da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22011da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22021da177e4SLinus Torvalds * 22031da177e4SLinus Torvalds * Returns 0 on success. 22041da177e4SLinus Torvalds */ 22058d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 22061da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22071da177e4SLinus Torvalds { 22088d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 22091da177e4SLinus Torvalds NULL,NULL); 22101da177e4SLinus Torvalds } 22111da177e4SLinus Torvalds 221234f5a398STheodore Ts'o /* 221334f5a398STheodore Ts'o * Taint values can only be increased 221425ddbb18SAndi Kleen * This means we can safely use a temporary. 221534f5a398STheodore Ts'o */ 22168d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 221734f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 221834f5a398STheodore Ts'o { 221925ddbb18SAndi Kleen struct ctl_table t; 222025ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 222125ddbb18SAndi Kleen int err; 222234f5a398STheodore Ts'o 222391fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 222434f5a398STheodore Ts'o return -EPERM; 222534f5a398STheodore Ts'o 222625ddbb18SAndi Kleen t = *table; 222725ddbb18SAndi Kleen t.data = &tmptaint; 22288d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 222925ddbb18SAndi Kleen if (err < 0) 223025ddbb18SAndi Kleen return err; 223125ddbb18SAndi Kleen 223225ddbb18SAndi Kleen if (write) { 223325ddbb18SAndi Kleen /* 223425ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 223525ddbb18SAndi Kleen * to everyone's atomic.h for this 223625ddbb18SAndi Kleen */ 223725ddbb18SAndi Kleen int i; 223825ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 223925ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 224025ddbb18SAndi Kleen add_taint(i); 224125ddbb18SAndi Kleen } 224225ddbb18SAndi Kleen } 224325ddbb18SAndi Kleen 224425ddbb18SAndi Kleen return err; 224534f5a398STheodore Ts'o } 224634f5a398STheodore Ts'o 22471da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 22481da177e4SLinus Torvalds int *min; 22491da177e4SLinus Torvalds int *max; 22501da177e4SLinus Torvalds }; 22511da177e4SLinus Torvalds 22521da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 22531da177e4SLinus Torvalds int *valp, 22541da177e4SLinus Torvalds int write, void *data) 22551da177e4SLinus Torvalds { 22561da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 22571da177e4SLinus Torvalds if (write) { 22581da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 22591da177e4SLinus Torvalds if ((param->min && *param->min > val) || 22601da177e4SLinus Torvalds (param->max && *param->max < val)) 22611da177e4SLinus Torvalds return -EINVAL; 22621da177e4SLinus Torvalds *valp = val; 22631da177e4SLinus Torvalds } else { 22641da177e4SLinus Torvalds int val = *valp; 22651da177e4SLinus Torvalds if (val < 0) { 22661da177e4SLinus Torvalds *negp = -1; 22671da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22681da177e4SLinus Torvalds } else { 22691da177e4SLinus Torvalds *negp = 0; 22701da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22711da177e4SLinus Torvalds } 22721da177e4SLinus Torvalds } 22731da177e4SLinus Torvalds return 0; 22741da177e4SLinus Torvalds } 22751da177e4SLinus Torvalds 22761da177e4SLinus Torvalds /** 22771da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 22781da177e4SLinus Torvalds * @table: the sysctl table 22791da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22801da177e4SLinus Torvalds * @buffer: the user buffer 22811da177e4SLinus Torvalds * @lenp: the size of the user buffer 22821da177e4SLinus Torvalds * @ppos: file position 22831da177e4SLinus Torvalds * 22841da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22851da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22861da177e4SLinus Torvalds * 22871da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 22881da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 22891da177e4SLinus Torvalds * 22901da177e4SLinus Torvalds * Returns 0 on success. 22911da177e4SLinus Torvalds */ 22928d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 22931da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22941da177e4SLinus Torvalds { 22951da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 22961da177e4SLinus Torvalds .min = (int *) table->extra1, 22971da177e4SLinus Torvalds .max = (int *) table->extra2, 22981da177e4SLinus Torvalds }; 22998d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 23001da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 23011da177e4SLinus Torvalds } 23021da177e4SLinus Torvalds 2303d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 23041da177e4SLinus Torvalds void __user *buffer, 23051da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 23061da177e4SLinus Torvalds unsigned long convmul, 23071da177e4SLinus Torvalds unsigned long convdiv) 23081da177e4SLinus Torvalds { 23091da177e4SLinus Torvalds #define TMPBUFLEN 21 23101da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 23111da177e4SLinus Torvalds int vleft, first=1, neg; 23121da177e4SLinus Torvalds size_t len, left; 23131da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 23141da177e4SLinus Torvalds char __user *s = buffer; 23151da177e4SLinus Torvalds 2316fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 23171da177e4SLinus Torvalds (*ppos && !write)) { 23181da177e4SLinus Torvalds *lenp = 0; 23191da177e4SLinus Torvalds return 0; 23201da177e4SLinus Torvalds } 23211da177e4SLinus Torvalds 2322fcfbd547SKirill Korotaev i = (unsigned long *) data; 23231da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 23241da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 23251da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 23261da177e4SLinus Torvalds left = *lenp; 23271da177e4SLinus Torvalds 23281da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 23291da177e4SLinus Torvalds if (write) { 23301da177e4SLinus Torvalds while (left) { 23311da177e4SLinus Torvalds char c; 23321da177e4SLinus Torvalds if (get_user(c, s)) 23331da177e4SLinus Torvalds return -EFAULT; 23341da177e4SLinus Torvalds if (!isspace(c)) 23351da177e4SLinus Torvalds break; 23361da177e4SLinus Torvalds left--; 23371da177e4SLinus Torvalds s++; 23381da177e4SLinus Torvalds } 23391da177e4SLinus Torvalds if (!left) 23401da177e4SLinus Torvalds break; 23411da177e4SLinus Torvalds neg = 0; 23421da177e4SLinus Torvalds len = left; 23431da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 23441da177e4SLinus Torvalds len = TMPBUFLEN-1; 23451da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 23461da177e4SLinus Torvalds return -EFAULT; 23471da177e4SLinus Torvalds buf[len] = 0; 23481da177e4SLinus Torvalds p = buf; 23491da177e4SLinus Torvalds if (*p == '-' && left > 1) { 23501da177e4SLinus Torvalds neg = 1; 2351bd9b0bacSBP, Praveen p++; 23521da177e4SLinus Torvalds } 23531da177e4SLinus Torvalds if (*p < '0' || *p > '9') 23541da177e4SLinus Torvalds break; 23551da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 23561da177e4SLinus Torvalds len = p-buf; 23571da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 23581da177e4SLinus Torvalds break; 23591da177e4SLinus Torvalds if (neg) 23601da177e4SLinus Torvalds val = -val; 23611da177e4SLinus Torvalds s += len; 23621da177e4SLinus Torvalds left -= len; 23631da177e4SLinus Torvalds 23641da177e4SLinus Torvalds if(neg) 23651da177e4SLinus Torvalds continue; 23661da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 23671da177e4SLinus Torvalds continue; 23681da177e4SLinus Torvalds *i = val; 23691da177e4SLinus Torvalds } else { 23701da177e4SLinus Torvalds p = buf; 23711da177e4SLinus Torvalds if (!first) 23721da177e4SLinus Torvalds *p++ = '\t'; 23731da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 23741da177e4SLinus Torvalds len = strlen(buf); 23751da177e4SLinus Torvalds if (len > left) 23761da177e4SLinus Torvalds len = left; 23771da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 23781da177e4SLinus Torvalds return -EFAULT; 23791da177e4SLinus Torvalds left -= len; 23801da177e4SLinus Torvalds s += len; 23811da177e4SLinus Torvalds } 23821da177e4SLinus Torvalds } 23831da177e4SLinus Torvalds 23841da177e4SLinus Torvalds if (!write && !first && left) { 23851da177e4SLinus Torvalds if(put_user('\n', s)) 23861da177e4SLinus Torvalds return -EFAULT; 23871da177e4SLinus Torvalds left--, s++; 23881da177e4SLinus Torvalds } 23891da177e4SLinus Torvalds if (write) { 23901da177e4SLinus Torvalds while (left) { 23911da177e4SLinus Torvalds char c; 23921da177e4SLinus Torvalds if (get_user(c, s++)) 23931da177e4SLinus Torvalds return -EFAULT; 23941da177e4SLinus Torvalds if (!isspace(c)) 23951da177e4SLinus Torvalds break; 23961da177e4SLinus Torvalds left--; 23971da177e4SLinus Torvalds } 23981da177e4SLinus Torvalds } 23991da177e4SLinus Torvalds if (write && first) 24001da177e4SLinus Torvalds return -EINVAL; 24011da177e4SLinus Torvalds *lenp -= left; 24021da177e4SLinus Torvalds *ppos += *lenp; 24031da177e4SLinus Torvalds return 0; 24041da177e4SLinus Torvalds #undef TMPBUFLEN 24051da177e4SLinus Torvalds } 24061da177e4SLinus Torvalds 2407d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2408fcfbd547SKirill Korotaev void __user *buffer, 2409fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2410fcfbd547SKirill Korotaev unsigned long convmul, 2411fcfbd547SKirill Korotaev unsigned long convdiv) 2412fcfbd547SKirill Korotaev { 2413fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 24148d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2415fcfbd547SKirill Korotaev } 2416fcfbd547SKirill Korotaev 24171da177e4SLinus Torvalds /** 24181da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 24191da177e4SLinus Torvalds * @table: the sysctl table 24201da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24211da177e4SLinus Torvalds * @buffer: the user buffer 24221da177e4SLinus Torvalds * @lenp: the size of the user buffer 24231da177e4SLinus Torvalds * @ppos: file position 24241da177e4SLinus Torvalds * 24251da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24261da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24271da177e4SLinus Torvalds * 24281da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24291da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24301da177e4SLinus Torvalds * 24311da177e4SLinus Torvalds * Returns 0 on success. 24321da177e4SLinus Torvalds */ 24338d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 24341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24351da177e4SLinus Torvalds { 24368d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 24371da177e4SLinus Torvalds } 24381da177e4SLinus Torvalds 24391da177e4SLinus Torvalds /** 24401da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 24411da177e4SLinus Torvalds * @table: the sysctl table 24421da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24431da177e4SLinus Torvalds * @buffer: the user buffer 24441da177e4SLinus Torvalds * @lenp: the size of the user buffer 24451da177e4SLinus Torvalds * @ppos: file position 24461da177e4SLinus Torvalds * 24471da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24481da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 24491da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 24501da177e4SLinus Torvalds * 24511da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24521da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24531da177e4SLinus Torvalds * 24541da177e4SLinus Torvalds * Returns 0 on success. 24551da177e4SLinus Torvalds */ 2456d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 24571da177e4SLinus Torvalds void __user *buffer, 24581da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 24591da177e4SLinus Torvalds { 24608d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 24611da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 24621da177e4SLinus Torvalds } 24631da177e4SLinus Torvalds 24641da177e4SLinus Torvalds 24651da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 24661da177e4SLinus Torvalds int *valp, 24671da177e4SLinus Torvalds int write, void *data) 24681da177e4SLinus Torvalds { 24691da177e4SLinus Torvalds if (write) { 2470cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2471cba9f33dSBart Samwel return 1; 24721da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 24731da177e4SLinus Torvalds } else { 24741da177e4SLinus Torvalds int val = *valp; 24751da177e4SLinus Torvalds unsigned long lval; 24761da177e4SLinus Torvalds if (val < 0) { 24771da177e4SLinus Torvalds *negp = -1; 24781da177e4SLinus Torvalds lval = (unsigned long)-val; 24791da177e4SLinus Torvalds } else { 24801da177e4SLinus Torvalds *negp = 0; 24811da177e4SLinus Torvalds lval = (unsigned long)val; 24821da177e4SLinus Torvalds } 24831da177e4SLinus Torvalds *lvalp = lval / HZ; 24841da177e4SLinus Torvalds } 24851da177e4SLinus Torvalds return 0; 24861da177e4SLinus Torvalds } 24871da177e4SLinus Torvalds 24881da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 24891da177e4SLinus Torvalds int *valp, 24901da177e4SLinus Torvalds int write, void *data) 24911da177e4SLinus Torvalds { 24921da177e4SLinus Torvalds if (write) { 2493cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2494cba9f33dSBart Samwel return 1; 24951da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 24961da177e4SLinus Torvalds } else { 24971da177e4SLinus Torvalds int val = *valp; 24981da177e4SLinus Torvalds unsigned long lval; 24991da177e4SLinus Torvalds if (val < 0) { 25001da177e4SLinus Torvalds *negp = -1; 25011da177e4SLinus Torvalds lval = (unsigned long)-val; 25021da177e4SLinus Torvalds } else { 25031da177e4SLinus Torvalds *negp = 0; 25041da177e4SLinus Torvalds lval = (unsigned long)val; 25051da177e4SLinus Torvalds } 25061da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 25071da177e4SLinus Torvalds } 25081da177e4SLinus Torvalds return 0; 25091da177e4SLinus Torvalds } 25101da177e4SLinus Torvalds 25111da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 25121da177e4SLinus Torvalds int *valp, 25131da177e4SLinus Torvalds int write, void *data) 25141da177e4SLinus Torvalds { 25151da177e4SLinus Torvalds if (write) { 25161da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 25171da177e4SLinus Torvalds } else { 25181da177e4SLinus Torvalds int val = *valp; 25191da177e4SLinus Torvalds unsigned long lval; 25201da177e4SLinus Torvalds if (val < 0) { 25211da177e4SLinus Torvalds *negp = -1; 25221da177e4SLinus Torvalds lval = (unsigned long)-val; 25231da177e4SLinus Torvalds } else { 25241da177e4SLinus Torvalds *negp = 0; 25251da177e4SLinus Torvalds lval = (unsigned long)val; 25261da177e4SLinus Torvalds } 25271da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 25281da177e4SLinus Torvalds } 25291da177e4SLinus Torvalds return 0; 25301da177e4SLinus Torvalds } 25311da177e4SLinus Torvalds 25321da177e4SLinus Torvalds /** 25331da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 25341da177e4SLinus Torvalds * @table: the sysctl table 25351da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25361da177e4SLinus Torvalds * @buffer: the user buffer 25371da177e4SLinus Torvalds * @lenp: the size of the user buffer 25381da177e4SLinus Torvalds * @ppos: file position 25391da177e4SLinus Torvalds * 25401da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25411da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25421da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 25431da177e4SLinus Torvalds * jiffies. 25441da177e4SLinus Torvalds * 25451da177e4SLinus Torvalds * Returns 0 on success. 25461da177e4SLinus Torvalds */ 25478d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 25481da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25491da177e4SLinus Torvalds { 25508d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 25511da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 25521da177e4SLinus Torvalds } 25531da177e4SLinus Torvalds 25541da177e4SLinus Torvalds /** 25551da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 25561da177e4SLinus Torvalds * @table: the sysctl table 25571da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25581da177e4SLinus Torvalds * @buffer: the user buffer 25591da177e4SLinus Torvalds * @lenp: the size of the user buffer 25601e5d5331SRandy Dunlap * @ppos: pointer to the file position 25611da177e4SLinus Torvalds * 25621da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25631da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25641da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 25651da177e4SLinus Torvalds * are converted into jiffies. 25661da177e4SLinus Torvalds * 25671da177e4SLinus Torvalds * Returns 0 on success. 25681da177e4SLinus Torvalds */ 25698d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 25701da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25711da177e4SLinus Torvalds { 25728d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 25731da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 25741da177e4SLinus Torvalds } 25751da177e4SLinus Torvalds 25761da177e4SLinus Torvalds /** 25771da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 25781da177e4SLinus Torvalds * @table: the sysctl table 25791da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25801da177e4SLinus Torvalds * @buffer: the user buffer 25811da177e4SLinus Torvalds * @lenp: the size of the user buffer 258267be2dd1SMartin Waitz * @ppos: file position 258367be2dd1SMartin Waitz * @ppos: the current position in the file 25841da177e4SLinus Torvalds * 25851da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25861da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25871da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 25881da177e4SLinus Torvalds * are converted into jiffies. 25891da177e4SLinus Torvalds * 25901da177e4SLinus Torvalds * Returns 0 on success. 25911da177e4SLinus Torvalds */ 25928d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 25931da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25941da177e4SLinus Torvalds { 25958d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 25961da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 25971da177e4SLinus Torvalds } 25981da177e4SLinus Torvalds 25998d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 26009ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 26019ec52099SCedric Le Goater { 26029ec52099SCedric Le Goater struct pid *new_pid; 26039ec52099SCedric Le Goater pid_t tmp; 26049ec52099SCedric Le Goater int r; 26059ec52099SCedric Le Goater 26066c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 26079ec52099SCedric Le Goater 26088d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 26099ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 26109ec52099SCedric Le Goater if (r || !write) 26119ec52099SCedric Le Goater return r; 26129ec52099SCedric Le Goater 26139ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 26149ec52099SCedric Le Goater if (!new_pid) 26159ec52099SCedric Le Goater return -ESRCH; 26169ec52099SCedric Le Goater 26179ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 26189ec52099SCedric Le Goater return 0; 26199ec52099SCedric Le Goater } 26209ec52099SCedric Le Goater 26211da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 26221da177e4SLinus Torvalds 26238d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 26241da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26251da177e4SLinus Torvalds { 26261da177e4SLinus Torvalds return -ENOSYS; 26271da177e4SLinus Torvalds } 26281da177e4SLinus Torvalds 26298d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 26301da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26311da177e4SLinus Torvalds { 26321da177e4SLinus Torvalds return -ENOSYS; 26331da177e4SLinus Torvalds } 26341da177e4SLinus Torvalds 26358d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 26361da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26371da177e4SLinus Torvalds { 26381da177e4SLinus Torvalds return -ENOSYS; 26391da177e4SLinus Torvalds } 26401da177e4SLinus Torvalds 26418d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 26421da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26431da177e4SLinus Torvalds { 26441da177e4SLinus Torvalds return -ENOSYS; 26451da177e4SLinus Torvalds } 26461da177e4SLinus Torvalds 26478d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 26481da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26491da177e4SLinus Torvalds { 26501da177e4SLinus Torvalds return -ENOSYS; 26511da177e4SLinus Torvalds } 26521da177e4SLinus Torvalds 26538d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 26541da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26551da177e4SLinus Torvalds { 26561da177e4SLinus Torvalds return -ENOSYS; 26571da177e4SLinus Torvalds } 26581da177e4SLinus Torvalds 26598d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 26601da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26611da177e4SLinus Torvalds { 26621da177e4SLinus Torvalds return -ENOSYS; 26631da177e4SLinus Torvalds } 26641da177e4SLinus Torvalds 2665d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26661da177e4SLinus Torvalds void __user *buffer, 26671da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26681da177e4SLinus Torvalds { 26691da177e4SLinus Torvalds return -ENOSYS; 26701da177e4SLinus Torvalds } 26711da177e4SLinus Torvalds 26721da177e4SLinus Torvalds 26731da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 26741da177e4SLinus Torvalds 26751da177e4SLinus Torvalds /* 26761da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 26771da177e4SLinus Torvalds * exception granted :-) 26781da177e4SLinus Torvalds */ 26791da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 26801da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 26811da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 26821da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 26831da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 26841da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 26851da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 26861da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 26871da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 268829e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 26891da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2690