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> 26*d33ed52dSDave Young #include <linux/signal.h> 271da177e4SLinus Torvalds #include <linux/proc_fs.h> 2872c2d582SAndrew Morgan #include <linux/security.h> 291da177e4SLinus Torvalds #include <linux/ctype.h> 30dfec072eSVegard Nossum #include <linux/kmemcheck.h> 3162239ac2SAdrian Bunk #include <linux/fs.h> 321da177e4SLinus Torvalds #include <linux/init.h> 331da177e4SLinus Torvalds #include <linux/kernel.h> 340296b228SKay Sievers #include <linux/kobject.h> 3520380731SArnaldo Carvalho de Melo #include <linux/net.h> 361da177e4SLinus Torvalds #include <linux/sysrq.h> 371da177e4SLinus Torvalds #include <linux/highuid.h> 381da177e4SLinus Torvalds #include <linux/writeback.h> 393fff4c42SIngo Molnar #include <linux/ratelimit.h> 401da177e4SLinus Torvalds #include <linux/hugetlb.h> 411da177e4SLinus Torvalds #include <linux/initrd.h> 420b77f5bfSDavid Howells #include <linux/key.h> 431da177e4SLinus Torvalds #include <linux/times.h> 441da177e4SLinus Torvalds #include <linux/limits.h> 451da177e4SLinus Torvalds #include <linux/dcache.h> 461da177e4SLinus Torvalds #include <linux/syscalls.h> 47c748e134SAdrian Bunk #include <linux/vmstat.h> 48c255d844SPavel Machek #include <linux/nfs_fs.h> 49c255d844SPavel Machek #include <linux/acpi.h> 5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 51b0fc494fSSteven Rostedt #include <linux/ftrace.h> 5212e22c5eSDavid Howells #include <linux/slow-work.h> 53cdd6c482SIngo Molnar #include <linux/perf_event.h> 54b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 551da177e4SLinus Torvalds 561da177e4SLinus Torvalds #include <asm/uaccess.h> 571da177e4SLinus Torvalds #include <asm/processor.h> 581da177e4SLinus Torvalds 5929cbc78bSAndi Kleen #ifdef CONFIG_X86 6029cbc78bSAndi Kleen #include <asm/nmi.h> 610741f4d2SChuck Ebbert #include <asm/stacktrace.h> 626e7c4025SIngo Molnar #include <asm/io.h> 6329cbc78bSAndi Kleen #endif 6429cbc78bSAndi Kleen 657058cb02SEric W. Biederman 661da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds /* External variables not in a header file. */ 691da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 701da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 71fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom; 72fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task; 73fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks; 741da177e4SLinus Torvalds extern int max_threads; 751da177e4SLinus Torvalds extern int core_uses_pid; 76d6e71144SAlan Cox extern int suid_dumpable; 771da177e4SLinus Torvalds extern char core_pattern[]; 78a293980cSNeil Horman extern unsigned int core_pipe_limit; 791da177e4SLinus Torvalds extern int pid_max; 801da177e4SLinus Torvalds extern int min_free_kbytes; 811da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 829d0243bcSAndrew Morton extern int sysctl_drop_caches; 838ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 84bebfa101SAndi Kleen extern int compat_log; 859745512cSArjan van de Ven extern int latencytop_enabled; 86eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 87dd8632a1SPaul Mundt #ifndef CONFIG_MMU 88dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 89dd8632a1SPaul Mundt #endif 9031a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 9131a72bceSPaul E. McKenney extern int rcutorture_runnable; 9231a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 93cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 945e605b64SJens Axboe extern int blk_iopoll_enabled; 95cb684b5bSJens Axboe #endif 961da177e4SLinus Torvalds 97c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 98195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 99c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1009383d967SDimitri Sivanich static int neg_one = -1; 101c4f3b63fSRavikiran G Thirumalai #endif 102c4f3b63fSRavikiran G Thirumalai 103c4f3b63fSRavikiran G Thirumalai static int zero; 104cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 105cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 106fc3501d4SSven Wegener static unsigned long one_ul = 1; 107c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 108af91322eSDave Young #ifdef CONFIG_PRINTK 109af91322eSDave Young static int ten_thousand = 10000; 110af91322eSDave Young #endif 111c4f3b63fSRavikiran G Thirumalai 1129e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1139e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1149e4a5bdaSAndrea Righi 1151da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1161da177e4SLinus Torvalds static int maxolduid = 65535; 1171da177e4SLinus Torvalds static int minolduid; 1188ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1191da177e4SLinus Torvalds 1201da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1211da177e4SLinus Torvalds 122a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 1231da177e4SLinus Torvalds extern char modprobe_path[]; 1243d43321bSKees Cook extern int modules_disabled; 1251da177e4SLinus Torvalds #endif 1261da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 1271da177e4SLinus Torvalds extern int sg_big_buff; 1281da177e4SLinus Torvalds #endif 1291da177e4SLinus Torvalds 13072c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 13117f04fbbSDavid S. Miller #include <asm/system.h> 1321da177e4SLinus Torvalds #endif 1331da177e4SLinus Torvalds 1340871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1350871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1360871420fSDavid S. Miller #endif 1370871420fSDavid S. Miller 1381da177e4SLinus Torvalds #ifdef __hppa__ 1391da177e4SLinus Torvalds extern int pwrsw_enabled; 1401da177e4SLinus Torvalds extern int unaligned_enabled; 1411da177e4SLinus Torvalds #endif 1421da177e4SLinus Torvalds 143347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1441da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1451da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1461da177e4SLinus Torvalds #endif 1471da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 148951f22d5SMartin Schwidefsky extern int spin_retry; 1491da177e4SLinus Torvalds #endif 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1521da177e4SLinus Torvalds extern int acct_parm[]; 1531da177e4SLinus Torvalds #endif 1541da177e4SLinus Torvalds 155d2b176edSJes Sorensen #ifdef CONFIG_IA64 156d2b176edSJes Sorensen extern int no_unaligned_warning; 15788fc241fSDoug Chapman extern int unaligned_dump_stack; 158d2b176edSJes Sorensen #endif 159d2b176edSJes Sorensen 1603fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state; 1613fff4c42SIngo Molnar 16223f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 16323f78d4aSIngo Molnar extern int max_lock_depth; 16423f78d4aSIngo Molnar #endif 16523f78d4aSIngo Molnar 166d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1678d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1689ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1698d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 17034f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 171d6f8ff73SRandy Dunlap #endif 1729ec52099SCedric Le Goater 173d8217f07SEric W. Biederman static struct ctl_table root_table[]; 174e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 175e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 176b380b0d4SAl Viro .count = 1, 177e51b6ba0SEric W. Biederman .ctl_table = root_table, 17873455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 179e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 18073455092SAl Viro .set = &sysctl_table_root.default_set, 181e51b6ba0SEric W. Biederman }; 182e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 183e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 18473455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 185e51b6ba0SEric W. Biederman }; 1861da177e4SLinus Torvalds 187d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 188d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 189d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 190d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 191d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 192d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1932d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 194d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1950399cb08SRobert Love #endif 1967ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 1977ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 1987ef9964eSDavide Libenzi #endif 1991da177e4SLinus Torvalds 2001da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2011da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2021da177e4SLinus Torvalds #endif 2031da177e4SLinus Torvalds 204f20786ffSPeter Zijlstra extern int prove_locking; 205f20786ffSPeter Zijlstra extern int lock_stat; 2069bc9a6bdSEric W. Biederman 2071da177e4SLinus Torvalds /* The default sysctl tables: */ 2081da177e4SLinus Torvalds 209d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2101da177e4SLinus Torvalds { 2111da177e4SLinus Torvalds .procname = "kernel", 2121da177e4SLinus Torvalds .mode = 0555, 2131da177e4SLinus Torvalds .child = kern_table, 2141da177e4SLinus Torvalds }, 2151da177e4SLinus Torvalds { 2161da177e4SLinus Torvalds .procname = "vm", 2171da177e4SLinus Torvalds .mode = 0555, 2181da177e4SLinus Torvalds .child = vm_table, 2191da177e4SLinus Torvalds }, 2201da177e4SLinus Torvalds { 2211da177e4SLinus Torvalds .procname = "fs", 2221da177e4SLinus Torvalds .mode = 0555, 2231da177e4SLinus Torvalds .child = fs_table, 2241da177e4SLinus Torvalds }, 2251da177e4SLinus Torvalds { 2261da177e4SLinus Torvalds .procname = "debug", 2271da177e4SLinus Torvalds .mode = 0555, 2281da177e4SLinus Torvalds .child = debug_table, 2291da177e4SLinus Torvalds }, 2301da177e4SLinus Torvalds { 2311da177e4SLinus Torvalds .procname = "dev", 2321da177e4SLinus Torvalds .mode = 0555, 2331da177e4SLinus Torvalds .child = dev_table, 2341da177e4SLinus Torvalds }, 2352be7fe07SAndrew Morton /* 2362be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2372be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2382be7fe07SAndrew Morton */ 2396fce56ecSEric W. Biederman { } 2401da177e4SLinus Torvalds }; 2411da177e4SLinus Torvalds 24277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 24373c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 24473c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 24573c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 24673c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2471983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2481983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 249acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */ 250acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */ 25177e54a1fSIngo Molnar #endif 25277e54a1fSIngo Molnar 253d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2542bba22c5SMike Galbraith { 2552bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2562bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2572bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2582bba22c5SMike Galbraith .mode = 0644, 2596d456111SEric W. Biederman .proc_handler = proc_dointvec, 2602bba22c5SMike Galbraith }, 26177e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 26277e54a1fSIngo Molnar { 263b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 264b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 26577e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 26677e54a1fSIngo Molnar .mode = 0644, 267702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 268b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 269b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 27077e54a1fSIngo Molnar }, 27177e54a1fSIngo Molnar { 27221805085SPeter Zijlstra .procname = "sched_latency_ns", 27321805085SPeter Zijlstra .data = &sysctl_sched_latency, 27421805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 27521805085SPeter Zijlstra .mode = 0644, 276702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 27721805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 27821805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 27921805085SPeter Zijlstra }, 28021805085SPeter Zijlstra { 28177e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 28277e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 28377e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28477e54a1fSIngo Molnar .mode = 0644, 285702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 28677e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 28777e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 28877e54a1fSIngo Molnar }, 28977e54a1fSIngo Molnar { 2902398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 2912398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 2922398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 2932398f2c6SPeter Zijlstra .mode = 0644, 294702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 295acb4a848SChristian Ehrhardt .extra1 = &min_sched_shares_ratelimit, 296acb4a848SChristian Ehrhardt .extra2 = &max_sched_shares_ratelimit, 2972398f2c6SPeter Zijlstra }, 2982398f2c6SPeter Zijlstra { 2991983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3001983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3011983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3021983a922SChristian Ehrhardt .mode = 0644, 303702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3041983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3051983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3062398f2c6SPeter Zijlstra }, 3072398f2c6SPeter Zijlstra { 308ffda12a1SPeter Zijlstra .procname = "sched_shares_thresh", 309ffda12a1SPeter Zijlstra .data = &sysctl_sched_shares_thresh, 310ffda12a1SPeter Zijlstra .maxlen = sizeof(unsigned int), 311ffda12a1SPeter Zijlstra .mode = 0644, 3126d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 313ffda12a1SPeter Zijlstra .extra1 = &zero, 314ffda12a1SPeter Zijlstra }, 315ffda12a1SPeter Zijlstra { 316da84d961SIngo Molnar .procname = "sched_migration_cost", 317da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 318da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 319da84d961SIngo Molnar .mode = 0644, 3206d456111SEric W. Biederman .proc_handler = proc_dointvec, 321da84d961SIngo Molnar }, 322b82d9fddSPeter Zijlstra { 323b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 324b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 325b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 326fa85ae24SPeter Zijlstra .mode = 0644, 3276d456111SEric W. Biederman .proc_handler = proc_dointvec, 328fa85ae24SPeter Zijlstra }, 329cd1bb94bSArun R Bharadwaj { 330e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 331e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 332e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 333e9e9250bSPeter Zijlstra .mode = 0644, 3346d456111SEric W. Biederman .proc_handler = proc_dointvec, 335e9e9250bSPeter Zijlstra }, 336e9e9250bSPeter Zijlstra { 337cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 338cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 339cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 340cd1bb94bSArun R Bharadwaj .mode = 0644, 3416d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 342bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 343bfdb4d9fSArun R Bharadwaj .extra2 = &one, 344cd1bb94bSArun R Bharadwaj }, 3451fc84aaaSPeter Zijlstra #endif 3461799e35dSIngo Molnar { 3479f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3489f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3499f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3509f0c1e56SPeter Zijlstra .mode = 0644, 3516d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3529f0c1e56SPeter Zijlstra }, 3539f0c1e56SPeter Zijlstra { 3549f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3559f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3569f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3579f0c1e56SPeter Zijlstra .mode = 0644, 3586d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3599f0c1e56SPeter Zijlstra }, 3609f0c1e56SPeter Zijlstra { 3611799e35dSIngo Molnar .procname = "sched_compat_yield", 3621799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3631799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3641799e35dSIngo Molnar .mode = 0644, 3656d456111SEric W. Biederman .proc_handler = proc_dointvec, 3661799e35dSIngo Molnar }, 367f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 368f20786ffSPeter Zijlstra { 369f20786ffSPeter Zijlstra .procname = "prove_locking", 370f20786ffSPeter Zijlstra .data = &prove_locking, 371f20786ffSPeter Zijlstra .maxlen = sizeof(int), 372f20786ffSPeter Zijlstra .mode = 0644, 3736d456111SEric W. Biederman .proc_handler = proc_dointvec, 374f20786ffSPeter Zijlstra }, 375f20786ffSPeter Zijlstra #endif 376f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 377f20786ffSPeter Zijlstra { 378f20786ffSPeter Zijlstra .procname = "lock_stat", 379f20786ffSPeter Zijlstra .data = &lock_stat, 380f20786ffSPeter Zijlstra .maxlen = sizeof(int), 381f20786ffSPeter Zijlstra .mode = 0644, 3826d456111SEric W. Biederman .proc_handler = proc_dointvec, 383f20786ffSPeter Zijlstra }, 384f20786ffSPeter Zijlstra #endif 38577e54a1fSIngo Molnar { 3861da177e4SLinus Torvalds .procname = "panic", 3871da177e4SLinus Torvalds .data = &panic_timeout, 3881da177e4SLinus Torvalds .maxlen = sizeof(int), 3891da177e4SLinus Torvalds .mode = 0644, 3906d456111SEric W. Biederman .proc_handler = proc_dointvec, 3911da177e4SLinus Torvalds }, 3921da177e4SLinus Torvalds { 3931da177e4SLinus Torvalds .procname = "core_uses_pid", 3941da177e4SLinus Torvalds .data = &core_uses_pid, 3951da177e4SLinus Torvalds .maxlen = sizeof(int), 3961da177e4SLinus Torvalds .mode = 0644, 3976d456111SEric W. Biederman .proc_handler = proc_dointvec, 3981da177e4SLinus Torvalds }, 3991da177e4SLinus Torvalds { 4001da177e4SLinus Torvalds .procname = "core_pattern", 4011da177e4SLinus Torvalds .data = core_pattern, 40271ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4031da177e4SLinus Torvalds .mode = 0644, 4046d456111SEric W. Biederman .proc_handler = proc_dostring, 4051da177e4SLinus Torvalds }, 406a293980cSNeil Horman { 407a293980cSNeil Horman .procname = "core_pipe_limit", 408a293980cSNeil Horman .data = &core_pipe_limit, 409a293980cSNeil Horman .maxlen = sizeof(unsigned int), 410a293980cSNeil Horman .mode = 0644, 4116d456111SEric W. Biederman .proc_handler = proc_dointvec, 412a293980cSNeil Horman }, 41334f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4141da177e4SLinus Torvalds { 4151da177e4SLinus Torvalds .procname = "tainted", 41625ddbb18SAndi Kleen .maxlen = sizeof(long), 41734f5a398STheodore Ts'o .mode = 0644, 4186d456111SEric W. Biederman .proc_handler = proc_taint, 4191da177e4SLinus Torvalds }, 42034f5a398STheodore Ts'o #endif 4219745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4229745512cSArjan van de Ven { 4239745512cSArjan van de Ven .procname = "latencytop", 4249745512cSArjan van de Ven .data = &latencytop_enabled, 4259745512cSArjan van de Ven .maxlen = sizeof(int), 4269745512cSArjan van de Ven .mode = 0644, 4276d456111SEric W. Biederman .proc_handler = proc_dointvec, 4289745512cSArjan van de Ven }, 4299745512cSArjan van de Ven #endif 4301da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4311da177e4SLinus Torvalds { 4321da177e4SLinus Torvalds .procname = "real-root-dev", 4331da177e4SLinus Torvalds .data = &real_root_dev, 4341da177e4SLinus Torvalds .maxlen = sizeof(int), 4351da177e4SLinus Torvalds .mode = 0644, 4366d456111SEric W. Biederman .proc_handler = proc_dointvec, 4371da177e4SLinus Torvalds }, 4381da177e4SLinus Torvalds #endif 43945807a1dSIngo Molnar { 44045807a1dSIngo Molnar .procname = "print-fatal-signals", 44145807a1dSIngo Molnar .data = &print_fatal_signals, 44245807a1dSIngo Molnar .maxlen = sizeof(int), 44345807a1dSIngo Molnar .mode = 0644, 4446d456111SEric W. Biederman .proc_handler = proc_dointvec, 44545807a1dSIngo Molnar }, 44672c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4471da177e4SLinus Torvalds { 4481da177e4SLinus Torvalds .procname = "reboot-cmd", 4491da177e4SLinus Torvalds .data = reboot_command, 4501da177e4SLinus Torvalds .maxlen = 256, 4511da177e4SLinus Torvalds .mode = 0644, 4526d456111SEric W. Biederman .proc_handler = proc_dostring, 4531da177e4SLinus Torvalds }, 4541da177e4SLinus Torvalds { 4551da177e4SLinus Torvalds .procname = "stop-a", 4561da177e4SLinus Torvalds .data = &stop_a_enabled, 4571da177e4SLinus Torvalds .maxlen = sizeof (int), 4581da177e4SLinus Torvalds .mode = 0644, 4596d456111SEric W. Biederman .proc_handler = proc_dointvec, 4601da177e4SLinus Torvalds }, 4611da177e4SLinus Torvalds { 4621da177e4SLinus Torvalds .procname = "scons-poweroff", 4631da177e4SLinus Torvalds .data = &scons_pwroff, 4641da177e4SLinus Torvalds .maxlen = sizeof (int), 4651da177e4SLinus Torvalds .mode = 0644, 4666d456111SEric W. Biederman .proc_handler = proc_dointvec, 4671da177e4SLinus Torvalds }, 4681da177e4SLinus Torvalds #endif 4690871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4700871420fSDavid S. Miller { 4710871420fSDavid S. Miller .procname = "tsb-ratio", 4720871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4730871420fSDavid S. Miller .maxlen = sizeof (int), 4740871420fSDavid S. Miller .mode = 0644, 4756d456111SEric W. Biederman .proc_handler = proc_dointvec, 4760871420fSDavid S. Miller }, 4770871420fSDavid S. Miller #endif 4781da177e4SLinus Torvalds #ifdef __hppa__ 4791da177e4SLinus Torvalds { 4801da177e4SLinus Torvalds .procname = "soft-power", 4811da177e4SLinus Torvalds .data = &pwrsw_enabled, 4821da177e4SLinus Torvalds .maxlen = sizeof (int), 4831da177e4SLinus Torvalds .mode = 0644, 4846d456111SEric W. Biederman .proc_handler = proc_dointvec, 4851da177e4SLinus Torvalds }, 4861da177e4SLinus Torvalds { 4871da177e4SLinus Torvalds .procname = "unaligned-trap", 4881da177e4SLinus Torvalds .data = &unaligned_enabled, 4891da177e4SLinus Torvalds .maxlen = sizeof (int), 4901da177e4SLinus Torvalds .mode = 0644, 4916d456111SEric W. Biederman .proc_handler = proc_dointvec, 4921da177e4SLinus Torvalds }, 4931da177e4SLinus Torvalds #endif 4941da177e4SLinus Torvalds { 4951da177e4SLinus Torvalds .procname = "ctrl-alt-del", 4961da177e4SLinus Torvalds .data = &C_A_D, 4971da177e4SLinus Torvalds .maxlen = sizeof(int), 4981da177e4SLinus Torvalds .mode = 0644, 4996d456111SEric W. Biederman .proc_handler = proc_dointvec, 5001da177e4SLinus Torvalds }, 501606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 502b0fc494fSSteven Rostedt { 503b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 504b0fc494fSSteven Rostedt .data = &ftrace_enabled, 505b0fc494fSSteven Rostedt .maxlen = sizeof(int), 506b0fc494fSSteven Rostedt .mode = 0644, 5076d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 508b0fc494fSSteven Rostedt }, 509b0fc494fSSteven Rostedt #endif 510f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 511f38f1d2aSSteven Rostedt { 512f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 513f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 514f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 515f38f1d2aSSteven Rostedt .mode = 0644, 5166d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 517f38f1d2aSSteven Rostedt }, 518f38f1d2aSSteven Rostedt #endif 519944ac425SSteven Rostedt #ifdef CONFIG_TRACING 520944ac425SSteven Rostedt { 5213299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 522944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 523944ac425SSteven Rostedt .maxlen = sizeof(int), 524944ac425SSteven Rostedt .mode = 0644, 5256d456111SEric W. Biederman .proc_handler = proc_dointvec, 526944ac425SSteven Rostedt }, 527944ac425SSteven Rostedt #endif 528a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5291da177e4SLinus Torvalds { 5301da177e4SLinus Torvalds .procname = "modprobe", 5311da177e4SLinus Torvalds .data = &modprobe_path, 5321da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5331da177e4SLinus Torvalds .mode = 0644, 5346d456111SEric W. Biederman .proc_handler = proc_dostring, 5351da177e4SLinus Torvalds }, 5363d43321bSKees Cook { 5373d43321bSKees Cook .procname = "modules_disabled", 5383d43321bSKees Cook .data = &modules_disabled, 5393d43321bSKees Cook .maxlen = sizeof(int), 5403d43321bSKees Cook .mode = 0644, 5413d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5426d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5433d43321bSKees Cook .extra1 = &one, 5443d43321bSKees Cook .extra2 = &one, 5453d43321bSKees Cook }, 5461da177e4SLinus Torvalds #endif 54757ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 5481da177e4SLinus Torvalds { 5491da177e4SLinus Torvalds .procname = "hotplug", 550312c004dSKay Sievers .data = &uevent_helper, 551312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5521da177e4SLinus Torvalds .mode = 0644, 5536d456111SEric W. Biederman .proc_handler = proc_dostring, 5541da177e4SLinus Torvalds }, 5551da177e4SLinus Torvalds #endif 5561da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5571da177e4SLinus Torvalds { 5581da177e4SLinus Torvalds .procname = "sg-big-buff", 5591da177e4SLinus Torvalds .data = &sg_big_buff, 5601da177e4SLinus Torvalds .maxlen = sizeof (int), 5611da177e4SLinus Torvalds .mode = 0444, 5626d456111SEric W. Biederman .proc_handler = proc_dointvec, 5631da177e4SLinus Torvalds }, 5641da177e4SLinus Torvalds #endif 5651da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5661da177e4SLinus Torvalds { 5671da177e4SLinus Torvalds .procname = "acct", 5681da177e4SLinus Torvalds .data = &acct_parm, 5691da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5701da177e4SLinus Torvalds .mode = 0644, 5716d456111SEric W. Biederman .proc_handler = proc_dointvec, 5721da177e4SLinus Torvalds }, 5731da177e4SLinus Torvalds #endif 5741da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5751da177e4SLinus Torvalds { 5761da177e4SLinus Torvalds .procname = "sysrq", 5775d6f647fSIngo Molnar .data = &__sysrq_enabled, 5781da177e4SLinus Torvalds .maxlen = sizeof (int), 5791da177e4SLinus Torvalds .mode = 0644, 5806d456111SEric W. Biederman .proc_handler = proc_dointvec, 5811da177e4SLinus Torvalds }, 5821da177e4SLinus Torvalds #endif 583d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5841da177e4SLinus Torvalds { 5851da177e4SLinus Torvalds .procname = "cad_pid", 5869ec52099SCedric Le Goater .data = NULL, 5871da177e4SLinus Torvalds .maxlen = sizeof (int), 5881da177e4SLinus Torvalds .mode = 0600, 5896d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 5901da177e4SLinus Torvalds }, 591d6f8ff73SRandy Dunlap #endif 5921da177e4SLinus Torvalds { 5931da177e4SLinus Torvalds .procname = "threads-max", 5941da177e4SLinus Torvalds .data = &max_threads, 5951da177e4SLinus Torvalds .maxlen = sizeof(int), 5961da177e4SLinus Torvalds .mode = 0644, 5976d456111SEric W. Biederman .proc_handler = proc_dointvec, 5981da177e4SLinus Torvalds }, 5991da177e4SLinus Torvalds { 6001da177e4SLinus Torvalds .procname = "random", 6011da177e4SLinus Torvalds .mode = 0555, 6021da177e4SLinus Torvalds .child = random_table, 6031da177e4SLinus Torvalds }, 6041da177e4SLinus Torvalds { 6051da177e4SLinus Torvalds .procname = "overflowuid", 6061da177e4SLinus Torvalds .data = &overflowuid, 6071da177e4SLinus Torvalds .maxlen = sizeof(int), 6081da177e4SLinus Torvalds .mode = 0644, 6096d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6101da177e4SLinus Torvalds .extra1 = &minolduid, 6111da177e4SLinus Torvalds .extra2 = &maxolduid, 6121da177e4SLinus Torvalds }, 6131da177e4SLinus Torvalds { 6141da177e4SLinus Torvalds .procname = "overflowgid", 6151da177e4SLinus Torvalds .data = &overflowgid, 6161da177e4SLinus Torvalds .maxlen = sizeof(int), 6171da177e4SLinus Torvalds .mode = 0644, 6186d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6191da177e4SLinus Torvalds .extra1 = &minolduid, 6201da177e4SLinus Torvalds .extra2 = &maxolduid, 6211da177e4SLinus Torvalds }, 622347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6231da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6241da177e4SLinus Torvalds { 6251da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6261da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6271da177e4SLinus Torvalds .maxlen = sizeof(int), 6281da177e4SLinus Torvalds .mode = 0644, 6296d456111SEric W. Biederman .proc_handler = proc_dointvec, 6301da177e4SLinus Torvalds }, 6311da177e4SLinus Torvalds #endif 6321da177e4SLinus Torvalds { 6331da177e4SLinus Torvalds .procname = "userprocess_debug", 6341da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 6351da177e4SLinus Torvalds .maxlen = sizeof(int), 6361da177e4SLinus Torvalds .mode = 0644, 6376d456111SEric W. Biederman .proc_handler = proc_dointvec, 6381da177e4SLinus Torvalds }, 6391da177e4SLinus Torvalds #endif 6401da177e4SLinus Torvalds { 6411da177e4SLinus Torvalds .procname = "pid_max", 6421da177e4SLinus Torvalds .data = &pid_max, 6431da177e4SLinus Torvalds .maxlen = sizeof (int), 6441da177e4SLinus Torvalds .mode = 0644, 6456d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6461da177e4SLinus Torvalds .extra1 = &pid_max_min, 6471da177e4SLinus Torvalds .extra2 = &pid_max_max, 6481da177e4SLinus Torvalds }, 6491da177e4SLinus Torvalds { 6501da177e4SLinus Torvalds .procname = "panic_on_oops", 6511da177e4SLinus Torvalds .data = &panic_on_oops, 6521da177e4SLinus Torvalds .maxlen = sizeof(int), 6531da177e4SLinus Torvalds .mode = 0644, 6546d456111SEric W. Biederman .proc_handler = proc_dointvec, 6551da177e4SLinus Torvalds }, 6567ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6577ef3d2fdSJoe Perches { 6587ef3d2fdSJoe Perches .procname = "printk", 6597ef3d2fdSJoe Perches .data = &console_loglevel, 6607ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6617ef3d2fdSJoe Perches .mode = 0644, 6626d456111SEric W. Biederman .proc_handler = proc_dointvec, 6637ef3d2fdSJoe Perches }, 6641da177e4SLinus Torvalds { 6651da177e4SLinus Torvalds .procname = "printk_ratelimit", 666717115e1SDave Young .data = &printk_ratelimit_state.interval, 6671da177e4SLinus Torvalds .maxlen = sizeof(int), 6681da177e4SLinus Torvalds .mode = 0644, 6696d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6701da177e4SLinus Torvalds }, 6711da177e4SLinus Torvalds { 6721da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 673717115e1SDave Young .data = &printk_ratelimit_state.burst, 6741da177e4SLinus Torvalds .maxlen = sizeof(int), 6751da177e4SLinus Torvalds .mode = 0644, 6766d456111SEric W. Biederman .proc_handler = proc_dointvec, 6771da177e4SLinus Torvalds }, 678af91322eSDave Young { 679af91322eSDave Young .procname = "printk_delay", 680af91322eSDave Young .data = &printk_delay_msec, 681af91322eSDave Young .maxlen = sizeof(int), 682af91322eSDave Young .mode = 0644, 6836d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 684af91322eSDave Young .extra1 = &zero, 685af91322eSDave Young .extra2 = &ten_thousand, 686af91322eSDave Young }, 6877ef3d2fdSJoe Perches #endif 6881da177e4SLinus Torvalds { 6891da177e4SLinus Torvalds .procname = "ngroups_max", 6901da177e4SLinus Torvalds .data = &ngroups_max, 6911da177e4SLinus Torvalds .maxlen = sizeof (int), 6921da177e4SLinus Torvalds .mode = 0444, 6936d456111SEric W. Biederman .proc_handler = proc_dointvec, 6941da177e4SLinus Torvalds }, 6951da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 6961da177e4SLinus Torvalds { 6971da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 6981da177e4SLinus Torvalds .data = &unknown_nmi_panic, 6991da177e4SLinus Torvalds .maxlen = sizeof (int), 7001da177e4SLinus Torvalds .mode = 0644, 7016d456111SEric W. Biederman .proc_handler = proc_dointvec, 7021da177e4SLinus Torvalds }, 703407984f1SDon Zickus { 704407984f1SDon Zickus .procname = "nmi_watchdog", 705407984f1SDon Zickus .data = &nmi_watchdog_enabled, 706407984f1SDon Zickus .maxlen = sizeof (int), 707407984f1SDon Zickus .mode = 0644, 7086d456111SEric W. Biederman .proc_handler = proc_nmi_enabled, 7091da177e4SLinus Torvalds }, 7101da177e4SLinus Torvalds #endif 7111da177e4SLinus Torvalds #if defined(CONFIG_X86) 7121da177e4SLinus Torvalds { 7138da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7148da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7158da5addaSDon Zickus .maxlen = sizeof(int), 7168da5addaSDon Zickus .mode = 0644, 7176d456111SEric W. Biederman .proc_handler = proc_dointvec, 7188da5addaSDon Zickus }, 7198da5addaSDon Zickus { 7205211a242SKurt Garloff .procname = "panic_on_io_nmi", 7215211a242SKurt Garloff .data = &panic_on_io_nmi, 7225211a242SKurt Garloff .maxlen = sizeof(int), 7235211a242SKurt Garloff .mode = 0644, 7246d456111SEric W. Biederman .proc_handler = proc_dointvec, 7255211a242SKurt Garloff }, 7265211a242SKurt Garloff { 7271da177e4SLinus Torvalds .procname = "bootloader_type", 7281da177e4SLinus Torvalds .data = &bootloader_type, 7291da177e4SLinus Torvalds .maxlen = sizeof (int), 7301da177e4SLinus Torvalds .mode = 0444, 7316d456111SEric W. Biederman .proc_handler = proc_dointvec, 7321da177e4SLinus Torvalds }, 7330741f4d2SChuck Ebbert { 7345031296cSH. Peter Anvin .procname = "bootloader_version", 7355031296cSH. Peter Anvin .data = &bootloader_version, 7365031296cSH. Peter Anvin .maxlen = sizeof (int), 7375031296cSH. Peter Anvin .mode = 0444, 7386d456111SEric W. Biederman .proc_handler = proc_dointvec, 7395031296cSH. Peter Anvin }, 7405031296cSH. Peter Anvin { 7410741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 7420741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 7430741f4d2SChuck Ebbert .maxlen = sizeof(int), 7440741f4d2SChuck Ebbert .mode = 0644, 7456d456111SEric W. Biederman .proc_handler = proc_dointvec, 7460741f4d2SChuck Ebbert }, 7476e7c4025SIngo Molnar { 7486e7c4025SIngo Molnar .procname = "io_delay_type", 7496e7c4025SIngo Molnar .data = &io_delay_type, 7506e7c4025SIngo Molnar .maxlen = sizeof(int), 7516e7c4025SIngo Molnar .mode = 0644, 7526d456111SEric W. Biederman .proc_handler = proc_dointvec, 7536e7c4025SIngo Molnar }, 7541da177e4SLinus Torvalds #endif 7557a9166e3SLuke Yang #if defined(CONFIG_MMU) 7561da177e4SLinus Torvalds { 7571da177e4SLinus Torvalds .procname = "randomize_va_space", 7581da177e4SLinus Torvalds .data = &randomize_va_space, 7591da177e4SLinus Torvalds .maxlen = sizeof(int), 7601da177e4SLinus Torvalds .mode = 0644, 7616d456111SEric W. Biederman .proc_handler = proc_dointvec, 7621da177e4SLinus Torvalds }, 7637a9166e3SLuke Yang #endif 7640152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 765951f22d5SMartin Schwidefsky { 766951f22d5SMartin Schwidefsky .procname = "spin_retry", 767951f22d5SMartin Schwidefsky .data = &spin_retry, 768951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 769951f22d5SMartin Schwidefsky .mode = 0644, 7706d456111SEric W. Biederman .proc_handler = proc_dointvec, 771951f22d5SMartin Schwidefsky }, 772951f22d5SMartin Schwidefsky #endif 773673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 774c255d844SPavel Machek { 775c255d844SPavel Machek .procname = "acpi_video_flags", 77677afcf78SPavel Machek .data = &acpi_realmode_flags, 777c255d844SPavel Machek .maxlen = sizeof (unsigned long), 778c255d844SPavel Machek .mode = 0644, 7796d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 780c255d844SPavel Machek }, 781c255d844SPavel Machek #endif 782d2b176edSJes Sorensen #ifdef CONFIG_IA64 783d2b176edSJes Sorensen { 784d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 785d2b176edSJes Sorensen .data = &no_unaligned_warning, 786d2b176edSJes Sorensen .maxlen = sizeof (int), 787d2b176edSJes Sorensen .mode = 0644, 7886d456111SEric W. Biederman .proc_handler = proc_dointvec, 789d2b176edSJes Sorensen }, 79088fc241fSDoug Chapman { 79188fc241fSDoug Chapman .procname = "unaligned-dump-stack", 79288fc241fSDoug Chapman .data = &unaligned_dump_stack, 79388fc241fSDoug Chapman .maxlen = sizeof (int), 79488fc241fSDoug Chapman .mode = 0644, 7956d456111SEric W. Biederman .proc_handler = proc_dointvec, 79688fc241fSDoug Chapman }, 797d2b176edSJes Sorensen #endif 798c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 799c4f3b63fSRavikiran G Thirumalai { 8009c44bc03SIngo Molnar .procname = "softlockup_panic", 8019c44bc03SIngo Molnar .data = &softlockup_panic, 8029c44bc03SIngo Molnar .maxlen = sizeof(int), 8039c44bc03SIngo Molnar .mode = 0644, 8046d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 8059c44bc03SIngo Molnar .extra1 = &zero, 8069c44bc03SIngo Molnar .extra2 = &one, 8079c44bc03SIngo Molnar }, 8089c44bc03SIngo Molnar { 809c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 810c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 8119383d967SDimitri Sivanich .maxlen = sizeof(int), 812c4f3b63fSRavikiran G Thirumalai .mode = 0644, 8136d456111SEric W. Biederman .proc_handler = proc_dosoftlockup_thresh, 8149383d967SDimitri Sivanich .extra1 = &neg_one, 815c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 816c4f3b63fSRavikiran G Thirumalai }, 817e162b39aSMandeep Singh Baines #endif 818e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 819e162b39aSMandeep Singh Baines { 820e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 821e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 822e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 823e162b39aSMandeep Singh Baines .mode = 0644, 8246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 825e162b39aSMandeep Singh Baines .extra1 = &zero, 826e162b39aSMandeep Singh Baines .extra2 = &one, 827e162b39aSMandeep Singh Baines }, 82882a1fcb9SIngo Molnar { 82982a1fcb9SIngo Molnar .procname = "hung_task_check_count", 83082a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 83190739081SIngo Molnar .maxlen = sizeof(unsigned long), 83282a1fcb9SIngo Molnar .mode = 0644, 8336d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 83482a1fcb9SIngo Molnar }, 83582a1fcb9SIngo Molnar { 83682a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 83782a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 83890739081SIngo Molnar .maxlen = sizeof(unsigned long), 83982a1fcb9SIngo Molnar .mode = 0644, 8406d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 84182a1fcb9SIngo Molnar }, 84282a1fcb9SIngo Molnar { 84382a1fcb9SIngo Molnar .procname = "hung_task_warnings", 84482a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 84590739081SIngo Molnar .maxlen = sizeof(unsigned long), 84682a1fcb9SIngo Molnar .mode = 0644, 8476d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 84882a1fcb9SIngo Molnar }, 849c4f3b63fSRavikiran G Thirumalai #endif 850bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 851bebfa101SAndi Kleen { 852bebfa101SAndi Kleen .procname = "compat-log", 853bebfa101SAndi Kleen .data = &compat_log, 854bebfa101SAndi Kleen .maxlen = sizeof (int), 855bebfa101SAndi Kleen .mode = 0644, 8566d456111SEric W. Biederman .proc_handler = proc_dointvec, 857bebfa101SAndi Kleen }, 858bebfa101SAndi Kleen #endif 85923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 86023f78d4aSIngo Molnar { 86123f78d4aSIngo Molnar .procname = "max_lock_depth", 86223f78d4aSIngo Molnar .data = &max_lock_depth, 86323f78d4aSIngo Molnar .maxlen = sizeof(int), 86423f78d4aSIngo Molnar .mode = 0644, 8656d456111SEric W. Biederman .proc_handler = proc_dointvec, 86623f78d4aSIngo Molnar }, 86723f78d4aSIngo Molnar #endif 86810a0a8d4SJeremy Fitzhardinge { 86910a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 87010a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 87110a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 87210a0a8d4SJeremy Fitzhardinge .mode = 0644, 8736d456111SEric W. Biederman .proc_handler = proc_dostring, 87410a0a8d4SJeremy Fitzhardinge }, 8750b77f5bfSDavid Howells #ifdef CONFIG_KEYS 8760b77f5bfSDavid Howells { 8770b77f5bfSDavid Howells .procname = "keys", 8780b77f5bfSDavid Howells .mode = 0555, 8790b77f5bfSDavid Howells .child = key_sysctls, 8800b77f5bfSDavid Howells }, 8810b77f5bfSDavid Howells #endif 88231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 88331a72bceSPaul E. McKenney { 88431a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 88531a72bceSPaul E. McKenney .data = &rcutorture_runnable, 88631a72bceSPaul E. McKenney .maxlen = sizeof(int), 88731a72bceSPaul E. McKenney .mode = 0644, 8886d456111SEric W. Biederman .proc_handler = proc_dointvec, 88931a72bceSPaul E. McKenney }, 89031a72bceSPaul E. McKenney #endif 89112e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK 89212e22c5eSDavid Howells { 89312e22c5eSDavid Howells .procname = "slow-work", 89412e22c5eSDavid Howells .mode = 0555, 89512e22c5eSDavid Howells .child = slow_work_sysctls, 89612e22c5eSDavid Howells }, 89712e22c5eSDavid Howells #endif 898cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 8991ccd1549SPeter Zijlstra { 900cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 901cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 902cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9031ccd1549SPeter Zijlstra .mode = 0644, 9046d456111SEric W. Biederman .proc_handler = proc_dointvec, 9051ccd1549SPeter Zijlstra }, 906c5078f78SPeter Zijlstra { 907cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 908cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 909cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 910c5078f78SPeter Zijlstra .mode = 0644, 9116d456111SEric W. Biederman .proc_handler = proc_dointvec, 912c5078f78SPeter Zijlstra }, 913a78ac325SPeter Zijlstra { 914cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 915cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 916cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 917a78ac325SPeter Zijlstra .mode = 0644, 9186d456111SEric W. Biederman .proc_handler = proc_dointvec, 919a78ac325SPeter Zijlstra }, 9201ccd1549SPeter Zijlstra #endif 921dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 922dfec072eSVegard Nossum { 923dfec072eSVegard Nossum .procname = "kmemcheck", 924dfec072eSVegard Nossum .data = &kmemcheck_enabled, 925dfec072eSVegard Nossum .maxlen = sizeof(int), 926dfec072eSVegard Nossum .mode = 0644, 9276d456111SEric W. Biederman .proc_handler = proc_dointvec, 928dfec072eSVegard Nossum }, 929dfec072eSVegard Nossum #endif 930cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9315e605b64SJens Axboe { 9325e605b64SJens Axboe .procname = "blk_iopoll", 9335e605b64SJens Axboe .data = &blk_iopoll_enabled, 9345e605b64SJens Axboe .maxlen = sizeof(int), 9355e605b64SJens Axboe .mode = 0644, 9366d456111SEric W. Biederman .proc_handler = proc_dointvec, 9375e605b64SJens Axboe }, 938cb684b5bSJens Axboe #endif 939ed2c12f3SAndrew Morton /* 940ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 941ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 942ed2c12f3SAndrew Morton */ 9436fce56ecSEric W. Biederman { } 9441da177e4SLinus Torvalds }; 9451da177e4SLinus Torvalds 946d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 9471da177e4SLinus Torvalds { 9481da177e4SLinus Torvalds .procname = "overcommit_memory", 9491da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 9501da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 9511da177e4SLinus Torvalds .mode = 0644, 9526d456111SEric W. Biederman .proc_handler = proc_dointvec, 9531da177e4SLinus Torvalds }, 9541da177e4SLinus Torvalds { 955fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 956fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 957fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 958fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 9596d456111SEric W. Biederman .proc_handler = proc_dointvec, 960fadd8fbdSKAMEZAWA Hiroyuki }, 961fadd8fbdSKAMEZAWA Hiroyuki { 962fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 963fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 964fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 965fe071d7eSDavid Rientjes .mode = 0644, 9666d456111SEric W. Biederman .proc_handler = proc_dointvec, 967fe071d7eSDavid Rientjes }, 968fe071d7eSDavid Rientjes { 969fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 970fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 971fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 972fef1bdd6SDavid Rientjes .mode = 0644, 9736d456111SEric W. Biederman .proc_handler = proc_dointvec, 974fef1bdd6SDavid Rientjes }, 975fef1bdd6SDavid Rientjes { 9761da177e4SLinus Torvalds .procname = "overcommit_ratio", 9771da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 9781da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 9791da177e4SLinus Torvalds .mode = 0644, 9806d456111SEric W. Biederman .proc_handler = proc_dointvec, 9811da177e4SLinus Torvalds }, 9821da177e4SLinus Torvalds { 9831da177e4SLinus Torvalds .procname = "page-cluster", 9841da177e4SLinus Torvalds .data = &page_cluster, 9851da177e4SLinus Torvalds .maxlen = sizeof(int), 9861da177e4SLinus Torvalds .mode = 0644, 9876d456111SEric W. Biederman .proc_handler = proc_dointvec, 9881da177e4SLinus Torvalds }, 9891da177e4SLinus Torvalds { 9901da177e4SLinus Torvalds .procname = "dirty_background_ratio", 9911da177e4SLinus Torvalds .data = &dirty_background_ratio, 9921da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 9931da177e4SLinus Torvalds .mode = 0644, 9946d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 9951da177e4SLinus Torvalds .extra1 = &zero, 9961da177e4SLinus Torvalds .extra2 = &one_hundred, 9971da177e4SLinus Torvalds }, 9981da177e4SLinus Torvalds { 9992da02997SDavid Rientjes .procname = "dirty_background_bytes", 10002da02997SDavid Rientjes .data = &dirty_background_bytes, 10012da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10022da02997SDavid Rientjes .mode = 0644, 10036d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1004fc3501d4SSven Wegener .extra1 = &one_ul, 10052da02997SDavid Rientjes }, 10062da02997SDavid Rientjes { 10071da177e4SLinus Torvalds .procname = "dirty_ratio", 10081da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10091da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10101da177e4SLinus Torvalds .mode = 0644, 10116d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10121da177e4SLinus Torvalds .extra1 = &zero, 10131da177e4SLinus Torvalds .extra2 = &one_hundred, 10141da177e4SLinus Torvalds }, 10151da177e4SLinus Torvalds { 10162da02997SDavid Rientjes .procname = "dirty_bytes", 10172da02997SDavid Rientjes .data = &vm_dirty_bytes, 10182da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10192da02997SDavid Rientjes .mode = 0644, 10206d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10219e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10222da02997SDavid Rientjes }, 10232da02997SDavid Rientjes { 10241da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1025f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1026f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10271da177e4SLinus Torvalds .mode = 0644, 10286d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10291da177e4SLinus Torvalds }, 10301da177e4SLinus Torvalds { 10311da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1032f6ef9438SBart Samwel .data = &dirty_expire_interval, 1033f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10341da177e4SLinus Torvalds .mode = 0644, 10356d456111SEric W. Biederman .proc_handler = proc_dointvec, 10361da177e4SLinus Torvalds }, 10371da177e4SLinus Torvalds { 10381da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10391da177e4SLinus Torvalds .data = &nr_pdflush_threads, 10401da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 10411da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 10426d456111SEric W. Biederman .proc_handler = proc_dointvec, 10431da177e4SLinus Torvalds }, 10441da177e4SLinus Torvalds { 10451da177e4SLinus Torvalds .procname = "swappiness", 10461da177e4SLinus Torvalds .data = &vm_swappiness, 10471da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 10481da177e4SLinus Torvalds .mode = 0644, 10496d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 10501da177e4SLinus Torvalds .extra1 = &zero, 10511da177e4SLinus Torvalds .extra2 = &one_hundred, 10521da177e4SLinus Torvalds }, 10531da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 10541da177e4SLinus Torvalds { 10551da177e4SLinus Torvalds .procname = "nr_hugepages", 1056e5ff2159SAndi Kleen .data = NULL, 10571da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 10581da177e4SLinus Torvalds .mode = 0644, 10596d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 10601da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 10611da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 10621da177e4SLinus Torvalds }, 106306808b08SLee Schermerhorn #ifdef CONFIG_NUMA 106406808b08SLee Schermerhorn { 106506808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 106606808b08SLee Schermerhorn .data = NULL, 106706808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 106806808b08SLee Schermerhorn .mode = 0644, 106906808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 107006808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 107106808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 107206808b08SLee Schermerhorn }, 107306808b08SLee Schermerhorn #endif 10741da177e4SLinus Torvalds { 10751da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 10761da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 10771da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 10781da177e4SLinus Torvalds .mode = 0644, 10796d456111SEric W. Biederman .proc_handler = proc_dointvec, 10801da177e4SLinus Torvalds }, 1081396faf03SMel Gorman { 1082396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1083396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1084396faf03SMel Gorman .maxlen = sizeof(int), 1085396faf03SMel Gorman .mode = 0644, 10866d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1087396faf03SMel Gorman }, 108854f9f80dSAdam Litke { 1089d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1090e5ff2159SAndi Kleen .data = NULL, 1091e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1092d1c3fb1fSNishanth Aravamudan .mode = 0644, 10936d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1094e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1095e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1096d1c3fb1fSNishanth Aravamudan }, 10971da177e4SLinus Torvalds #endif 10981da177e4SLinus Torvalds { 10991da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11001da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11011da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11021da177e4SLinus Torvalds .mode = 0644, 11036d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11041da177e4SLinus Torvalds }, 11051da177e4SLinus Torvalds { 11069d0243bcSAndrew Morton .procname = "drop_caches", 11079d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11089d0243bcSAndrew Morton .maxlen = sizeof(int), 11099d0243bcSAndrew Morton .mode = 0644, 11109d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 11119d0243bcSAndrew Morton }, 11129d0243bcSAndrew Morton { 11131da177e4SLinus Torvalds .procname = "min_free_kbytes", 11141da177e4SLinus Torvalds .data = &min_free_kbytes, 11151da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11161da177e4SLinus Torvalds .mode = 0644, 11176d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 11181da177e4SLinus Torvalds .extra1 = &zero, 11191da177e4SLinus Torvalds }, 11208ad4b1fbSRohit Seth { 11218ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 11228ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 11238ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 11248ad4b1fbSRohit Seth .mode = 0644, 11256d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 11268ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 11278ad4b1fbSRohit Seth }, 11281da177e4SLinus Torvalds #ifdef CONFIG_MMU 11291da177e4SLinus Torvalds { 11301da177e4SLinus Torvalds .procname = "max_map_count", 11311da177e4SLinus Torvalds .data = &sysctl_max_map_count, 11321da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 11331da177e4SLinus Torvalds .mode = 0644, 11343e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 113570da2340SAmerigo Wang .extra1 = &zero, 11361da177e4SLinus Torvalds }, 1137dd8632a1SPaul Mundt #else 1138dd8632a1SPaul Mundt { 1139dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1140dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1141dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1142dd8632a1SPaul Mundt .mode = 0644, 11436d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1144dd8632a1SPaul Mundt .extra1 = &zero, 1145dd8632a1SPaul Mundt }, 11461da177e4SLinus Torvalds #endif 11471da177e4SLinus Torvalds { 11481da177e4SLinus Torvalds .procname = "laptop_mode", 11491da177e4SLinus Torvalds .data = &laptop_mode, 11501da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 11511da177e4SLinus Torvalds .mode = 0644, 11526d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 11531da177e4SLinus Torvalds }, 11541da177e4SLinus Torvalds { 11551da177e4SLinus Torvalds .procname = "block_dump", 11561da177e4SLinus Torvalds .data = &block_dump, 11571da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 11581da177e4SLinus Torvalds .mode = 0644, 11596d456111SEric W. Biederman .proc_handler = proc_dointvec, 11601da177e4SLinus Torvalds .extra1 = &zero, 11611da177e4SLinus Torvalds }, 11621da177e4SLinus Torvalds { 11631da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 11641da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 11651da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 11661da177e4SLinus Torvalds .mode = 0644, 11676d456111SEric W. Biederman .proc_handler = proc_dointvec, 11681da177e4SLinus Torvalds .extra1 = &zero, 11691da177e4SLinus Torvalds }, 11701da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 11711da177e4SLinus Torvalds { 11721da177e4SLinus Torvalds .procname = "legacy_va_layout", 11731da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 11741da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 11751da177e4SLinus Torvalds .mode = 0644, 11766d456111SEric W. Biederman .proc_handler = proc_dointvec, 11771da177e4SLinus Torvalds .extra1 = &zero, 11781da177e4SLinus Torvalds }, 11791da177e4SLinus Torvalds #endif 11801743660bSChristoph Lameter #ifdef CONFIG_NUMA 11811743660bSChristoph Lameter { 11821743660bSChristoph Lameter .procname = "zone_reclaim_mode", 11831743660bSChristoph Lameter .data = &zone_reclaim_mode, 11841743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 11851743660bSChristoph Lameter .mode = 0644, 11866d456111SEric W. Biederman .proc_handler = proc_dointvec, 1187c84db23cSChristoph Lameter .extra1 = &zero, 11881743660bSChristoph Lameter }, 11899614634fSChristoph Lameter { 11909614634fSChristoph Lameter .procname = "min_unmapped_ratio", 11919614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 11929614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 11939614634fSChristoph Lameter .mode = 0644, 11946d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 11959614634fSChristoph Lameter .extra1 = &zero, 11969614634fSChristoph Lameter .extra2 = &one_hundred, 11979614634fSChristoph Lameter }, 11980ff38490SChristoph Lameter { 11990ff38490SChristoph Lameter .procname = "min_slab_ratio", 12000ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12010ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12020ff38490SChristoph Lameter .mode = 0644, 12036d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12040ff38490SChristoph Lameter .extra1 = &zero, 12050ff38490SChristoph Lameter .extra2 = &one_hundred, 12060ff38490SChristoph Lameter }, 12071743660bSChristoph Lameter #endif 120877461ab3SChristoph Lameter #ifdef CONFIG_SMP 120977461ab3SChristoph Lameter { 121077461ab3SChristoph Lameter .procname = "stat_interval", 121177461ab3SChristoph Lameter .data = &sysctl_stat_interval, 121277461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 121377461ab3SChristoph Lameter .mode = 0644, 12146d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 121577461ab3SChristoph Lameter }, 121677461ab3SChristoph Lameter #endif 12176e141546SDavid Howells #ifdef CONFIG_MMU 1218ed032189SEric Paris { 1219ed032189SEric Paris .procname = "mmap_min_addr", 1220788084abSEric Paris .data = &dac_mmap_min_addr, 1221ed032189SEric Paris .maxlen = sizeof(unsigned long), 1222ed032189SEric Paris .mode = 0644, 12236d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1224ed032189SEric Paris }, 12256e141546SDavid Howells #endif 1226f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1227f0c0b2b8SKAMEZAWA Hiroyuki { 1228f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1229f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1230f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1231f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 12326d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1233f0c0b2b8SKAMEZAWA Hiroyuki }, 1234f0c0b2b8SKAMEZAWA Hiroyuki #endif 12352b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 12365c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1237e6e5494cSIngo Molnar { 1238e6e5494cSIngo Molnar .procname = "vdso_enabled", 1239e6e5494cSIngo Molnar .data = &vdso_enabled, 1240e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1241e6e5494cSIngo Molnar .mode = 0644, 12426d456111SEric W. Biederman .proc_handler = proc_dointvec, 1243e6e5494cSIngo Molnar .extra1 = &zero, 1244e6e5494cSIngo Molnar }, 1245e6e5494cSIngo Molnar #endif 1246195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1247195cf453SBron Gondwana { 1248195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1249195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1250195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1251195cf453SBron Gondwana .mode = 0644, 12526d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1253195cf453SBron Gondwana .extra1 = &zero, 1254195cf453SBron Gondwana .extra2 = &one, 1255195cf453SBron Gondwana }, 1256195cf453SBron Gondwana #endif 12574be6f6bbSPeter Zijlstra { 12584be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 12594be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 12604be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 12614be6f6bbSPeter Zijlstra .mode = 0644, 12626d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 12634be6f6bbSPeter Zijlstra }, 12646a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 12656a46079cSAndi Kleen { 12666a46079cSAndi Kleen .procname = "memory_failure_early_kill", 12676a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 12686a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 12696a46079cSAndi Kleen .mode = 0644, 12706d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12716a46079cSAndi Kleen .extra1 = &zero, 12726a46079cSAndi Kleen .extra2 = &one, 12736a46079cSAndi Kleen }, 12746a46079cSAndi Kleen { 12756a46079cSAndi Kleen .procname = "memory_failure_recovery", 12766a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 12776a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 12786a46079cSAndi Kleen .mode = 0644, 12796d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12806a46079cSAndi Kleen .extra1 = &zero, 12816a46079cSAndi Kleen .extra2 = &one, 12826a46079cSAndi Kleen }, 12836a46079cSAndi Kleen #endif 12846a46079cSAndi Kleen 12852be7fe07SAndrew Morton /* 12862be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 12872be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 12882be7fe07SAndrew Morton */ 12896fce56ecSEric W. Biederman { } 12901da177e4SLinus Torvalds }; 12911da177e4SLinus Torvalds 12922abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1293d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 12946fce56ecSEric W. Biederman { } 12952abc26fcSEric W. Biederman }; 12962abc26fcSEric W. Biederman #endif 12972abc26fcSEric W. Biederman 1298d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 12991da177e4SLinus Torvalds { 13001da177e4SLinus Torvalds .procname = "inode-nr", 13011da177e4SLinus Torvalds .data = &inodes_stat, 13021da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13031da177e4SLinus Torvalds .mode = 0444, 13046d456111SEric W. Biederman .proc_handler = proc_dointvec, 13051da177e4SLinus Torvalds }, 13061da177e4SLinus Torvalds { 13071da177e4SLinus Torvalds .procname = "inode-state", 13081da177e4SLinus Torvalds .data = &inodes_stat, 13091da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13101da177e4SLinus Torvalds .mode = 0444, 13116d456111SEric W. Biederman .proc_handler = proc_dointvec, 13121da177e4SLinus Torvalds }, 13131da177e4SLinus Torvalds { 13141da177e4SLinus Torvalds .procname = "file-nr", 13151da177e4SLinus Torvalds .data = &files_stat, 13161da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 13171da177e4SLinus Torvalds .mode = 0444, 13186d456111SEric W. Biederman .proc_handler = proc_nr_files, 13191da177e4SLinus Torvalds }, 13201da177e4SLinus Torvalds { 13211da177e4SLinus Torvalds .procname = "file-max", 13221da177e4SLinus Torvalds .data = &files_stat.max_files, 13231da177e4SLinus Torvalds .maxlen = sizeof(int), 13241da177e4SLinus Torvalds .mode = 0644, 13256d456111SEric W. Biederman .proc_handler = proc_dointvec, 13261da177e4SLinus Torvalds }, 13271da177e4SLinus Torvalds { 13289cfe015aSEric Dumazet .procname = "nr_open", 13299cfe015aSEric Dumazet .data = &sysctl_nr_open, 13309cfe015aSEric Dumazet .maxlen = sizeof(int), 13319cfe015aSEric Dumazet .mode = 0644, 13326d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1333eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1334eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 13359cfe015aSEric Dumazet }, 13369cfe015aSEric Dumazet { 13371da177e4SLinus Torvalds .procname = "dentry-state", 13381da177e4SLinus Torvalds .data = &dentry_stat, 13391da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 13401da177e4SLinus Torvalds .mode = 0444, 13416d456111SEric W. Biederman .proc_handler = proc_dointvec, 13421da177e4SLinus Torvalds }, 13431da177e4SLinus Torvalds { 13441da177e4SLinus Torvalds .procname = "overflowuid", 13451da177e4SLinus Torvalds .data = &fs_overflowuid, 13461da177e4SLinus Torvalds .maxlen = sizeof(int), 13471da177e4SLinus Torvalds .mode = 0644, 13486d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13491da177e4SLinus Torvalds .extra1 = &minolduid, 13501da177e4SLinus Torvalds .extra2 = &maxolduid, 13511da177e4SLinus Torvalds }, 13521da177e4SLinus Torvalds { 13531da177e4SLinus Torvalds .procname = "overflowgid", 13541da177e4SLinus Torvalds .data = &fs_overflowgid, 13551da177e4SLinus Torvalds .maxlen = sizeof(int), 13561da177e4SLinus Torvalds .mode = 0644, 13576d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13581da177e4SLinus Torvalds .extra1 = &minolduid, 13591da177e4SLinus Torvalds .extra2 = &maxolduid, 13601da177e4SLinus Torvalds }, 1361bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13621da177e4SLinus Torvalds { 13631da177e4SLinus Torvalds .procname = "leases-enable", 13641da177e4SLinus Torvalds .data = &leases_enable, 13651da177e4SLinus Torvalds .maxlen = sizeof(int), 13661da177e4SLinus Torvalds .mode = 0644, 13676d456111SEric W. Biederman .proc_handler = proc_dointvec, 13681da177e4SLinus Torvalds }, 1369bfcd17a6SThomas Petazzoni #endif 13701da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 13711da177e4SLinus Torvalds { 13721da177e4SLinus Torvalds .procname = "dir-notify-enable", 13731da177e4SLinus Torvalds .data = &dir_notify_enable, 13741da177e4SLinus Torvalds .maxlen = sizeof(int), 13751da177e4SLinus Torvalds .mode = 0644, 13766d456111SEric W. Biederman .proc_handler = proc_dointvec, 13771da177e4SLinus Torvalds }, 13781da177e4SLinus Torvalds #endif 13791da177e4SLinus Torvalds #ifdef CONFIG_MMU 1380bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13811da177e4SLinus Torvalds { 13821da177e4SLinus Torvalds .procname = "lease-break-time", 13831da177e4SLinus Torvalds .data = &lease_break_time, 13841da177e4SLinus Torvalds .maxlen = sizeof(int), 13851da177e4SLinus Torvalds .mode = 0644, 13866d456111SEric W. Biederman .proc_handler = proc_dointvec, 13871da177e4SLinus Torvalds }, 1388bfcd17a6SThomas Petazzoni #endif 1389ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 13901da177e4SLinus Torvalds { 13911da177e4SLinus Torvalds .procname = "aio-nr", 13921da177e4SLinus Torvalds .data = &aio_nr, 13931da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 13941da177e4SLinus Torvalds .mode = 0444, 13956d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 13961da177e4SLinus Torvalds }, 13971da177e4SLinus Torvalds { 13981da177e4SLinus Torvalds .procname = "aio-max-nr", 13991da177e4SLinus Torvalds .data = &aio_max_nr, 14001da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14011da177e4SLinus Torvalds .mode = 0644, 14026d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14031da177e4SLinus Torvalds }, 1404ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14052d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14060399cb08SRobert Love { 14070399cb08SRobert Love .procname = "inotify", 14080399cb08SRobert Love .mode = 0555, 14090399cb08SRobert Love .child = inotify_table, 14100399cb08SRobert Love }, 14110399cb08SRobert Love #endif 14127ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14137ef9964eSDavide Libenzi { 14147ef9964eSDavide Libenzi .procname = "epoll", 14157ef9964eSDavide Libenzi .mode = 0555, 14167ef9964eSDavide Libenzi .child = epoll_table, 14177ef9964eSDavide Libenzi }, 14187ef9964eSDavide Libenzi #endif 14191da177e4SLinus Torvalds #endif 1420d6e71144SAlan Cox { 1421d6e71144SAlan Cox .procname = "suid_dumpable", 1422d6e71144SAlan Cox .data = &suid_dumpable, 1423d6e71144SAlan Cox .maxlen = sizeof(int), 1424d6e71144SAlan Cox .mode = 0644, 14256d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14268e654fbaSMatthew Wilcox .extra1 = &zero, 14278e654fbaSMatthew Wilcox .extra2 = &two, 1428d6e71144SAlan Cox }, 14292abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14302abc26fcSEric W. Biederman { 14312abc26fcSEric W. Biederman .procname = "binfmt_misc", 14322abc26fcSEric W. Biederman .mode = 0555, 14332abc26fcSEric W. Biederman .child = binfmt_misc_table, 14342abc26fcSEric W. Biederman }, 14352abc26fcSEric W. Biederman #endif 14362be7fe07SAndrew Morton /* 14372be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14382be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14392be7fe07SAndrew Morton */ 14406fce56ecSEric W. Biederman { } 14411da177e4SLinus Torvalds }; 14421da177e4SLinus Torvalds 1443d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 14444b177647SDavid S. Miller #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) 1445abd4f750SMasoud Asgharifard Sharbiani { 1446abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1447abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1448abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1449abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1450abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1451abd4f750SMasoud Asgharifard Sharbiani }, 1452abd4f750SMasoud Asgharifard Sharbiani #endif 1453b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1454b2be84dfSMasami Hiramatsu { 1455b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1456b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1457b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1458b2be84dfSMasami Hiramatsu .mode = 0644, 1459b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1460b2be84dfSMasami Hiramatsu .extra1 = &zero, 1461b2be84dfSMasami Hiramatsu .extra2 = &one, 1462b2be84dfSMasami Hiramatsu }, 1463b2be84dfSMasami Hiramatsu #endif 14646fce56ecSEric W. Biederman { } 14651da177e4SLinus Torvalds }; 14661da177e4SLinus Torvalds 1467d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 14686fce56ecSEric W. Biederman { } 14691da177e4SLinus Torvalds }; 14701da177e4SLinus Torvalds 1471330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1472330d57fbSAl Viro 1473330d57fbSAl Viro /* called under sysctl_lock */ 1474330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1475330d57fbSAl Viro { 1476330d57fbSAl Viro if (unlikely(p->unregistering)) 1477330d57fbSAl Viro return 0; 1478330d57fbSAl Viro p->used++; 1479330d57fbSAl Viro return 1; 1480330d57fbSAl Viro } 1481330d57fbSAl Viro 1482330d57fbSAl Viro /* called under sysctl_lock */ 1483330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1484330d57fbSAl Viro { 1485330d57fbSAl Viro if (!--p->used) 1486330d57fbSAl Viro if (unlikely(p->unregistering)) 1487330d57fbSAl Viro complete(p->unregistering); 1488330d57fbSAl Viro } 1489330d57fbSAl Viro 1490330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1491330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1492330d57fbSAl Viro { 1493330d57fbSAl Viro /* 1494330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1495330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1496330d57fbSAl Viro */ 1497330d57fbSAl Viro if (unlikely(p->used)) { 1498330d57fbSAl Viro struct completion wait; 1499330d57fbSAl Viro init_completion(&wait); 1500330d57fbSAl Viro p->unregistering = &wait; 1501330d57fbSAl Viro spin_unlock(&sysctl_lock); 1502330d57fbSAl Viro wait_for_completion(&wait); 1503330d57fbSAl Viro spin_lock(&sysctl_lock); 1504f7e6ced4SAl Viro } else { 1505f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1506f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1507330d57fbSAl Viro } 1508330d57fbSAl Viro /* 1509330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1510330d57fbSAl Viro * list in do_sysctl() relies on that. 1511330d57fbSAl Viro */ 1512330d57fbSAl Viro list_del_init(&p->ctl_entry); 1513330d57fbSAl Viro } 1514330d57fbSAl Viro 1515f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1516f7e6ced4SAl Viro { 1517f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1518f7e6ced4SAl Viro head->count++; 1519f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1520f7e6ced4SAl Viro } 1521f7e6ced4SAl Viro 1522f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1523f7e6ced4SAl Viro { 1524f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1525f7e6ced4SAl Viro if (!--head->count) 1526f7e6ced4SAl Viro kfree(head); 1527f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1528f7e6ced4SAl Viro } 1529f7e6ced4SAl Viro 1530f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1531f7e6ced4SAl Viro { 1532f7e6ced4SAl Viro if (!head) 1533f7e6ced4SAl Viro BUG(); 1534f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1535f7e6ced4SAl Viro if (!use_table(head)) 1536f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1537f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1538f7e6ced4SAl Viro return head; 1539f7e6ced4SAl Viro } 1540f7e6ced4SAl Viro 1541805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1542805b5d5eSEric W. Biederman { 1543805b5d5eSEric W. Biederman if (!head) 1544805b5d5eSEric W. Biederman return; 1545805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1546805b5d5eSEric W. Biederman unuse_table(head); 1547805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1548805b5d5eSEric W. Biederman } 1549805b5d5eSEric W. Biederman 155073455092SAl Viro static struct ctl_table_set * 155173455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 155273455092SAl Viro { 155373455092SAl Viro struct ctl_table_set *set = &root->default_set; 155473455092SAl Viro if (root->lookup) 155573455092SAl Viro set = root->lookup(root, namespaces); 155673455092SAl Viro return set; 155773455092SAl Viro } 155873455092SAl Viro 1559e51b6ba0SEric W. Biederman static struct list_head * 1560e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1561805b5d5eSEric W. Biederman { 156273455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 156373455092SAl Viro return &set->list; 1564e51b6ba0SEric W. Biederman } 1565e51b6ba0SEric W. Biederman 1566e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1567e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1568e51b6ba0SEric W. Biederman { 1569e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1570e51b6ba0SEric W. Biederman struct list_head *header_list; 1571805b5d5eSEric W. Biederman struct ctl_table_header *head; 1572805b5d5eSEric W. Biederman struct list_head *tmp; 1573e51b6ba0SEric W. Biederman 1574805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1575805b5d5eSEric W. Biederman if (prev) { 1576e51b6ba0SEric W. Biederman head = prev; 1577805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1578805b5d5eSEric W. Biederman unuse_table(prev); 1579805b5d5eSEric W. Biederman goto next; 1580805b5d5eSEric W. Biederman } 1581805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1582805b5d5eSEric W. Biederman for (;;) { 1583805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1584805b5d5eSEric W. Biederman 1585805b5d5eSEric W. Biederman if (!use_table(head)) 1586805b5d5eSEric W. Biederman goto next; 1587805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1588805b5d5eSEric W. Biederman return head; 1589805b5d5eSEric W. Biederman next: 1590e51b6ba0SEric W. Biederman root = head->root; 1591805b5d5eSEric W. Biederman tmp = tmp->next; 1592e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1593e51b6ba0SEric W. Biederman if (tmp != header_list) 1594e51b6ba0SEric W. Biederman continue; 1595e51b6ba0SEric W. Biederman 1596e51b6ba0SEric W. Biederman do { 1597e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1598e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1599e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1600e51b6ba0SEric W. Biederman goto out; 1601e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1602e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1603e51b6ba0SEric W. Biederman tmp = header_list->next; 1604805b5d5eSEric W. Biederman } 1605e51b6ba0SEric W. Biederman out: 1606805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1607805b5d5eSEric W. Biederman return NULL; 1608805b5d5eSEric W. Biederman } 1609805b5d5eSEric W. Biederman 1610e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1611e51b6ba0SEric W. Biederman { 1612e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1613e51b6ba0SEric W. Biederman } 1614e51b6ba0SEric W. Biederman 1615e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1616e51b6ba0SEric W. Biederman { 1617e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1618e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1619e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1620e51b6ba0SEric W. Biederman } 1621e51b6ba0SEric W. Biederman 16221da177e4SLinus Torvalds /* 16231ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 16241da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 16251da177e4SLinus Torvalds */ 16261da177e4SLinus Torvalds 16271da177e4SLinus Torvalds static int test_perm(int mode, int op) 16281da177e4SLinus Torvalds { 162976aac0e9SDavid Howells if (!current_euid()) 16301da177e4SLinus Torvalds mode >>= 6; 16311da177e4SLinus Torvalds else if (in_egroup_p(0)) 16321da177e4SLinus Torvalds mode >>= 3; 1633e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 16341da177e4SLinus Torvalds return 0; 16351da177e4SLinus Torvalds return -EACCES; 16361da177e4SLinus Torvalds } 16371da177e4SLinus Torvalds 1638d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 16391da177e4SLinus Torvalds { 16401da177e4SLinus Torvalds int error; 1641d7321cd6SPavel Emelyanov int mode; 1642d7321cd6SPavel Emelyanov 1643e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 16441da177e4SLinus Torvalds if (error) 16451da177e4SLinus Torvalds return error; 1646d7321cd6SPavel Emelyanov 1647d7321cd6SPavel Emelyanov if (root->permissions) 1648d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1649d7321cd6SPavel Emelyanov else 1650d7321cd6SPavel Emelyanov mode = table->mode; 1651d7321cd6SPavel Emelyanov 1652d7321cd6SPavel Emelyanov return test_perm(mode, op); 16531da177e4SLinus Torvalds } 16541da177e4SLinus Torvalds 1655d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1656d912b0ccSEric W. Biederman { 16572315ffa0SEric W. Biederman for (; table->procname; table++) { 1658d912b0ccSEric W. Biederman table->parent = parent; 1659d912b0ccSEric W. Biederman if (table->child) 1660d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1661d912b0ccSEric W. Biederman } 1662d912b0ccSEric W. Biederman } 1663d912b0ccSEric W. Biederman 1664d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1665d912b0ccSEric W. Biederman { 1666d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 166788f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 166888f458e4SHolger Schurig { 166988f458e4SHolger Schurig int err; 1670e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 167188f458e4SHolger Schurig } 167288f458e4SHolger Schurig #endif 1673d912b0ccSEric W. Biederman return 0; 1674d912b0ccSEric W. Biederman } 1675d912b0ccSEric W. Biederman 1676d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1677d912b0ccSEric W. Biederman 1678bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1679bfbcf034SAl Viro struct ctl_table *table) 1680ae7edeccSAl Viro { 1681ae7edeccSAl Viro struct ctl_table *p; 1682ae7edeccSAl Viro const char *s = branch->procname; 1683ae7edeccSAl Viro 1684ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1685ae7edeccSAl Viro if (!s || !branch->child) 1686bfbcf034SAl Viro return NULL; 1687ae7edeccSAl Viro 1688ae7edeccSAl Viro /* ... and nothing else */ 16892315ffa0SEric W. Biederman if (branch[1].procname) 1690bfbcf034SAl Viro return NULL; 1691ae7edeccSAl Viro 1692ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 16932315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1694ae7edeccSAl Viro if (!p->child) 1695ae7edeccSAl Viro continue; 1696ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1697bfbcf034SAl Viro return p; 1698ae7edeccSAl Viro } 1699bfbcf034SAl Viro return NULL; 1700ae7edeccSAl Viro } 1701ae7edeccSAl Viro 1702ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1703ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1704ae7edeccSAl Viro { 1705ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1706bfbcf034SAl Viro struct ctl_table *next; 1707ae7edeccSAl Viro int is_better = 0; 1708ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1709ae7edeccSAl Viro 1710bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1711ae7edeccSAl Viro if (by == q->attached_by) 1712ae7edeccSAl Viro is_better = 1; 1713ae7edeccSAl Viro if (to == p->attached_by) 1714ae7edeccSAl Viro not_in_parent = 1; 1715ae7edeccSAl Viro by = by->child; 1716bfbcf034SAl Viro to = next->child; 1717ae7edeccSAl Viro } 1718ae7edeccSAl Viro 1719ae7edeccSAl Viro if (is_better && not_in_parent) { 1720ae7edeccSAl Viro q->attached_by = by; 1721ae7edeccSAl Viro q->attached_to = to; 1722ae7edeccSAl Viro q->parent = p; 1723ae7edeccSAl Viro } 1724ae7edeccSAl Viro } 1725ae7edeccSAl Viro 17261da177e4SLinus Torvalds /** 1727e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1728e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1729e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 173029e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 17311da177e4SLinus Torvalds * @table: the top-level table structure 17321da177e4SLinus Torvalds * 17331da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 173429e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 17351da177e4SLinus Torvalds * 1736d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 17371da177e4SLinus Torvalds * 17381da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 17391da177e4SLinus Torvalds * enter a sysctl file 17401da177e4SLinus Torvalds * 17411da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 17421da177e4SLinus Torvalds * 17431da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 17441da177e4SLinus Torvalds * 17451da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 17461da177e4SLinus Torvalds * 17471da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 17481da177e4SLinus Torvalds * %NULL. 17491da177e4SLinus Torvalds * 17501da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 17511da177e4SLinus Torvalds * 17521da177e4SLinus Torvalds * de - for internal use by the sysctl routines 17531da177e4SLinus Torvalds * 17541da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 17551da177e4SLinus Torvalds * 17561da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 17571da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 17581da177e4SLinus Torvalds * 17591da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 17601da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 17611da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 17621da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 17631da177e4SLinus Torvalds * 17641da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 17651da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 17661da177e4SLinus Torvalds * directory handler). Several default handlers are available to 17671da177e4SLinus Torvalds * cover common cases - 17681da177e4SLinus Torvalds * 17691da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 17701da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 17711da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 17721da177e4SLinus Torvalds * 17731da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 17741da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 17751da177e4SLinus Torvalds * 17761da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 17771da177e4SLinus Torvalds * to the table header on success. 17781da177e4SLinus Torvalds */ 1779e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1780e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1781e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1782e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 17831da177e4SLinus Torvalds { 178429e796fdSEric W. Biederman struct ctl_table_header *header; 178529e796fdSEric W. Biederman struct ctl_table *new, **prevp; 178629e796fdSEric W. Biederman unsigned int n, npath; 1787ae7edeccSAl Viro struct ctl_table_set *set; 178829e796fdSEric W. Biederman 178929e796fdSEric W. Biederman /* Count the path components */ 17902315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 179129e796fdSEric W. Biederman ; 179229e796fdSEric W. Biederman 179329e796fdSEric W. Biederman /* 179429e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 179529e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 17962315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 179729e796fdSEric W. Biederman * 179829e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 179929e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 180029e796fdSEric W. Biederman */ 180129e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 180229e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 180329e796fdSEric W. Biederman if (!header) 18041da177e4SLinus Torvalds return NULL; 180529e796fdSEric W. Biederman 180629e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 180729e796fdSEric W. Biederman 180829e796fdSEric W. Biederman /* Now connect the dots */ 180929e796fdSEric W. Biederman prevp = &header->ctl_table; 181029e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 181129e796fdSEric W. Biederman /* Copy the procname */ 181229e796fdSEric W. Biederman new->procname = path->procname; 181329e796fdSEric W. Biederman new->mode = 0555; 181429e796fdSEric W. Biederman 181529e796fdSEric W. Biederman *prevp = new; 181629e796fdSEric W. Biederman prevp = &new->child; 181729e796fdSEric W. Biederman 181829e796fdSEric W. Biederman new += 2; 181929e796fdSEric W. Biederman } 182029e796fdSEric W. Biederman *prevp = table; 182123eb06deSEric W. Biederman header->ctl_table_arg = table; 182229e796fdSEric W. Biederman 182329e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 182429e796fdSEric W. Biederman header->used = 0; 182529e796fdSEric W. Biederman header->unregistering = NULL; 1826e51b6ba0SEric W. Biederman header->root = root; 182729e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1828f7e6ced4SAl Viro header->count = 1; 182988f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1830e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 183129e796fdSEric W. Biederman kfree(header); 1832fc6cd25bSEric W. Biederman return NULL; 1833fc6cd25bSEric W. Biederman } 183488f458e4SHolger Schurig #endif 1835330d57fbSAl Viro spin_lock(&sysctl_lock); 183673455092SAl Viro header->set = lookup_header_set(root, namespaces); 1837ae7edeccSAl Viro header->attached_by = header->ctl_table; 1838ae7edeccSAl Viro header->attached_to = root_table; 1839ae7edeccSAl Viro header->parent = &root_table_header; 1840ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1841ae7edeccSAl Viro struct ctl_table_header *p; 1842ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1843ae7edeccSAl Viro if (p->unregistering) 1844ae7edeccSAl Viro continue; 1845ae7edeccSAl Viro try_attach(p, header); 1846ae7edeccSAl Viro } 1847ae7edeccSAl Viro } 1848ae7edeccSAl Viro header->parent->count++; 184973455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1850330d57fbSAl Viro spin_unlock(&sysctl_lock); 185129e796fdSEric W. Biederman 185229e796fdSEric W. Biederman return header; 185329e796fdSEric W. Biederman } 185429e796fdSEric W. Biederman 185529e796fdSEric W. Biederman /** 1856e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1857e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1858e51b6ba0SEric W. Biederman * @table: the top-level table structure 1859e51b6ba0SEric W. Biederman * 1860e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1861e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1862e51b6ba0SEric W. Biederman * 1863e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1864e51b6ba0SEric W. Biederman */ 1865e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1866e51b6ba0SEric W. Biederman struct ctl_table *table) 1867e51b6ba0SEric W. Biederman { 1868e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1869e51b6ba0SEric W. Biederman path, table); 1870e51b6ba0SEric W. Biederman } 1871e51b6ba0SEric W. Biederman 1872e51b6ba0SEric W. Biederman /** 187329e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 187429e796fdSEric W. Biederman * @table: the top-level table structure 187529e796fdSEric W. Biederman * 187629e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 187729e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 187829e796fdSEric W. Biederman * 187929e796fdSEric W. Biederman * See register_sysctl_paths for more details. 188029e796fdSEric W. Biederman */ 188129e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 188229e796fdSEric W. Biederman { 188329e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 188429e796fdSEric W. Biederman 188529e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 18861da177e4SLinus Torvalds } 18871da177e4SLinus Torvalds 18881da177e4SLinus Torvalds /** 18891da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 18901da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 18911da177e4SLinus Torvalds * 18921da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 18931da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 18941da177e4SLinus Torvalds */ 18951da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 18961da177e4SLinus Torvalds { 1897330d57fbSAl Viro might_sleep(); 1898f1dad166SPavel Emelyanov 1899f1dad166SPavel Emelyanov if (header == NULL) 1900f1dad166SPavel Emelyanov return; 1901f1dad166SPavel Emelyanov 1902330d57fbSAl Viro spin_lock(&sysctl_lock); 1903330d57fbSAl Viro start_unregistering(header); 1904ae7edeccSAl Viro if (!--header->parent->count) { 1905ae7edeccSAl Viro WARN_ON(1); 1906ae7edeccSAl Viro kfree(header->parent); 1907ae7edeccSAl Viro } 1908f7e6ced4SAl Viro if (!--header->count) 19091da177e4SLinus Torvalds kfree(header); 1910f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19111da177e4SLinus Torvalds } 19121da177e4SLinus Torvalds 19139043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19149043476fSAl Viro { 19159043476fSAl Viro struct ctl_table_set *set = p->set; 19169043476fSAl Viro int res; 19179043476fSAl Viro spin_lock(&sysctl_lock); 19189043476fSAl Viro if (p->unregistering) 19199043476fSAl Viro res = 0; 19209043476fSAl Viro else if (!set->is_seen) 19219043476fSAl Viro res = 1; 19229043476fSAl Viro else 19239043476fSAl Viro res = set->is_seen(set); 19249043476fSAl Viro spin_unlock(&sysctl_lock); 19259043476fSAl Viro return res; 19269043476fSAl Viro } 19279043476fSAl Viro 192873455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 192973455092SAl Viro struct ctl_table_set *parent, 193073455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 193173455092SAl Viro { 193273455092SAl Viro INIT_LIST_HEAD(&p->list); 193373455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 193473455092SAl Viro p->is_seen = is_seen; 193573455092SAl Viro } 193673455092SAl Viro 1937b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 1938d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1939b89a8171SEric W. Biederman { 1940b89a8171SEric W. Biederman return NULL; 1941b89a8171SEric W. Biederman } 1942b89a8171SEric W. Biederman 194329e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 194429e796fdSEric W. Biederman struct ctl_table *table) 194529e796fdSEric W. Biederman { 194629e796fdSEric W. Biederman return NULL; 194729e796fdSEric W. Biederman } 194829e796fdSEric W. Biederman 1949b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 1950b89a8171SEric W. Biederman { 1951b89a8171SEric W. Biederman } 1952b89a8171SEric W. Biederman 195373455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 195473455092SAl Viro struct ctl_table_set *parent, 195573455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 195673455092SAl Viro { 195773455092SAl Viro } 195873455092SAl Viro 1959f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1960f7e6ced4SAl Viro { 1961f7e6ced4SAl Viro } 1962f7e6ced4SAl Viro 1963b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1964b89a8171SEric W. Biederman 19651da177e4SLinus Torvalds /* 19661da177e4SLinus Torvalds * /proc/sys support 19671da177e4SLinus Torvalds */ 19681da177e4SLinus Torvalds 1969b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 19701da177e4SLinus Torvalds 1971b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 19728d65af78SAlexey Dobriyan void __user *buffer, 1973b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1974f5dd3d6fSSam Vilain { 1975f5dd3d6fSSam Vilain size_t len; 1976f5dd3d6fSSam Vilain char __user *p; 1977f5dd3d6fSSam Vilain char c; 1978f5dd3d6fSSam Vilain 19798d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1980f5dd3d6fSSam Vilain *lenp = 0; 1981f5dd3d6fSSam Vilain return 0; 1982f5dd3d6fSSam Vilain } 1983f5dd3d6fSSam Vilain 1984f5dd3d6fSSam Vilain if (write) { 1985f5dd3d6fSSam Vilain len = 0; 1986f5dd3d6fSSam Vilain p = buffer; 1987f5dd3d6fSSam Vilain while (len < *lenp) { 1988f5dd3d6fSSam Vilain if (get_user(c, p++)) 1989f5dd3d6fSSam Vilain return -EFAULT; 1990f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1991f5dd3d6fSSam Vilain break; 1992f5dd3d6fSSam Vilain len++; 1993f5dd3d6fSSam Vilain } 1994f5dd3d6fSSam Vilain if (len >= maxlen) 1995f5dd3d6fSSam Vilain len = maxlen-1; 1996f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1997f5dd3d6fSSam Vilain return -EFAULT; 1998f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 1999f5dd3d6fSSam Vilain *ppos += *lenp; 2000f5dd3d6fSSam Vilain } else { 2001f5dd3d6fSSam Vilain len = strlen(data); 2002f5dd3d6fSSam Vilain if (len > maxlen) 2003f5dd3d6fSSam Vilain len = maxlen; 20048d060877SOleg Nesterov 20058d060877SOleg Nesterov if (*ppos > len) { 20068d060877SOleg Nesterov *lenp = 0; 20078d060877SOleg Nesterov return 0; 20088d060877SOleg Nesterov } 20098d060877SOleg Nesterov 20108d060877SOleg Nesterov data += *ppos; 20118d060877SOleg Nesterov len -= *ppos; 20128d060877SOleg Nesterov 2013f5dd3d6fSSam Vilain if (len > *lenp) 2014f5dd3d6fSSam Vilain len = *lenp; 2015f5dd3d6fSSam Vilain if (len) 2016f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2017f5dd3d6fSSam Vilain return -EFAULT; 2018f5dd3d6fSSam Vilain if (len < *lenp) { 2019f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2020f5dd3d6fSSam Vilain return -EFAULT; 2021f5dd3d6fSSam Vilain len++; 2022f5dd3d6fSSam Vilain } 2023f5dd3d6fSSam Vilain *lenp = len; 2024f5dd3d6fSSam Vilain *ppos += len; 2025f5dd3d6fSSam Vilain } 2026f5dd3d6fSSam Vilain return 0; 2027f5dd3d6fSSam Vilain } 2028f5dd3d6fSSam Vilain 20291da177e4SLinus Torvalds /** 20301da177e4SLinus Torvalds * proc_dostring - read a string sysctl 20311da177e4SLinus Torvalds * @table: the sysctl table 20321da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20331da177e4SLinus Torvalds * @buffer: the user buffer 20341da177e4SLinus Torvalds * @lenp: the size of the user buffer 20351da177e4SLinus Torvalds * @ppos: file position 20361da177e4SLinus Torvalds * 20371da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 20381da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 20391da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 20401da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 20411da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 20421da177e4SLinus Torvalds * not large enough. 20431da177e4SLinus Torvalds * 20441da177e4SLinus Torvalds * Returns 0 on success. 20451da177e4SLinus Torvalds */ 20468d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 20471da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20481da177e4SLinus Torvalds { 20498d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2050f5dd3d6fSSam Vilain buffer, lenp, ppos); 20511da177e4SLinus Torvalds } 20521da177e4SLinus Torvalds 20531da177e4SLinus Torvalds 20541da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 20551da177e4SLinus Torvalds int *valp, 20561da177e4SLinus Torvalds int write, void *data) 20571da177e4SLinus Torvalds { 20581da177e4SLinus Torvalds if (write) { 20591da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 20601da177e4SLinus Torvalds } else { 20611da177e4SLinus Torvalds int val = *valp; 20621da177e4SLinus Torvalds if (val < 0) { 20631da177e4SLinus Torvalds *negp = -1; 20641da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 20651da177e4SLinus Torvalds } else { 20661da177e4SLinus Torvalds *negp = 0; 20671da177e4SLinus Torvalds *lvalp = (unsigned long)val; 20681da177e4SLinus Torvalds } 20691da177e4SLinus Torvalds } 20701da177e4SLinus Torvalds return 0; 20711da177e4SLinus Torvalds } 20721da177e4SLinus Torvalds 2073d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 20748d65af78SAlexey Dobriyan int write, void __user *buffer, 2075fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 20761da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 20771da177e4SLinus Torvalds int write, void *data), 20781da177e4SLinus Torvalds void *data) 20791da177e4SLinus Torvalds { 20801da177e4SLinus Torvalds #define TMPBUFLEN 21 20817338f299SSukanto Ghosh int *i, vleft, first = 1, neg; 20821da177e4SLinus Torvalds unsigned long lval; 20831da177e4SLinus Torvalds size_t left, len; 20841da177e4SLinus Torvalds 20851da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 20861da177e4SLinus Torvalds char __user *s = buffer; 20871da177e4SLinus Torvalds 2088fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 20891da177e4SLinus Torvalds (*ppos && !write)) { 20901da177e4SLinus Torvalds *lenp = 0; 20911da177e4SLinus Torvalds return 0; 20921da177e4SLinus Torvalds } 20931da177e4SLinus Torvalds 2094fcfbd547SKirill Korotaev i = (int *) tbl_data; 20951da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 20961da177e4SLinus Torvalds left = *lenp; 20971da177e4SLinus Torvalds 20981da177e4SLinus Torvalds if (!conv) 20991da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 21001da177e4SLinus Torvalds 21011da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 21021da177e4SLinus Torvalds if (write) { 21031da177e4SLinus Torvalds while (left) { 21041da177e4SLinus Torvalds char c; 21051da177e4SLinus Torvalds if (get_user(c, s)) 21061da177e4SLinus Torvalds return -EFAULT; 21071da177e4SLinus Torvalds if (!isspace(c)) 21081da177e4SLinus Torvalds break; 21091da177e4SLinus Torvalds left--; 21101da177e4SLinus Torvalds s++; 21111da177e4SLinus Torvalds } 21121da177e4SLinus Torvalds if (!left) 21131da177e4SLinus Torvalds break; 21141da177e4SLinus Torvalds neg = 0; 21151da177e4SLinus Torvalds len = left; 21161da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 21171da177e4SLinus Torvalds len = sizeof(buf) - 1; 21181da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 21191da177e4SLinus Torvalds return -EFAULT; 21201da177e4SLinus Torvalds buf[len] = 0; 21211da177e4SLinus Torvalds p = buf; 21221da177e4SLinus Torvalds if (*p == '-' && left > 1) { 21231da177e4SLinus Torvalds neg = 1; 2124bd9b0bacSBP, Praveen p++; 21251da177e4SLinus Torvalds } 21261da177e4SLinus Torvalds if (*p < '0' || *p > '9') 21271da177e4SLinus Torvalds break; 21281da177e4SLinus Torvalds 21291da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 21301da177e4SLinus Torvalds 21311da177e4SLinus Torvalds len = p-buf; 21321da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 21331da177e4SLinus Torvalds break; 21341da177e4SLinus Torvalds s += len; 21351da177e4SLinus Torvalds left -= len; 21361da177e4SLinus Torvalds 21371da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 21381da177e4SLinus Torvalds break; 21391da177e4SLinus Torvalds } else { 21401da177e4SLinus Torvalds p = buf; 21411da177e4SLinus Torvalds if (!first) 21421da177e4SLinus Torvalds *p++ = '\t'; 21431da177e4SLinus Torvalds 21441da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 21451da177e4SLinus Torvalds break; 21461da177e4SLinus Torvalds 21471da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 21481da177e4SLinus Torvalds len = strlen(buf); 21491da177e4SLinus Torvalds if (len > left) 21501da177e4SLinus Torvalds len = left; 21511da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 21521da177e4SLinus Torvalds return -EFAULT; 21531da177e4SLinus Torvalds left -= len; 21541da177e4SLinus Torvalds s += len; 21551da177e4SLinus Torvalds } 21561da177e4SLinus Torvalds } 21571da177e4SLinus Torvalds 21581da177e4SLinus Torvalds if (!write && !first && left) { 21591da177e4SLinus Torvalds if(put_user('\n', s)) 21601da177e4SLinus Torvalds return -EFAULT; 21611da177e4SLinus Torvalds left--, s++; 21621da177e4SLinus Torvalds } 21631da177e4SLinus Torvalds if (write) { 21641da177e4SLinus Torvalds while (left) { 21651da177e4SLinus Torvalds char c; 21661da177e4SLinus Torvalds if (get_user(c, s++)) 21671da177e4SLinus Torvalds return -EFAULT; 21681da177e4SLinus Torvalds if (!isspace(c)) 21691da177e4SLinus Torvalds break; 21701da177e4SLinus Torvalds left--; 21711da177e4SLinus Torvalds } 21721da177e4SLinus Torvalds } 21731da177e4SLinus Torvalds if (write && first) 21741da177e4SLinus Torvalds return -EINVAL; 21751da177e4SLinus Torvalds *lenp -= left; 21761da177e4SLinus Torvalds *ppos += *lenp; 21771da177e4SLinus Torvalds return 0; 21781da177e4SLinus Torvalds #undef TMPBUFLEN 21791da177e4SLinus Torvalds } 21801da177e4SLinus Torvalds 21818d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2182fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2183fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2184fcfbd547SKirill Korotaev int write, void *data), 2185fcfbd547SKirill Korotaev void *data) 2186fcfbd547SKirill Korotaev { 21878d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2188fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2189fcfbd547SKirill Korotaev } 2190fcfbd547SKirill Korotaev 21911da177e4SLinus Torvalds /** 21921da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 21931da177e4SLinus Torvalds * @table: the sysctl table 21941da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21951da177e4SLinus Torvalds * @buffer: the user buffer 21961da177e4SLinus Torvalds * @lenp: the size of the user buffer 21971da177e4SLinus Torvalds * @ppos: file position 21981da177e4SLinus Torvalds * 21991da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22001da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22011da177e4SLinus Torvalds * 22021da177e4SLinus Torvalds * Returns 0 on success. 22031da177e4SLinus Torvalds */ 22048d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 22051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22061da177e4SLinus Torvalds { 22078d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 22081da177e4SLinus Torvalds NULL,NULL); 22091da177e4SLinus Torvalds } 22101da177e4SLinus Torvalds 221134f5a398STheodore Ts'o /* 221234f5a398STheodore Ts'o * Taint values can only be increased 221325ddbb18SAndi Kleen * This means we can safely use a temporary. 221434f5a398STheodore Ts'o */ 22158d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 221634f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 221734f5a398STheodore Ts'o { 221825ddbb18SAndi Kleen struct ctl_table t; 221925ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 222025ddbb18SAndi Kleen int err; 222134f5a398STheodore Ts'o 222291fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 222334f5a398STheodore Ts'o return -EPERM; 222434f5a398STheodore Ts'o 222525ddbb18SAndi Kleen t = *table; 222625ddbb18SAndi Kleen t.data = &tmptaint; 22278d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 222825ddbb18SAndi Kleen if (err < 0) 222925ddbb18SAndi Kleen return err; 223025ddbb18SAndi Kleen 223125ddbb18SAndi Kleen if (write) { 223225ddbb18SAndi Kleen /* 223325ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 223425ddbb18SAndi Kleen * to everyone's atomic.h for this 223525ddbb18SAndi Kleen */ 223625ddbb18SAndi Kleen int i; 223725ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 223825ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 223925ddbb18SAndi Kleen add_taint(i); 224025ddbb18SAndi Kleen } 224125ddbb18SAndi Kleen } 224225ddbb18SAndi Kleen 224325ddbb18SAndi Kleen return err; 224434f5a398STheodore Ts'o } 224534f5a398STheodore Ts'o 22461da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 22471da177e4SLinus Torvalds int *min; 22481da177e4SLinus Torvalds int *max; 22491da177e4SLinus Torvalds }; 22501da177e4SLinus Torvalds 22511da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 22521da177e4SLinus Torvalds int *valp, 22531da177e4SLinus Torvalds int write, void *data) 22541da177e4SLinus Torvalds { 22551da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 22561da177e4SLinus Torvalds if (write) { 22571da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 22581da177e4SLinus Torvalds if ((param->min && *param->min > val) || 22591da177e4SLinus Torvalds (param->max && *param->max < val)) 22601da177e4SLinus Torvalds return -EINVAL; 22611da177e4SLinus Torvalds *valp = val; 22621da177e4SLinus Torvalds } else { 22631da177e4SLinus Torvalds int val = *valp; 22641da177e4SLinus Torvalds if (val < 0) { 22651da177e4SLinus Torvalds *negp = -1; 22661da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22671da177e4SLinus Torvalds } else { 22681da177e4SLinus Torvalds *negp = 0; 22691da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22701da177e4SLinus Torvalds } 22711da177e4SLinus Torvalds } 22721da177e4SLinus Torvalds return 0; 22731da177e4SLinus Torvalds } 22741da177e4SLinus Torvalds 22751da177e4SLinus Torvalds /** 22761da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 22771da177e4SLinus Torvalds * @table: the sysctl table 22781da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22791da177e4SLinus Torvalds * @buffer: the user buffer 22801da177e4SLinus Torvalds * @lenp: the size of the user buffer 22811da177e4SLinus Torvalds * @ppos: file position 22821da177e4SLinus Torvalds * 22831da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22841da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22851da177e4SLinus Torvalds * 22861da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 22871da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 22881da177e4SLinus Torvalds * 22891da177e4SLinus Torvalds * Returns 0 on success. 22901da177e4SLinus Torvalds */ 22918d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 22921da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22931da177e4SLinus Torvalds { 22941da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 22951da177e4SLinus Torvalds .min = (int *) table->extra1, 22961da177e4SLinus Torvalds .max = (int *) table->extra2, 22971da177e4SLinus Torvalds }; 22988d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 22991da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 23001da177e4SLinus Torvalds } 23011da177e4SLinus Torvalds 2302d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 23031da177e4SLinus Torvalds void __user *buffer, 23041da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 23051da177e4SLinus Torvalds unsigned long convmul, 23061da177e4SLinus Torvalds unsigned long convdiv) 23071da177e4SLinus Torvalds { 23081da177e4SLinus Torvalds #define TMPBUFLEN 21 23091da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 23101da177e4SLinus Torvalds int vleft, first=1, neg; 23111da177e4SLinus Torvalds size_t len, left; 23121da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 23131da177e4SLinus Torvalds char __user *s = buffer; 23141da177e4SLinus Torvalds 2315fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 23161da177e4SLinus Torvalds (*ppos && !write)) { 23171da177e4SLinus Torvalds *lenp = 0; 23181da177e4SLinus Torvalds return 0; 23191da177e4SLinus Torvalds } 23201da177e4SLinus Torvalds 2321fcfbd547SKirill Korotaev i = (unsigned long *) data; 23221da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 23231da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 23241da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 23251da177e4SLinus Torvalds left = *lenp; 23261da177e4SLinus Torvalds 23271da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 23281da177e4SLinus Torvalds if (write) { 23291da177e4SLinus Torvalds while (left) { 23301da177e4SLinus Torvalds char c; 23311da177e4SLinus Torvalds if (get_user(c, s)) 23321da177e4SLinus Torvalds return -EFAULT; 23331da177e4SLinus Torvalds if (!isspace(c)) 23341da177e4SLinus Torvalds break; 23351da177e4SLinus Torvalds left--; 23361da177e4SLinus Torvalds s++; 23371da177e4SLinus Torvalds } 23381da177e4SLinus Torvalds if (!left) 23391da177e4SLinus Torvalds break; 23401da177e4SLinus Torvalds neg = 0; 23411da177e4SLinus Torvalds len = left; 23421da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 23431da177e4SLinus Torvalds len = TMPBUFLEN-1; 23441da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 23451da177e4SLinus Torvalds return -EFAULT; 23461da177e4SLinus Torvalds buf[len] = 0; 23471da177e4SLinus Torvalds p = buf; 23481da177e4SLinus Torvalds if (*p == '-' && left > 1) { 23491da177e4SLinus Torvalds neg = 1; 2350bd9b0bacSBP, Praveen p++; 23511da177e4SLinus Torvalds } 23521da177e4SLinus Torvalds if (*p < '0' || *p > '9') 23531da177e4SLinus Torvalds break; 23541da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 23551da177e4SLinus Torvalds len = p-buf; 23561da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 23571da177e4SLinus Torvalds break; 23581da177e4SLinus Torvalds if (neg) 23591da177e4SLinus Torvalds val = -val; 23601da177e4SLinus Torvalds s += len; 23611da177e4SLinus Torvalds left -= len; 23621da177e4SLinus Torvalds 23631da177e4SLinus Torvalds if(neg) 23641da177e4SLinus Torvalds continue; 23651da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 23661da177e4SLinus Torvalds continue; 23671da177e4SLinus Torvalds *i = val; 23681da177e4SLinus Torvalds } else { 23691da177e4SLinus Torvalds p = buf; 23701da177e4SLinus Torvalds if (!first) 23711da177e4SLinus Torvalds *p++ = '\t'; 23721da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 23731da177e4SLinus Torvalds len = strlen(buf); 23741da177e4SLinus Torvalds if (len > left) 23751da177e4SLinus Torvalds len = left; 23761da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 23771da177e4SLinus Torvalds return -EFAULT; 23781da177e4SLinus Torvalds left -= len; 23791da177e4SLinus Torvalds s += len; 23801da177e4SLinus Torvalds } 23811da177e4SLinus Torvalds } 23821da177e4SLinus Torvalds 23831da177e4SLinus Torvalds if (!write && !first && left) { 23841da177e4SLinus Torvalds if(put_user('\n', s)) 23851da177e4SLinus Torvalds return -EFAULT; 23861da177e4SLinus Torvalds left--, s++; 23871da177e4SLinus Torvalds } 23881da177e4SLinus Torvalds if (write) { 23891da177e4SLinus Torvalds while (left) { 23901da177e4SLinus Torvalds char c; 23911da177e4SLinus Torvalds if (get_user(c, s++)) 23921da177e4SLinus Torvalds return -EFAULT; 23931da177e4SLinus Torvalds if (!isspace(c)) 23941da177e4SLinus Torvalds break; 23951da177e4SLinus Torvalds left--; 23961da177e4SLinus Torvalds } 23971da177e4SLinus Torvalds } 23981da177e4SLinus Torvalds if (write && first) 23991da177e4SLinus Torvalds return -EINVAL; 24001da177e4SLinus Torvalds *lenp -= left; 24011da177e4SLinus Torvalds *ppos += *lenp; 24021da177e4SLinus Torvalds return 0; 24031da177e4SLinus Torvalds #undef TMPBUFLEN 24041da177e4SLinus Torvalds } 24051da177e4SLinus Torvalds 2406d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2407fcfbd547SKirill Korotaev void __user *buffer, 2408fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2409fcfbd547SKirill Korotaev unsigned long convmul, 2410fcfbd547SKirill Korotaev unsigned long convdiv) 2411fcfbd547SKirill Korotaev { 2412fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 24138d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2414fcfbd547SKirill Korotaev } 2415fcfbd547SKirill Korotaev 24161da177e4SLinus Torvalds /** 24171da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 24181da177e4SLinus Torvalds * @table: the sysctl table 24191da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24201da177e4SLinus Torvalds * @buffer: the user buffer 24211da177e4SLinus Torvalds * @lenp: the size of the user buffer 24221da177e4SLinus Torvalds * @ppos: file position 24231da177e4SLinus Torvalds * 24241da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24251da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24261da177e4SLinus Torvalds * 24271da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24281da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24291da177e4SLinus Torvalds * 24301da177e4SLinus Torvalds * Returns 0 on success. 24311da177e4SLinus Torvalds */ 24328d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 24331da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24341da177e4SLinus Torvalds { 24358d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 24361da177e4SLinus Torvalds } 24371da177e4SLinus Torvalds 24381da177e4SLinus Torvalds /** 24391da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 24401da177e4SLinus Torvalds * @table: the sysctl table 24411da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24421da177e4SLinus Torvalds * @buffer: the user buffer 24431da177e4SLinus Torvalds * @lenp: the size of the user buffer 24441da177e4SLinus Torvalds * @ppos: file position 24451da177e4SLinus Torvalds * 24461da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24471da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 24481da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 24491da177e4SLinus Torvalds * 24501da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24511da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24521da177e4SLinus Torvalds * 24531da177e4SLinus Torvalds * Returns 0 on success. 24541da177e4SLinus Torvalds */ 2455d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 24561da177e4SLinus Torvalds void __user *buffer, 24571da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 24581da177e4SLinus Torvalds { 24598d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 24601da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 24611da177e4SLinus Torvalds } 24621da177e4SLinus Torvalds 24631da177e4SLinus Torvalds 24641da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 24651da177e4SLinus Torvalds int *valp, 24661da177e4SLinus Torvalds int write, void *data) 24671da177e4SLinus Torvalds { 24681da177e4SLinus Torvalds if (write) { 2469cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2470cba9f33dSBart Samwel return 1; 24711da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 24721da177e4SLinus Torvalds } else { 24731da177e4SLinus Torvalds int val = *valp; 24741da177e4SLinus Torvalds unsigned long lval; 24751da177e4SLinus Torvalds if (val < 0) { 24761da177e4SLinus Torvalds *negp = -1; 24771da177e4SLinus Torvalds lval = (unsigned long)-val; 24781da177e4SLinus Torvalds } else { 24791da177e4SLinus Torvalds *negp = 0; 24801da177e4SLinus Torvalds lval = (unsigned long)val; 24811da177e4SLinus Torvalds } 24821da177e4SLinus Torvalds *lvalp = lval / HZ; 24831da177e4SLinus Torvalds } 24841da177e4SLinus Torvalds return 0; 24851da177e4SLinus Torvalds } 24861da177e4SLinus Torvalds 24871da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 24881da177e4SLinus Torvalds int *valp, 24891da177e4SLinus Torvalds int write, void *data) 24901da177e4SLinus Torvalds { 24911da177e4SLinus Torvalds if (write) { 2492cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2493cba9f33dSBart Samwel return 1; 24941da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 24951da177e4SLinus Torvalds } else { 24961da177e4SLinus Torvalds int val = *valp; 24971da177e4SLinus Torvalds unsigned long lval; 24981da177e4SLinus Torvalds if (val < 0) { 24991da177e4SLinus Torvalds *negp = -1; 25001da177e4SLinus Torvalds lval = (unsigned long)-val; 25011da177e4SLinus Torvalds } else { 25021da177e4SLinus Torvalds *negp = 0; 25031da177e4SLinus Torvalds lval = (unsigned long)val; 25041da177e4SLinus Torvalds } 25051da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 25061da177e4SLinus Torvalds } 25071da177e4SLinus Torvalds return 0; 25081da177e4SLinus Torvalds } 25091da177e4SLinus Torvalds 25101da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 25111da177e4SLinus Torvalds int *valp, 25121da177e4SLinus Torvalds int write, void *data) 25131da177e4SLinus Torvalds { 25141da177e4SLinus Torvalds if (write) { 25151da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 25161da177e4SLinus Torvalds } else { 25171da177e4SLinus Torvalds int val = *valp; 25181da177e4SLinus Torvalds unsigned long lval; 25191da177e4SLinus Torvalds if (val < 0) { 25201da177e4SLinus Torvalds *negp = -1; 25211da177e4SLinus Torvalds lval = (unsigned long)-val; 25221da177e4SLinus Torvalds } else { 25231da177e4SLinus Torvalds *negp = 0; 25241da177e4SLinus Torvalds lval = (unsigned long)val; 25251da177e4SLinus Torvalds } 25261da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 25271da177e4SLinus Torvalds } 25281da177e4SLinus Torvalds return 0; 25291da177e4SLinus Torvalds } 25301da177e4SLinus Torvalds 25311da177e4SLinus Torvalds /** 25321da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 25331da177e4SLinus Torvalds * @table: the sysctl table 25341da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25351da177e4SLinus Torvalds * @buffer: the user buffer 25361da177e4SLinus Torvalds * @lenp: the size of the user buffer 25371da177e4SLinus Torvalds * @ppos: file position 25381da177e4SLinus Torvalds * 25391da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25401da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25411da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 25421da177e4SLinus Torvalds * jiffies. 25431da177e4SLinus Torvalds * 25441da177e4SLinus Torvalds * Returns 0 on success. 25451da177e4SLinus Torvalds */ 25468d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 25471da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25481da177e4SLinus Torvalds { 25498d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 25501da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 25511da177e4SLinus Torvalds } 25521da177e4SLinus Torvalds 25531da177e4SLinus Torvalds /** 25541da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 25551da177e4SLinus Torvalds * @table: the sysctl table 25561da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25571da177e4SLinus Torvalds * @buffer: the user buffer 25581da177e4SLinus Torvalds * @lenp: the size of the user buffer 25591e5d5331SRandy Dunlap * @ppos: pointer to the file position 25601da177e4SLinus Torvalds * 25611da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25621da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25631da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 25641da177e4SLinus Torvalds * are converted into jiffies. 25651da177e4SLinus Torvalds * 25661da177e4SLinus Torvalds * Returns 0 on success. 25671da177e4SLinus Torvalds */ 25688d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 25691da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25701da177e4SLinus Torvalds { 25718d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 25721da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 25731da177e4SLinus Torvalds } 25741da177e4SLinus Torvalds 25751da177e4SLinus Torvalds /** 25761da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 25771da177e4SLinus Torvalds * @table: the sysctl table 25781da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25791da177e4SLinus Torvalds * @buffer: the user buffer 25801da177e4SLinus Torvalds * @lenp: the size of the user buffer 258167be2dd1SMartin Waitz * @ppos: file position 258267be2dd1SMartin Waitz * @ppos: the current position in the file 25831da177e4SLinus Torvalds * 25841da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25851da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25861da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 25871da177e4SLinus Torvalds * are converted into jiffies. 25881da177e4SLinus Torvalds * 25891da177e4SLinus Torvalds * Returns 0 on success. 25901da177e4SLinus Torvalds */ 25918d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 25921da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25931da177e4SLinus Torvalds { 25948d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 25951da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 25961da177e4SLinus Torvalds } 25971da177e4SLinus Torvalds 25988d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 25999ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 26009ec52099SCedric Le Goater { 26019ec52099SCedric Le Goater struct pid *new_pid; 26029ec52099SCedric Le Goater pid_t tmp; 26039ec52099SCedric Le Goater int r; 26049ec52099SCedric Le Goater 26056c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 26069ec52099SCedric Le Goater 26078d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 26089ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 26099ec52099SCedric Le Goater if (r || !write) 26109ec52099SCedric Le Goater return r; 26119ec52099SCedric Le Goater 26129ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 26139ec52099SCedric Le Goater if (!new_pid) 26149ec52099SCedric Le Goater return -ESRCH; 26159ec52099SCedric Le Goater 26169ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 26179ec52099SCedric Le Goater return 0; 26189ec52099SCedric Le Goater } 26199ec52099SCedric Le Goater 26201da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 26211da177e4SLinus Torvalds 26228d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 26231da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26241da177e4SLinus Torvalds { 26251da177e4SLinus Torvalds return -ENOSYS; 26261da177e4SLinus Torvalds } 26271da177e4SLinus Torvalds 26288d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 26291da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26301da177e4SLinus Torvalds { 26311da177e4SLinus Torvalds return -ENOSYS; 26321da177e4SLinus Torvalds } 26331da177e4SLinus Torvalds 26348d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 26351da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26361da177e4SLinus Torvalds { 26371da177e4SLinus Torvalds return -ENOSYS; 26381da177e4SLinus Torvalds } 26391da177e4SLinus Torvalds 26408d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 26411da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26421da177e4SLinus Torvalds { 26431da177e4SLinus Torvalds return -ENOSYS; 26441da177e4SLinus Torvalds } 26451da177e4SLinus Torvalds 26468d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 26471da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26481da177e4SLinus Torvalds { 26491da177e4SLinus Torvalds return -ENOSYS; 26501da177e4SLinus Torvalds } 26511da177e4SLinus Torvalds 26528d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 26531da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26541da177e4SLinus Torvalds { 26551da177e4SLinus Torvalds return -ENOSYS; 26561da177e4SLinus Torvalds } 26571da177e4SLinus Torvalds 26588d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 26591da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26601da177e4SLinus Torvalds { 26611da177e4SLinus Torvalds return -ENOSYS; 26621da177e4SLinus Torvalds } 26631da177e4SLinus Torvalds 2664d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26651da177e4SLinus Torvalds void __user *buffer, 26661da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26671da177e4SLinus Torvalds { 26681da177e4SLinus Torvalds return -ENOSYS; 26691da177e4SLinus Torvalds } 26701da177e4SLinus Torvalds 26711da177e4SLinus Torvalds 26721da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 26731da177e4SLinus Torvalds 26741da177e4SLinus Torvalds /* 26751da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 26761da177e4SLinus Torvalds * exception granted :-) 26771da177e4SLinus Torvalds */ 26781da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 26791da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 26801da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 26811da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 26821da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 26831da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 26841da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 26851da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 26861da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 268729e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 26881da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2689