11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * sysctl.c: General linux system control interface 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Begun 24 March 1995, Stephen Tweedie 51da177e4SLinus Torvalds * Added /proc support, Dec 1995 61da177e4SLinus Torvalds * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 71da177e4SLinus Torvalds * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. 81da177e4SLinus Torvalds * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. 91da177e4SLinus Torvalds * Dynamic registration fixes, Stephen Tweedie. 101da177e4SLinus Torvalds * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. 111da177e4SLinus Torvalds * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris 121da177e4SLinus Torvalds * Horn. 131da177e4SLinus Torvalds * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. 141da177e4SLinus Torvalds * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. 151da177e4SLinus Torvalds * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill 161da177e4SLinus Torvalds * Wendling. 171da177e4SLinus Torvalds * The list_for_each() macro wasn't appropriate for the sysctl loop. 181da177e4SLinus Torvalds * Removed it and replaced it with older style, 03/23/00, Bill Wendling 191da177e4SLinus Torvalds */ 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds #include <linux/module.h> 221da177e4SLinus Torvalds #include <linux/mm.h> 231da177e4SLinus Torvalds #include <linux/swap.h> 241da177e4SLinus Torvalds #include <linux/slab.h> 251da177e4SLinus Torvalds #include <linux/sysctl.h> 261da177e4SLinus Torvalds #include <linux/proc_fs.h> 2772c2d582SAndrew Morgan #include <linux/security.h> 281da177e4SLinus Torvalds #include <linux/ctype.h> 29dfec072eSVegard Nossum #include <linux/kmemcheck.h> 3062239ac2SAdrian Bunk #include <linux/fs.h> 311da177e4SLinus Torvalds #include <linux/init.h> 321da177e4SLinus Torvalds #include <linux/kernel.h> 330296b228SKay Sievers #include <linux/kobject.h> 3420380731SArnaldo Carvalho de Melo #include <linux/net.h> 351da177e4SLinus Torvalds #include <linux/sysrq.h> 361da177e4SLinus Torvalds #include <linux/highuid.h> 371da177e4SLinus Torvalds #include <linux/writeback.h> 383fff4c42SIngo Molnar #include <linux/ratelimit.h> 391da177e4SLinus Torvalds #include <linux/hugetlb.h> 401da177e4SLinus Torvalds #include <linux/initrd.h> 410b77f5bfSDavid Howells #include <linux/key.h> 421da177e4SLinus Torvalds #include <linux/times.h> 431da177e4SLinus Torvalds #include <linux/limits.h> 441da177e4SLinus Torvalds #include <linux/dcache.h> 451da177e4SLinus Torvalds #include <linux/syscalls.h> 46c748e134SAdrian Bunk #include <linux/vmstat.h> 47c255d844SPavel Machek #include <linux/nfs_fs.h> 48c255d844SPavel Machek #include <linux/acpi.h> 4910a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 50b0fc494fSSteven Rostedt #include <linux/ftrace.h> 5112e22c5eSDavid Howells #include <linux/slow-work.h> 52cdd6c482SIngo Molnar #include <linux/perf_event.h> 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds #include <asm/uaccess.h> 551da177e4SLinus Torvalds #include <asm/processor.h> 561da177e4SLinus Torvalds 5729cbc78bSAndi Kleen #ifdef CONFIG_X86 5829cbc78bSAndi Kleen #include <asm/nmi.h> 590741f4d2SChuck Ebbert #include <asm/stacktrace.h> 606e7c4025SIngo Molnar #include <asm/io.h> 6129cbc78bSAndi Kleen #endif 6229cbc78bSAndi Kleen 637058cb02SEric W. Biederman 641da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds /* External variables not in a header file. */ 671da177e4SLinus Torvalds extern int C_A_D; 6845807a1dSIngo Molnar extern int print_fatal_signals; 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, 1134*3e26120cSWANG 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 1217ed032189SEric Paris { 1218ed032189SEric Paris .procname = "mmap_min_addr", 1219788084abSEric Paris .data = &dac_mmap_min_addr, 1220ed032189SEric Paris .maxlen = sizeof(unsigned long), 1221ed032189SEric Paris .mode = 0644, 12226d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1223ed032189SEric Paris }, 1224f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1225f0c0b2b8SKAMEZAWA Hiroyuki { 1226f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1227f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1228f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1229f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 12306d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1231f0c0b2b8SKAMEZAWA Hiroyuki }, 1232f0c0b2b8SKAMEZAWA Hiroyuki #endif 12332b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 12345c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1235e6e5494cSIngo Molnar { 1236e6e5494cSIngo Molnar .procname = "vdso_enabled", 1237e6e5494cSIngo Molnar .data = &vdso_enabled, 1238e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1239e6e5494cSIngo Molnar .mode = 0644, 12406d456111SEric W. Biederman .proc_handler = proc_dointvec, 1241e6e5494cSIngo Molnar .extra1 = &zero, 1242e6e5494cSIngo Molnar }, 1243e6e5494cSIngo Molnar #endif 1244195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1245195cf453SBron Gondwana { 1246195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1247195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1248195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1249195cf453SBron Gondwana .mode = 0644, 12506d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1251195cf453SBron Gondwana .extra1 = &zero, 1252195cf453SBron Gondwana .extra2 = &one, 1253195cf453SBron Gondwana }, 1254195cf453SBron Gondwana #endif 12554be6f6bbSPeter Zijlstra { 12564be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 12574be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 12584be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 12594be6f6bbSPeter Zijlstra .mode = 0644, 12606d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 12614be6f6bbSPeter Zijlstra }, 12626a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 12636a46079cSAndi Kleen { 12646a46079cSAndi Kleen .procname = "memory_failure_early_kill", 12656a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 12666a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 12676a46079cSAndi Kleen .mode = 0644, 12686d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12696a46079cSAndi Kleen .extra1 = &zero, 12706a46079cSAndi Kleen .extra2 = &one, 12716a46079cSAndi Kleen }, 12726a46079cSAndi Kleen { 12736a46079cSAndi Kleen .procname = "memory_failure_recovery", 12746a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 12756a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 12766a46079cSAndi Kleen .mode = 0644, 12776d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12786a46079cSAndi Kleen .extra1 = &zero, 12796a46079cSAndi Kleen .extra2 = &one, 12806a46079cSAndi Kleen }, 12816a46079cSAndi Kleen #endif 12826a46079cSAndi Kleen 12832be7fe07SAndrew Morton /* 12842be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 12852be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 12862be7fe07SAndrew Morton */ 12876fce56ecSEric W. Biederman { } 12881da177e4SLinus Torvalds }; 12891da177e4SLinus Torvalds 12902abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1291d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 12926fce56ecSEric W. Biederman { } 12932abc26fcSEric W. Biederman }; 12942abc26fcSEric W. Biederman #endif 12952abc26fcSEric W. Biederman 1296d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 12971da177e4SLinus Torvalds { 12981da177e4SLinus Torvalds .procname = "inode-nr", 12991da177e4SLinus Torvalds .data = &inodes_stat, 13001da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13011da177e4SLinus Torvalds .mode = 0444, 13026d456111SEric W. Biederman .proc_handler = proc_dointvec, 13031da177e4SLinus Torvalds }, 13041da177e4SLinus Torvalds { 13051da177e4SLinus Torvalds .procname = "inode-state", 13061da177e4SLinus Torvalds .data = &inodes_stat, 13071da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13081da177e4SLinus Torvalds .mode = 0444, 13096d456111SEric W. Biederman .proc_handler = proc_dointvec, 13101da177e4SLinus Torvalds }, 13111da177e4SLinus Torvalds { 13121da177e4SLinus Torvalds .procname = "file-nr", 13131da177e4SLinus Torvalds .data = &files_stat, 13141da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 13151da177e4SLinus Torvalds .mode = 0444, 13166d456111SEric W. Biederman .proc_handler = proc_nr_files, 13171da177e4SLinus Torvalds }, 13181da177e4SLinus Torvalds { 13191da177e4SLinus Torvalds .procname = "file-max", 13201da177e4SLinus Torvalds .data = &files_stat.max_files, 13211da177e4SLinus Torvalds .maxlen = sizeof(int), 13221da177e4SLinus Torvalds .mode = 0644, 13236d456111SEric W. Biederman .proc_handler = proc_dointvec, 13241da177e4SLinus Torvalds }, 13251da177e4SLinus Torvalds { 13269cfe015aSEric Dumazet .procname = "nr_open", 13279cfe015aSEric Dumazet .data = &sysctl_nr_open, 13289cfe015aSEric Dumazet .maxlen = sizeof(int), 13299cfe015aSEric Dumazet .mode = 0644, 13306d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1331eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1332eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 13339cfe015aSEric Dumazet }, 13349cfe015aSEric Dumazet { 13351da177e4SLinus Torvalds .procname = "dentry-state", 13361da177e4SLinus Torvalds .data = &dentry_stat, 13371da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 13381da177e4SLinus Torvalds .mode = 0444, 13396d456111SEric W. Biederman .proc_handler = proc_dointvec, 13401da177e4SLinus Torvalds }, 13411da177e4SLinus Torvalds { 13421da177e4SLinus Torvalds .procname = "overflowuid", 13431da177e4SLinus Torvalds .data = &fs_overflowuid, 13441da177e4SLinus Torvalds .maxlen = sizeof(int), 13451da177e4SLinus Torvalds .mode = 0644, 13466d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13471da177e4SLinus Torvalds .extra1 = &minolduid, 13481da177e4SLinus Torvalds .extra2 = &maxolduid, 13491da177e4SLinus Torvalds }, 13501da177e4SLinus Torvalds { 13511da177e4SLinus Torvalds .procname = "overflowgid", 13521da177e4SLinus Torvalds .data = &fs_overflowgid, 13531da177e4SLinus Torvalds .maxlen = sizeof(int), 13541da177e4SLinus Torvalds .mode = 0644, 13556d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13561da177e4SLinus Torvalds .extra1 = &minolduid, 13571da177e4SLinus Torvalds .extra2 = &maxolduid, 13581da177e4SLinus Torvalds }, 1359bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13601da177e4SLinus Torvalds { 13611da177e4SLinus Torvalds .procname = "leases-enable", 13621da177e4SLinus Torvalds .data = &leases_enable, 13631da177e4SLinus Torvalds .maxlen = sizeof(int), 13641da177e4SLinus Torvalds .mode = 0644, 13656d456111SEric W. Biederman .proc_handler = proc_dointvec, 13661da177e4SLinus Torvalds }, 1367bfcd17a6SThomas Petazzoni #endif 13681da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 13691da177e4SLinus Torvalds { 13701da177e4SLinus Torvalds .procname = "dir-notify-enable", 13711da177e4SLinus Torvalds .data = &dir_notify_enable, 13721da177e4SLinus Torvalds .maxlen = sizeof(int), 13731da177e4SLinus Torvalds .mode = 0644, 13746d456111SEric W. Biederman .proc_handler = proc_dointvec, 13751da177e4SLinus Torvalds }, 13761da177e4SLinus Torvalds #endif 13771da177e4SLinus Torvalds #ifdef CONFIG_MMU 1378bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13791da177e4SLinus Torvalds { 13801da177e4SLinus Torvalds .procname = "lease-break-time", 13811da177e4SLinus Torvalds .data = &lease_break_time, 13821da177e4SLinus Torvalds .maxlen = sizeof(int), 13831da177e4SLinus Torvalds .mode = 0644, 13846d456111SEric W. Biederman .proc_handler = proc_dointvec, 13851da177e4SLinus Torvalds }, 1386bfcd17a6SThomas Petazzoni #endif 1387ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 13881da177e4SLinus Torvalds { 13891da177e4SLinus Torvalds .procname = "aio-nr", 13901da177e4SLinus Torvalds .data = &aio_nr, 13911da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 13921da177e4SLinus Torvalds .mode = 0444, 13936d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 13941da177e4SLinus Torvalds }, 13951da177e4SLinus Torvalds { 13961da177e4SLinus Torvalds .procname = "aio-max-nr", 13971da177e4SLinus Torvalds .data = &aio_max_nr, 13981da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 13991da177e4SLinus Torvalds .mode = 0644, 14006d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14011da177e4SLinus Torvalds }, 1402ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14032d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14040399cb08SRobert Love { 14050399cb08SRobert Love .procname = "inotify", 14060399cb08SRobert Love .mode = 0555, 14070399cb08SRobert Love .child = inotify_table, 14080399cb08SRobert Love }, 14090399cb08SRobert Love #endif 14107ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14117ef9964eSDavide Libenzi { 14127ef9964eSDavide Libenzi .procname = "epoll", 14137ef9964eSDavide Libenzi .mode = 0555, 14147ef9964eSDavide Libenzi .child = epoll_table, 14157ef9964eSDavide Libenzi }, 14167ef9964eSDavide Libenzi #endif 14171da177e4SLinus Torvalds #endif 1418d6e71144SAlan Cox { 1419d6e71144SAlan Cox .procname = "suid_dumpable", 1420d6e71144SAlan Cox .data = &suid_dumpable, 1421d6e71144SAlan Cox .maxlen = sizeof(int), 1422d6e71144SAlan Cox .mode = 0644, 14236d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14248e654fbaSMatthew Wilcox .extra1 = &zero, 14258e654fbaSMatthew Wilcox .extra2 = &two, 1426d6e71144SAlan Cox }, 14272abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14282abc26fcSEric W. Biederman { 14292abc26fcSEric W. Biederman .procname = "binfmt_misc", 14302abc26fcSEric W. Biederman .mode = 0555, 14312abc26fcSEric W. Biederman .child = binfmt_misc_table, 14322abc26fcSEric W. Biederman }, 14332abc26fcSEric W. Biederman #endif 14342be7fe07SAndrew Morton /* 14352be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14362be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14372be7fe07SAndrew Morton */ 14386fce56ecSEric W. Biederman { } 14391da177e4SLinus Torvalds }; 14401da177e4SLinus Torvalds 1441d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1442d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC) 1443abd4f750SMasoud Asgharifard Sharbiani { 1444abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1445abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1446abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1447abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1448abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1449abd4f750SMasoud Asgharifard Sharbiani }, 1450abd4f750SMasoud Asgharifard Sharbiani #endif 14516fce56ecSEric W. Biederman { } 14521da177e4SLinus Torvalds }; 14531da177e4SLinus Torvalds 1454d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 14556fce56ecSEric W. Biederman { } 14561da177e4SLinus Torvalds }; 14571da177e4SLinus Torvalds 1458330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1459330d57fbSAl Viro 1460330d57fbSAl Viro /* called under sysctl_lock */ 1461330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1462330d57fbSAl Viro { 1463330d57fbSAl Viro if (unlikely(p->unregistering)) 1464330d57fbSAl Viro return 0; 1465330d57fbSAl Viro p->used++; 1466330d57fbSAl Viro return 1; 1467330d57fbSAl Viro } 1468330d57fbSAl Viro 1469330d57fbSAl Viro /* called under sysctl_lock */ 1470330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1471330d57fbSAl Viro { 1472330d57fbSAl Viro if (!--p->used) 1473330d57fbSAl Viro if (unlikely(p->unregistering)) 1474330d57fbSAl Viro complete(p->unregistering); 1475330d57fbSAl Viro } 1476330d57fbSAl Viro 1477330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1478330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1479330d57fbSAl Viro { 1480330d57fbSAl Viro /* 1481330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1482330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1483330d57fbSAl Viro */ 1484330d57fbSAl Viro if (unlikely(p->used)) { 1485330d57fbSAl Viro struct completion wait; 1486330d57fbSAl Viro init_completion(&wait); 1487330d57fbSAl Viro p->unregistering = &wait; 1488330d57fbSAl Viro spin_unlock(&sysctl_lock); 1489330d57fbSAl Viro wait_for_completion(&wait); 1490330d57fbSAl Viro spin_lock(&sysctl_lock); 1491f7e6ced4SAl Viro } else { 1492f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1493f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1494330d57fbSAl Viro } 1495330d57fbSAl Viro /* 1496330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1497330d57fbSAl Viro * list in do_sysctl() relies on that. 1498330d57fbSAl Viro */ 1499330d57fbSAl Viro list_del_init(&p->ctl_entry); 1500330d57fbSAl Viro } 1501330d57fbSAl Viro 1502f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1503f7e6ced4SAl Viro { 1504f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1505f7e6ced4SAl Viro head->count++; 1506f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1507f7e6ced4SAl Viro } 1508f7e6ced4SAl Viro 1509f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1510f7e6ced4SAl Viro { 1511f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1512f7e6ced4SAl Viro if (!--head->count) 1513f7e6ced4SAl Viro kfree(head); 1514f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1515f7e6ced4SAl Viro } 1516f7e6ced4SAl Viro 1517f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1518f7e6ced4SAl Viro { 1519f7e6ced4SAl Viro if (!head) 1520f7e6ced4SAl Viro BUG(); 1521f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1522f7e6ced4SAl Viro if (!use_table(head)) 1523f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1524f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1525f7e6ced4SAl Viro return head; 1526f7e6ced4SAl Viro } 1527f7e6ced4SAl Viro 1528805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1529805b5d5eSEric W. Biederman { 1530805b5d5eSEric W. Biederman if (!head) 1531805b5d5eSEric W. Biederman return; 1532805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1533805b5d5eSEric W. Biederman unuse_table(head); 1534805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1535805b5d5eSEric W. Biederman } 1536805b5d5eSEric W. Biederman 153773455092SAl Viro static struct ctl_table_set * 153873455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 153973455092SAl Viro { 154073455092SAl Viro struct ctl_table_set *set = &root->default_set; 154173455092SAl Viro if (root->lookup) 154273455092SAl Viro set = root->lookup(root, namespaces); 154373455092SAl Viro return set; 154473455092SAl Viro } 154573455092SAl Viro 1546e51b6ba0SEric W. Biederman static struct list_head * 1547e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1548805b5d5eSEric W. Biederman { 154973455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 155073455092SAl Viro return &set->list; 1551e51b6ba0SEric W. Biederman } 1552e51b6ba0SEric W. Biederman 1553e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1554e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1555e51b6ba0SEric W. Biederman { 1556e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1557e51b6ba0SEric W. Biederman struct list_head *header_list; 1558805b5d5eSEric W. Biederman struct ctl_table_header *head; 1559805b5d5eSEric W. Biederman struct list_head *tmp; 1560e51b6ba0SEric W. Biederman 1561805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1562805b5d5eSEric W. Biederman if (prev) { 1563e51b6ba0SEric W. Biederman head = prev; 1564805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1565805b5d5eSEric W. Biederman unuse_table(prev); 1566805b5d5eSEric W. Biederman goto next; 1567805b5d5eSEric W. Biederman } 1568805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1569805b5d5eSEric W. Biederman for (;;) { 1570805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1571805b5d5eSEric W. Biederman 1572805b5d5eSEric W. Biederman if (!use_table(head)) 1573805b5d5eSEric W. Biederman goto next; 1574805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1575805b5d5eSEric W. Biederman return head; 1576805b5d5eSEric W. Biederman next: 1577e51b6ba0SEric W. Biederman root = head->root; 1578805b5d5eSEric W. Biederman tmp = tmp->next; 1579e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1580e51b6ba0SEric W. Biederman if (tmp != header_list) 1581e51b6ba0SEric W. Biederman continue; 1582e51b6ba0SEric W. Biederman 1583e51b6ba0SEric W. Biederman do { 1584e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1585e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1586e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1587e51b6ba0SEric W. Biederman goto out; 1588e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1589e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1590e51b6ba0SEric W. Biederman tmp = header_list->next; 1591805b5d5eSEric W. Biederman } 1592e51b6ba0SEric W. Biederman out: 1593805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1594805b5d5eSEric W. Biederman return NULL; 1595805b5d5eSEric W. Biederman } 1596805b5d5eSEric W. Biederman 1597e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1598e51b6ba0SEric W. Biederman { 1599e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1600e51b6ba0SEric W. Biederman } 1601e51b6ba0SEric W. Biederman 1602e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1603e51b6ba0SEric W. Biederman { 1604e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1605e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1606e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1607e51b6ba0SEric W. Biederman } 1608e51b6ba0SEric W. Biederman 16091da177e4SLinus Torvalds /* 16101ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 16111da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 16121da177e4SLinus Torvalds */ 16131da177e4SLinus Torvalds 16141da177e4SLinus Torvalds static int test_perm(int mode, int op) 16151da177e4SLinus Torvalds { 161676aac0e9SDavid Howells if (!current_euid()) 16171da177e4SLinus Torvalds mode >>= 6; 16181da177e4SLinus Torvalds else if (in_egroup_p(0)) 16191da177e4SLinus Torvalds mode >>= 3; 1620e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 16211da177e4SLinus Torvalds return 0; 16221da177e4SLinus Torvalds return -EACCES; 16231da177e4SLinus Torvalds } 16241da177e4SLinus Torvalds 1625d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 16261da177e4SLinus Torvalds { 16271da177e4SLinus Torvalds int error; 1628d7321cd6SPavel Emelyanov int mode; 1629d7321cd6SPavel Emelyanov 1630e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 16311da177e4SLinus Torvalds if (error) 16321da177e4SLinus Torvalds return error; 1633d7321cd6SPavel Emelyanov 1634d7321cd6SPavel Emelyanov if (root->permissions) 1635d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1636d7321cd6SPavel Emelyanov else 1637d7321cd6SPavel Emelyanov mode = table->mode; 1638d7321cd6SPavel Emelyanov 1639d7321cd6SPavel Emelyanov return test_perm(mode, op); 16401da177e4SLinus Torvalds } 16411da177e4SLinus Torvalds 1642d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1643d912b0ccSEric W. Biederman { 16442315ffa0SEric W. Biederman for (; table->procname; table++) { 1645d912b0ccSEric W. Biederman table->parent = parent; 1646d912b0ccSEric W. Biederman if (table->child) 1647d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1648d912b0ccSEric W. Biederman } 1649d912b0ccSEric W. Biederman } 1650d912b0ccSEric W. Biederman 1651d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1652d912b0ccSEric W. Biederman { 1653d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 165488f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 165588f458e4SHolger Schurig { 165688f458e4SHolger Schurig int err; 1657e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 165888f458e4SHolger Schurig } 165988f458e4SHolger Schurig #endif 1660d912b0ccSEric W. Biederman return 0; 1661d912b0ccSEric W. Biederman } 1662d912b0ccSEric W. Biederman 1663d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1664d912b0ccSEric W. Biederman 1665bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1666bfbcf034SAl Viro struct ctl_table *table) 1667ae7edeccSAl Viro { 1668ae7edeccSAl Viro struct ctl_table *p; 1669ae7edeccSAl Viro const char *s = branch->procname; 1670ae7edeccSAl Viro 1671ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1672ae7edeccSAl Viro if (!s || !branch->child) 1673bfbcf034SAl Viro return NULL; 1674ae7edeccSAl Viro 1675ae7edeccSAl Viro /* ... and nothing else */ 16762315ffa0SEric W. Biederman if (branch[1].procname) 1677bfbcf034SAl Viro return NULL; 1678ae7edeccSAl Viro 1679ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 16802315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1681ae7edeccSAl Viro if (!p->child) 1682ae7edeccSAl Viro continue; 1683ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1684bfbcf034SAl Viro return p; 1685ae7edeccSAl Viro } 1686bfbcf034SAl Viro return NULL; 1687ae7edeccSAl Viro } 1688ae7edeccSAl Viro 1689ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1690ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1691ae7edeccSAl Viro { 1692ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1693bfbcf034SAl Viro struct ctl_table *next; 1694ae7edeccSAl Viro int is_better = 0; 1695ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1696ae7edeccSAl Viro 1697bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1698ae7edeccSAl Viro if (by == q->attached_by) 1699ae7edeccSAl Viro is_better = 1; 1700ae7edeccSAl Viro if (to == p->attached_by) 1701ae7edeccSAl Viro not_in_parent = 1; 1702ae7edeccSAl Viro by = by->child; 1703bfbcf034SAl Viro to = next->child; 1704ae7edeccSAl Viro } 1705ae7edeccSAl Viro 1706ae7edeccSAl Viro if (is_better && not_in_parent) { 1707ae7edeccSAl Viro q->attached_by = by; 1708ae7edeccSAl Viro q->attached_to = to; 1709ae7edeccSAl Viro q->parent = p; 1710ae7edeccSAl Viro } 1711ae7edeccSAl Viro } 1712ae7edeccSAl Viro 17131da177e4SLinus Torvalds /** 1714e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1715e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1716e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 171729e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 17181da177e4SLinus Torvalds * @table: the top-level table structure 17191da177e4SLinus Torvalds * 17201da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 172129e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 17221da177e4SLinus Torvalds * 1723d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 17241da177e4SLinus Torvalds * 17251da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 17261da177e4SLinus Torvalds * enter a sysctl file 17271da177e4SLinus Torvalds * 17281da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 17291da177e4SLinus Torvalds * 17301da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 17311da177e4SLinus Torvalds * 17321da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 17331da177e4SLinus Torvalds * 17341da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 17351da177e4SLinus Torvalds * %NULL. 17361da177e4SLinus Torvalds * 17371da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 17381da177e4SLinus Torvalds * 17391da177e4SLinus Torvalds * de - for internal use by the sysctl routines 17401da177e4SLinus Torvalds * 17411da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 17421da177e4SLinus Torvalds * 17431da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 17441da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 17451da177e4SLinus Torvalds * 17461da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 17471da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 17481da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 17491da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 17501da177e4SLinus Torvalds * 17511da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 17521da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 17531da177e4SLinus Torvalds * directory handler). Several default handlers are available to 17541da177e4SLinus Torvalds * cover common cases - 17551da177e4SLinus Torvalds * 17561da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 17571da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 17581da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 17591da177e4SLinus Torvalds * 17601da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 17611da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 17621da177e4SLinus Torvalds * 17631da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 17641da177e4SLinus Torvalds * to the table header on success. 17651da177e4SLinus Torvalds */ 1766e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1767e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1768e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1769e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 17701da177e4SLinus Torvalds { 177129e796fdSEric W. Biederman struct ctl_table_header *header; 177229e796fdSEric W. Biederman struct ctl_table *new, **prevp; 177329e796fdSEric W. Biederman unsigned int n, npath; 1774ae7edeccSAl Viro struct ctl_table_set *set; 177529e796fdSEric W. Biederman 177629e796fdSEric W. Biederman /* Count the path components */ 17772315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 177829e796fdSEric W. Biederman ; 177929e796fdSEric W. Biederman 178029e796fdSEric W. Biederman /* 178129e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 178229e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 17832315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 178429e796fdSEric W. Biederman * 178529e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 178629e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 178729e796fdSEric W. Biederman */ 178829e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 178929e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 179029e796fdSEric W. Biederman if (!header) 17911da177e4SLinus Torvalds return NULL; 179229e796fdSEric W. Biederman 179329e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 179429e796fdSEric W. Biederman 179529e796fdSEric W. Biederman /* Now connect the dots */ 179629e796fdSEric W. Biederman prevp = &header->ctl_table; 179729e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 179829e796fdSEric W. Biederman /* Copy the procname */ 179929e796fdSEric W. Biederman new->procname = path->procname; 180029e796fdSEric W. Biederman new->mode = 0555; 180129e796fdSEric W. Biederman 180229e796fdSEric W. Biederman *prevp = new; 180329e796fdSEric W. Biederman prevp = &new->child; 180429e796fdSEric W. Biederman 180529e796fdSEric W. Biederman new += 2; 180629e796fdSEric W. Biederman } 180729e796fdSEric W. Biederman *prevp = table; 180823eb06deSEric W. Biederman header->ctl_table_arg = table; 180929e796fdSEric W. Biederman 181029e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 181129e796fdSEric W. Biederman header->used = 0; 181229e796fdSEric W. Biederman header->unregistering = NULL; 1813e51b6ba0SEric W. Biederman header->root = root; 181429e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1815f7e6ced4SAl Viro header->count = 1; 181688f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1817e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 181829e796fdSEric W. Biederman kfree(header); 1819fc6cd25bSEric W. Biederman return NULL; 1820fc6cd25bSEric W. Biederman } 182188f458e4SHolger Schurig #endif 1822330d57fbSAl Viro spin_lock(&sysctl_lock); 182373455092SAl Viro header->set = lookup_header_set(root, namespaces); 1824ae7edeccSAl Viro header->attached_by = header->ctl_table; 1825ae7edeccSAl Viro header->attached_to = root_table; 1826ae7edeccSAl Viro header->parent = &root_table_header; 1827ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1828ae7edeccSAl Viro struct ctl_table_header *p; 1829ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1830ae7edeccSAl Viro if (p->unregistering) 1831ae7edeccSAl Viro continue; 1832ae7edeccSAl Viro try_attach(p, header); 1833ae7edeccSAl Viro } 1834ae7edeccSAl Viro } 1835ae7edeccSAl Viro header->parent->count++; 183673455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1837330d57fbSAl Viro spin_unlock(&sysctl_lock); 183829e796fdSEric W. Biederman 183929e796fdSEric W. Biederman return header; 184029e796fdSEric W. Biederman } 184129e796fdSEric W. Biederman 184229e796fdSEric W. Biederman /** 1843e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1844e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1845e51b6ba0SEric W. Biederman * @table: the top-level table structure 1846e51b6ba0SEric W. Biederman * 1847e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1848e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1849e51b6ba0SEric W. Biederman * 1850e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1851e51b6ba0SEric W. Biederman */ 1852e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1853e51b6ba0SEric W. Biederman struct ctl_table *table) 1854e51b6ba0SEric W. Biederman { 1855e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1856e51b6ba0SEric W. Biederman path, table); 1857e51b6ba0SEric W. Biederman } 1858e51b6ba0SEric W. Biederman 1859e51b6ba0SEric W. Biederman /** 186029e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 186129e796fdSEric W. Biederman * @table: the top-level table structure 186229e796fdSEric W. Biederman * 186329e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 186429e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 186529e796fdSEric W. Biederman * 186629e796fdSEric W. Biederman * See register_sysctl_paths for more details. 186729e796fdSEric W. Biederman */ 186829e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 186929e796fdSEric W. Biederman { 187029e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 187129e796fdSEric W. Biederman 187229e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 18731da177e4SLinus Torvalds } 18741da177e4SLinus Torvalds 18751da177e4SLinus Torvalds /** 18761da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 18771da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 18781da177e4SLinus Torvalds * 18791da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 18801da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 18811da177e4SLinus Torvalds */ 18821da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 18831da177e4SLinus Torvalds { 1884330d57fbSAl Viro might_sleep(); 1885f1dad166SPavel Emelyanov 1886f1dad166SPavel Emelyanov if (header == NULL) 1887f1dad166SPavel Emelyanov return; 1888f1dad166SPavel Emelyanov 1889330d57fbSAl Viro spin_lock(&sysctl_lock); 1890330d57fbSAl Viro start_unregistering(header); 1891ae7edeccSAl Viro if (!--header->parent->count) { 1892ae7edeccSAl Viro WARN_ON(1); 1893ae7edeccSAl Viro kfree(header->parent); 1894ae7edeccSAl Viro } 1895f7e6ced4SAl Viro if (!--header->count) 18961da177e4SLinus Torvalds kfree(header); 1897f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 18981da177e4SLinus Torvalds } 18991da177e4SLinus Torvalds 19009043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19019043476fSAl Viro { 19029043476fSAl Viro struct ctl_table_set *set = p->set; 19039043476fSAl Viro int res; 19049043476fSAl Viro spin_lock(&sysctl_lock); 19059043476fSAl Viro if (p->unregistering) 19069043476fSAl Viro res = 0; 19079043476fSAl Viro else if (!set->is_seen) 19089043476fSAl Viro res = 1; 19099043476fSAl Viro else 19109043476fSAl Viro res = set->is_seen(set); 19119043476fSAl Viro spin_unlock(&sysctl_lock); 19129043476fSAl Viro return res; 19139043476fSAl Viro } 19149043476fSAl Viro 191573455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 191673455092SAl Viro struct ctl_table_set *parent, 191773455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 191873455092SAl Viro { 191973455092SAl Viro INIT_LIST_HEAD(&p->list); 192073455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 192173455092SAl Viro p->is_seen = is_seen; 192273455092SAl Viro } 192373455092SAl Viro 1924b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 1925d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1926b89a8171SEric W. Biederman { 1927b89a8171SEric W. Biederman return NULL; 1928b89a8171SEric W. Biederman } 1929b89a8171SEric W. Biederman 193029e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 193129e796fdSEric W. Biederman struct ctl_table *table) 193229e796fdSEric W. Biederman { 193329e796fdSEric W. Biederman return NULL; 193429e796fdSEric W. Biederman } 193529e796fdSEric W. Biederman 1936b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 1937b89a8171SEric W. Biederman { 1938b89a8171SEric W. Biederman } 1939b89a8171SEric W. Biederman 194073455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 194173455092SAl Viro struct ctl_table_set *parent, 194273455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 194373455092SAl Viro { 194473455092SAl Viro } 194573455092SAl Viro 1946f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1947f7e6ced4SAl Viro { 1948f7e6ced4SAl Viro } 1949f7e6ced4SAl Viro 1950b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1951b89a8171SEric W. Biederman 19521da177e4SLinus Torvalds /* 19531da177e4SLinus Torvalds * /proc/sys support 19541da177e4SLinus Torvalds */ 19551da177e4SLinus Torvalds 1956b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 19571da177e4SLinus Torvalds 1958b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 19598d65af78SAlexey Dobriyan void __user *buffer, 1960b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1961f5dd3d6fSSam Vilain { 1962f5dd3d6fSSam Vilain size_t len; 1963f5dd3d6fSSam Vilain char __user *p; 1964f5dd3d6fSSam Vilain char c; 1965f5dd3d6fSSam Vilain 19668d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1967f5dd3d6fSSam Vilain *lenp = 0; 1968f5dd3d6fSSam Vilain return 0; 1969f5dd3d6fSSam Vilain } 1970f5dd3d6fSSam Vilain 1971f5dd3d6fSSam Vilain if (write) { 1972f5dd3d6fSSam Vilain len = 0; 1973f5dd3d6fSSam Vilain p = buffer; 1974f5dd3d6fSSam Vilain while (len < *lenp) { 1975f5dd3d6fSSam Vilain if (get_user(c, p++)) 1976f5dd3d6fSSam Vilain return -EFAULT; 1977f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1978f5dd3d6fSSam Vilain break; 1979f5dd3d6fSSam Vilain len++; 1980f5dd3d6fSSam Vilain } 1981f5dd3d6fSSam Vilain if (len >= maxlen) 1982f5dd3d6fSSam Vilain len = maxlen-1; 1983f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1984f5dd3d6fSSam Vilain return -EFAULT; 1985f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 1986f5dd3d6fSSam Vilain *ppos += *lenp; 1987f5dd3d6fSSam Vilain } else { 1988f5dd3d6fSSam Vilain len = strlen(data); 1989f5dd3d6fSSam Vilain if (len > maxlen) 1990f5dd3d6fSSam Vilain len = maxlen; 19918d060877SOleg Nesterov 19928d060877SOleg Nesterov if (*ppos > len) { 19938d060877SOleg Nesterov *lenp = 0; 19948d060877SOleg Nesterov return 0; 19958d060877SOleg Nesterov } 19968d060877SOleg Nesterov 19978d060877SOleg Nesterov data += *ppos; 19988d060877SOleg Nesterov len -= *ppos; 19998d060877SOleg Nesterov 2000f5dd3d6fSSam Vilain if (len > *lenp) 2001f5dd3d6fSSam Vilain len = *lenp; 2002f5dd3d6fSSam Vilain if (len) 2003f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2004f5dd3d6fSSam Vilain return -EFAULT; 2005f5dd3d6fSSam Vilain if (len < *lenp) { 2006f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2007f5dd3d6fSSam Vilain return -EFAULT; 2008f5dd3d6fSSam Vilain len++; 2009f5dd3d6fSSam Vilain } 2010f5dd3d6fSSam Vilain *lenp = len; 2011f5dd3d6fSSam Vilain *ppos += len; 2012f5dd3d6fSSam Vilain } 2013f5dd3d6fSSam Vilain return 0; 2014f5dd3d6fSSam Vilain } 2015f5dd3d6fSSam Vilain 20161da177e4SLinus Torvalds /** 20171da177e4SLinus Torvalds * proc_dostring - read a string sysctl 20181da177e4SLinus Torvalds * @table: the sysctl table 20191da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20201da177e4SLinus Torvalds * @buffer: the user buffer 20211da177e4SLinus Torvalds * @lenp: the size of the user buffer 20221da177e4SLinus Torvalds * @ppos: file position 20231da177e4SLinus Torvalds * 20241da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 20251da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 20261da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 20271da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 20281da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 20291da177e4SLinus Torvalds * not large enough. 20301da177e4SLinus Torvalds * 20311da177e4SLinus Torvalds * Returns 0 on success. 20321da177e4SLinus Torvalds */ 20338d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 20341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20351da177e4SLinus Torvalds { 20368d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2037f5dd3d6fSSam Vilain buffer, lenp, ppos); 20381da177e4SLinus Torvalds } 20391da177e4SLinus Torvalds 20401da177e4SLinus Torvalds 20411da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 20421da177e4SLinus Torvalds int *valp, 20431da177e4SLinus Torvalds int write, void *data) 20441da177e4SLinus Torvalds { 20451da177e4SLinus Torvalds if (write) { 20461da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 20471da177e4SLinus Torvalds } else { 20481da177e4SLinus Torvalds int val = *valp; 20491da177e4SLinus Torvalds if (val < 0) { 20501da177e4SLinus Torvalds *negp = -1; 20511da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 20521da177e4SLinus Torvalds } else { 20531da177e4SLinus Torvalds *negp = 0; 20541da177e4SLinus Torvalds *lvalp = (unsigned long)val; 20551da177e4SLinus Torvalds } 20561da177e4SLinus Torvalds } 20571da177e4SLinus Torvalds return 0; 20581da177e4SLinus Torvalds } 20591da177e4SLinus Torvalds 2060d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 20618d65af78SAlexey Dobriyan int write, void __user *buffer, 2062fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 20631da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 20641da177e4SLinus Torvalds int write, void *data), 20651da177e4SLinus Torvalds void *data) 20661da177e4SLinus Torvalds { 20671da177e4SLinus Torvalds #define TMPBUFLEN 21 20687338f299SSukanto Ghosh int *i, vleft, first = 1, neg; 20691da177e4SLinus Torvalds unsigned long lval; 20701da177e4SLinus Torvalds size_t left, len; 20711da177e4SLinus Torvalds 20721da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 20731da177e4SLinus Torvalds char __user *s = buffer; 20741da177e4SLinus Torvalds 2075fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 20761da177e4SLinus Torvalds (*ppos && !write)) { 20771da177e4SLinus Torvalds *lenp = 0; 20781da177e4SLinus Torvalds return 0; 20791da177e4SLinus Torvalds } 20801da177e4SLinus Torvalds 2081fcfbd547SKirill Korotaev i = (int *) tbl_data; 20821da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 20831da177e4SLinus Torvalds left = *lenp; 20841da177e4SLinus Torvalds 20851da177e4SLinus Torvalds if (!conv) 20861da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 20871da177e4SLinus Torvalds 20881da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 20891da177e4SLinus Torvalds if (write) { 20901da177e4SLinus Torvalds while (left) { 20911da177e4SLinus Torvalds char c; 20921da177e4SLinus Torvalds if (get_user(c, s)) 20931da177e4SLinus Torvalds return -EFAULT; 20941da177e4SLinus Torvalds if (!isspace(c)) 20951da177e4SLinus Torvalds break; 20961da177e4SLinus Torvalds left--; 20971da177e4SLinus Torvalds s++; 20981da177e4SLinus Torvalds } 20991da177e4SLinus Torvalds if (!left) 21001da177e4SLinus Torvalds break; 21011da177e4SLinus Torvalds neg = 0; 21021da177e4SLinus Torvalds len = left; 21031da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 21041da177e4SLinus Torvalds len = sizeof(buf) - 1; 21051da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 21061da177e4SLinus Torvalds return -EFAULT; 21071da177e4SLinus Torvalds buf[len] = 0; 21081da177e4SLinus Torvalds p = buf; 21091da177e4SLinus Torvalds if (*p == '-' && left > 1) { 21101da177e4SLinus Torvalds neg = 1; 2111bd9b0bacSBP, Praveen p++; 21121da177e4SLinus Torvalds } 21131da177e4SLinus Torvalds if (*p < '0' || *p > '9') 21141da177e4SLinus Torvalds break; 21151da177e4SLinus Torvalds 21161da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 21171da177e4SLinus Torvalds 21181da177e4SLinus Torvalds len = p-buf; 21191da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 21201da177e4SLinus Torvalds break; 21211da177e4SLinus Torvalds s += len; 21221da177e4SLinus Torvalds left -= len; 21231da177e4SLinus Torvalds 21241da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 21251da177e4SLinus Torvalds break; 21261da177e4SLinus Torvalds } else { 21271da177e4SLinus Torvalds p = buf; 21281da177e4SLinus Torvalds if (!first) 21291da177e4SLinus Torvalds *p++ = '\t'; 21301da177e4SLinus Torvalds 21311da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 21321da177e4SLinus Torvalds break; 21331da177e4SLinus Torvalds 21341da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 21351da177e4SLinus Torvalds len = strlen(buf); 21361da177e4SLinus Torvalds if (len > left) 21371da177e4SLinus Torvalds len = left; 21381da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 21391da177e4SLinus Torvalds return -EFAULT; 21401da177e4SLinus Torvalds left -= len; 21411da177e4SLinus Torvalds s += len; 21421da177e4SLinus Torvalds } 21431da177e4SLinus Torvalds } 21441da177e4SLinus Torvalds 21451da177e4SLinus Torvalds if (!write && !first && left) { 21461da177e4SLinus Torvalds if(put_user('\n', s)) 21471da177e4SLinus Torvalds return -EFAULT; 21481da177e4SLinus Torvalds left--, s++; 21491da177e4SLinus Torvalds } 21501da177e4SLinus Torvalds if (write) { 21511da177e4SLinus Torvalds while (left) { 21521da177e4SLinus Torvalds char c; 21531da177e4SLinus Torvalds if (get_user(c, s++)) 21541da177e4SLinus Torvalds return -EFAULT; 21551da177e4SLinus Torvalds if (!isspace(c)) 21561da177e4SLinus Torvalds break; 21571da177e4SLinus Torvalds left--; 21581da177e4SLinus Torvalds } 21591da177e4SLinus Torvalds } 21601da177e4SLinus Torvalds if (write && first) 21611da177e4SLinus Torvalds return -EINVAL; 21621da177e4SLinus Torvalds *lenp -= left; 21631da177e4SLinus Torvalds *ppos += *lenp; 21641da177e4SLinus Torvalds return 0; 21651da177e4SLinus Torvalds #undef TMPBUFLEN 21661da177e4SLinus Torvalds } 21671da177e4SLinus Torvalds 21688d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2169fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2170fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2171fcfbd547SKirill Korotaev int write, void *data), 2172fcfbd547SKirill Korotaev void *data) 2173fcfbd547SKirill Korotaev { 21748d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2175fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2176fcfbd547SKirill Korotaev } 2177fcfbd547SKirill Korotaev 21781da177e4SLinus Torvalds /** 21791da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 21801da177e4SLinus Torvalds * @table: the sysctl table 21811da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21821da177e4SLinus Torvalds * @buffer: the user buffer 21831da177e4SLinus Torvalds * @lenp: the size of the user buffer 21841da177e4SLinus Torvalds * @ppos: file position 21851da177e4SLinus Torvalds * 21861da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 21871da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 21881da177e4SLinus Torvalds * 21891da177e4SLinus Torvalds * Returns 0 on success. 21901da177e4SLinus Torvalds */ 21918d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 21921da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21931da177e4SLinus Torvalds { 21948d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 21951da177e4SLinus Torvalds NULL,NULL); 21961da177e4SLinus Torvalds } 21971da177e4SLinus Torvalds 219834f5a398STheodore Ts'o /* 219934f5a398STheodore Ts'o * Taint values can only be increased 220025ddbb18SAndi Kleen * This means we can safely use a temporary. 220134f5a398STheodore Ts'o */ 22028d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 220334f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 220434f5a398STheodore Ts'o { 220525ddbb18SAndi Kleen struct ctl_table t; 220625ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 220725ddbb18SAndi Kleen int err; 220834f5a398STheodore Ts'o 220991fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 221034f5a398STheodore Ts'o return -EPERM; 221134f5a398STheodore Ts'o 221225ddbb18SAndi Kleen t = *table; 221325ddbb18SAndi Kleen t.data = &tmptaint; 22148d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 221525ddbb18SAndi Kleen if (err < 0) 221625ddbb18SAndi Kleen return err; 221725ddbb18SAndi Kleen 221825ddbb18SAndi Kleen if (write) { 221925ddbb18SAndi Kleen /* 222025ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 222125ddbb18SAndi Kleen * to everyone's atomic.h for this 222225ddbb18SAndi Kleen */ 222325ddbb18SAndi Kleen int i; 222425ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 222525ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 222625ddbb18SAndi Kleen add_taint(i); 222725ddbb18SAndi Kleen } 222825ddbb18SAndi Kleen } 222925ddbb18SAndi Kleen 223025ddbb18SAndi Kleen return err; 223134f5a398STheodore Ts'o } 223234f5a398STheodore Ts'o 22331da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 22341da177e4SLinus Torvalds int *min; 22351da177e4SLinus Torvalds int *max; 22361da177e4SLinus Torvalds }; 22371da177e4SLinus Torvalds 22381da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 22391da177e4SLinus Torvalds int *valp, 22401da177e4SLinus Torvalds int write, void *data) 22411da177e4SLinus Torvalds { 22421da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 22431da177e4SLinus Torvalds if (write) { 22441da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 22451da177e4SLinus Torvalds if ((param->min && *param->min > val) || 22461da177e4SLinus Torvalds (param->max && *param->max < val)) 22471da177e4SLinus Torvalds return -EINVAL; 22481da177e4SLinus Torvalds *valp = val; 22491da177e4SLinus Torvalds } else { 22501da177e4SLinus Torvalds int val = *valp; 22511da177e4SLinus Torvalds if (val < 0) { 22521da177e4SLinus Torvalds *negp = -1; 22531da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22541da177e4SLinus Torvalds } else { 22551da177e4SLinus Torvalds *negp = 0; 22561da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22571da177e4SLinus Torvalds } 22581da177e4SLinus Torvalds } 22591da177e4SLinus Torvalds return 0; 22601da177e4SLinus Torvalds } 22611da177e4SLinus Torvalds 22621da177e4SLinus Torvalds /** 22631da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 22641da177e4SLinus Torvalds * @table: the sysctl table 22651da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22661da177e4SLinus Torvalds * @buffer: the user buffer 22671da177e4SLinus Torvalds * @lenp: the size of the user buffer 22681da177e4SLinus Torvalds * @ppos: file position 22691da177e4SLinus Torvalds * 22701da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22711da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22721da177e4SLinus Torvalds * 22731da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 22741da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 22751da177e4SLinus Torvalds * 22761da177e4SLinus Torvalds * Returns 0 on success. 22771da177e4SLinus Torvalds */ 22788d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 22791da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22801da177e4SLinus Torvalds { 22811da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 22821da177e4SLinus Torvalds .min = (int *) table->extra1, 22831da177e4SLinus Torvalds .max = (int *) table->extra2, 22841da177e4SLinus Torvalds }; 22858d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 22861da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 22871da177e4SLinus Torvalds } 22881da177e4SLinus Torvalds 2289d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 22901da177e4SLinus Torvalds void __user *buffer, 22911da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 22921da177e4SLinus Torvalds unsigned long convmul, 22931da177e4SLinus Torvalds unsigned long convdiv) 22941da177e4SLinus Torvalds { 22951da177e4SLinus Torvalds #define TMPBUFLEN 21 22961da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 22971da177e4SLinus Torvalds int vleft, first=1, neg; 22981da177e4SLinus Torvalds size_t len, left; 22991da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 23001da177e4SLinus Torvalds char __user *s = buffer; 23011da177e4SLinus Torvalds 2302fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 23031da177e4SLinus Torvalds (*ppos && !write)) { 23041da177e4SLinus Torvalds *lenp = 0; 23051da177e4SLinus Torvalds return 0; 23061da177e4SLinus Torvalds } 23071da177e4SLinus Torvalds 2308fcfbd547SKirill Korotaev i = (unsigned long *) data; 23091da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 23101da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 23111da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 23121da177e4SLinus Torvalds left = *lenp; 23131da177e4SLinus Torvalds 23141da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 23151da177e4SLinus Torvalds if (write) { 23161da177e4SLinus Torvalds while (left) { 23171da177e4SLinus Torvalds char c; 23181da177e4SLinus Torvalds if (get_user(c, s)) 23191da177e4SLinus Torvalds return -EFAULT; 23201da177e4SLinus Torvalds if (!isspace(c)) 23211da177e4SLinus Torvalds break; 23221da177e4SLinus Torvalds left--; 23231da177e4SLinus Torvalds s++; 23241da177e4SLinus Torvalds } 23251da177e4SLinus Torvalds if (!left) 23261da177e4SLinus Torvalds break; 23271da177e4SLinus Torvalds neg = 0; 23281da177e4SLinus Torvalds len = left; 23291da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 23301da177e4SLinus Torvalds len = TMPBUFLEN-1; 23311da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 23321da177e4SLinus Torvalds return -EFAULT; 23331da177e4SLinus Torvalds buf[len] = 0; 23341da177e4SLinus Torvalds p = buf; 23351da177e4SLinus Torvalds if (*p == '-' && left > 1) { 23361da177e4SLinus Torvalds neg = 1; 2337bd9b0bacSBP, Praveen p++; 23381da177e4SLinus Torvalds } 23391da177e4SLinus Torvalds if (*p < '0' || *p > '9') 23401da177e4SLinus Torvalds break; 23411da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 23421da177e4SLinus Torvalds len = p-buf; 23431da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 23441da177e4SLinus Torvalds break; 23451da177e4SLinus Torvalds if (neg) 23461da177e4SLinus Torvalds val = -val; 23471da177e4SLinus Torvalds s += len; 23481da177e4SLinus Torvalds left -= len; 23491da177e4SLinus Torvalds 23501da177e4SLinus Torvalds if(neg) 23511da177e4SLinus Torvalds continue; 23521da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 23531da177e4SLinus Torvalds continue; 23541da177e4SLinus Torvalds *i = val; 23551da177e4SLinus Torvalds } else { 23561da177e4SLinus Torvalds p = buf; 23571da177e4SLinus Torvalds if (!first) 23581da177e4SLinus Torvalds *p++ = '\t'; 23591da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 23601da177e4SLinus Torvalds len = strlen(buf); 23611da177e4SLinus Torvalds if (len > left) 23621da177e4SLinus Torvalds len = left; 23631da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 23641da177e4SLinus Torvalds return -EFAULT; 23651da177e4SLinus Torvalds left -= len; 23661da177e4SLinus Torvalds s += len; 23671da177e4SLinus Torvalds } 23681da177e4SLinus Torvalds } 23691da177e4SLinus Torvalds 23701da177e4SLinus Torvalds if (!write && !first && left) { 23711da177e4SLinus Torvalds if(put_user('\n', s)) 23721da177e4SLinus Torvalds return -EFAULT; 23731da177e4SLinus Torvalds left--, s++; 23741da177e4SLinus Torvalds } 23751da177e4SLinus Torvalds if (write) { 23761da177e4SLinus Torvalds while (left) { 23771da177e4SLinus Torvalds char c; 23781da177e4SLinus Torvalds if (get_user(c, s++)) 23791da177e4SLinus Torvalds return -EFAULT; 23801da177e4SLinus Torvalds if (!isspace(c)) 23811da177e4SLinus Torvalds break; 23821da177e4SLinus Torvalds left--; 23831da177e4SLinus Torvalds } 23841da177e4SLinus Torvalds } 23851da177e4SLinus Torvalds if (write && first) 23861da177e4SLinus Torvalds return -EINVAL; 23871da177e4SLinus Torvalds *lenp -= left; 23881da177e4SLinus Torvalds *ppos += *lenp; 23891da177e4SLinus Torvalds return 0; 23901da177e4SLinus Torvalds #undef TMPBUFLEN 23911da177e4SLinus Torvalds } 23921da177e4SLinus Torvalds 2393d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2394fcfbd547SKirill Korotaev void __user *buffer, 2395fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2396fcfbd547SKirill Korotaev unsigned long convmul, 2397fcfbd547SKirill Korotaev unsigned long convdiv) 2398fcfbd547SKirill Korotaev { 2399fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 24008d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2401fcfbd547SKirill Korotaev } 2402fcfbd547SKirill Korotaev 24031da177e4SLinus Torvalds /** 24041da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 24051da177e4SLinus Torvalds * @table: the sysctl table 24061da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24071da177e4SLinus Torvalds * @buffer: the user buffer 24081da177e4SLinus Torvalds * @lenp: the size of the user buffer 24091da177e4SLinus Torvalds * @ppos: file position 24101da177e4SLinus Torvalds * 24111da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24121da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24131da177e4SLinus Torvalds * 24141da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24151da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24161da177e4SLinus Torvalds * 24171da177e4SLinus Torvalds * Returns 0 on success. 24181da177e4SLinus Torvalds */ 24198d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 24201da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24211da177e4SLinus Torvalds { 24228d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 24231da177e4SLinus Torvalds } 24241da177e4SLinus Torvalds 24251da177e4SLinus Torvalds /** 24261da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 24271da177e4SLinus Torvalds * @table: the sysctl table 24281da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24291da177e4SLinus Torvalds * @buffer: the user buffer 24301da177e4SLinus Torvalds * @lenp: the size of the user buffer 24311da177e4SLinus Torvalds * @ppos: file position 24321da177e4SLinus Torvalds * 24331da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24341da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 24351da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 24361da177e4SLinus Torvalds * 24371da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24381da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24391da177e4SLinus Torvalds * 24401da177e4SLinus Torvalds * Returns 0 on success. 24411da177e4SLinus Torvalds */ 2442d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 24431da177e4SLinus Torvalds void __user *buffer, 24441da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 24451da177e4SLinus Torvalds { 24468d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 24471da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 24481da177e4SLinus Torvalds } 24491da177e4SLinus Torvalds 24501da177e4SLinus Torvalds 24511da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 24521da177e4SLinus Torvalds int *valp, 24531da177e4SLinus Torvalds int write, void *data) 24541da177e4SLinus Torvalds { 24551da177e4SLinus Torvalds if (write) { 2456cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2457cba9f33dSBart Samwel return 1; 24581da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 24591da177e4SLinus Torvalds } else { 24601da177e4SLinus Torvalds int val = *valp; 24611da177e4SLinus Torvalds unsigned long lval; 24621da177e4SLinus Torvalds if (val < 0) { 24631da177e4SLinus Torvalds *negp = -1; 24641da177e4SLinus Torvalds lval = (unsigned long)-val; 24651da177e4SLinus Torvalds } else { 24661da177e4SLinus Torvalds *negp = 0; 24671da177e4SLinus Torvalds lval = (unsigned long)val; 24681da177e4SLinus Torvalds } 24691da177e4SLinus Torvalds *lvalp = lval / HZ; 24701da177e4SLinus Torvalds } 24711da177e4SLinus Torvalds return 0; 24721da177e4SLinus Torvalds } 24731da177e4SLinus Torvalds 24741da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 24751da177e4SLinus Torvalds int *valp, 24761da177e4SLinus Torvalds int write, void *data) 24771da177e4SLinus Torvalds { 24781da177e4SLinus Torvalds if (write) { 2479cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2480cba9f33dSBart Samwel return 1; 24811da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 24821da177e4SLinus Torvalds } else { 24831da177e4SLinus Torvalds int val = *valp; 24841da177e4SLinus Torvalds unsigned long lval; 24851da177e4SLinus Torvalds if (val < 0) { 24861da177e4SLinus Torvalds *negp = -1; 24871da177e4SLinus Torvalds lval = (unsigned long)-val; 24881da177e4SLinus Torvalds } else { 24891da177e4SLinus Torvalds *negp = 0; 24901da177e4SLinus Torvalds lval = (unsigned long)val; 24911da177e4SLinus Torvalds } 24921da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 24931da177e4SLinus Torvalds } 24941da177e4SLinus Torvalds return 0; 24951da177e4SLinus Torvalds } 24961da177e4SLinus Torvalds 24971da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 24981da177e4SLinus Torvalds int *valp, 24991da177e4SLinus Torvalds int write, void *data) 25001da177e4SLinus Torvalds { 25011da177e4SLinus Torvalds if (write) { 25021da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 25031da177e4SLinus Torvalds } else { 25041da177e4SLinus Torvalds int val = *valp; 25051da177e4SLinus Torvalds unsigned long lval; 25061da177e4SLinus Torvalds if (val < 0) { 25071da177e4SLinus Torvalds *negp = -1; 25081da177e4SLinus Torvalds lval = (unsigned long)-val; 25091da177e4SLinus Torvalds } else { 25101da177e4SLinus Torvalds *negp = 0; 25111da177e4SLinus Torvalds lval = (unsigned long)val; 25121da177e4SLinus Torvalds } 25131da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 25141da177e4SLinus Torvalds } 25151da177e4SLinus Torvalds return 0; 25161da177e4SLinus Torvalds } 25171da177e4SLinus Torvalds 25181da177e4SLinus Torvalds /** 25191da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 25201da177e4SLinus Torvalds * @table: the sysctl table 25211da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25221da177e4SLinus Torvalds * @buffer: the user buffer 25231da177e4SLinus Torvalds * @lenp: the size of the user buffer 25241da177e4SLinus Torvalds * @ppos: file position 25251da177e4SLinus Torvalds * 25261da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25271da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25281da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 25291da177e4SLinus Torvalds * jiffies. 25301da177e4SLinus Torvalds * 25311da177e4SLinus Torvalds * Returns 0 on success. 25321da177e4SLinus Torvalds */ 25338d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 25341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25351da177e4SLinus Torvalds { 25368d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 25371da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 25381da177e4SLinus Torvalds } 25391da177e4SLinus Torvalds 25401da177e4SLinus Torvalds /** 25411da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 25421da177e4SLinus Torvalds * @table: the sysctl table 25431da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25441da177e4SLinus Torvalds * @buffer: the user buffer 25451da177e4SLinus Torvalds * @lenp: the size of the user buffer 25461e5d5331SRandy Dunlap * @ppos: pointer to the file position 25471da177e4SLinus Torvalds * 25481da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25491da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25501da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 25511da177e4SLinus Torvalds * are converted into jiffies. 25521da177e4SLinus Torvalds * 25531da177e4SLinus Torvalds * Returns 0 on success. 25541da177e4SLinus Torvalds */ 25558d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 25561da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25571da177e4SLinus Torvalds { 25588d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 25591da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 25601da177e4SLinus Torvalds } 25611da177e4SLinus Torvalds 25621da177e4SLinus Torvalds /** 25631da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 25641da177e4SLinus Torvalds * @table: the sysctl table 25651da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25661da177e4SLinus Torvalds * @buffer: the user buffer 25671da177e4SLinus Torvalds * @lenp: the size of the user buffer 256867be2dd1SMartin Waitz * @ppos: file position 256967be2dd1SMartin Waitz * @ppos: the current position in the file 25701da177e4SLinus Torvalds * 25711da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25721da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25731da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 25741da177e4SLinus Torvalds * are converted into jiffies. 25751da177e4SLinus Torvalds * 25761da177e4SLinus Torvalds * Returns 0 on success. 25771da177e4SLinus Torvalds */ 25788d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 25791da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25801da177e4SLinus Torvalds { 25818d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 25821da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 25831da177e4SLinus Torvalds } 25841da177e4SLinus Torvalds 25858d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 25869ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 25879ec52099SCedric Le Goater { 25889ec52099SCedric Le Goater struct pid *new_pid; 25899ec52099SCedric Le Goater pid_t tmp; 25909ec52099SCedric Le Goater int r; 25919ec52099SCedric Le Goater 25926c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 25939ec52099SCedric Le Goater 25948d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 25959ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 25969ec52099SCedric Le Goater if (r || !write) 25979ec52099SCedric Le Goater return r; 25989ec52099SCedric Le Goater 25999ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 26009ec52099SCedric Le Goater if (!new_pid) 26019ec52099SCedric Le Goater return -ESRCH; 26029ec52099SCedric Le Goater 26039ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 26049ec52099SCedric Le Goater return 0; 26059ec52099SCedric Le Goater } 26069ec52099SCedric Le Goater 26071da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 26081da177e4SLinus Torvalds 26098d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 26101da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26111da177e4SLinus Torvalds { 26121da177e4SLinus Torvalds return -ENOSYS; 26131da177e4SLinus Torvalds } 26141da177e4SLinus Torvalds 26158d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 26161da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26171da177e4SLinus Torvalds { 26181da177e4SLinus Torvalds return -ENOSYS; 26191da177e4SLinus Torvalds } 26201da177e4SLinus Torvalds 26218d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 26221da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26231da177e4SLinus Torvalds { 26241da177e4SLinus Torvalds return -ENOSYS; 26251da177e4SLinus Torvalds } 26261da177e4SLinus Torvalds 26278d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 26281da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26291da177e4SLinus Torvalds { 26301da177e4SLinus Torvalds return -ENOSYS; 26311da177e4SLinus Torvalds } 26321da177e4SLinus Torvalds 26338d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 26341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26351da177e4SLinus Torvalds { 26361da177e4SLinus Torvalds return -ENOSYS; 26371da177e4SLinus Torvalds } 26381da177e4SLinus Torvalds 26398d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 26401da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26411da177e4SLinus Torvalds { 26421da177e4SLinus Torvalds return -ENOSYS; 26431da177e4SLinus Torvalds } 26441da177e4SLinus Torvalds 26458d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 26461da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26471da177e4SLinus Torvalds { 26481da177e4SLinus Torvalds return -ENOSYS; 26491da177e4SLinus Torvalds } 26501da177e4SLinus Torvalds 2651d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26521da177e4SLinus Torvalds void __user *buffer, 26531da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26541da177e4SLinus Torvalds { 26551da177e4SLinus Torvalds return -ENOSYS; 26561da177e4SLinus Torvalds } 26571da177e4SLinus Torvalds 26581da177e4SLinus Torvalds 26591da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 26601da177e4SLinus Torvalds 26611da177e4SLinus Torvalds /* 26621da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 26631da177e4SLinus Torvalds * exception granted :-) 26641da177e4SLinus Torvalds */ 26651da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 26661da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 26671da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 26681da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 26691da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 26701da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 26711da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 26721da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 26731da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 267429e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 26751da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2676