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> 301da177e4SLinus Torvalds #include <linux/smp_lock.h> 3162239ac2SAdrian Bunk #include <linux/fs.h> 321da177e4SLinus Torvalds #include <linux/init.h> 331da177e4SLinus Torvalds #include <linux/kernel.h> 340296b228SKay Sievers #include <linux/kobject.h> 3520380731SArnaldo Carvalho de Melo #include <linux/net.h> 361da177e4SLinus Torvalds #include <linux/sysrq.h> 371da177e4SLinus Torvalds #include <linux/highuid.h> 381da177e4SLinus Torvalds #include <linux/writeback.h> 393fff4c42SIngo Molnar #include <linux/ratelimit.h> 401da177e4SLinus Torvalds #include <linux/hugetlb.h> 411da177e4SLinus Torvalds #include <linux/initrd.h> 420b77f5bfSDavid Howells #include <linux/key.h> 431da177e4SLinus Torvalds #include <linux/times.h> 441da177e4SLinus Torvalds #include <linux/limits.h> 451da177e4SLinus Torvalds #include <linux/dcache.h> 461da177e4SLinus Torvalds #include <linux/syscalls.h> 47c748e134SAdrian Bunk #include <linux/vmstat.h> 48c255d844SPavel Machek #include <linux/nfs_fs.h> 49c255d844SPavel Machek #include <linux/acpi.h> 5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 51b0fc494fSSteven Rostedt #include <linux/ftrace.h> 5212e22c5eSDavid Howells #include <linux/slow-work.h> 53cdd6c482SIngo Molnar #include <linux/perf_event.h> 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds #include <asm/uaccess.h> 561da177e4SLinus Torvalds #include <asm/processor.h> 571da177e4SLinus Torvalds 5829cbc78bSAndi Kleen #ifdef CONFIG_X86 5929cbc78bSAndi Kleen #include <asm/nmi.h> 600741f4d2SChuck Ebbert #include <asm/stacktrace.h> 616e7c4025SIngo Molnar #include <asm/io.h> 6229cbc78bSAndi Kleen #endif 6329cbc78bSAndi Kleen 647058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args); 657058cb02SEric W. Biederman 661da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds /* External variables not in a header file. */ 691da177e4SLinus Torvalds extern int C_A_D; 7045807a1dSIngo Molnar extern int print_fatal_signals; 711da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 721da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 73fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom; 74fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task; 75fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks; 761da177e4SLinus Torvalds extern int max_threads; 771da177e4SLinus Torvalds extern int core_uses_pid; 78d6e71144SAlan Cox extern int suid_dumpable; 791da177e4SLinus Torvalds extern char core_pattern[]; 80a293980cSNeil Horman extern unsigned int core_pipe_limit; 811da177e4SLinus Torvalds extern int pid_max; 821da177e4SLinus Torvalds extern int min_free_kbytes; 831da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 849d0243bcSAndrew Morton extern int sysctl_drop_caches; 858ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 86bebfa101SAndi Kleen extern int compat_log; 879745512cSArjan van de Ven extern int latencytop_enabled; 88eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 89dd8632a1SPaul Mundt #ifndef CONFIG_MMU 90dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 91dd8632a1SPaul Mundt #endif 9231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 9331a72bceSPaul E. McKenney extern int rcutorture_runnable; 9431a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 95cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 965e605b64SJens Axboe extern int blk_iopoll_enabled; 97cb684b5bSJens Axboe #endif 981da177e4SLinus Torvalds 99c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 100195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 101c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1029383d967SDimitri Sivanich static int neg_one = -1; 103c4f3b63fSRavikiran G Thirumalai #endif 104c4f3b63fSRavikiran G Thirumalai 105c4f3b63fSRavikiran G Thirumalai static int zero; 106cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 107cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 108fc3501d4SSven Wegener static unsigned long one_ul = 1; 109c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 110af91322eSDave Young #ifdef CONFIG_PRINTK 111af91322eSDave Young static int ten_thousand = 10000; 112af91322eSDave Young #endif 113c4f3b63fSRavikiran G Thirumalai 1149e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1159e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1169e4a5bdaSAndrea Righi 1171da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1181da177e4SLinus Torvalds static int maxolduid = 65535; 1191da177e4SLinus Torvalds static int minolduid; 1208ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1211da177e4SLinus Torvalds 1221da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1231da177e4SLinus Torvalds 124a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 1251da177e4SLinus Torvalds extern char modprobe_path[]; 1263d43321bSKees Cook extern int modules_disabled; 1271da177e4SLinus Torvalds #endif 1281da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 1291da177e4SLinus Torvalds extern int sg_big_buff; 1301da177e4SLinus Torvalds #endif 1311da177e4SLinus Torvalds 13272c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 13317f04fbbSDavid S. Miller #include <asm/system.h> 1341da177e4SLinus Torvalds #endif 1351da177e4SLinus Torvalds 1360871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1370871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1380871420fSDavid S. Miller #endif 1390871420fSDavid S. Miller 1401da177e4SLinus Torvalds #ifdef __hppa__ 1411da177e4SLinus Torvalds extern int pwrsw_enabled; 1421da177e4SLinus Torvalds extern int unaligned_enabled; 1431da177e4SLinus Torvalds #endif 1441da177e4SLinus Torvalds 145347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1461da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1471da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1481da177e4SLinus Torvalds #endif 1491da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 150951f22d5SMartin Schwidefsky extern int spin_retry; 1511da177e4SLinus Torvalds #endif 1521da177e4SLinus Torvalds 1531da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1541da177e4SLinus Torvalds extern int acct_parm[]; 1551da177e4SLinus Torvalds #endif 1561da177e4SLinus Torvalds 157d2b176edSJes Sorensen #ifdef CONFIG_IA64 158d2b176edSJes Sorensen extern int no_unaligned_warning; 15988fc241fSDoug Chapman extern int unaligned_dump_stack; 160d2b176edSJes Sorensen #endif 161d2b176edSJes Sorensen 1623fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state; 1633fff4c42SIngo Molnar 16423f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 16523f78d4aSIngo Molnar extern int max_lock_depth; 16623f78d4aSIngo Molnar #endif 16723f78d4aSIngo Molnar 168d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1698d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1709ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1718d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 17234f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 173d6f8ff73SRandy Dunlap #endif 1749ec52099SCedric Le Goater 175d8217f07SEric W. Biederman static struct ctl_table root_table[]; 176e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 177e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 178b380b0d4SAl Viro .count = 1, 179e51b6ba0SEric W. Biederman .ctl_table = root_table, 18073455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 181e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 18273455092SAl Viro .set = &sysctl_table_root.default_set, 183e51b6ba0SEric W. Biederman }; 184e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 185e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 18673455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 187e51b6ba0SEric W. Biederman }; 1881da177e4SLinus Torvalds 189d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 190d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 191d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 192d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 193d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 194d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1952d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 196d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1970399cb08SRobert Love #endif 1987ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 1997ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 2007ef9964eSDavide Libenzi #endif 2011da177e4SLinus Torvalds 2021da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2031da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2041da177e4SLinus Torvalds #endif 2051da177e4SLinus Torvalds 206f20786ffSPeter Zijlstra extern int prove_locking; 207f20786ffSPeter Zijlstra extern int lock_stat; 2089bc9a6bdSEric W. Biederman 2091da177e4SLinus Torvalds /* The default sysctl tables: */ 2101da177e4SLinus Torvalds 211d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2121da177e4SLinus Torvalds { 2131da177e4SLinus Torvalds .ctl_name = CTL_KERN, 2141da177e4SLinus Torvalds .procname = "kernel", 2151da177e4SLinus Torvalds .mode = 0555, 2161da177e4SLinus Torvalds .child = kern_table, 2171da177e4SLinus Torvalds }, 2181da177e4SLinus Torvalds { 2191da177e4SLinus Torvalds .ctl_name = CTL_VM, 2201da177e4SLinus Torvalds .procname = "vm", 2211da177e4SLinus Torvalds .mode = 0555, 2221da177e4SLinus Torvalds .child = vm_table, 2231da177e4SLinus Torvalds }, 2241da177e4SLinus Torvalds { 2251da177e4SLinus Torvalds .ctl_name = CTL_FS, 2261da177e4SLinus Torvalds .procname = "fs", 2271da177e4SLinus Torvalds .mode = 0555, 2281da177e4SLinus Torvalds .child = fs_table, 2291da177e4SLinus Torvalds }, 2301da177e4SLinus Torvalds { 2311da177e4SLinus Torvalds .ctl_name = CTL_DEBUG, 2321da177e4SLinus Torvalds .procname = "debug", 2331da177e4SLinus Torvalds .mode = 0555, 2341da177e4SLinus Torvalds .child = debug_table, 2351da177e4SLinus Torvalds }, 2361da177e4SLinus Torvalds { 2371da177e4SLinus Torvalds .ctl_name = CTL_DEV, 2381da177e4SLinus Torvalds .procname = "dev", 2391da177e4SLinus Torvalds .mode = 0555, 2401da177e4SLinus Torvalds .child = dev_table, 2411da177e4SLinus Torvalds }, 2422be7fe07SAndrew Morton /* 2432be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2442be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2452be7fe07SAndrew Morton */ 2461da177e4SLinus Torvalds { .ctl_name = 0 } 2471da177e4SLinus Torvalds }; 2481da177e4SLinus Torvalds 24977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 25073c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 25173c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 25273c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 25373c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 254*1983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 255*1983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 25677e54a1fSIngo Molnar #endif 25777e54a1fSIngo Molnar 258d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2592bba22c5SMike Galbraith { 2602bba22c5SMike Galbraith .ctl_name = CTL_UNNUMBERED, 2612bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2622bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2632bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2642bba22c5SMike Galbraith .mode = 0644, 2652bba22c5SMike Galbraith .proc_handler = &proc_dointvec, 2662bba22c5SMike Galbraith }, 26777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 26877e54a1fSIngo Molnar { 26977e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 270b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 271b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 27277e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 27377e54a1fSIngo Molnar .mode = 0644, 274b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 275b2be5e96SPeter Zijlstra .strategy = &sysctl_intvec, 276b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 277b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 27877e54a1fSIngo Molnar }, 27977e54a1fSIngo Molnar { 28077e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 28121805085SPeter Zijlstra .procname = "sched_latency_ns", 28221805085SPeter Zijlstra .data = &sysctl_sched_latency, 28321805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 28421805085SPeter Zijlstra .mode = 0644, 285b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 28621805085SPeter Zijlstra .strategy = &sysctl_intvec, 28721805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 28821805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28921805085SPeter Zijlstra }, 29021805085SPeter Zijlstra { 29121805085SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 29277e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 29377e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 29477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 29577e54a1fSIngo Molnar .mode = 0644, 29677e54a1fSIngo Molnar .proc_handler = &proc_dointvec_minmax, 29777e54a1fSIngo Molnar .strategy = &sysctl_intvec, 29877e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 29977e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 30077e54a1fSIngo Molnar }, 30177e54a1fSIngo Molnar { 30277e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 3032398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 3042398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 3052398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 3062398f2c6SPeter Zijlstra .mode = 0644, 3072398f2c6SPeter Zijlstra .proc_handler = &proc_dointvec, 3082398f2c6SPeter Zijlstra }, 3092398f2c6SPeter Zijlstra { 3102398f2c6SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 311*1983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 312*1983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 313*1983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 314*1983a922SChristian Ehrhardt .mode = 0644, 315*1983a922SChristian Ehrhardt .proc_handler = &proc_dointvec_minmax, 316*1983a922SChristian Ehrhardt .strategy = &sysctl_intvec, 317*1983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 318*1983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 319*1983a922SChristian Ehrhardt }, 320*1983a922SChristian Ehrhardt 321*1983a922SChristian Ehrhardt { 322*1983a922SChristian Ehrhardt .ctl_name = CTL_UNNUMBERED, 323ffda12a1SPeter Zijlstra .procname = "sched_shares_thresh", 324ffda12a1SPeter Zijlstra .data = &sysctl_sched_shares_thresh, 325ffda12a1SPeter Zijlstra .maxlen = sizeof(unsigned int), 326ffda12a1SPeter Zijlstra .mode = 0644, 327ffda12a1SPeter Zijlstra .proc_handler = &proc_dointvec_minmax, 328ffda12a1SPeter Zijlstra .strategy = &sysctl_intvec, 329ffda12a1SPeter Zijlstra .extra1 = &zero, 330ffda12a1SPeter Zijlstra }, 331ffda12a1SPeter Zijlstra { 332ffda12a1SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 333da84d961SIngo Molnar .procname = "sched_migration_cost", 334da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 335da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 336da84d961SIngo Molnar .mode = 0644, 337da84d961SIngo Molnar .proc_handler = &proc_dointvec, 338da84d961SIngo Molnar }, 339b82d9fddSPeter Zijlstra { 340b82d9fddSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 341b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 342b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 343b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 344fa85ae24SPeter Zijlstra .mode = 0644, 345fa85ae24SPeter Zijlstra .proc_handler = &proc_dointvec, 346fa85ae24SPeter Zijlstra }, 347cd1bb94bSArun R Bharadwaj { 348cd1bb94bSArun R Bharadwaj .ctl_name = CTL_UNNUMBERED, 349e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 350e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 351e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 352e9e9250bSPeter Zijlstra .mode = 0644, 353e9e9250bSPeter Zijlstra .proc_handler = &proc_dointvec, 354e9e9250bSPeter Zijlstra }, 355e9e9250bSPeter Zijlstra { 356e9e9250bSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 357cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 358cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 359cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 360cd1bb94bSArun R Bharadwaj .mode = 0644, 361bfdb4d9fSArun R Bharadwaj .proc_handler = &proc_dointvec_minmax, 362bfdb4d9fSArun R Bharadwaj .strategy = &sysctl_intvec, 363bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 364bfdb4d9fSArun R Bharadwaj .extra2 = &one, 365cd1bb94bSArun R Bharadwaj }, 3661fc84aaaSPeter Zijlstra #endif 3671799e35dSIngo Molnar { 3681799e35dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 3699f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3709f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3719f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3729f0c1e56SPeter Zijlstra .mode = 0644, 373d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3749f0c1e56SPeter Zijlstra }, 3759f0c1e56SPeter Zijlstra { 3769f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3779f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3789f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3799f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3809f0c1e56SPeter Zijlstra .mode = 0644, 381d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3829f0c1e56SPeter Zijlstra }, 3839f0c1e56SPeter Zijlstra { 3849f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3851799e35dSIngo Molnar .procname = "sched_compat_yield", 3861799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3871799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3881799e35dSIngo Molnar .mode = 0644, 3891799e35dSIngo Molnar .proc_handler = &proc_dointvec, 3901799e35dSIngo Molnar }, 391f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 392f20786ffSPeter Zijlstra { 393f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 394f20786ffSPeter Zijlstra .procname = "prove_locking", 395f20786ffSPeter Zijlstra .data = &prove_locking, 396f20786ffSPeter Zijlstra .maxlen = sizeof(int), 397f20786ffSPeter Zijlstra .mode = 0644, 398f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 399f20786ffSPeter Zijlstra }, 400f20786ffSPeter Zijlstra #endif 401f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 402f20786ffSPeter Zijlstra { 403f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 404f20786ffSPeter Zijlstra .procname = "lock_stat", 405f20786ffSPeter Zijlstra .data = &lock_stat, 406f20786ffSPeter Zijlstra .maxlen = sizeof(int), 407f20786ffSPeter Zijlstra .mode = 0644, 408f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 409f20786ffSPeter Zijlstra }, 410f20786ffSPeter Zijlstra #endif 41177e54a1fSIngo Molnar { 4121da177e4SLinus Torvalds .ctl_name = KERN_PANIC, 4131da177e4SLinus Torvalds .procname = "panic", 4141da177e4SLinus Torvalds .data = &panic_timeout, 4151da177e4SLinus Torvalds .maxlen = sizeof(int), 4161da177e4SLinus Torvalds .mode = 0644, 4171da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4181da177e4SLinus Torvalds }, 4191da177e4SLinus Torvalds { 4201da177e4SLinus Torvalds .ctl_name = KERN_CORE_USES_PID, 4211da177e4SLinus Torvalds .procname = "core_uses_pid", 4221da177e4SLinus Torvalds .data = &core_uses_pid, 4231da177e4SLinus Torvalds .maxlen = sizeof(int), 4241da177e4SLinus Torvalds .mode = 0644, 4251da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4261da177e4SLinus Torvalds }, 4271da177e4SLinus Torvalds { 4281da177e4SLinus Torvalds .ctl_name = KERN_CORE_PATTERN, 4291da177e4SLinus Torvalds .procname = "core_pattern", 4301da177e4SLinus Torvalds .data = core_pattern, 43171ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4321da177e4SLinus Torvalds .mode = 0644, 4331da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4341da177e4SLinus Torvalds .strategy = &sysctl_string, 4351da177e4SLinus Torvalds }, 436a293980cSNeil Horman { 437a293980cSNeil Horman .ctl_name = CTL_UNNUMBERED, 438a293980cSNeil Horman .procname = "core_pipe_limit", 439a293980cSNeil Horman .data = &core_pipe_limit, 440a293980cSNeil Horman .maxlen = sizeof(unsigned int), 441a293980cSNeil Horman .mode = 0644, 442a293980cSNeil Horman .proc_handler = &proc_dointvec, 443a293980cSNeil Horman }, 44434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4451da177e4SLinus Torvalds { 4461da177e4SLinus Torvalds .procname = "tainted", 44725ddbb18SAndi Kleen .maxlen = sizeof(long), 44834f5a398STheodore Ts'o .mode = 0644, 44925ddbb18SAndi Kleen .proc_handler = &proc_taint, 4501da177e4SLinus Torvalds }, 45134f5a398STheodore Ts'o #endif 4529745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4539745512cSArjan van de Ven { 4549745512cSArjan van de Ven .procname = "latencytop", 4559745512cSArjan van de Ven .data = &latencytop_enabled, 4569745512cSArjan van de Ven .maxlen = sizeof(int), 4579745512cSArjan van de Ven .mode = 0644, 4589745512cSArjan van de Ven .proc_handler = &proc_dointvec, 4599745512cSArjan van de Ven }, 4609745512cSArjan van de Ven #endif 4611da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4621da177e4SLinus Torvalds { 4631da177e4SLinus Torvalds .ctl_name = KERN_REALROOTDEV, 4641da177e4SLinus Torvalds .procname = "real-root-dev", 4651da177e4SLinus Torvalds .data = &real_root_dev, 4661da177e4SLinus Torvalds .maxlen = sizeof(int), 4671da177e4SLinus Torvalds .mode = 0644, 4681da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4691da177e4SLinus Torvalds }, 4701da177e4SLinus Torvalds #endif 47145807a1dSIngo Molnar { 47245807a1dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 47345807a1dSIngo Molnar .procname = "print-fatal-signals", 47445807a1dSIngo Molnar .data = &print_fatal_signals, 47545807a1dSIngo Molnar .maxlen = sizeof(int), 47645807a1dSIngo Molnar .mode = 0644, 47745807a1dSIngo Molnar .proc_handler = &proc_dointvec, 47845807a1dSIngo Molnar }, 47972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4801da177e4SLinus Torvalds { 4811da177e4SLinus Torvalds .ctl_name = KERN_SPARC_REBOOT, 4821da177e4SLinus Torvalds .procname = "reboot-cmd", 4831da177e4SLinus Torvalds .data = reboot_command, 4841da177e4SLinus Torvalds .maxlen = 256, 4851da177e4SLinus Torvalds .mode = 0644, 4861da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4871da177e4SLinus Torvalds .strategy = &sysctl_string, 4881da177e4SLinus Torvalds }, 4891da177e4SLinus Torvalds { 4901da177e4SLinus Torvalds .ctl_name = KERN_SPARC_STOP_A, 4911da177e4SLinus Torvalds .procname = "stop-a", 4921da177e4SLinus Torvalds .data = &stop_a_enabled, 4931da177e4SLinus Torvalds .maxlen = sizeof (int), 4941da177e4SLinus Torvalds .mode = 0644, 4951da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4961da177e4SLinus Torvalds }, 4971da177e4SLinus Torvalds { 4981da177e4SLinus Torvalds .ctl_name = KERN_SPARC_SCONS_PWROFF, 4991da177e4SLinus Torvalds .procname = "scons-poweroff", 5001da177e4SLinus Torvalds .data = &scons_pwroff, 5011da177e4SLinus Torvalds .maxlen = sizeof (int), 5021da177e4SLinus Torvalds .mode = 0644, 5031da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5041da177e4SLinus Torvalds }, 5051da177e4SLinus Torvalds #endif 5060871420fSDavid S. Miller #ifdef CONFIG_SPARC64 5070871420fSDavid S. Miller { 5080871420fSDavid S. Miller .ctl_name = CTL_UNNUMBERED, 5090871420fSDavid S. Miller .procname = "tsb-ratio", 5100871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 5110871420fSDavid S. Miller .maxlen = sizeof (int), 5120871420fSDavid S. Miller .mode = 0644, 5130871420fSDavid S. Miller .proc_handler = &proc_dointvec, 5140871420fSDavid S. Miller }, 5150871420fSDavid S. Miller #endif 5161da177e4SLinus Torvalds #ifdef __hppa__ 5171da177e4SLinus Torvalds { 5181da177e4SLinus Torvalds .ctl_name = KERN_HPPA_PWRSW, 5191da177e4SLinus Torvalds .procname = "soft-power", 5201da177e4SLinus Torvalds .data = &pwrsw_enabled, 5211da177e4SLinus Torvalds .maxlen = sizeof (int), 5221da177e4SLinus Torvalds .mode = 0644, 5231da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5241da177e4SLinus Torvalds }, 5251da177e4SLinus Torvalds { 5261da177e4SLinus Torvalds .ctl_name = KERN_HPPA_UNALIGNED, 5271da177e4SLinus Torvalds .procname = "unaligned-trap", 5281da177e4SLinus Torvalds .data = &unaligned_enabled, 5291da177e4SLinus Torvalds .maxlen = sizeof (int), 5301da177e4SLinus Torvalds .mode = 0644, 5311da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5321da177e4SLinus Torvalds }, 5331da177e4SLinus Torvalds #endif 5341da177e4SLinus Torvalds { 5351da177e4SLinus Torvalds .ctl_name = KERN_CTLALTDEL, 5361da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5371da177e4SLinus Torvalds .data = &C_A_D, 5381da177e4SLinus Torvalds .maxlen = sizeof(int), 5391da177e4SLinus Torvalds .mode = 0644, 5401da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5411da177e4SLinus Torvalds }, 542606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 543b0fc494fSSteven Rostedt { 544b0fc494fSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 545b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 546b0fc494fSSteven Rostedt .data = &ftrace_enabled, 547b0fc494fSSteven Rostedt .maxlen = sizeof(int), 548b0fc494fSSteven Rostedt .mode = 0644, 549b0fc494fSSteven Rostedt .proc_handler = &ftrace_enable_sysctl, 550b0fc494fSSteven Rostedt }, 551b0fc494fSSteven Rostedt #endif 552f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 553f38f1d2aSSteven Rostedt { 554f38f1d2aSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 555f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 556f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 557f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 558f38f1d2aSSteven Rostedt .mode = 0644, 559f38f1d2aSSteven Rostedt .proc_handler = &stack_trace_sysctl, 560f38f1d2aSSteven Rostedt }, 561f38f1d2aSSteven Rostedt #endif 562944ac425SSteven Rostedt #ifdef CONFIG_TRACING 563944ac425SSteven Rostedt { 564944ac425SSteven Rostedt .ctl_name = CTL_UNNUMBERED, 5653299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 566944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 567944ac425SSteven Rostedt .maxlen = sizeof(int), 568944ac425SSteven Rostedt .mode = 0644, 569944ac425SSteven Rostedt .proc_handler = &proc_dointvec, 570944ac425SSteven Rostedt }, 571944ac425SSteven Rostedt #endif 572a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5731da177e4SLinus Torvalds { 5741da177e4SLinus Torvalds .ctl_name = KERN_MODPROBE, 5751da177e4SLinus Torvalds .procname = "modprobe", 5761da177e4SLinus Torvalds .data = &modprobe_path, 5771da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5781da177e4SLinus Torvalds .mode = 0644, 5791da177e4SLinus Torvalds .proc_handler = &proc_dostring, 5801da177e4SLinus Torvalds .strategy = &sysctl_string, 5811da177e4SLinus Torvalds }, 5823d43321bSKees Cook { 5833d43321bSKees Cook .ctl_name = CTL_UNNUMBERED, 5843d43321bSKees Cook .procname = "modules_disabled", 5853d43321bSKees Cook .data = &modules_disabled, 5863d43321bSKees Cook .maxlen = sizeof(int), 5873d43321bSKees Cook .mode = 0644, 5883d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5893d43321bSKees Cook .proc_handler = &proc_dointvec_minmax, 5903d43321bSKees Cook .extra1 = &one, 5913d43321bSKees Cook .extra2 = &one, 5923d43321bSKees Cook }, 5931da177e4SLinus Torvalds #endif 59457ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 5951da177e4SLinus Torvalds { 5961da177e4SLinus Torvalds .ctl_name = KERN_HOTPLUG, 5971da177e4SLinus Torvalds .procname = "hotplug", 598312c004dSKay Sievers .data = &uevent_helper, 599312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 6001da177e4SLinus Torvalds .mode = 0644, 6011da177e4SLinus Torvalds .proc_handler = &proc_dostring, 6021da177e4SLinus Torvalds .strategy = &sysctl_string, 6031da177e4SLinus Torvalds }, 6041da177e4SLinus Torvalds #endif 6051da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 6061da177e4SLinus Torvalds { 6071da177e4SLinus Torvalds .ctl_name = KERN_SG_BIG_BUFF, 6081da177e4SLinus Torvalds .procname = "sg-big-buff", 6091da177e4SLinus Torvalds .data = &sg_big_buff, 6101da177e4SLinus Torvalds .maxlen = sizeof (int), 6111da177e4SLinus Torvalds .mode = 0444, 6121da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6131da177e4SLinus Torvalds }, 6141da177e4SLinus Torvalds #endif 6151da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 6161da177e4SLinus Torvalds { 6171da177e4SLinus Torvalds .ctl_name = KERN_ACCT, 6181da177e4SLinus Torvalds .procname = "acct", 6191da177e4SLinus Torvalds .data = &acct_parm, 6201da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 6211da177e4SLinus Torvalds .mode = 0644, 6221da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6231da177e4SLinus Torvalds }, 6241da177e4SLinus Torvalds #endif 6251da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 6261da177e4SLinus Torvalds { 6271da177e4SLinus Torvalds .ctl_name = KERN_SYSRQ, 6281da177e4SLinus Torvalds .procname = "sysrq", 6295d6f647fSIngo Molnar .data = &__sysrq_enabled, 6301da177e4SLinus Torvalds .maxlen = sizeof (int), 6311da177e4SLinus Torvalds .mode = 0644, 6321da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6331da177e4SLinus Torvalds }, 6341da177e4SLinus Torvalds #endif 635d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 6361da177e4SLinus Torvalds { 6371da177e4SLinus Torvalds .procname = "cad_pid", 6389ec52099SCedric Le Goater .data = NULL, 6391da177e4SLinus Torvalds .maxlen = sizeof (int), 6401da177e4SLinus Torvalds .mode = 0600, 6419ec52099SCedric Le Goater .proc_handler = &proc_do_cad_pid, 6421da177e4SLinus Torvalds }, 643d6f8ff73SRandy Dunlap #endif 6441da177e4SLinus Torvalds { 6451da177e4SLinus Torvalds .ctl_name = KERN_MAX_THREADS, 6461da177e4SLinus Torvalds .procname = "threads-max", 6471da177e4SLinus Torvalds .data = &max_threads, 6481da177e4SLinus Torvalds .maxlen = sizeof(int), 6491da177e4SLinus Torvalds .mode = 0644, 6501da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6511da177e4SLinus Torvalds }, 6521da177e4SLinus Torvalds { 6531da177e4SLinus Torvalds .ctl_name = KERN_RANDOM, 6541da177e4SLinus Torvalds .procname = "random", 6551da177e4SLinus Torvalds .mode = 0555, 6561da177e4SLinus Torvalds .child = random_table, 6571da177e4SLinus Torvalds }, 6581da177e4SLinus Torvalds { 6591da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWUID, 6601da177e4SLinus Torvalds .procname = "overflowuid", 6611da177e4SLinus Torvalds .data = &overflowuid, 6621da177e4SLinus Torvalds .maxlen = sizeof(int), 6631da177e4SLinus Torvalds .mode = 0644, 6641da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6651da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6661da177e4SLinus Torvalds .extra1 = &minolduid, 6671da177e4SLinus Torvalds .extra2 = &maxolduid, 6681da177e4SLinus Torvalds }, 6691da177e4SLinus Torvalds { 6701da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWGID, 6711da177e4SLinus Torvalds .procname = "overflowgid", 6721da177e4SLinus Torvalds .data = &overflowgid, 6731da177e4SLinus Torvalds .maxlen = sizeof(int), 6741da177e4SLinus Torvalds .mode = 0644, 6751da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6761da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6771da177e4SLinus Torvalds .extra1 = &minolduid, 6781da177e4SLinus Torvalds .extra2 = &maxolduid, 6791da177e4SLinus Torvalds }, 680347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6811da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6821da177e4SLinus Torvalds { 6831da177e4SLinus Torvalds .ctl_name = KERN_IEEE_EMULATION_WARNINGS, 6841da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6851da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6861da177e4SLinus Torvalds .maxlen = sizeof(int), 6871da177e4SLinus Torvalds .mode = 0644, 6881da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6891da177e4SLinus Torvalds }, 6901da177e4SLinus Torvalds #endif 6911da177e4SLinus Torvalds { 6921da177e4SLinus Torvalds .ctl_name = KERN_S390_USER_DEBUG_LOGGING, 6931da177e4SLinus Torvalds .procname = "userprocess_debug", 6941da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 6951da177e4SLinus Torvalds .maxlen = sizeof(int), 6961da177e4SLinus Torvalds .mode = 0644, 6971da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6981da177e4SLinus Torvalds }, 6991da177e4SLinus Torvalds #endif 7001da177e4SLinus Torvalds { 7011da177e4SLinus Torvalds .ctl_name = KERN_PIDMAX, 7021da177e4SLinus Torvalds .procname = "pid_max", 7031da177e4SLinus Torvalds .data = &pid_max, 7041da177e4SLinus Torvalds .maxlen = sizeof (int), 7051da177e4SLinus Torvalds .mode = 0644, 7061da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 7071da177e4SLinus Torvalds .strategy = sysctl_intvec, 7081da177e4SLinus Torvalds .extra1 = &pid_max_min, 7091da177e4SLinus Torvalds .extra2 = &pid_max_max, 7101da177e4SLinus Torvalds }, 7111da177e4SLinus Torvalds { 7121da177e4SLinus Torvalds .ctl_name = KERN_PANIC_ON_OOPS, 7131da177e4SLinus Torvalds .procname = "panic_on_oops", 7141da177e4SLinus Torvalds .data = &panic_on_oops, 7151da177e4SLinus Torvalds .maxlen = sizeof(int), 7161da177e4SLinus Torvalds .mode = 0644, 7171da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7181da177e4SLinus Torvalds }, 7197ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 7207ef3d2fdSJoe Perches { 7217ef3d2fdSJoe Perches .ctl_name = KERN_PRINTK, 7227ef3d2fdSJoe Perches .procname = "printk", 7237ef3d2fdSJoe Perches .data = &console_loglevel, 7247ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 7257ef3d2fdSJoe Perches .mode = 0644, 7267ef3d2fdSJoe Perches .proc_handler = &proc_dointvec, 7277ef3d2fdSJoe Perches }, 7281da177e4SLinus Torvalds { 7291da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT, 7301da177e4SLinus Torvalds .procname = "printk_ratelimit", 731717115e1SDave Young .data = &printk_ratelimit_state.interval, 7321da177e4SLinus Torvalds .maxlen = sizeof(int), 7331da177e4SLinus Torvalds .mode = 0644, 7341da177e4SLinus Torvalds .proc_handler = &proc_dointvec_jiffies, 7351da177e4SLinus Torvalds .strategy = &sysctl_jiffies, 7361da177e4SLinus Torvalds }, 7371da177e4SLinus Torvalds { 7381da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT_BURST, 7391da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 740717115e1SDave Young .data = &printk_ratelimit_state.burst, 7411da177e4SLinus Torvalds .maxlen = sizeof(int), 7421da177e4SLinus Torvalds .mode = 0644, 7431da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7441da177e4SLinus Torvalds }, 745af91322eSDave Young { 746af91322eSDave Young .ctl_name = CTL_UNNUMBERED, 747af91322eSDave Young .procname = "printk_delay", 748af91322eSDave Young .data = &printk_delay_msec, 749af91322eSDave Young .maxlen = sizeof(int), 750af91322eSDave Young .mode = 0644, 751af91322eSDave Young .proc_handler = &proc_dointvec_minmax, 752af91322eSDave Young .strategy = &sysctl_intvec, 753af91322eSDave Young .extra1 = &zero, 754af91322eSDave Young .extra2 = &ten_thousand, 755af91322eSDave Young }, 7567ef3d2fdSJoe Perches #endif 7571da177e4SLinus Torvalds { 7581da177e4SLinus Torvalds .ctl_name = KERN_NGROUPS_MAX, 7591da177e4SLinus Torvalds .procname = "ngroups_max", 7601da177e4SLinus Torvalds .data = &ngroups_max, 7611da177e4SLinus Torvalds .maxlen = sizeof (int), 7621da177e4SLinus Torvalds .mode = 0444, 7631da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7641da177e4SLinus Torvalds }, 7651da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7661da177e4SLinus Torvalds { 7671da177e4SLinus Torvalds .ctl_name = KERN_UNKNOWN_NMI_PANIC, 7681da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 7691da177e4SLinus Torvalds .data = &unknown_nmi_panic, 7701da177e4SLinus Torvalds .maxlen = sizeof (int), 7711da177e4SLinus Torvalds .mode = 0644, 7722fbe7b25SDon Zickus .proc_handler = &proc_dointvec, 7731da177e4SLinus Torvalds }, 774407984f1SDon Zickus { 775407984f1SDon Zickus .procname = "nmi_watchdog", 776407984f1SDon Zickus .data = &nmi_watchdog_enabled, 777407984f1SDon Zickus .maxlen = sizeof (int), 778407984f1SDon Zickus .mode = 0644, 779407984f1SDon Zickus .proc_handler = &proc_nmi_enabled, 7801da177e4SLinus Torvalds }, 7811da177e4SLinus Torvalds #endif 7821da177e4SLinus Torvalds #if defined(CONFIG_X86) 7831da177e4SLinus Torvalds { 7848da5addaSDon Zickus .ctl_name = KERN_PANIC_ON_NMI, 7858da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7868da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7878da5addaSDon Zickus .maxlen = sizeof(int), 7888da5addaSDon Zickus .mode = 0644, 7898da5addaSDon Zickus .proc_handler = &proc_dointvec, 7908da5addaSDon Zickus }, 7918da5addaSDon Zickus { 7925211a242SKurt Garloff .ctl_name = CTL_UNNUMBERED, 7935211a242SKurt Garloff .procname = "panic_on_io_nmi", 7945211a242SKurt Garloff .data = &panic_on_io_nmi, 7955211a242SKurt Garloff .maxlen = sizeof(int), 7965211a242SKurt Garloff .mode = 0644, 7975211a242SKurt Garloff .proc_handler = &proc_dointvec, 7985211a242SKurt Garloff }, 7995211a242SKurt Garloff { 8001da177e4SLinus Torvalds .ctl_name = KERN_BOOTLOADER_TYPE, 8011da177e4SLinus Torvalds .procname = "bootloader_type", 8021da177e4SLinus Torvalds .data = &bootloader_type, 8031da177e4SLinus Torvalds .maxlen = sizeof (int), 8041da177e4SLinus Torvalds .mode = 0444, 8051da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8061da177e4SLinus Torvalds }, 8070741f4d2SChuck Ebbert { 8080741f4d2SChuck Ebbert .ctl_name = CTL_UNNUMBERED, 8095031296cSH. Peter Anvin .procname = "bootloader_version", 8105031296cSH. Peter Anvin .data = &bootloader_version, 8115031296cSH. Peter Anvin .maxlen = sizeof (int), 8125031296cSH. Peter Anvin .mode = 0444, 8135031296cSH. Peter Anvin .proc_handler = &proc_dointvec, 8145031296cSH. Peter Anvin }, 8155031296cSH. Peter Anvin { 8165031296cSH. Peter Anvin .ctl_name = CTL_UNNUMBERED, 8170741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 8180741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 8190741f4d2SChuck Ebbert .maxlen = sizeof(int), 8200741f4d2SChuck Ebbert .mode = 0644, 8210741f4d2SChuck Ebbert .proc_handler = &proc_dointvec, 8220741f4d2SChuck Ebbert }, 8236e7c4025SIngo Molnar { 8246e7c4025SIngo Molnar .ctl_name = CTL_UNNUMBERED, 8256e7c4025SIngo Molnar .procname = "io_delay_type", 8266e7c4025SIngo Molnar .data = &io_delay_type, 8276e7c4025SIngo Molnar .maxlen = sizeof(int), 8286e7c4025SIngo Molnar .mode = 0644, 8296e7c4025SIngo Molnar .proc_handler = &proc_dointvec, 8306e7c4025SIngo Molnar }, 8311da177e4SLinus Torvalds #endif 8327a9166e3SLuke Yang #if defined(CONFIG_MMU) 8331da177e4SLinus Torvalds { 8341da177e4SLinus Torvalds .ctl_name = KERN_RANDOMIZE, 8351da177e4SLinus Torvalds .procname = "randomize_va_space", 8361da177e4SLinus Torvalds .data = &randomize_va_space, 8371da177e4SLinus Torvalds .maxlen = sizeof(int), 8381da177e4SLinus Torvalds .mode = 0644, 8391da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8401da177e4SLinus Torvalds }, 8417a9166e3SLuke Yang #endif 8420152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 843951f22d5SMartin Schwidefsky { 844951f22d5SMartin Schwidefsky .ctl_name = KERN_SPIN_RETRY, 845951f22d5SMartin Schwidefsky .procname = "spin_retry", 846951f22d5SMartin Schwidefsky .data = &spin_retry, 847951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 848951f22d5SMartin Schwidefsky .mode = 0644, 849951f22d5SMartin Schwidefsky .proc_handler = &proc_dointvec, 850951f22d5SMartin Schwidefsky }, 851951f22d5SMartin Schwidefsky #endif 852673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 853c255d844SPavel Machek { 854c255d844SPavel Machek .procname = "acpi_video_flags", 85577afcf78SPavel Machek .data = &acpi_realmode_flags, 856c255d844SPavel Machek .maxlen = sizeof (unsigned long), 857c255d844SPavel Machek .mode = 0644, 8587f99f06fSStefan Seyfried .proc_handler = &proc_doulongvec_minmax, 859c255d844SPavel Machek }, 860c255d844SPavel Machek #endif 861d2b176edSJes Sorensen #ifdef CONFIG_IA64 862d2b176edSJes Sorensen { 863d2b176edSJes Sorensen .ctl_name = KERN_IA64_UNALIGNED, 864d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 865d2b176edSJes Sorensen .data = &no_unaligned_warning, 866d2b176edSJes Sorensen .maxlen = sizeof (int), 867d2b176edSJes Sorensen .mode = 0644, 868d2b176edSJes Sorensen .proc_handler = &proc_dointvec, 869d2b176edSJes Sorensen }, 87088fc241fSDoug Chapman { 87188fc241fSDoug Chapman .ctl_name = CTL_UNNUMBERED, 87288fc241fSDoug Chapman .procname = "unaligned-dump-stack", 87388fc241fSDoug Chapman .data = &unaligned_dump_stack, 87488fc241fSDoug Chapman .maxlen = sizeof (int), 87588fc241fSDoug Chapman .mode = 0644, 87688fc241fSDoug Chapman .proc_handler = &proc_dointvec, 87788fc241fSDoug Chapman }, 878d2b176edSJes Sorensen #endif 879c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 880c4f3b63fSRavikiran G Thirumalai { 881c4f3b63fSRavikiran G Thirumalai .ctl_name = CTL_UNNUMBERED, 8829c44bc03SIngo Molnar .procname = "softlockup_panic", 8839c44bc03SIngo Molnar .data = &softlockup_panic, 8849c44bc03SIngo Molnar .maxlen = sizeof(int), 8859c44bc03SIngo Molnar .mode = 0644, 8864dca10a9SHiroshi Shimamoto .proc_handler = &proc_dointvec_minmax, 8879c44bc03SIngo Molnar .strategy = &sysctl_intvec, 8889c44bc03SIngo Molnar .extra1 = &zero, 8899c44bc03SIngo Molnar .extra2 = &one, 8909c44bc03SIngo Molnar }, 8919c44bc03SIngo Molnar { 8929c44bc03SIngo Molnar .ctl_name = CTL_UNNUMBERED, 893c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 894c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 8959383d967SDimitri Sivanich .maxlen = sizeof(int), 896c4f3b63fSRavikiran G Thirumalai .mode = 0644, 897baf48f65SMandeep Singh Baines .proc_handler = &proc_dosoftlockup_thresh, 898c4f3b63fSRavikiran G Thirumalai .strategy = &sysctl_intvec, 8999383d967SDimitri Sivanich .extra1 = &neg_one, 900c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 901c4f3b63fSRavikiran G Thirumalai }, 902e162b39aSMandeep Singh Baines #endif 903e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 904e162b39aSMandeep Singh Baines { 905e162b39aSMandeep Singh Baines .ctl_name = CTL_UNNUMBERED, 906e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 907e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 908e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 909e162b39aSMandeep Singh Baines .mode = 0644, 910e162b39aSMandeep Singh Baines .proc_handler = &proc_dointvec_minmax, 911e162b39aSMandeep Singh Baines .strategy = &sysctl_intvec, 912e162b39aSMandeep Singh Baines .extra1 = &zero, 913e162b39aSMandeep Singh Baines .extra2 = &one, 914e162b39aSMandeep Singh Baines }, 91582a1fcb9SIngo Molnar { 91682a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 91782a1fcb9SIngo Molnar .procname = "hung_task_check_count", 91882a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 91990739081SIngo Molnar .maxlen = sizeof(unsigned long), 92082a1fcb9SIngo Molnar .mode = 0644, 92190739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 92282a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 92382a1fcb9SIngo Molnar }, 92482a1fcb9SIngo Molnar { 92582a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 92682a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 92782a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 92890739081SIngo Molnar .maxlen = sizeof(unsigned long), 92982a1fcb9SIngo Molnar .mode = 0644, 930e162b39aSMandeep Singh Baines .proc_handler = &proc_dohung_task_timeout_secs, 93182a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 93282a1fcb9SIngo Molnar }, 93382a1fcb9SIngo Molnar { 93482a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 93582a1fcb9SIngo Molnar .procname = "hung_task_warnings", 93682a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 93790739081SIngo Molnar .maxlen = sizeof(unsigned long), 93882a1fcb9SIngo Molnar .mode = 0644, 93990739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 94082a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 94182a1fcb9SIngo Molnar }, 942c4f3b63fSRavikiran G Thirumalai #endif 943bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 944bebfa101SAndi Kleen { 945bebfa101SAndi Kleen .ctl_name = KERN_COMPAT_LOG, 946bebfa101SAndi Kleen .procname = "compat-log", 947bebfa101SAndi Kleen .data = &compat_log, 948bebfa101SAndi Kleen .maxlen = sizeof (int), 949bebfa101SAndi Kleen .mode = 0644, 950bebfa101SAndi Kleen .proc_handler = &proc_dointvec, 951bebfa101SAndi Kleen }, 952bebfa101SAndi Kleen #endif 95323f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 95423f78d4aSIngo Molnar { 95523f78d4aSIngo Molnar .ctl_name = KERN_MAX_LOCK_DEPTH, 95623f78d4aSIngo Molnar .procname = "max_lock_depth", 95723f78d4aSIngo Molnar .data = &max_lock_depth, 95823f78d4aSIngo Molnar .maxlen = sizeof(int), 95923f78d4aSIngo Molnar .mode = 0644, 96023f78d4aSIngo Molnar .proc_handler = &proc_dointvec, 96123f78d4aSIngo Molnar }, 96223f78d4aSIngo Molnar #endif 96310a0a8d4SJeremy Fitzhardinge { 96410a0a8d4SJeremy Fitzhardinge .ctl_name = CTL_UNNUMBERED, 96510a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 96610a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 96710a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 96810a0a8d4SJeremy Fitzhardinge .mode = 0644, 96910a0a8d4SJeremy Fitzhardinge .proc_handler = &proc_dostring, 97010a0a8d4SJeremy Fitzhardinge .strategy = &sysctl_string, 97110a0a8d4SJeremy Fitzhardinge }, 9720b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9730b77f5bfSDavid Howells { 9740b77f5bfSDavid Howells .ctl_name = CTL_UNNUMBERED, 9750b77f5bfSDavid Howells .procname = "keys", 9760b77f5bfSDavid Howells .mode = 0555, 9770b77f5bfSDavid Howells .child = key_sysctls, 9780b77f5bfSDavid Howells }, 9790b77f5bfSDavid Howells #endif 98031a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 98131a72bceSPaul E. McKenney { 98231a72bceSPaul E. McKenney .ctl_name = CTL_UNNUMBERED, 98331a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 98431a72bceSPaul E. McKenney .data = &rcutorture_runnable, 98531a72bceSPaul E. McKenney .maxlen = sizeof(int), 98631a72bceSPaul E. McKenney .mode = 0644, 98731a72bceSPaul E. McKenney .proc_handler = &proc_dointvec, 98831a72bceSPaul E. McKenney }, 98931a72bceSPaul E. McKenney #endif 99012e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK 99112e22c5eSDavid Howells { 99212e22c5eSDavid Howells .ctl_name = CTL_UNNUMBERED, 99312e22c5eSDavid Howells .procname = "slow-work", 99412e22c5eSDavid Howells .mode = 0555, 99512e22c5eSDavid Howells .child = slow_work_sysctls, 99612e22c5eSDavid Howells }, 99712e22c5eSDavid Howells #endif 998cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 9991ccd1549SPeter Zijlstra { 10001ccd1549SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 1001cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 1002cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 1003cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 10041ccd1549SPeter Zijlstra .mode = 0644, 10051ccd1549SPeter Zijlstra .proc_handler = &proc_dointvec, 10061ccd1549SPeter Zijlstra }, 1007c5078f78SPeter Zijlstra { 1008c5078f78SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 1009cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 1010cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 1011cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 1012c5078f78SPeter Zijlstra .mode = 0644, 1013c5078f78SPeter Zijlstra .proc_handler = &proc_dointvec, 1014c5078f78SPeter Zijlstra }, 1015a78ac325SPeter Zijlstra { 1016a78ac325SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 1017cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 1018cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 1019cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 1020a78ac325SPeter Zijlstra .mode = 0644, 1021a78ac325SPeter Zijlstra .proc_handler = &proc_dointvec, 1022a78ac325SPeter Zijlstra }, 10231ccd1549SPeter Zijlstra #endif 1024dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 1025dfec072eSVegard Nossum { 1026dfec072eSVegard Nossum .ctl_name = CTL_UNNUMBERED, 1027dfec072eSVegard Nossum .procname = "kmemcheck", 1028dfec072eSVegard Nossum .data = &kmemcheck_enabled, 1029dfec072eSVegard Nossum .maxlen = sizeof(int), 1030dfec072eSVegard Nossum .mode = 0644, 1031dfec072eSVegard Nossum .proc_handler = &proc_dointvec, 1032dfec072eSVegard Nossum }, 1033dfec072eSVegard Nossum #endif 1034cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 10355e605b64SJens Axboe { 10365e605b64SJens Axboe .ctl_name = CTL_UNNUMBERED, 10375e605b64SJens Axboe .procname = "blk_iopoll", 10385e605b64SJens Axboe .data = &blk_iopoll_enabled, 10395e605b64SJens Axboe .maxlen = sizeof(int), 10405e605b64SJens Axboe .mode = 0644, 10415e605b64SJens Axboe .proc_handler = &proc_dointvec, 10425e605b64SJens Axboe }, 1043cb684b5bSJens Axboe #endif 1044ed2c12f3SAndrew Morton /* 1045ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 1046ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 1047ed2c12f3SAndrew Morton */ 10481da177e4SLinus Torvalds { .ctl_name = 0 } 10491da177e4SLinus Torvalds }; 10501da177e4SLinus Torvalds 1051d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 10521da177e4SLinus Torvalds { 10531da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_MEMORY, 10541da177e4SLinus Torvalds .procname = "overcommit_memory", 10551da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 10561da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 10571da177e4SLinus Torvalds .mode = 0644, 10581da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10591da177e4SLinus Torvalds }, 10601da177e4SLinus Torvalds { 1061fadd8fbdSKAMEZAWA Hiroyuki .ctl_name = VM_PANIC_ON_OOM, 1062fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1063fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1064fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1065fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1066fadd8fbdSKAMEZAWA Hiroyuki .proc_handler = &proc_dointvec, 1067fadd8fbdSKAMEZAWA Hiroyuki }, 1068fadd8fbdSKAMEZAWA Hiroyuki { 1069fe071d7eSDavid Rientjes .ctl_name = CTL_UNNUMBERED, 1070fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1071fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1072fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1073fe071d7eSDavid Rientjes .mode = 0644, 1074fe071d7eSDavid Rientjes .proc_handler = &proc_dointvec, 1075fe071d7eSDavid Rientjes }, 1076fe071d7eSDavid Rientjes { 1077fef1bdd6SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 1078fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1079fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1080fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1081fef1bdd6SDavid Rientjes .mode = 0644, 1082fef1bdd6SDavid Rientjes .proc_handler = &proc_dointvec, 1083fef1bdd6SDavid Rientjes }, 1084fef1bdd6SDavid Rientjes { 10851da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_RATIO, 10861da177e4SLinus Torvalds .procname = "overcommit_ratio", 10871da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10881da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10891da177e4SLinus Torvalds .mode = 0644, 10901da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10911da177e4SLinus Torvalds }, 10921da177e4SLinus Torvalds { 10931da177e4SLinus Torvalds .ctl_name = VM_PAGE_CLUSTER, 10941da177e4SLinus Torvalds .procname = "page-cluster", 10951da177e4SLinus Torvalds .data = &page_cluster, 10961da177e4SLinus Torvalds .maxlen = sizeof(int), 10971da177e4SLinus Torvalds .mode = 0644, 10981da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10991da177e4SLinus Torvalds }, 11001da177e4SLinus Torvalds { 11011da177e4SLinus Torvalds .ctl_name = VM_DIRTY_BACKGROUND, 11021da177e4SLinus Torvalds .procname = "dirty_background_ratio", 11031da177e4SLinus Torvalds .data = &dirty_background_ratio, 11041da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 11051da177e4SLinus Torvalds .mode = 0644, 11062da02997SDavid Rientjes .proc_handler = &dirty_background_ratio_handler, 11071da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11081da177e4SLinus Torvalds .extra1 = &zero, 11091da177e4SLinus Torvalds .extra2 = &one_hundred, 11101da177e4SLinus Torvalds }, 11111da177e4SLinus Torvalds { 11122da02997SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 11132da02997SDavid Rientjes .procname = "dirty_background_bytes", 11142da02997SDavid Rientjes .data = &dirty_background_bytes, 11152da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 11162da02997SDavid Rientjes .mode = 0644, 11172da02997SDavid Rientjes .proc_handler = &dirty_background_bytes_handler, 11182da02997SDavid Rientjes .strategy = &sysctl_intvec, 1119fc3501d4SSven Wegener .extra1 = &one_ul, 11202da02997SDavid Rientjes }, 11212da02997SDavid Rientjes { 11221da177e4SLinus Torvalds .ctl_name = VM_DIRTY_RATIO, 11231da177e4SLinus Torvalds .procname = "dirty_ratio", 11241da177e4SLinus Torvalds .data = &vm_dirty_ratio, 11251da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 11261da177e4SLinus Torvalds .mode = 0644, 112704fbfdc1SPeter Zijlstra .proc_handler = &dirty_ratio_handler, 11281da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11291da177e4SLinus Torvalds .extra1 = &zero, 11301da177e4SLinus Torvalds .extra2 = &one_hundred, 11311da177e4SLinus Torvalds }, 11321da177e4SLinus Torvalds { 11332da02997SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 11342da02997SDavid Rientjes .procname = "dirty_bytes", 11352da02997SDavid Rientjes .data = &vm_dirty_bytes, 11362da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 11372da02997SDavid Rientjes .mode = 0644, 11382da02997SDavid Rientjes .proc_handler = &dirty_bytes_handler, 11392da02997SDavid Rientjes .strategy = &sysctl_intvec, 11409e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 11412da02997SDavid Rientjes }, 11422da02997SDavid Rientjes { 11431da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1144f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1145f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 11461da177e4SLinus Torvalds .mode = 0644, 11471da177e4SLinus Torvalds .proc_handler = &dirty_writeback_centisecs_handler, 11481da177e4SLinus Torvalds }, 11491da177e4SLinus Torvalds { 11501da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1151f6ef9438SBart Samwel .data = &dirty_expire_interval, 1152f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 11531da177e4SLinus Torvalds .mode = 0644, 1154704503d8SAlexey Dobriyan .proc_handler = &proc_dointvec, 11551da177e4SLinus Torvalds }, 11561da177e4SLinus Torvalds { 11571da177e4SLinus Torvalds .ctl_name = VM_NR_PDFLUSH_THREADS, 11581da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 11591da177e4SLinus Torvalds .data = &nr_pdflush_threads, 11601da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 11611da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 11621da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11631da177e4SLinus Torvalds }, 11641da177e4SLinus Torvalds { 11651da177e4SLinus Torvalds .ctl_name = VM_SWAPPINESS, 11661da177e4SLinus Torvalds .procname = "swappiness", 11671da177e4SLinus Torvalds .data = &vm_swappiness, 11681da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 11691da177e4SLinus Torvalds .mode = 0644, 11701da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 11711da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11721da177e4SLinus Torvalds .extra1 = &zero, 11731da177e4SLinus Torvalds .extra2 = &one_hundred, 11741da177e4SLinus Torvalds }, 11751da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11761da177e4SLinus Torvalds { 11771da177e4SLinus Torvalds .procname = "nr_hugepages", 1178e5ff2159SAndi Kleen .data = NULL, 11791da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11801da177e4SLinus Torvalds .mode = 0644, 11811da177e4SLinus Torvalds .proc_handler = &hugetlb_sysctl_handler, 11821da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11831da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11841da177e4SLinus Torvalds }, 11851da177e4SLinus Torvalds { 11861da177e4SLinus Torvalds .ctl_name = VM_HUGETLB_GROUP, 11871da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11881da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11891da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11901da177e4SLinus Torvalds .mode = 0644, 11911da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11921da177e4SLinus Torvalds }, 1193396faf03SMel Gorman { 1194396faf03SMel Gorman .ctl_name = CTL_UNNUMBERED, 1195396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1196396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1197396faf03SMel Gorman .maxlen = sizeof(int), 1198396faf03SMel Gorman .mode = 0644, 1199396faf03SMel Gorman .proc_handler = &hugetlb_treat_movable_handler, 1200396faf03SMel Gorman }, 120154f9f80dSAdam Litke { 120254f9f80dSAdam Litke .ctl_name = CTL_UNNUMBERED, 1203d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1204e5ff2159SAndi Kleen .data = NULL, 1205e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1206d1c3fb1fSNishanth Aravamudan .mode = 0644, 1207a3d0c6aaSNishanth Aravamudan .proc_handler = &hugetlb_overcommit_handler, 1208e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1209e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1210d1c3fb1fSNishanth Aravamudan }, 12111da177e4SLinus Torvalds #endif 12121da177e4SLinus Torvalds { 12131da177e4SLinus Torvalds .ctl_name = VM_LOWMEM_RESERVE_RATIO, 12141da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 12151da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 12161da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 12171da177e4SLinus Torvalds .mode = 0644, 12181da177e4SLinus Torvalds .proc_handler = &lowmem_reserve_ratio_sysctl_handler, 12191da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12201da177e4SLinus Torvalds }, 12211da177e4SLinus Torvalds { 12229d0243bcSAndrew Morton .ctl_name = VM_DROP_PAGECACHE, 12239d0243bcSAndrew Morton .procname = "drop_caches", 12249d0243bcSAndrew Morton .data = &sysctl_drop_caches, 12259d0243bcSAndrew Morton .maxlen = sizeof(int), 12269d0243bcSAndrew Morton .mode = 0644, 12279d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 12289d0243bcSAndrew Morton .strategy = &sysctl_intvec, 12299d0243bcSAndrew Morton }, 12309d0243bcSAndrew Morton { 12311da177e4SLinus Torvalds .ctl_name = VM_MIN_FREE_KBYTES, 12321da177e4SLinus Torvalds .procname = "min_free_kbytes", 12331da177e4SLinus Torvalds .data = &min_free_kbytes, 12341da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 12351da177e4SLinus Torvalds .mode = 0644, 12361da177e4SLinus Torvalds .proc_handler = &min_free_kbytes_sysctl_handler, 12371da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12381da177e4SLinus Torvalds .extra1 = &zero, 12391da177e4SLinus Torvalds }, 12408ad4b1fbSRohit Seth { 12418ad4b1fbSRohit Seth .ctl_name = VM_PERCPU_PAGELIST_FRACTION, 12428ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 12438ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 12448ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 12458ad4b1fbSRohit Seth .mode = 0644, 12468ad4b1fbSRohit Seth .proc_handler = &percpu_pagelist_fraction_sysctl_handler, 12478ad4b1fbSRohit Seth .strategy = &sysctl_intvec, 12488ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 12498ad4b1fbSRohit Seth }, 12501da177e4SLinus Torvalds #ifdef CONFIG_MMU 12511da177e4SLinus Torvalds { 12521da177e4SLinus Torvalds .ctl_name = VM_MAX_MAP_COUNT, 12531da177e4SLinus Torvalds .procname = "max_map_count", 12541da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12551da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12561da177e4SLinus Torvalds .mode = 0644, 12571da177e4SLinus Torvalds .proc_handler = &proc_dointvec 12581da177e4SLinus Torvalds }, 1259dd8632a1SPaul Mundt #else 1260dd8632a1SPaul Mundt { 1261dd8632a1SPaul Mundt .ctl_name = CTL_UNNUMBERED, 1262dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1263dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1264dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1265dd8632a1SPaul Mundt .mode = 0644, 1266dd8632a1SPaul Mundt .proc_handler = &proc_dointvec_minmax, 1267dd8632a1SPaul Mundt .strategy = &sysctl_intvec, 1268dd8632a1SPaul Mundt .extra1 = &zero, 1269dd8632a1SPaul Mundt }, 12701da177e4SLinus Torvalds #endif 12711da177e4SLinus Torvalds { 12721da177e4SLinus Torvalds .ctl_name = VM_LAPTOP_MODE, 12731da177e4SLinus Torvalds .procname = "laptop_mode", 12741da177e4SLinus Torvalds .data = &laptop_mode, 12751da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12761da177e4SLinus Torvalds .mode = 0644, 1277ed5b43f1SBart Samwel .proc_handler = &proc_dointvec_jiffies, 1278ed5b43f1SBart Samwel .strategy = &sysctl_jiffies, 12791da177e4SLinus Torvalds }, 12801da177e4SLinus Torvalds { 12811da177e4SLinus Torvalds .ctl_name = VM_BLOCK_DUMP, 12821da177e4SLinus Torvalds .procname = "block_dump", 12831da177e4SLinus Torvalds .data = &block_dump, 12841da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12851da177e4SLinus Torvalds .mode = 0644, 12861da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12871da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12881da177e4SLinus Torvalds .extra1 = &zero, 12891da177e4SLinus Torvalds }, 12901da177e4SLinus Torvalds { 12911da177e4SLinus Torvalds .ctl_name = VM_VFS_CACHE_PRESSURE, 12921da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12931da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12941da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12951da177e4SLinus Torvalds .mode = 0644, 12961da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12971da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12981da177e4SLinus Torvalds .extra1 = &zero, 12991da177e4SLinus Torvalds }, 13001da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 13011da177e4SLinus Torvalds { 13021da177e4SLinus Torvalds .ctl_name = VM_LEGACY_VA_LAYOUT, 13031da177e4SLinus Torvalds .procname = "legacy_va_layout", 13041da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 13051da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 13061da177e4SLinus Torvalds .mode = 0644, 13071da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 13081da177e4SLinus Torvalds .strategy = &sysctl_intvec, 13091da177e4SLinus Torvalds .extra1 = &zero, 13101da177e4SLinus Torvalds }, 13111da177e4SLinus Torvalds #endif 13121743660bSChristoph Lameter #ifdef CONFIG_NUMA 13131743660bSChristoph Lameter { 13141743660bSChristoph Lameter .ctl_name = VM_ZONE_RECLAIM_MODE, 13151743660bSChristoph Lameter .procname = "zone_reclaim_mode", 13161743660bSChristoph Lameter .data = &zone_reclaim_mode, 13171743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 13181743660bSChristoph Lameter .mode = 0644, 13191743660bSChristoph Lameter .proc_handler = &proc_dointvec, 1320c84db23cSChristoph Lameter .strategy = &sysctl_intvec, 1321c84db23cSChristoph Lameter .extra1 = &zero, 13221743660bSChristoph Lameter }, 13239614634fSChristoph Lameter { 13249614634fSChristoph Lameter .ctl_name = VM_MIN_UNMAPPED, 13259614634fSChristoph Lameter .procname = "min_unmapped_ratio", 13269614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 13279614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 13289614634fSChristoph Lameter .mode = 0644, 13299614634fSChristoph Lameter .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler, 13309614634fSChristoph Lameter .strategy = &sysctl_intvec, 13319614634fSChristoph Lameter .extra1 = &zero, 13329614634fSChristoph Lameter .extra2 = &one_hundred, 13339614634fSChristoph Lameter }, 13340ff38490SChristoph Lameter { 13350ff38490SChristoph Lameter .ctl_name = VM_MIN_SLAB, 13360ff38490SChristoph Lameter .procname = "min_slab_ratio", 13370ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 13380ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 13390ff38490SChristoph Lameter .mode = 0644, 13400ff38490SChristoph Lameter .proc_handler = &sysctl_min_slab_ratio_sysctl_handler, 13410ff38490SChristoph Lameter .strategy = &sysctl_intvec, 13420ff38490SChristoph Lameter .extra1 = &zero, 13430ff38490SChristoph Lameter .extra2 = &one_hundred, 13440ff38490SChristoph Lameter }, 13451743660bSChristoph Lameter #endif 134677461ab3SChristoph Lameter #ifdef CONFIG_SMP 134777461ab3SChristoph Lameter { 134877461ab3SChristoph Lameter .ctl_name = CTL_UNNUMBERED, 134977461ab3SChristoph Lameter .procname = "stat_interval", 135077461ab3SChristoph Lameter .data = &sysctl_stat_interval, 135177461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 135277461ab3SChristoph Lameter .mode = 0644, 135377461ab3SChristoph Lameter .proc_handler = &proc_dointvec_jiffies, 135477461ab3SChristoph Lameter .strategy = &sysctl_jiffies, 135577461ab3SChristoph Lameter }, 135677461ab3SChristoph Lameter #endif 1357ed032189SEric Paris { 1358ed032189SEric Paris .ctl_name = CTL_UNNUMBERED, 1359ed032189SEric Paris .procname = "mmap_min_addr", 1360788084abSEric Paris .data = &dac_mmap_min_addr, 1361ed032189SEric Paris .maxlen = sizeof(unsigned long), 1362ed032189SEric Paris .mode = 0644, 1363788084abSEric Paris .proc_handler = &mmap_min_addr_handler, 1364ed032189SEric Paris }, 1365f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1366f0c0b2b8SKAMEZAWA Hiroyuki { 1367f0c0b2b8SKAMEZAWA Hiroyuki .ctl_name = CTL_UNNUMBERED, 1368f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1369f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1370f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1371f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 1372f0c0b2b8SKAMEZAWA Hiroyuki .proc_handler = &numa_zonelist_order_handler, 1373f0c0b2b8SKAMEZAWA Hiroyuki .strategy = &sysctl_string, 1374f0c0b2b8SKAMEZAWA Hiroyuki }, 1375f0c0b2b8SKAMEZAWA Hiroyuki #endif 13762b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13775c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1378e6e5494cSIngo Molnar { 1379e6e5494cSIngo Molnar .ctl_name = VM_VDSO_ENABLED, 1380e6e5494cSIngo Molnar .procname = "vdso_enabled", 1381e6e5494cSIngo Molnar .data = &vdso_enabled, 1382e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1383e6e5494cSIngo Molnar .mode = 0644, 1384e6e5494cSIngo Molnar .proc_handler = &proc_dointvec, 1385e6e5494cSIngo Molnar .strategy = &sysctl_intvec, 1386e6e5494cSIngo Molnar .extra1 = &zero, 1387e6e5494cSIngo Molnar }, 1388e6e5494cSIngo Molnar #endif 1389195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1390195cf453SBron Gondwana { 1391195cf453SBron Gondwana .ctl_name = CTL_UNNUMBERED, 1392195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1393195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1394195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1395195cf453SBron Gondwana .mode = 0644, 1396195cf453SBron Gondwana .proc_handler = &proc_dointvec_minmax, 1397195cf453SBron Gondwana .strategy = &sysctl_intvec, 1398195cf453SBron Gondwana .extra1 = &zero, 1399195cf453SBron Gondwana .extra2 = &one, 1400195cf453SBron Gondwana }, 1401195cf453SBron Gondwana #endif 14024be6f6bbSPeter Zijlstra { 14034be6f6bbSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 14044be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 14054be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 14064be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 14074be6f6bbSPeter Zijlstra .mode = 0644, 14084be6f6bbSPeter Zijlstra .proc_handler = &scan_unevictable_handler, 14094be6f6bbSPeter Zijlstra }, 14106a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 14116a46079cSAndi Kleen { 14126a46079cSAndi Kleen .ctl_name = CTL_UNNUMBERED, 14136a46079cSAndi Kleen .procname = "memory_failure_early_kill", 14146a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 14156a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 14166a46079cSAndi Kleen .mode = 0644, 14176a46079cSAndi Kleen .proc_handler = &proc_dointvec_minmax, 14186a46079cSAndi Kleen .strategy = &sysctl_intvec, 14196a46079cSAndi Kleen .extra1 = &zero, 14206a46079cSAndi Kleen .extra2 = &one, 14216a46079cSAndi Kleen }, 14226a46079cSAndi Kleen { 14236a46079cSAndi Kleen .ctl_name = CTL_UNNUMBERED, 14246a46079cSAndi Kleen .procname = "memory_failure_recovery", 14256a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 14266a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 14276a46079cSAndi Kleen .mode = 0644, 14286a46079cSAndi Kleen .proc_handler = &proc_dointvec_minmax, 14296a46079cSAndi Kleen .strategy = &sysctl_intvec, 14306a46079cSAndi Kleen .extra1 = &zero, 14316a46079cSAndi Kleen .extra2 = &one, 14326a46079cSAndi Kleen }, 14336a46079cSAndi Kleen #endif 14346a46079cSAndi Kleen 14352be7fe07SAndrew Morton /* 14362be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14372be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14382be7fe07SAndrew Morton */ 14391da177e4SLinus Torvalds { .ctl_name = 0 } 14401da177e4SLinus Torvalds }; 14411da177e4SLinus Torvalds 14422abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1443d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 14442abc26fcSEric W. Biederman { .ctl_name = 0 } 14452abc26fcSEric W. Biederman }; 14462abc26fcSEric W. Biederman #endif 14472abc26fcSEric W. Biederman 1448d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 14491da177e4SLinus Torvalds { 14501da177e4SLinus Torvalds .ctl_name = FS_NRINODE, 14511da177e4SLinus Torvalds .procname = "inode-nr", 14521da177e4SLinus Torvalds .data = &inodes_stat, 14531da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 14541da177e4SLinus Torvalds .mode = 0444, 14551da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14561da177e4SLinus Torvalds }, 14571da177e4SLinus Torvalds { 14581da177e4SLinus Torvalds .ctl_name = FS_STATINODE, 14591da177e4SLinus Torvalds .procname = "inode-state", 14601da177e4SLinus Torvalds .data = &inodes_stat, 14611da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 14621da177e4SLinus Torvalds .mode = 0444, 14631da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14641da177e4SLinus Torvalds }, 14651da177e4SLinus Torvalds { 14661da177e4SLinus Torvalds .procname = "file-nr", 14671da177e4SLinus Torvalds .data = &files_stat, 14681da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 14691da177e4SLinus Torvalds .mode = 0444, 1470529bf6beSDipankar Sarma .proc_handler = &proc_nr_files, 14711da177e4SLinus Torvalds }, 14721da177e4SLinus Torvalds { 14731da177e4SLinus Torvalds .ctl_name = FS_MAXFILE, 14741da177e4SLinus Torvalds .procname = "file-max", 14751da177e4SLinus Torvalds .data = &files_stat.max_files, 14761da177e4SLinus Torvalds .maxlen = sizeof(int), 14771da177e4SLinus Torvalds .mode = 0644, 14781da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14791da177e4SLinus Torvalds }, 14801da177e4SLinus Torvalds { 14819cfe015aSEric Dumazet .ctl_name = CTL_UNNUMBERED, 14829cfe015aSEric Dumazet .procname = "nr_open", 14839cfe015aSEric Dumazet .data = &sysctl_nr_open, 14849cfe015aSEric Dumazet .maxlen = sizeof(int), 14859cfe015aSEric Dumazet .mode = 0644, 1486eceea0b3SAl Viro .proc_handler = &proc_dointvec_minmax, 1487eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1488eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14899cfe015aSEric Dumazet }, 14909cfe015aSEric Dumazet { 14911da177e4SLinus Torvalds .ctl_name = FS_DENTRY, 14921da177e4SLinus Torvalds .procname = "dentry-state", 14931da177e4SLinus Torvalds .data = &dentry_stat, 14941da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14951da177e4SLinus Torvalds .mode = 0444, 14961da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14971da177e4SLinus Torvalds }, 14981da177e4SLinus Torvalds { 14991da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWUID, 15001da177e4SLinus Torvalds .procname = "overflowuid", 15011da177e4SLinus Torvalds .data = &fs_overflowuid, 15021da177e4SLinus Torvalds .maxlen = sizeof(int), 15031da177e4SLinus Torvalds .mode = 0644, 15041da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 15051da177e4SLinus Torvalds .strategy = &sysctl_intvec, 15061da177e4SLinus Torvalds .extra1 = &minolduid, 15071da177e4SLinus Torvalds .extra2 = &maxolduid, 15081da177e4SLinus Torvalds }, 15091da177e4SLinus Torvalds { 15101da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWGID, 15111da177e4SLinus Torvalds .procname = "overflowgid", 15121da177e4SLinus Torvalds .data = &fs_overflowgid, 15131da177e4SLinus Torvalds .maxlen = sizeof(int), 15141da177e4SLinus Torvalds .mode = 0644, 15151da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 15161da177e4SLinus Torvalds .strategy = &sysctl_intvec, 15171da177e4SLinus Torvalds .extra1 = &minolduid, 15181da177e4SLinus Torvalds .extra2 = &maxolduid, 15191da177e4SLinus Torvalds }, 1520bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 15211da177e4SLinus Torvalds { 15221da177e4SLinus Torvalds .ctl_name = FS_LEASES, 15231da177e4SLinus Torvalds .procname = "leases-enable", 15241da177e4SLinus Torvalds .data = &leases_enable, 15251da177e4SLinus Torvalds .maxlen = sizeof(int), 15261da177e4SLinus Torvalds .mode = 0644, 15271da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 15281da177e4SLinus Torvalds }, 1529bfcd17a6SThomas Petazzoni #endif 15301da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 15311da177e4SLinus Torvalds { 15321da177e4SLinus Torvalds .ctl_name = FS_DIR_NOTIFY, 15331da177e4SLinus Torvalds .procname = "dir-notify-enable", 15341da177e4SLinus Torvalds .data = &dir_notify_enable, 15351da177e4SLinus Torvalds .maxlen = sizeof(int), 15361da177e4SLinus Torvalds .mode = 0644, 15371da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 15381da177e4SLinus Torvalds }, 15391da177e4SLinus Torvalds #endif 15401da177e4SLinus Torvalds #ifdef CONFIG_MMU 1541bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 15421da177e4SLinus Torvalds { 15431da177e4SLinus Torvalds .ctl_name = FS_LEASE_TIME, 15441da177e4SLinus Torvalds .procname = "lease-break-time", 15451da177e4SLinus Torvalds .data = &lease_break_time, 15461da177e4SLinus Torvalds .maxlen = sizeof(int), 15471da177e4SLinus Torvalds .mode = 0644, 15488e654fbaSMatthew Wilcox .proc_handler = &proc_dointvec, 15491da177e4SLinus Torvalds }, 1550bfcd17a6SThomas Petazzoni #endif 1551ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 15521da177e4SLinus Torvalds { 15531da177e4SLinus Torvalds .procname = "aio-nr", 15541da177e4SLinus Torvalds .data = &aio_nr, 15551da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 15561da177e4SLinus Torvalds .mode = 0444, 1557d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 15581da177e4SLinus Torvalds }, 15591da177e4SLinus Torvalds { 15601da177e4SLinus Torvalds .procname = "aio-max-nr", 15611da177e4SLinus Torvalds .data = &aio_max_nr, 15621da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 15631da177e4SLinus Torvalds .mode = 0644, 1564d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 15651da177e4SLinus Torvalds }, 1566ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 15672d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 15680399cb08SRobert Love { 15690399cb08SRobert Love .ctl_name = FS_INOTIFY, 15700399cb08SRobert Love .procname = "inotify", 15710399cb08SRobert Love .mode = 0555, 15720399cb08SRobert Love .child = inotify_table, 15730399cb08SRobert Love }, 15740399cb08SRobert Love #endif 15757ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 15767ef9964eSDavide Libenzi { 15777ef9964eSDavide Libenzi .procname = "epoll", 15787ef9964eSDavide Libenzi .mode = 0555, 15797ef9964eSDavide Libenzi .child = epoll_table, 15807ef9964eSDavide Libenzi }, 15817ef9964eSDavide Libenzi #endif 15821da177e4SLinus Torvalds #endif 1583d6e71144SAlan Cox { 1584d6e71144SAlan Cox .ctl_name = KERN_SETUID_DUMPABLE, 1585d6e71144SAlan Cox .procname = "suid_dumpable", 1586d6e71144SAlan Cox .data = &suid_dumpable, 1587d6e71144SAlan Cox .maxlen = sizeof(int), 1588d6e71144SAlan Cox .mode = 0644, 15898e654fbaSMatthew Wilcox .proc_handler = &proc_dointvec_minmax, 15908e654fbaSMatthew Wilcox .strategy = &sysctl_intvec, 15918e654fbaSMatthew Wilcox .extra1 = &zero, 15928e654fbaSMatthew Wilcox .extra2 = &two, 1593d6e71144SAlan Cox }, 15942abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 15952abc26fcSEric W. Biederman { 15962abc26fcSEric W. Biederman .ctl_name = CTL_UNNUMBERED, 15972abc26fcSEric W. Biederman .procname = "binfmt_misc", 15982abc26fcSEric W. Biederman .mode = 0555, 15992abc26fcSEric W. Biederman .child = binfmt_misc_table, 16002abc26fcSEric W. Biederman }, 16012abc26fcSEric W. Biederman #endif 16022be7fe07SAndrew Morton /* 16032be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 16042be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 16052be7fe07SAndrew Morton */ 16061da177e4SLinus Torvalds { .ctl_name = 0 } 16071da177e4SLinus Torvalds }; 16081da177e4SLinus Torvalds 1609d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1610d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC) 1611abd4f750SMasoud Asgharifard Sharbiani { 1612abd4f750SMasoud Asgharifard Sharbiani .ctl_name = CTL_UNNUMBERED, 1613abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1614abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1615abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1616abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1617abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1618abd4f750SMasoud Asgharifard Sharbiani }, 1619abd4f750SMasoud Asgharifard Sharbiani #endif 16201da177e4SLinus Torvalds { .ctl_name = 0 } 16211da177e4SLinus Torvalds }; 16221da177e4SLinus Torvalds 1623d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 16241da177e4SLinus Torvalds { .ctl_name = 0 } 16251da177e4SLinus Torvalds }; 16261da177e4SLinus Torvalds 1627330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1628330d57fbSAl Viro 1629330d57fbSAl Viro /* called under sysctl_lock */ 1630330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1631330d57fbSAl Viro { 1632330d57fbSAl Viro if (unlikely(p->unregistering)) 1633330d57fbSAl Viro return 0; 1634330d57fbSAl Viro p->used++; 1635330d57fbSAl Viro return 1; 1636330d57fbSAl Viro } 1637330d57fbSAl Viro 1638330d57fbSAl Viro /* called under sysctl_lock */ 1639330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1640330d57fbSAl Viro { 1641330d57fbSAl Viro if (!--p->used) 1642330d57fbSAl Viro if (unlikely(p->unregistering)) 1643330d57fbSAl Viro complete(p->unregistering); 1644330d57fbSAl Viro } 1645330d57fbSAl Viro 1646330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1647330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1648330d57fbSAl Viro { 1649330d57fbSAl Viro /* 1650330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1651330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1652330d57fbSAl Viro */ 1653330d57fbSAl Viro if (unlikely(p->used)) { 1654330d57fbSAl Viro struct completion wait; 1655330d57fbSAl Viro init_completion(&wait); 1656330d57fbSAl Viro p->unregistering = &wait; 1657330d57fbSAl Viro spin_unlock(&sysctl_lock); 1658330d57fbSAl Viro wait_for_completion(&wait); 1659330d57fbSAl Viro spin_lock(&sysctl_lock); 1660f7e6ced4SAl Viro } else { 1661f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1662f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1663330d57fbSAl Viro } 1664330d57fbSAl Viro /* 1665330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1666330d57fbSAl Viro * list in do_sysctl() relies on that. 1667330d57fbSAl Viro */ 1668330d57fbSAl Viro list_del_init(&p->ctl_entry); 1669330d57fbSAl Viro } 1670330d57fbSAl Viro 1671f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1672f7e6ced4SAl Viro { 1673f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1674f7e6ced4SAl Viro head->count++; 1675f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1676f7e6ced4SAl Viro } 1677f7e6ced4SAl Viro 1678f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1679f7e6ced4SAl Viro { 1680f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1681f7e6ced4SAl Viro if (!--head->count) 1682f7e6ced4SAl Viro kfree(head); 1683f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1684f7e6ced4SAl Viro } 1685f7e6ced4SAl Viro 1686f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1687f7e6ced4SAl Viro { 1688f7e6ced4SAl Viro if (!head) 1689f7e6ced4SAl Viro BUG(); 1690f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1691f7e6ced4SAl Viro if (!use_table(head)) 1692f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1693f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1694f7e6ced4SAl Viro return head; 1695f7e6ced4SAl Viro } 1696f7e6ced4SAl Viro 1697805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1698805b5d5eSEric W. Biederman { 1699805b5d5eSEric W. Biederman if (!head) 1700805b5d5eSEric W. Biederman return; 1701805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1702805b5d5eSEric W. Biederman unuse_table(head); 1703805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1704805b5d5eSEric W. Biederman } 1705805b5d5eSEric W. Biederman 170673455092SAl Viro static struct ctl_table_set * 170773455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 170873455092SAl Viro { 170973455092SAl Viro struct ctl_table_set *set = &root->default_set; 171073455092SAl Viro if (root->lookup) 171173455092SAl Viro set = root->lookup(root, namespaces); 171273455092SAl Viro return set; 171373455092SAl Viro } 171473455092SAl Viro 1715e51b6ba0SEric W. Biederman static struct list_head * 1716e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1717805b5d5eSEric W. Biederman { 171873455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 171973455092SAl Viro return &set->list; 1720e51b6ba0SEric W. Biederman } 1721e51b6ba0SEric W. Biederman 1722e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1723e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1724e51b6ba0SEric W. Biederman { 1725e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1726e51b6ba0SEric W. Biederman struct list_head *header_list; 1727805b5d5eSEric W. Biederman struct ctl_table_header *head; 1728805b5d5eSEric W. Biederman struct list_head *tmp; 1729e51b6ba0SEric W. Biederman 1730805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1731805b5d5eSEric W. Biederman if (prev) { 1732e51b6ba0SEric W. Biederman head = prev; 1733805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1734805b5d5eSEric W. Biederman unuse_table(prev); 1735805b5d5eSEric W. Biederman goto next; 1736805b5d5eSEric W. Biederman } 1737805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1738805b5d5eSEric W. Biederman for (;;) { 1739805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1740805b5d5eSEric W. Biederman 1741805b5d5eSEric W. Biederman if (!use_table(head)) 1742805b5d5eSEric W. Biederman goto next; 1743805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1744805b5d5eSEric W. Biederman return head; 1745805b5d5eSEric W. Biederman next: 1746e51b6ba0SEric W. Biederman root = head->root; 1747805b5d5eSEric W. Biederman tmp = tmp->next; 1748e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1749e51b6ba0SEric W. Biederman if (tmp != header_list) 1750e51b6ba0SEric W. Biederman continue; 1751e51b6ba0SEric W. Biederman 1752e51b6ba0SEric W. Biederman do { 1753e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1754e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1755e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1756e51b6ba0SEric W. Biederman goto out; 1757e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1758e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1759e51b6ba0SEric W. Biederman tmp = header_list->next; 1760805b5d5eSEric W. Biederman } 1761e51b6ba0SEric W. Biederman out: 1762805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1763805b5d5eSEric W. Biederman return NULL; 1764805b5d5eSEric W. Biederman } 1765805b5d5eSEric W. Biederman 1766e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1767e51b6ba0SEric W. Biederman { 1768e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1769e51b6ba0SEric W. Biederman } 1770e51b6ba0SEric W. Biederman 1771e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1772e51b6ba0SEric W. Biederman { 1773e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1774e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1775e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1776e51b6ba0SEric W. Biederman } 1777e51b6ba0SEric W. Biederman 1778b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 17792c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */ 1780d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root, 1781d7321cd6SPavel Emelyanov struct ctl_table *table, 17822c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 17832c4c7155SPavel Emelyanov void __user *newval, size_t newlen) 17842c4c7155SPavel Emelyanov { 17852c4c7155SPavel Emelyanov int op = 0, rc; 17862c4c7155SPavel Emelyanov 17872c4c7155SPavel Emelyanov if (oldval) 1788e6305c43SAl Viro op |= MAY_READ; 17892c4c7155SPavel Emelyanov if (newval) 1790e6305c43SAl Viro op |= MAY_WRITE; 1791d7321cd6SPavel Emelyanov if (sysctl_perm(root, table, op)) 17922c4c7155SPavel Emelyanov return -EPERM; 17932c4c7155SPavel Emelyanov 17942c4c7155SPavel Emelyanov if (table->strategy) { 1795f221e726SAlexey Dobriyan rc = table->strategy(table, oldval, oldlenp, newval, newlen); 17962c4c7155SPavel Emelyanov if (rc < 0) 17972c4c7155SPavel Emelyanov return rc; 17982c4c7155SPavel Emelyanov if (rc > 0) 17992c4c7155SPavel Emelyanov return 0; 18002c4c7155SPavel Emelyanov } 18012c4c7155SPavel Emelyanov 18022c4c7155SPavel Emelyanov /* If there is no strategy routine, or if the strategy returns 18032c4c7155SPavel Emelyanov * zero, proceed with automatic r/w */ 18042c4c7155SPavel Emelyanov if (table->data && table->maxlen) { 1805f221e726SAlexey Dobriyan rc = sysctl_data(table, oldval, oldlenp, newval, newlen); 18062c4c7155SPavel Emelyanov if (rc < 0) 18072c4c7155SPavel Emelyanov return rc; 18082c4c7155SPavel Emelyanov } 18092c4c7155SPavel Emelyanov return 0; 18102c4c7155SPavel Emelyanov } 18112c4c7155SPavel Emelyanov 18122c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen, 18132c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 18142c4c7155SPavel Emelyanov void __user *newval, size_t newlen, 1815d7321cd6SPavel Emelyanov struct ctl_table_root *root, 18162c4c7155SPavel Emelyanov struct ctl_table *table) 18172c4c7155SPavel Emelyanov { 18182c4c7155SPavel Emelyanov int n; 18192c4c7155SPavel Emelyanov repeat: 18202c4c7155SPavel Emelyanov if (!nlen) 18212c4c7155SPavel Emelyanov return -ENOTDIR; 18222c4c7155SPavel Emelyanov if (get_user(n, name)) 18232c4c7155SPavel Emelyanov return -EFAULT; 18242c4c7155SPavel Emelyanov for ( ; table->ctl_name || table->procname; table++) { 18252c4c7155SPavel Emelyanov if (!table->ctl_name) 18262c4c7155SPavel Emelyanov continue; 18272c4c7155SPavel Emelyanov if (n == table->ctl_name) { 18282c4c7155SPavel Emelyanov int error; 18292c4c7155SPavel Emelyanov if (table->child) { 1830e6305c43SAl Viro if (sysctl_perm(root, table, MAY_EXEC)) 18312c4c7155SPavel Emelyanov return -EPERM; 18322c4c7155SPavel Emelyanov name++; 18332c4c7155SPavel Emelyanov nlen--; 18342c4c7155SPavel Emelyanov table = table->child; 18352c4c7155SPavel Emelyanov goto repeat; 18362c4c7155SPavel Emelyanov } 1837f221e726SAlexey Dobriyan error = do_sysctl_strategy(root, table, 18382c4c7155SPavel Emelyanov oldval, oldlenp, 18392c4c7155SPavel Emelyanov newval, newlen); 18402c4c7155SPavel Emelyanov return error; 18412c4c7155SPavel Emelyanov } 18422c4c7155SPavel Emelyanov } 18432c4c7155SPavel Emelyanov return -ENOTDIR; 18442c4c7155SPavel Emelyanov } 18452c4c7155SPavel Emelyanov 18461da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 18471da177e4SLinus Torvalds void __user *newval, size_t newlen) 18481da177e4SLinus Torvalds { 1849805b5d5eSEric W. Biederman struct ctl_table_header *head; 1850330d57fbSAl Viro int error = -ENOTDIR; 18511da177e4SLinus Torvalds 18521da177e4SLinus Torvalds if (nlen <= 0 || nlen >= CTL_MAXNAME) 18531da177e4SLinus Torvalds return -ENOTDIR; 18541da177e4SLinus Torvalds if (oldval) { 18551da177e4SLinus Torvalds int old_len; 18561da177e4SLinus Torvalds if (!oldlenp || get_user(old_len, oldlenp)) 18571da177e4SLinus Torvalds return -EFAULT; 18581da177e4SLinus Torvalds } 1859330d57fbSAl Viro 1860805b5d5eSEric W. Biederman for (head = sysctl_head_next(NULL); head; 1861805b5d5eSEric W. Biederman head = sysctl_head_next(head)) { 1862330d57fbSAl Viro error = parse_table(name, nlen, oldval, oldlenp, 1863d7321cd6SPavel Emelyanov newval, newlen, 1864d7321cd6SPavel Emelyanov head->root, head->ctl_table); 1865805b5d5eSEric W. Biederman if (error != -ENOTDIR) { 1866805b5d5eSEric W. Biederman sysctl_head_finish(head); 1867330d57fbSAl Viro break; 1868805b5d5eSEric W. Biederman } 1869805b5d5eSEric W. Biederman } 18701da177e4SLinus Torvalds return error; 18711da177e4SLinus Torvalds } 18721da177e4SLinus Torvalds 18731e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) 18741da177e4SLinus Torvalds { 18751da177e4SLinus Torvalds struct __sysctl_args tmp; 18761da177e4SLinus Torvalds int error; 18771da177e4SLinus Torvalds 18781da177e4SLinus Torvalds if (copy_from_user(&tmp, args, sizeof(tmp))) 18791da177e4SLinus Torvalds return -EFAULT; 18801da177e4SLinus Torvalds 18817058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 18827058cb02SEric W. Biederman if (error) 18837058cb02SEric W. Biederman goto out; 18847058cb02SEric W. Biederman 18851da177e4SLinus Torvalds lock_kernel(); 18861da177e4SLinus Torvalds error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, 18871da177e4SLinus Torvalds tmp.newval, tmp.newlen); 18881da177e4SLinus Torvalds unlock_kernel(); 18897058cb02SEric W. Biederman out: 18901da177e4SLinus Torvalds return error; 18911da177e4SLinus Torvalds } 1892b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 18931da177e4SLinus Torvalds 18941da177e4SLinus Torvalds /* 18951ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 18961da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 18971da177e4SLinus Torvalds */ 18981da177e4SLinus Torvalds 18991da177e4SLinus Torvalds static int test_perm(int mode, int op) 19001da177e4SLinus Torvalds { 190176aac0e9SDavid Howells if (!current_euid()) 19021da177e4SLinus Torvalds mode >>= 6; 19031da177e4SLinus Torvalds else if (in_egroup_p(0)) 19041da177e4SLinus Torvalds mode >>= 3; 1905e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 19061da177e4SLinus Torvalds return 0; 19071da177e4SLinus Torvalds return -EACCES; 19081da177e4SLinus Torvalds } 19091da177e4SLinus Torvalds 1910d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 19111da177e4SLinus Torvalds { 19121da177e4SLinus Torvalds int error; 1913d7321cd6SPavel Emelyanov int mode; 1914d7321cd6SPavel Emelyanov 1915e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 19161da177e4SLinus Torvalds if (error) 19171da177e4SLinus Torvalds return error; 1918d7321cd6SPavel Emelyanov 1919d7321cd6SPavel Emelyanov if (root->permissions) 1920d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1921d7321cd6SPavel Emelyanov else 1922d7321cd6SPavel Emelyanov mode = table->mode; 1923d7321cd6SPavel Emelyanov 1924d7321cd6SPavel Emelyanov return test_perm(mode, op); 19251da177e4SLinus Torvalds } 19261da177e4SLinus Torvalds 1927d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1928d912b0ccSEric W. Biederman { 1929d912b0ccSEric W. Biederman for (; table->ctl_name || table->procname; table++) { 1930d912b0ccSEric W. Biederman table->parent = parent; 1931d912b0ccSEric W. Biederman if (table->child) 1932d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1933d912b0ccSEric W. Biederman } 1934d912b0ccSEric W. Biederman } 1935d912b0ccSEric W. Biederman 1936d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1937d912b0ccSEric W. Biederman { 1938d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 193988f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 194088f458e4SHolger Schurig { 194188f458e4SHolger Schurig int err; 1942e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 194388f458e4SHolger Schurig } 194488f458e4SHolger Schurig #endif 1945d912b0ccSEric W. Biederman return 0; 1946d912b0ccSEric W. Biederman } 1947d912b0ccSEric W. Biederman 1948d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1949d912b0ccSEric W. Biederman 1950bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1951bfbcf034SAl Viro struct ctl_table *table) 1952ae7edeccSAl Viro { 1953ae7edeccSAl Viro struct ctl_table *p; 1954ae7edeccSAl Viro const char *s = branch->procname; 1955ae7edeccSAl Viro 1956ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1957ae7edeccSAl Viro if (!s || !branch->child) 1958bfbcf034SAl Viro return NULL; 1959ae7edeccSAl Viro 1960ae7edeccSAl Viro /* ... and nothing else */ 1961ae7edeccSAl Viro if (branch[1].procname || branch[1].ctl_name) 1962bfbcf034SAl Viro return NULL; 1963ae7edeccSAl Viro 1964ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 1965ae7edeccSAl Viro for (p = table; p->procname || p->ctl_name; p++) { 1966ae7edeccSAl Viro if (!p->child) 1967ae7edeccSAl Viro continue; 1968ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1969bfbcf034SAl Viro return p; 1970ae7edeccSAl Viro } 1971bfbcf034SAl Viro return NULL; 1972ae7edeccSAl Viro } 1973ae7edeccSAl Viro 1974ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1975ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1976ae7edeccSAl Viro { 1977ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1978bfbcf034SAl Viro struct ctl_table *next; 1979ae7edeccSAl Viro int is_better = 0; 1980ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1981ae7edeccSAl Viro 1982bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1983ae7edeccSAl Viro if (by == q->attached_by) 1984ae7edeccSAl Viro is_better = 1; 1985ae7edeccSAl Viro if (to == p->attached_by) 1986ae7edeccSAl Viro not_in_parent = 1; 1987ae7edeccSAl Viro by = by->child; 1988bfbcf034SAl Viro to = next->child; 1989ae7edeccSAl Viro } 1990ae7edeccSAl Viro 1991ae7edeccSAl Viro if (is_better && not_in_parent) { 1992ae7edeccSAl Viro q->attached_by = by; 1993ae7edeccSAl Viro q->attached_to = to; 1994ae7edeccSAl Viro q->parent = p; 1995ae7edeccSAl Viro } 1996ae7edeccSAl Viro } 1997ae7edeccSAl Viro 19981da177e4SLinus Torvalds /** 1999e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 2000e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 2001e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 200229e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 20031da177e4SLinus Torvalds * @table: the top-level table structure 20041da177e4SLinus Torvalds * 20051da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 200629e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 20071da177e4SLinus Torvalds * 2008d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 20091da177e4SLinus Torvalds * 20101da177e4SLinus Torvalds * ctl_name - This is the numeric sysctl value used by sysctl(2). The number 20111da177e4SLinus Torvalds * must be unique within that level of sysctl 20121da177e4SLinus Torvalds * 20131da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 20141da177e4SLinus Torvalds * enter a sysctl file 20151da177e4SLinus Torvalds * 20161da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 20171da177e4SLinus Torvalds * 20181da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 20191da177e4SLinus Torvalds * 20201da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 20211da177e4SLinus Torvalds * 20221da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 20231da177e4SLinus Torvalds * %NULL. 20241da177e4SLinus Torvalds * 20251da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 20261da177e4SLinus Torvalds * 20271da177e4SLinus Torvalds * strategy - the strategy routine (described below) 20281da177e4SLinus Torvalds * 20291da177e4SLinus Torvalds * de - for internal use by the sysctl routines 20301da177e4SLinus Torvalds * 20311da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 20321da177e4SLinus Torvalds * 20331da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 20341da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 20351da177e4SLinus Torvalds * 20361da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 20371da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 20381da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 20391da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 20401da177e4SLinus Torvalds * 20411da177e4SLinus Torvalds * More sophisticated management can be enabled by the provision of a 20421da177e4SLinus Torvalds * strategy routine with the table entry. This will be called before 20431da177e4SLinus Torvalds * any automatic read or write of the data is performed. 20441da177e4SLinus Torvalds * 20451da177e4SLinus Torvalds * The strategy routine may return 20461da177e4SLinus Torvalds * 20471da177e4SLinus Torvalds * < 0 - Error occurred (error is passed to user process) 20481da177e4SLinus Torvalds * 20491da177e4SLinus Torvalds * 0 - OK - proceed with automatic read or write. 20501da177e4SLinus Torvalds * 20511da177e4SLinus Torvalds * > 0 - OK - read or write has been done by the strategy routine, so 20521da177e4SLinus Torvalds * return immediately. 20531da177e4SLinus Torvalds * 20541da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 20551da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 20561da177e4SLinus Torvalds * directory handler). Several default handlers are available to 20571da177e4SLinus Torvalds * cover common cases - 20581da177e4SLinus Torvalds * 20591da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 20601da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 20611da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 20621da177e4SLinus Torvalds * 20631da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 20641da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 20651da177e4SLinus Torvalds * 20661da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 20671da177e4SLinus Torvalds * to the table header on success. 20681da177e4SLinus Torvalds */ 2069e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 2070e51b6ba0SEric W. Biederman struct ctl_table_root *root, 2071e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 2072e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 20731da177e4SLinus Torvalds { 207429e796fdSEric W. Biederman struct ctl_table_header *header; 207529e796fdSEric W. Biederman struct ctl_table *new, **prevp; 207629e796fdSEric W. Biederman unsigned int n, npath; 2077ae7edeccSAl Viro struct ctl_table_set *set; 207829e796fdSEric W. Biederman 207929e796fdSEric W. Biederman /* Count the path components */ 208029e796fdSEric W. Biederman for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath) 208129e796fdSEric W. Biederman ; 208229e796fdSEric W. Biederman 208329e796fdSEric W. Biederman /* 208429e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 208529e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 208629e796fdSEric W. Biederman * for this, the second will be the sentinel (ctl_name == 0). 208729e796fdSEric W. Biederman * 208829e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 208929e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 209029e796fdSEric W. Biederman */ 209129e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 209229e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 209329e796fdSEric W. Biederman if (!header) 20941da177e4SLinus Torvalds return NULL; 209529e796fdSEric W. Biederman 209629e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 209729e796fdSEric W. Biederman 209829e796fdSEric W. Biederman /* Now connect the dots */ 209929e796fdSEric W. Biederman prevp = &header->ctl_table; 210029e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 210129e796fdSEric W. Biederman /* Copy the procname */ 210229e796fdSEric W. Biederman new->procname = path->procname; 210329e796fdSEric W. Biederman new->ctl_name = path->ctl_name; 210429e796fdSEric W. Biederman new->mode = 0555; 210529e796fdSEric W. Biederman 210629e796fdSEric W. Biederman *prevp = new; 210729e796fdSEric W. Biederman prevp = &new->child; 210829e796fdSEric W. Biederman 210929e796fdSEric W. Biederman new += 2; 211029e796fdSEric W. Biederman } 211129e796fdSEric W. Biederman *prevp = table; 211223eb06deSEric W. Biederman header->ctl_table_arg = table; 211329e796fdSEric W. Biederman 211429e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 211529e796fdSEric W. Biederman header->used = 0; 211629e796fdSEric W. Biederman header->unregistering = NULL; 2117e51b6ba0SEric W. Biederman header->root = root; 211829e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 2119f7e6ced4SAl Viro header->count = 1; 212088f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 2121e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 212229e796fdSEric W. Biederman kfree(header); 2123fc6cd25bSEric W. Biederman return NULL; 2124fc6cd25bSEric W. Biederman } 212588f458e4SHolger Schurig #endif 2126330d57fbSAl Viro spin_lock(&sysctl_lock); 212773455092SAl Viro header->set = lookup_header_set(root, namespaces); 2128ae7edeccSAl Viro header->attached_by = header->ctl_table; 2129ae7edeccSAl Viro header->attached_to = root_table; 2130ae7edeccSAl Viro header->parent = &root_table_header; 2131ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 2132ae7edeccSAl Viro struct ctl_table_header *p; 2133ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 2134ae7edeccSAl Viro if (p->unregistering) 2135ae7edeccSAl Viro continue; 2136ae7edeccSAl Viro try_attach(p, header); 2137ae7edeccSAl Viro } 2138ae7edeccSAl Viro } 2139ae7edeccSAl Viro header->parent->count++; 214073455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 2141330d57fbSAl Viro spin_unlock(&sysctl_lock); 214229e796fdSEric W. Biederman 214329e796fdSEric W. Biederman return header; 214429e796fdSEric W. Biederman } 214529e796fdSEric W. Biederman 214629e796fdSEric W. Biederman /** 2147e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 2148e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 2149e51b6ba0SEric W. Biederman * @table: the top-level table structure 2150e51b6ba0SEric W. Biederman * 2151e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 2152e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 2153e51b6ba0SEric W. Biederman * 2154e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 2155e51b6ba0SEric W. Biederman */ 2156e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 2157e51b6ba0SEric W. Biederman struct ctl_table *table) 2158e51b6ba0SEric W. Biederman { 2159e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 2160e51b6ba0SEric W. Biederman path, table); 2161e51b6ba0SEric W. Biederman } 2162e51b6ba0SEric W. Biederman 2163e51b6ba0SEric W. Biederman /** 216429e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 216529e796fdSEric W. Biederman * @table: the top-level table structure 216629e796fdSEric W. Biederman * 216729e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 216829e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 216929e796fdSEric W. Biederman * 217029e796fdSEric W. Biederman * See register_sysctl_paths for more details. 217129e796fdSEric W. Biederman */ 217229e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 217329e796fdSEric W. Biederman { 217429e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 217529e796fdSEric W. Biederman 217629e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 21771da177e4SLinus Torvalds } 21781da177e4SLinus Torvalds 21791da177e4SLinus Torvalds /** 21801da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 21811da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 21821da177e4SLinus Torvalds * 21831da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 21841da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 21851da177e4SLinus Torvalds */ 21861da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 21871da177e4SLinus Torvalds { 2188330d57fbSAl Viro might_sleep(); 2189f1dad166SPavel Emelyanov 2190f1dad166SPavel Emelyanov if (header == NULL) 2191f1dad166SPavel Emelyanov return; 2192f1dad166SPavel Emelyanov 2193330d57fbSAl Viro spin_lock(&sysctl_lock); 2194330d57fbSAl Viro start_unregistering(header); 2195ae7edeccSAl Viro if (!--header->parent->count) { 2196ae7edeccSAl Viro WARN_ON(1); 2197ae7edeccSAl Viro kfree(header->parent); 2198ae7edeccSAl Viro } 2199f7e6ced4SAl Viro if (!--header->count) 22001da177e4SLinus Torvalds kfree(header); 2201f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 22021da177e4SLinus Torvalds } 22031da177e4SLinus Torvalds 22049043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 22059043476fSAl Viro { 22069043476fSAl Viro struct ctl_table_set *set = p->set; 22079043476fSAl Viro int res; 22089043476fSAl Viro spin_lock(&sysctl_lock); 22099043476fSAl Viro if (p->unregistering) 22109043476fSAl Viro res = 0; 22119043476fSAl Viro else if (!set->is_seen) 22129043476fSAl Viro res = 1; 22139043476fSAl Viro else 22149043476fSAl Viro res = set->is_seen(set); 22159043476fSAl Viro spin_unlock(&sysctl_lock); 22169043476fSAl Viro return res; 22179043476fSAl Viro } 22189043476fSAl Viro 221973455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 222073455092SAl Viro struct ctl_table_set *parent, 222173455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 222273455092SAl Viro { 222373455092SAl Viro INIT_LIST_HEAD(&p->list); 222473455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 222573455092SAl Viro p->is_seen = is_seen; 222673455092SAl Viro } 222773455092SAl Viro 2228b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 2229d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 2230b89a8171SEric W. Biederman { 2231b89a8171SEric W. Biederman return NULL; 2232b89a8171SEric W. Biederman } 2233b89a8171SEric W. Biederman 223429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 223529e796fdSEric W. Biederman struct ctl_table *table) 223629e796fdSEric W. Biederman { 223729e796fdSEric W. Biederman return NULL; 223829e796fdSEric W. Biederman } 223929e796fdSEric W. Biederman 2240b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2241b89a8171SEric W. Biederman { 2242b89a8171SEric W. Biederman } 2243b89a8171SEric W. Biederman 224473455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 224573455092SAl Viro struct ctl_table_set *parent, 224673455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 224773455092SAl Viro { 224873455092SAl Viro } 224973455092SAl Viro 2250f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2251f7e6ced4SAl Viro { 2252f7e6ced4SAl Viro } 2253f7e6ced4SAl Viro 2254b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2255b89a8171SEric W. Biederman 22561da177e4SLinus Torvalds /* 22571da177e4SLinus Torvalds * /proc/sys support 22581da177e4SLinus Torvalds */ 22591da177e4SLinus Torvalds 2260b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 22611da177e4SLinus Torvalds 2262b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 22638d65af78SAlexey Dobriyan void __user *buffer, 2264b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2265f5dd3d6fSSam Vilain { 2266f5dd3d6fSSam Vilain size_t len; 2267f5dd3d6fSSam Vilain char __user *p; 2268f5dd3d6fSSam Vilain char c; 2269f5dd3d6fSSam Vilain 22708d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2271f5dd3d6fSSam Vilain *lenp = 0; 2272f5dd3d6fSSam Vilain return 0; 2273f5dd3d6fSSam Vilain } 2274f5dd3d6fSSam Vilain 2275f5dd3d6fSSam Vilain if (write) { 2276f5dd3d6fSSam Vilain len = 0; 2277f5dd3d6fSSam Vilain p = buffer; 2278f5dd3d6fSSam Vilain while (len < *lenp) { 2279f5dd3d6fSSam Vilain if (get_user(c, p++)) 2280f5dd3d6fSSam Vilain return -EFAULT; 2281f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2282f5dd3d6fSSam Vilain break; 2283f5dd3d6fSSam Vilain len++; 2284f5dd3d6fSSam Vilain } 2285f5dd3d6fSSam Vilain if (len >= maxlen) 2286f5dd3d6fSSam Vilain len = maxlen-1; 2287f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2288f5dd3d6fSSam Vilain return -EFAULT; 2289f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2290f5dd3d6fSSam Vilain *ppos += *lenp; 2291f5dd3d6fSSam Vilain } else { 2292f5dd3d6fSSam Vilain len = strlen(data); 2293f5dd3d6fSSam Vilain if (len > maxlen) 2294f5dd3d6fSSam Vilain len = maxlen; 22958d060877SOleg Nesterov 22968d060877SOleg Nesterov if (*ppos > len) { 22978d060877SOleg Nesterov *lenp = 0; 22988d060877SOleg Nesterov return 0; 22998d060877SOleg Nesterov } 23008d060877SOleg Nesterov 23018d060877SOleg Nesterov data += *ppos; 23028d060877SOleg Nesterov len -= *ppos; 23038d060877SOleg Nesterov 2304f5dd3d6fSSam Vilain if (len > *lenp) 2305f5dd3d6fSSam Vilain len = *lenp; 2306f5dd3d6fSSam Vilain if (len) 2307f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2308f5dd3d6fSSam Vilain return -EFAULT; 2309f5dd3d6fSSam Vilain if (len < *lenp) { 2310f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2311f5dd3d6fSSam Vilain return -EFAULT; 2312f5dd3d6fSSam Vilain len++; 2313f5dd3d6fSSam Vilain } 2314f5dd3d6fSSam Vilain *lenp = len; 2315f5dd3d6fSSam Vilain *ppos += len; 2316f5dd3d6fSSam Vilain } 2317f5dd3d6fSSam Vilain return 0; 2318f5dd3d6fSSam Vilain } 2319f5dd3d6fSSam Vilain 23201da177e4SLinus Torvalds /** 23211da177e4SLinus Torvalds * proc_dostring - read a string sysctl 23221da177e4SLinus Torvalds * @table: the sysctl table 23231da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23241da177e4SLinus Torvalds * @buffer: the user buffer 23251da177e4SLinus Torvalds * @lenp: the size of the user buffer 23261da177e4SLinus Torvalds * @ppos: file position 23271da177e4SLinus Torvalds * 23281da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 23291da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 23301da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 23311da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 23321da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 23331da177e4SLinus Torvalds * not large enough. 23341da177e4SLinus Torvalds * 23351da177e4SLinus Torvalds * Returns 0 on success. 23361da177e4SLinus Torvalds */ 23378d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 23381da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23391da177e4SLinus Torvalds { 23408d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2341f5dd3d6fSSam Vilain buffer, lenp, ppos); 23421da177e4SLinus Torvalds } 23431da177e4SLinus Torvalds 23441da177e4SLinus Torvalds 23451da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 23461da177e4SLinus Torvalds int *valp, 23471da177e4SLinus Torvalds int write, void *data) 23481da177e4SLinus Torvalds { 23491da177e4SLinus Torvalds if (write) { 23501da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 23511da177e4SLinus Torvalds } else { 23521da177e4SLinus Torvalds int val = *valp; 23531da177e4SLinus Torvalds if (val < 0) { 23541da177e4SLinus Torvalds *negp = -1; 23551da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 23561da177e4SLinus Torvalds } else { 23571da177e4SLinus Torvalds *negp = 0; 23581da177e4SLinus Torvalds *lvalp = (unsigned long)val; 23591da177e4SLinus Torvalds } 23601da177e4SLinus Torvalds } 23611da177e4SLinus Torvalds return 0; 23621da177e4SLinus Torvalds } 23631da177e4SLinus Torvalds 2364d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 23658d65af78SAlexey Dobriyan int write, void __user *buffer, 2366fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 23671da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 23681da177e4SLinus Torvalds int write, void *data), 23691da177e4SLinus Torvalds void *data) 23701da177e4SLinus Torvalds { 23711da177e4SLinus Torvalds #define TMPBUFLEN 21 23727338f299SSukanto Ghosh int *i, vleft, first = 1, neg; 23731da177e4SLinus Torvalds unsigned long lval; 23741da177e4SLinus Torvalds size_t left, len; 23751da177e4SLinus Torvalds 23761da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 23771da177e4SLinus Torvalds char __user *s = buffer; 23781da177e4SLinus Torvalds 2379fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 23801da177e4SLinus Torvalds (*ppos && !write)) { 23811da177e4SLinus Torvalds *lenp = 0; 23821da177e4SLinus Torvalds return 0; 23831da177e4SLinus Torvalds } 23841da177e4SLinus Torvalds 2385fcfbd547SKirill Korotaev i = (int *) tbl_data; 23861da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 23871da177e4SLinus Torvalds left = *lenp; 23881da177e4SLinus Torvalds 23891da177e4SLinus Torvalds if (!conv) 23901da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 23911da177e4SLinus Torvalds 23921da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 23931da177e4SLinus Torvalds if (write) { 23941da177e4SLinus Torvalds while (left) { 23951da177e4SLinus Torvalds char c; 23961da177e4SLinus Torvalds if (get_user(c, s)) 23971da177e4SLinus Torvalds return -EFAULT; 23981da177e4SLinus Torvalds if (!isspace(c)) 23991da177e4SLinus Torvalds break; 24001da177e4SLinus Torvalds left--; 24011da177e4SLinus Torvalds s++; 24021da177e4SLinus Torvalds } 24031da177e4SLinus Torvalds if (!left) 24041da177e4SLinus Torvalds break; 24051da177e4SLinus Torvalds neg = 0; 24061da177e4SLinus Torvalds len = left; 24071da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 24081da177e4SLinus Torvalds len = sizeof(buf) - 1; 24091da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 24101da177e4SLinus Torvalds return -EFAULT; 24111da177e4SLinus Torvalds buf[len] = 0; 24121da177e4SLinus Torvalds p = buf; 24131da177e4SLinus Torvalds if (*p == '-' && left > 1) { 24141da177e4SLinus Torvalds neg = 1; 2415bd9b0bacSBP, Praveen p++; 24161da177e4SLinus Torvalds } 24171da177e4SLinus Torvalds if (*p < '0' || *p > '9') 24181da177e4SLinus Torvalds break; 24191da177e4SLinus Torvalds 24201da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 24211da177e4SLinus Torvalds 24221da177e4SLinus Torvalds len = p-buf; 24231da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 24241da177e4SLinus Torvalds break; 24251da177e4SLinus Torvalds s += len; 24261da177e4SLinus Torvalds left -= len; 24271da177e4SLinus Torvalds 24281da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 24291da177e4SLinus Torvalds break; 24301da177e4SLinus Torvalds } else { 24311da177e4SLinus Torvalds p = buf; 24321da177e4SLinus Torvalds if (!first) 24331da177e4SLinus Torvalds *p++ = '\t'; 24341da177e4SLinus Torvalds 24351da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 24361da177e4SLinus Torvalds break; 24371da177e4SLinus Torvalds 24381da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 24391da177e4SLinus Torvalds len = strlen(buf); 24401da177e4SLinus Torvalds if (len > left) 24411da177e4SLinus Torvalds len = left; 24421da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 24431da177e4SLinus Torvalds return -EFAULT; 24441da177e4SLinus Torvalds left -= len; 24451da177e4SLinus Torvalds s += len; 24461da177e4SLinus Torvalds } 24471da177e4SLinus Torvalds } 24481da177e4SLinus Torvalds 24491da177e4SLinus Torvalds if (!write && !first && left) { 24501da177e4SLinus Torvalds if(put_user('\n', s)) 24511da177e4SLinus Torvalds return -EFAULT; 24521da177e4SLinus Torvalds left--, s++; 24531da177e4SLinus Torvalds } 24541da177e4SLinus Torvalds if (write) { 24551da177e4SLinus Torvalds while (left) { 24561da177e4SLinus Torvalds char c; 24571da177e4SLinus Torvalds if (get_user(c, s++)) 24581da177e4SLinus Torvalds return -EFAULT; 24591da177e4SLinus Torvalds if (!isspace(c)) 24601da177e4SLinus Torvalds break; 24611da177e4SLinus Torvalds left--; 24621da177e4SLinus Torvalds } 24631da177e4SLinus Torvalds } 24641da177e4SLinus Torvalds if (write && first) 24651da177e4SLinus Torvalds return -EINVAL; 24661da177e4SLinus Torvalds *lenp -= left; 24671da177e4SLinus Torvalds *ppos += *lenp; 24681da177e4SLinus Torvalds return 0; 24691da177e4SLinus Torvalds #undef TMPBUFLEN 24701da177e4SLinus Torvalds } 24711da177e4SLinus Torvalds 24728d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2473fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2474fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2475fcfbd547SKirill Korotaev int write, void *data), 2476fcfbd547SKirill Korotaev void *data) 2477fcfbd547SKirill Korotaev { 24788d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2479fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2480fcfbd547SKirill Korotaev } 2481fcfbd547SKirill Korotaev 24821da177e4SLinus Torvalds /** 24831da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 24841da177e4SLinus Torvalds * @table: the sysctl table 24851da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24861da177e4SLinus Torvalds * @buffer: the user buffer 24871da177e4SLinus Torvalds * @lenp: the size of the user buffer 24881da177e4SLinus Torvalds * @ppos: file position 24891da177e4SLinus Torvalds * 24901da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24911da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24921da177e4SLinus Torvalds * 24931da177e4SLinus Torvalds * Returns 0 on success. 24941da177e4SLinus Torvalds */ 24958d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 24961da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24971da177e4SLinus Torvalds { 24988d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 24991da177e4SLinus Torvalds NULL,NULL); 25001da177e4SLinus Torvalds } 25011da177e4SLinus Torvalds 250234f5a398STheodore Ts'o /* 250334f5a398STheodore Ts'o * Taint values can only be increased 250425ddbb18SAndi Kleen * This means we can safely use a temporary. 250534f5a398STheodore Ts'o */ 25068d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 250734f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 250834f5a398STheodore Ts'o { 250925ddbb18SAndi Kleen struct ctl_table t; 251025ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 251125ddbb18SAndi Kleen int err; 251234f5a398STheodore Ts'o 251391fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 251434f5a398STheodore Ts'o return -EPERM; 251534f5a398STheodore Ts'o 251625ddbb18SAndi Kleen t = *table; 251725ddbb18SAndi Kleen t.data = &tmptaint; 25188d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 251925ddbb18SAndi Kleen if (err < 0) 252025ddbb18SAndi Kleen return err; 252125ddbb18SAndi Kleen 252225ddbb18SAndi Kleen if (write) { 252325ddbb18SAndi Kleen /* 252425ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 252525ddbb18SAndi Kleen * to everyone's atomic.h for this 252625ddbb18SAndi Kleen */ 252725ddbb18SAndi Kleen int i; 252825ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 252925ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 253025ddbb18SAndi Kleen add_taint(i); 253125ddbb18SAndi Kleen } 253225ddbb18SAndi Kleen } 253325ddbb18SAndi Kleen 253425ddbb18SAndi Kleen return err; 253534f5a398STheodore Ts'o } 253634f5a398STheodore Ts'o 25371da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 25381da177e4SLinus Torvalds int *min; 25391da177e4SLinus Torvalds int *max; 25401da177e4SLinus Torvalds }; 25411da177e4SLinus Torvalds 25421da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 25431da177e4SLinus Torvalds int *valp, 25441da177e4SLinus Torvalds int write, void *data) 25451da177e4SLinus Torvalds { 25461da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 25471da177e4SLinus Torvalds if (write) { 25481da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 25491da177e4SLinus Torvalds if ((param->min && *param->min > val) || 25501da177e4SLinus Torvalds (param->max && *param->max < val)) 25511da177e4SLinus Torvalds return -EINVAL; 25521da177e4SLinus Torvalds *valp = val; 25531da177e4SLinus Torvalds } else { 25541da177e4SLinus Torvalds int val = *valp; 25551da177e4SLinus Torvalds if (val < 0) { 25561da177e4SLinus Torvalds *negp = -1; 25571da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 25581da177e4SLinus Torvalds } else { 25591da177e4SLinus Torvalds *negp = 0; 25601da177e4SLinus Torvalds *lvalp = (unsigned long)val; 25611da177e4SLinus Torvalds } 25621da177e4SLinus Torvalds } 25631da177e4SLinus Torvalds return 0; 25641da177e4SLinus Torvalds } 25651da177e4SLinus Torvalds 25661da177e4SLinus Torvalds /** 25671da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 25681da177e4SLinus Torvalds * @table: the sysctl table 25691da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25701da177e4SLinus Torvalds * @buffer: the user buffer 25711da177e4SLinus Torvalds * @lenp: the size of the user buffer 25721da177e4SLinus Torvalds * @ppos: file position 25731da177e4SLinus Torvalds * 25741da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25751da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25761da177e4SLinus Torvalds * 25771da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25781da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25791da177e4SLinus Torvalds * 25801da177e4SLinus Torvalds * Returns 0 on success. 25811da177e4SLinus Torvalds */ 25828d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 25831da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25841da177e4SLinus Torvalds { 25851da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 25861da177e4SLinus Torvalds .min = (int *) table->extra1, 25871da177e4SLinus Torvalds .max = (int *) table->extra2, 25881da177e4SLinus Torvalds }; 25898d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 25901da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 25911da177e4SLinus Torvalds } 25921da177e4SLinus Torvalds 2593d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 25941da177e4SLinus Torvalds void __user *buffer, 25951da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 25961da177e4SLinus Torvalds unsigned long convmul, 25971da177e4SLinus Torvalds unsigned long convdiv) 25981da177e4SLinus Torvalds { 25991da177e4SLinus Torvalds #define TMPBUFLEN 21 26001da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 26011da177e4SLinus Torvalds int vleft, first=1, neg; 26021da177e4SLinus Torvalds size_t len, left; 26031da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 26041da177e4SLinus Torvalds char __user *s = buffer; 26051da177e4SLinus Torvalds 2606fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 26071da177e4SLinus Torvalds (*ppos && !write)) { 26081da177e4SLinus Torvalds *lenp = 0; 26091da177e4SLinus Torvalds return 0; 26101da177e4SLinus Torvalds } 26111da177e4SLinus Torvalds 2612fcfbd547SKirill Korotaev i = (unsigned long *) data; 26131da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 26141da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 26151da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 26161da177e4SLinus Torvalds left = *lenp; 26171da177e4SLinus Torvalds 26181da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 26191da177e4SLinus Torvalds if (write) { 26201da177e4SLinus Torvalds while (left) { 26211da177e4SLinus Torvalds char c; 26221da177e4SLinus Torvalds if (get_user(c, s)) 26231da177e4SLinus Torvalds return -EFAULT; 26241da177e4SLinus Torvalds if (!isspace(c)) 26251da177e4SLinus Torvalds break; 26261da177e4SLinus Torvalds left--; 26271da177e4SLinus Torvalds s++; 26281da177e4SLinus Torvalds } 26291da177e4SLinus Torvalds if (!left) 26301da177e4SLinus Torvalds break; 26311da177e4SLinus Torvalds neg = 0; 26321da177e4SLinus Torvalds len = left; 26331da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 26341da177e4SLinus Torvalds len = TMPBUFLEN-1; 26351da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 26361da177e4SLinus Torvalds return -EFAULT; 26371da177e4SLinus Torvalds buf[len] = 0; 26381da177e4SLinus Torvalds p = buf; 26391da177e4SLinus Torvalds if (*p == '-' && left > 1) { 26401da177e4SLinus Torvalds neg = 1; 2641bd9b0bacSBP, Praveen p++; 26421da177e4SLinus Torvalds } 26431da177e4SLinus Torvalds if (*p < '0' || *p > '9') 26441da177e4SLinus Torvalds break; 26451da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 26461da177e4SLinus Torvalds len = p-buf; 26471da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 26481da177e4SLinus Torvalds break; 26491da177e4SLinus Torvalds if (neg) 26501da177e4SLinus Torvalds val = -val; 26511da177e4SLinus Torvalds s += len; 26521da177e4SLinus Torvalds left -= len; 26531da177e4SLinus Torvalds 26541da177e4SLinus Torvalds if(neg) 26551da177e4SLinus Torvalds continue; 26561da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 26571da177e4SLinus Torvalds continue; 26581da177e4SLinus Torvalds *i = val; 26591da177e4SLinus Torvalds } else { 26601da177e4SLinus Torvalds p = buf; 26611da177e4SLinus Torvalds if (!first) 26621da177e4SLinus Torvalds *p++ = '\t'; 26631da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 26641da177e4SLinus Torvalds len = strlen(buf); 26651da177e4SLinus Torvalds if (len > left) 26661da177e4SLinus Torvalds len = left; 26671da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 26681da177e4SLinus Torvalds return -EFAULT; 26691da177e4SLinus Torvalds left -= len; 26701da177e4SLinus Torvalds s += len; 26711da177e4SLinus Torvalds } 26721da177e4SLinus Torvalds } 26731da177e4SLinus Torvalds 26741da177e4SLinus Torvalds if (!write && !first && left) { 26751da177e4SLinus Torvalds if(put_user('\n', s)) 26761da177e4SLinus Torvalds return -EFAULT; 26771da177e4SLinus Torvalds left--, s++; 26781da177e4SLinus Torvalds } 26791da177e4SLinus Torvalds if (write) { 26801da177e4SLinus Torvalds while (left) { 26811da177e4SLinus Torvalds char c; 26821da177e4SLinus Torvalds if (get_user(c, s++)) 26831da177e4SLinus Torvalds return -EFAULT; 26841da177e4SLinus Torvalds if (!isspace(c)) 26851da177e4SLinus Torvalds break; 26861da177e4SLinus Torvalds left--; 26871da177e4SLinus Torvalds } 26881da177e4SLinus Torvalds } 26891da177e4SLinus Torvalds if (write && first) 26901da177e4SLinus Torvalds return -EINVAL; 26911da177e4SLinus Torvalds *lenp -= left; 26921da177e4SLinus Torvalds *ppos += *lenp; 26931da177e4SLinus Torvalds return 0; 26941da177e4SLinus Torvalds #undef TMPBUFLEN 26951da177e4SLinus Torvalds } 26961da177e4SLinus Torvalds 2697d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2698fcfbd547SKirill Korotaev void __user *buffer, 2699fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2700fcfbd547SKirill Korotaev unsigned long convmul, 2701fcfbd547SKirill Korotaev unsigned long convdiv) 2702fcfbd547SKirill Korotaev { 2703fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 27048d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2705fcfbd547SKirill Korotaev } 2706fcfbd547SKirill Korotaev 27071da177e4SLinus Torvalds /** 27081da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 27091da177e4SLinus Torvalds * @table: the sysctl table 27101da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27111da177e4SLinus Torvalds * @buffer: the user buffer 27121da177e4SLinus Torvalds * @lenp: the size of the user buffer 27131da177e4SLinus Torvalds * @ppos: file position 27141da177e4SLinus Torvalds * 27151da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 27161da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27171da177e4SLinus Torvalds * 27181da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 27191da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 27201da177e4SLinus Torvalds * 27211da177e4SLinus Torvalds * Returns 0 on success. 27221da177e4SLinus Torvalds */ 27238d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 27241da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27251da177e4SLinus Torvalds { 27268d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 27271da177e4SLinus Torvalds } 27281da177e4SLinus Torvalds 27291da177e4SLinus Torvalds /** 27301da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 27311da177e4SLinus Torvalds * @table: the sysctl table 27321da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27331da177e4SLinus Torvalds * @buffer: the user buffer 27341da177e4SLinus Torvalds * @lenp: the size of the user buffer 27351da177e4SLinus Torvalds * @ppos: file position 27361da177e4SLinus Torvalds * 27371da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 27381da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 27391da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 27401da177e4SLinus Torvalds * 27411da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 27421da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 27431da177e4SLinus Torvalds * 27441da177e4SLinus Torvalds * Returns 0 on success. 27451da177e4SLinus Torvalds */ 2746d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 27471da177e4SLinus Torvalds void __user *buffer, 27481da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 27491da177e4SLinus Torvalds { 27508d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 27511da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 27521da177e4SLinus Torvalds } 27531da177e4SLinus Torvalds 27541da177e4SLinus Torvalds 27551da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 27561da177e4SLinus Torvalds int *valp, 27571da177e4SLinus Torvalds int write, void *data) 27581da177e4SLinus Torvalds { 27591da177e4SLinus Torvalds if (write) { 2760cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2761cba9f33dSBart Samwel return 1; 27621da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 27631da177e4SLinus Torvalds } else { 27641da177e4SLinus Torvalds int val = *valp; 27651da177e4SLinus Torvalds unsigned long lval; 27661da177e4SLinus Torvalds if (val < 0) { 27671da177e4SLinus Torvalds *negp = -1; 27681da177e4SLinus Torvalds lval = (unsigned long)-val; 27691da177e4SLinus Torvalds } else { 27701da177e4SLinus Torvalds *negp = 0; 27711da177e4SLinus Torvalds lval = (unsigned long)val; 27721da177e4SLinus Torvalds } 27731da177e4SLinus Torvalds *lvalp = lval / HZ; 27741da177e4SLinus Torvalds } 27751da177e4SLinus Torvalds return 0; 27761da177e4SLinus Torvalds } 27771da177e4SLinus Torvalds 27781da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 27791da177e4SLinus Torvalds int *valp, 27801da177e4SLinus Torvalds int write, void *data) 27811da177e4SLinus Torvalds { 27821da177e4SLinus Torvalds if (write) { 2783cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2784cba9f33dSBart Samwel return 1; 27851da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 27861da177e4SLinus Torvalds } else { 27871da177e4SLinus Torvalds int val = *valp; 27881da177e4SLinus Torvalds unsigned long lval; 27891da177e4SLinus Torvalds if (val < 0) { 27901da177e4SLinus Torvalds *negp = -1; 27911da177e4SLinus Torvalds lval = (unsigned long)-val; 27921da177e4SLinus Torvalds } else { 27931da177e4SLinus Torvalds *negp = 0; 27941da177e4SLinus Torvalds lval = (unsigned long)val; 27951da177e4SLinus Torvalds } 27961da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 27971da177e4SLinus Torvalds } 27981da177e4SLinus Torvalds return 0; 27991da177e4SLinus Torvalds } 28001da177e4SLinus Torvalds 28011da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 28021da177e4SLinus Torvalds int *valp, 28031da177e4SLinus Torvalds int write, void *data) 28041da177e4SLinus Torvalds { 28051da177e4SLinus Torvalds if (write) { 28061da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 28071da177e4SLinus Torvalds } else { 28081da177e4SLinus Torvalds int val = *valp; 28091da177e4SLinus Torvalds unsigned long lval; 28101da177e4SLinus Torvalds if (val < 0) { 28111da177e4SLinus Torvalds *negp = -1; 28121da177e4SLinus Torvalds lval = (unsigned long)-val; 28131da177e4SLinus Torvalds } else { 28141da177e4SLinus Torvalds *negp = 0; 28151da177e4SLinus Torvalds lval = (unsigned long)val; 28161da177e4SLinus Torvalds } 28171da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 28181da177e4SLinus Torvalds } 28191da177e4SLinus Torvalds return 0; 28201da177e4SLinus Torvalds } 28211da177e4SLinus Torvalds 28221da177e4SLinus Torvalds /** 28231da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 28241da177e4SLinus Torvalds * @table: the sysctl table 28251da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 28261da177e4SLinus Torvalds * @buffer: the user buffer 28271da177e4SLinus Torvalds * @lenp: the size of the user buffer 28281da177e4SLinus Torvalds * @ppos: file position 28291da177e4SLinus Torvalds * 28301da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 28311da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 28321da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 28331da177e4SLinus Torvalds * jiffies. 28341da177e4SLinus Torvalds * 28351da177e4SLinus Torvalds * Returns 0 on success. 28361da177e4SLinus Torvalds */ 28378d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 28381da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28391da177e4SLinus Torvalds { 28408d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 28411da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 28421da177e4SLinus Torvalds } 28431da177e4SLinus Torvalds 28441da177e4SLinus Torvalds /** 28451da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 28461da177e4SLinus Torvalds * @table: the sysctl table 28471da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 28481da177e4SLinus Torvalds * @buffer: the user buffer 28491da177e4SLinus Torvalds * @lenp: the size of the user buffer 28501e5d5331SRandy Dunlap * @ppos: pointer to the file position 28511da177e4SLinus Torvalds * 28521da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 28531da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 28541da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 28551da177e4SLinus Torvalds * are converted into jiffies. 28561da177e4SLinus Torvalds * 28571da177e4SLinus Torvalds * Returns 0 on success. 28581da177e4SLinus Torvalds */ 28598d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 28601da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28611da177e4SLinus Torvalds { 28628d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 28631da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 28641da177e4SLinus Torvalds } 28651da177e4SLinus Torvalds 28661da177e4SLinus Torvalds /** 28671da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 28681da177e4SLinus Torvalds * @table: the sysctl table 28691da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 28701da177e4SLinus Torvalds * @buffer: the user buffer 28711da177e4SLinus Torvalds * @lenp: the size of the user buffer 287267be2dd1SMartin Waitz * @ppos: file position 287367be2dd1SMartin Waitz * @ppos: the current position in the file 28741da177e4SLinus Torvalds * 28751da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 28761da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 28771da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 28781da177e4SLinus Torvalds * are converted into jiffies. 28791da177e4SLinus Torvalds * 28801da177e4SLinus Torvalds * Returns 0 on success. 28811da177e4SLinus Torvalds */ 28828d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 28831da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28841da177e4SLinus Torvalds { 28858d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 28861da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 28871da177e4SLinus Torvalds } 28881da177e4SLinus Torvalds 28898d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 28909ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 28919ec52099SCedric Le Goater { 28929ec52099SCedric Le Goater struct pid *new_pid; 28939ec52099SCedric Le Goater pid_t tmp; 28949ec52099SCedric Le Goater int r; 28959ec52099SCedric Le Goater 28966c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 28979ec52099SCedric Le Goater 28988d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 28999ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 29009ec52099SCedric Le Goater if (r || !write) 29019ec52099SCedric Le Goater return r; 29029ec52099SCedric Le Goater 29039ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 29049ec52099SCedric Le Goater if (!new_pid) 29059ec52099SCedric Le Goater return -ESRCH; 29069ec52099SCedric Le Goater 29079ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 29089ec52099SCedric Le Goater return 0; 29099ec52099SCedric Le Goater } 29109ec52099SCedric Le Goater 29111da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 29121da177e4SLinus Torvalds 29138d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 29141da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29151da177e4SLinus Torvalds { 29161da177e4SLinus Torvalds return -ENOSYS; 29171da177e4SLinus Torvalds } 29181da177e4SLinus Torvalds 29198d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 29201da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29211da177e4SLinus Torvalds { 29221da177e4SLinus Torvalds return -ENOSYS; 29231da177e4SLinus Torvalds } 29241da177e4SLinus Torvalds 29258d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 29261da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29271da177e4SLinus Torvalds { 29281da177e4SLinus Torvalds return -ENOSYS; 29291da177e4SLinus Torvalds } 29301da177e4SLinus Torvalds 29318d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 29321da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29331da177e4SLinus Torvalds { 29341da177e4SLinus Torvalds return -ENOSYS; 29351da177e4SLinus Torvalds } 29361da177e4SLinus Torvalds 29378d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 29381da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29391da177e4SLinus Torvalds { 29401da177e4SLinus Torvalds return -ENOSYS; 29411da177e4SLinus Torvalds } 29421da177e4SLinus Torvalds 29438d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 29441da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29451da177e4SLinus Torvalds { 29461da177e4SLinus Torvalds return -ENOSYS; 29471da177e4SLinus Torvalds } 29481da177e4SLinus Torvalds 29498d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 29501da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29511da177e4SLinus Torvalds { 29521da177e4SLinus Torvalds return -ENOSYS; 29531da177e4SLinus Torvalds } 29541da177e4SLinus Torvalds 2955d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 29561da177e4SLinus Torvalds void __user *buffer, 29571da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 29581da177e4SLinus Torvalds { 29591da177e4SLinus Torvalds return -ENOSYS; 29601da177e4SLinus Torvalds } 29611da177e4SLinus Torvalds 29621da177e4SLinus Torvalds 29631da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 29641da177e4SLinus Torvalds 29651da177e4SLinus Torvalds 2966b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 29671da177e4SLinus Torvalds /* 29681da177e4SLinus Torvalds * General sysctl support routines 29691da177e4SLinus Torvalds */ 29701da177e4SLinus Torvalds 297149a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */ 2972f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table, 297349a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 297449a0c458SEric W. Biederman void __user *newval, size_t newlen) 297549a0c458SEric W. Biederman { 297649a0c458SEric W. Biederman size_t len; 297749a0c458SEric W. Biederman 297849a0c458SEric W. Biederman /* Get out of I don't have a variable */ 297949a0c458SEric W. Biederman if (!table->data || !table->maxlen) 298049a0c458SEric W. Biederman return -ENOTDIR; 298149a0c458SEric W. Biederman 298249a0c458SEric W. Biederman if (oldval && oldlenp) { 298349a0c458SEric W. Biederman if (get_user(len, oldlenp)) 298449a0c458SEric W. Biederman return -EFAULT; 298549a0c458SEric W. Biederman if (len) { 298649a0c458SEric W. Biederman if (len > table->maxlen) 298749a0c458SEric W. Biederman len = table->maxlen; 298849a0c458SEric W. Biederman if (copy_to_user(oldval, table->data, len)) 298949a0c458SEric W. Biederman return -EFAULT; 299049a0c458SEric W. Biederman if (put_user(len, oldlenp)) 299149a0c458SEric W. Biederman return -EFAULT; 299249a0c458SEric W. Biederman } 299349a0c458SEric W. Biederman } 299449a0c458SEric W. Biederman 299549a0c458SEric W. Biederman if (newval && newlen) { 299649a0c458SEric W. Biederman if (newlen > table->maxlen) 299749a0c458SEric W. Biederman newlen = table->maxlen; 299849a0c458SEric W. Biederman 299949a0c458SEric W. Biederman if (copy_from_user(table->data, newval, newlen)) 300049a0c458SEric W. Biederman return -EFAULT; 300149a0c458SEric W. Biederman } 300249a0c458SEric W. Biederman return 1; 300349a0c458SEric W. Biederman } 300449a0c458SEric W. Biederman 30051da177e4SLinus Torvalds /* The generic string strategy routine: */ 3006f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table, 30071da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30081f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30091da177e4SLinus Torvalds { 30101da177e4SLinus Torvalds if (!table->data || !table->maxlen) 30111da177e4SLinus Torvalds return -ENOTDIR; 30121da177e4SLinus Torvalds 30131da177e4SLinus Torvalds if (oldval && oldlenp) { 3014de9e007dSLinus Torvalds size_t bufsize; 3015de9e007dSLinus Torvalds if (get_user(bufsize, oldlenp)) 30161da177e4SLinus Torvalds return -EFAULT; 3017de9e007dSLinus Torvalds if (bufsize) { 3018de9e007dSLinus Torvalds size_t len = strlen(table->data), copied; 3019de9e007dSLinus Torvalds 3020de9e007dSLinus Torvalds /* This shouldn't trigger for a well-formed sysctl */ 3021de9e007dSLinus Torvalds if (len > table->maxlen) 30221da177e4SLinus Torvalds len = table->maxlen; 3023de9e007dSLinus Torvalds 3024de9e007dSLinus Torvalds /* Copy up to a max of bufsize-1 bytes of the string */ 3025de9e007dSLinus Torvalds copied = (len >= bufsize) ? bufsize - 1 : len; 3026de9e007dSLinus Torvalds 3027de9e007dSLinus Torvalds if (copy_to_user(oldval, table->data, copied) || 3028de9e007dSLinus Torvalds put_user(0, (char __user *)(oldval + copied))) 30291da177e4SLinus Torvalds return -EFAULT; 30301da177e4SLinus Torvalds if (put_user(len, oldlenp)) 30311da177e4SLinus Torvalds return -EFAULT; 30321da177e4SLinus Torvalds } 30331da177e4SLinus Torvalds } 30341da177e4SLinus Torvalds if (newval && newlen) { 3035de9e007dSLinus Torvalds size_t len = newlen; 30361da177e4SLinus Torvalds if (len > table->maxlen) 30371da177e4SLinus Torvalds len = table->maxlen; 30381da177e4SLinus Torvalds if(copy_from_user(table->data, newval, len)) 30391da177e4SLinus Torvalds return -EFAULT; 30401da177e4SLinus Torvalds if (len == table->maxlen) 30411da177e4SLinus Torvalds len--; 30421da177e4SLinus Torvalds ((char *) table->data)[len] = 0; 30431da177e4SLinus Torvalds } 304482c9df82SYi Yang return 1; 30451da177e4SLinus Torvalds } 30461da177e4SLinus Torvalds 30471da177e4SLinus Torvalds /* 30481da177e4SLinus Torvalds * This function makes sure that all of the integers in the vector 30491da177e4SLinus Torvalds * are between the minimum and maximum values given in the arrays 30501da177e4SLinus Torvalds * table->extra1 and table->extra2, respectively. 30511da177e4SLinus Torvalds */ 3052f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table, 30531da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30541f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30551da177e4SLinus Torvalds { 30561da177e4SLinus Torvalds 30571da177e4SLinus Torvalds if (newval && newlen) { 30581da177e4SLinus Torvalds int __user *vec = (int __user *) newval; 30591da177e4SLinus Torvalds int *min = (int *) table->extra1; 30601da177e4SLinus Torvalds int *max = (int *) table->extra2; 30611da177e4SLinus Torvalds size_t length; 30621da177e4SLinus Torvalds int i; 30631da177e4SLinus Torvalds 30641da177e4SLinus Torvalds if (newlen % sizeof(int) != 0) 30651da177e4SLinus Torvalds return -EINVAL; 30661da177e4SLinus Torvalds 30671da177e4SLinus Torvalds if (!table->extra1 && !table->extra2) 30681da177e4SLinus Torvalds return 0; 30691da177e4SLinus Torvalds 30701da177e4SLinus Torvalds if (newlen > table->maxlen) 30711da177e4SLinus Torvalds newlen = table->maxlen; 30721da177e4SLinus Torvalds length = newlen / sizeof(int); 30731da177e4SLinus Torvalds 30741da177e4SLinus Torvalds for (i = 0; i < length; i++) { 30751da177e4SLinus Torvalds int value; 30761da177e4SLinus Torvalds if (get_user(value, vec + i)) 30771da177e4SLinus Torvalds return -EFAULT; 30781da177e4SLinus Torvalds if (min && value < min[i]) 30791da177e4SLinus Torvalds return -EINVAL; 30801da177e4SLinus Torvalds if (max && value > max[i]) 30811da177e4SLinus Torvalds return -EINVAL; 30821da177e4SLinus Torvalds } 30831da177e4SLinus Torvalds } 30841da177e4SLinus Torvalds return 0; 30851da177e4SLinus Torvalds } 30861da177e4SLinus Torvalds 30871da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 3088f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table, 30891da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30901f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30911da177e4SLinus Torvalds { 30923ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 30931da177e4SLinus Torvalds size_t olen; 30943ee75ac3SAlexey Dobriyan 30951da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 30961da177e4SLinus Torvalds return -EFAULT; 30973ee75ac3SAlexey Dobriyan if (olen) { 30983ee75ac3SAlexey Dobriyan int val; 30993ee75ac3SAlexey Dobriyan 31003ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 31011da177e4SLinus Torvalds return -EINVAL; 31023ee75ac3SAlexey Dobriyan 31033ee75ac3SAlexey Dobriyan val = *(int *)(table->data) / HZ; 31043ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 31051da177e4SLinus Torvalds return -EFAULT; 31063ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 31073ee75ac3SAlexey Dobriyan return -EFAULT; 31083ee75ac3SAlexey Dobriyan } 31091da177e4SLinus Torvalds } 31101da177e4SLinus Torvalds if (newval && newlen) { 31111da177e4SLinus Torvalds int new; 31121da177e4SLinus Torvalds if (newlen != sizeof(int)) 31131da177e4SLinus Torvalds return -EINVAL; 31141da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 31151da177e4SLinus Torvalds return -EFAULT; 31161da177e4SLinus Torvalds *(int *)(table->data) = new*HZ; 31171da177e4SLinus Torvalds } 31181da177e4SLinus Torvalds return 1; 31191da177e4SLinus Torvalds } 31201da177e4SLinus Torvalds 31211da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 3122f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table, 31231da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31241f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31251da177e4SLinus Torvalds { 31263ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 31271da177e4SLinus Torvalds size_t olen; 31283ee75ac3SAlexey Dobriyan 31291da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 31301da177e4SLinus Torvalds return -EFAULT; 31313ee75ac3SAlexey Dobriyan if (olen) { 31323ee75ac3SAlexey Dobriyan int val; 31333ee75ac3SAlexey Dobriyan 31343ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 31351da177e4SLinus Torvalds return -EINVAL; 31363ee75ac3SAlexey Dobriyan 31373ee75ac3SAlexey Dobriyan val = jiffies_to_msecs(*(int *)(table->data)); 31383ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 31391da177e4SLinus Torvalds return -EFAULT; 31403ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 31413ee75ac3SAlexey Dobriyan return -EFAULT; 31423ee75ac3SAlexey Dobriyan } 31431da177e4SLinus Torvalds } 31441da177e4SLinus Torvalds if (newval && newlen) { 31451da177e4SLinus Torvalds int new; 31461da177e4SLinus Torvalds if (newlen != sizeof(int)) 31471da177e4SLinus Torvalds return -EINVAL; 31481da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 31491da177e4SLinus Torvalds return -EFAULT; 31501da177e4SLinus Torvalds *(int *)(table->data) = msecs_to_jiffies(new); 31511da177e4SLinus Torvalds } 31521da177e4SLinus Torvalds return 1; 31531da177e4SLinus Torvalds } 31541da177e4SLinus Torvalds 3155c4b8b769SEric W. Biederman 3156c4b8b769SEric W. Biederman 3157b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */ 31581da177e4SLinus Torvalds 31591da177e4SLinus Torvalds 31601e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) 31611da177e4SLinus Torvalds { 31620e009be8SEric W. Biederman struct __sysctl_args tmp; 31637058cb02SEric W. Biederman int error; 31640e009be8SEric W. Biederman 31650e009be8SEric W. Biederman if (copy_from_user(&tmp, args, sizeof(tmp))) 31660e009be8SEric W. Biederman return -EFAULT; 31670e009be8SEric W. Biederman 31687058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 3169b89a8171SEric W. Biederman 31707058cb02SEric W. Biederman /* If no error reading the parameters then just -ENOSYS ... */ 31717058cb02SEric W. Biederman if (!error) 31727058cb02SEric W. Biederman error = -ENOSYS; 31737058cb02SEric W. Biederman 31747058cb02SEric W. Biederman return error; 31751da177e4SLinus Torvalds } 31761da177e4SLinus Torvalds 3177f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table, 317849a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 317949a0c458SEric W. Biederman void __user *newval, size_t newlen) 318049a0c458SEric W. Biederman { 318149a0c458SEric W. Biederman return -ENOSYS; 318249a0c458SEric W. Biederman } 318349a0c458SEric W. Biederman 3184f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table, 31851da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31861f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31871da177e4SLinus Torvalds { 31881da177e4SLinus Torvalds return -ENOSYS; 31891da177e4SLinus Torvalds } 31901da177e4SLinus Torvalds 3191f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table, 31921da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31931f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31941da177e4SLinus Torvalds { 31951da177e4SLinus Torvalds return -ENOSYS; 31961da177e4SLinus Torvalds } 31971da177e4SLinus Torvalds 3198f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table, 31991da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 32001f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 32011da177e4SLinus Torvalds { 32021da177e4SLinus Torvalds return -ENOSYS; 32031da177e4SLinus Torvalds } 32041da177e4SLinus Torvalds 3205f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table, 32061da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 32071f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 32081da177e4SLinus Torvalds { 32091da177e4SLinus Torvalds return -ENOSYS; 32101da177e4SLinus Torvalds } 32111da177e4SLinus Torvalds 3212b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 32131da177e4SLinus Torvalds 32147058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args) 32157058cb02SEric W. Biederman { 32167058cb02SEric W. Biederman static int msg_count; 32177058cb02SEric W. Biederman int name[CTL_MAXNAME]; 32187058cb02SEric W. Biederman int i; 32197058cb02SEric W. Biederman 32206fc48af8STetsuo Handa /* Check args->nlen. */ 32216fc48af8STetsuo Handa if (args->nlen < 0 || args->nlen > CTL_MAXNAME) 32226fc48af8STetsuo Handa return -ENOTDIR; 32236fc48af8STetsuo Handa 32247058cb02SEric W. Biederman /* Read in the sysctl name for better debug message logging */ 32257058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 32267058cb02SEric W. Biederman if (get_user(name[i], args->name + i)) 32277058cb02SEric W. Biederman return -EFAULT; 32287058cb02SEric W. Biederman 32297058cb02SEric W. Biederman /* Ignore accesses to kernel.version */ 32307058cb02SEric W. Biederman if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION)) 32317058cb02SEric W. Biederman return 0; 32327058cb02SEric W. Biederman 32337058cb02SEric W. Biederman if (msg_count < 5) { 32347058cb02SEric W. Biederman msg_count++; 32357058cb02SEric W. Biederman printk(KERN_INFO 32367058cb02SEric W. Biederman "warning: process `%s' used the deprecated sysctl " 32377058cb02SEric W. Biederman "system call with ", current->comm); 32387058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 32397058cb02SEric W. Biederman printk("%d.", name[i]); 32407058cb02SEric W. Biederman printk("\n"); 32417058cb02SEric W. Biederman } 32427058cb02SEric W. Biederman return 0; 32437058cb02SEric W. Biederman } 32447058cb02SEric W. Biederman 32451da177e4SLinus Torvalds /* 32461da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 32471da177e4SLinus Torvalds * exception granted :-) 32481da177e4SLinus Torvalds */ 32491da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 32501da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 32511da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 32521da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 32531da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 32541da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 32551da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 32561da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 32571da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 325829e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 32591da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec); 32601da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies); 32611da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies); 32621da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string); 326349a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data); 32641da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 3265