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> 291da177e4SLinus Torvalds #include <linux/utsname.h> 30dfec072eSVegard Nossum #include <linux/kmemcheck.h> 311da177e4SLinus Torvalds #include <linux/smp_lock.h> 3262239ac2SAdrian Bunk #include <linux/fs.h> 331da177e4SLinus Torvalds #include <linux/init.h> 341da177e4SLinus Torvalds #include <linux/kernel.h> 350296b228SKay Sievers #include <linux/kobject.h> 3620380731SArnaldo Carvalho de Melo #include <linux/net.h> 371da177e4SLinus Torvalds #include <linux/sysrq.h> 381da177e4SLinus Torvalds #include <linux/highuid.h> 391da177e4SLinus Torvalds #include <linux/writeback.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> 53*cdd6c482SIngo 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[]; 801da177e4SLinus Torvalds extern int pid_max; 811da177e4SLinus Torvalds extern int min_free_kbytes; 821da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 839d0243bcSAndrew Morton extern int sysctl_drop_caches; 848ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 85bebfa101SAndi Kleen extern int compat_log; 869745512cSArjan van de Ven extern int latencytop_enabled; 87eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 88dd8632a1SPaul Mundt #ifndef CONFIG_MMU 89dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 90dd8632a1SPaul Mundt #endif 9131a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 9231a72bceSPaul E. McKenney extern int rcutorture_runnable; 9331a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 94cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 955e605b64SJens Axboe extern int blk_iopoll_enabled; 96cb684b5bSJens Axboe #endif 971da177e4SLinus Torvalds 98c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 99195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 100c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1019383d967SDimitri Sivanich static int neg_one = -1; 102c4f3b63fSRavikiran G Thirumalai #endif 103c4f3b63fSRavikiran G Thirumalai 104c4f3b63fSRavikiran G Thirumalai static int zero; 105cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 106cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 107fc3501d4SSven Wegener static unsigned long one_ul = 1; 108c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 109c4f3b63fSRavikiran G Thirumalai 1109e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1119e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1129e4a5bdaSAndrea Righi 1131da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1141da177e4SLinus Torvalds static int maxolduid = 65535; 1151da177e4SLinus Torvalds static int minolduid; 1168ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1171da177e4SLinus Torvalds 1181da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1191da177e4SLinus Torvalds 120a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 1211da177e4SLinus Torvalds extern char modprobe_path[]; 1223d43321bSKees Cook extern int modules_disabled; 1231da177e4SLinus Torvalds #endif 1241da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 1251da177e4SLinus Torvalds extern int sg_big_buff; 1261da177e4SLinus Torvalds #endif 1271da177e4SLinus Torvalds 12872c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 12917f04fbbSDavid S. Miller #include <asm/system.h> 1301da177e4SLinus Torvalds #endif 1311da177e4SLinus Torvalds 1320871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1330871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1340871420fSDavid S. Miller #endif 1350871420fSDavid S. Miller 1361da177e4SLinus Torvalds #ifdef __hppa__ 1371da177e4SLinus Torvalds extern int pwrsw_enabled; 1381da177e4SLinus Torvalds extern int unaligned_enabled; 1391da177e4SLinus Torvalds #endif 1401da177e4SLinus Torvalds 141347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1421da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1431da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1441da177e4SLinus Torvalds #endif 1451da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 146951f22d5SMartin Schwidefsky extern int spin_retry; 1471da177e4SLinus Torvalds #endif 1481da177e4SLinus Torvalds 1491da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1501da177e4SLinus Torvalds extern int acct_parm[]; 1511da177e4SLinus Torvalds #endif 1521da177e4SLinus Torvalds 153d2b176edSJes Sorensen #ifdef CONFIG_IA64 154d2b176edSJes Sorensen extern int no_unaligned_warning; 15588fc241fSDoug Chapman extern int unaligned_dump_stack; 156d2b176edSJes Sorensen #endif 157d2b176edSJes Sorensen 15823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 15923f78d4aSIngo Molnar extern int max_lock_depth; 16023f78d4aSIngo Molnar #endif 16123f78d4aSIngo Molnar 162d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 163d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 1649ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 16525ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp, 16634f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 167d6f8ff73SRandy Dunlap #endif 1689ec52099SCedric Le Goater 169d8217f07SEric W. Biederman static struct ctl_table root_table[]; 170e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 171e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 172b380b0d4SAl Viro .count = 1, 173e51b6ba0SEric W. Biederman .ctl_table = root_table, 17473455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 175e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 17673455092SAl Viro .set = &sysctl_table_root.default_set, 177e51b6ba0SEric W. Biederman }; 178e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 179e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 18073455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 181e51b6ba0SEric W. Biederman }; 1821da177e4SLinus Torvalds 183d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 184d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 185d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 186d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 187d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 188d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1892d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 190d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1910399cb08SRobert Love #endif 1927ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 1937ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 1947ef9964eSDavide Libenzi #endif 1951da177e4SLinus Torvalds 1961da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 1971da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1981da177e4SLinus Torvalds #endif 1991da177e4SLinus Torvalds 200f20786ffSPeter Zijlstra extern int prove_locking; 201f20786ffSPeter Zijlstra extern int lock_stat; 2029bc9a6bdSEric W. Biederman 2031da177e4SLinus Torvalds /* The default sysctl tables: */ 2041da177e4SLinus Torvalds 205d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2061da177e4SLinus Torvalds { 2071da177e4SLinus Torvalds .ctl_name = CTL_KERN, 2081da177e4SLinus Torvalds .procname = "kernel", 2091da177e4SLinus Torvalds .mode = 0555, 2101da177e4SLinus Torvalds .child = kern_table, 2111da177e4SLinus Torvalds }, 2121da177e4SLinus Torvalds { 2131da177e4SLinus Torvalds .ctl_name = CTL_VM, 2141da177e4SLinus Torvalds .procname = "vm", 2151da177e4SLinus Torvalds .mode = 0555, 2161da177e4SLinus Torvalds .child = vm_table, 2171da177e4SLinus Torvalds }, 2181da177e4SLinus Torvalds { 2191da177e4SLinus Torvalds .ctl_name = CTL_FS, 2201da177e4SLinus Torvalds .procname = "fs", 2211da177e4SLinus Torvalds .mode = 0555, 2221da177e4SLinus Torvalds .child = fs_table, 2231da177e4SLinus Torvalds }, 2241da177e4SLinus Torvalds { 2251da177e4SLinus Torvalds .ctl_name = CTL_DEBUG, 2261da177e4SLinus Torvalds .procname = "debug", 2271da177e4SLinus Torvalds .mode = 0555, 2281da177e4SLinus Torvalds .child = debug_table, 2291da177e4SLinus Torvalds }, 2301da177e4SLinus Torvalds { 2311da177e4SLinus Torvalds .ctl_name = CTL_DEV, 2321da177e4SLinus Torvalds .procname = "dev", 2331da177e4SLinus Torvalds .mode = 0555, 2341da177e4SLinus Torvalds .child = dev_table, 2351da177e4SLinus Torvalds }, 2362be7fe07SAndrew Morton /* 2372be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2382be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2392be7fe07SAndrew Morton */ 2401da177e4SLinus Torvalds { .ctl_name = 0 } 2411da177e4SLinus Torvalds }; 2421da177e4SLinus Torvalds 24377e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 24473c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 24573c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 24673c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 24773c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 24877e54a1fSIngo Molnar #endif 24977e54a1fSIngo Molnar 250d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2512bba22c5SMike Galbraith { 2522bba22c5SMike Galbraith .ctl_name = CTL_UNNUMBERED, 2532bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2542bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2552bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2562bba22c5SMike Galbraith .mode = 0644, 2572bba22c5SMike Galbraith .proc_handler = &proc_dointvec, 2582bba22c5SMike Galbraith }, 25977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 26077e54a1fSIngo Molnar { 26177e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 262b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 263b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 26477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 26577e54a1fSIngo Molnar .mode = 0644, 266b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 267b2be5e96SPeter Zijlstra .strategy = &sysctl_intvec, 268b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 269b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 27077e54a1fSIngo Molnar }, 27177e54a1fSIngo Molnar { 27277e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 27321805085SPeter Zijlstra .procname = "sched_latency_ns", 27421805085SPeter Zijlstra .data = &sysctl_sched_latency, 27521805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 27621805085SPeter Zijlstra .mode = 0644, 277b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 27821805085SPeter Zijlstra .strategy = &sysctl_intvec, 27921805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 28021805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28121805085SPeter Zijlstra }, 28221805085SPeter Zijlstra { 28321805085SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 28477e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 28577e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 28677e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28777e54a1fSIngo Molnar .mode = 0644, 28877e54a1fSIngo Molnar .proc_handler = &proc_dointvec_minmax, 28977e54a1fSIngo Molnar .strategy = &sysctl_intvec, 29077e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 29177e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 29277e54a1fSIngo Molnar }, 29377e54a1fSIngo Molnar { 29477e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 2952398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 2962398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 2972398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 2982398f2c6SPeter Zijlstra .mode = 0644, 2992398f2c6SPeter Zijlstra .proc_handler = &proc_dointvec, 3002398f2c6SPeter Zijlstra }, 3012398f2c6SPeter Zijlstra { 3022398f2c6SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 303ffda12a1SPeter Zijlstra .procname = "sched_shares_thresh", 304ffda12a1SPeter Zijlstra .data = &sysctl_sched_shares_thresh, 305ffda12a1SPeter Zijlstra .maxlen = sizeof(unsigned int), 306ffda12a1SPeter Zijlstra .mode = 0644, 307ffda12a1SPeter Zijlstra .proc_handler = &proc_dointvec_minmax, 308ffda12a1SPeter Zijlstra .strategy = &sysctl_intvec, 309ffda12a1SPeter Zijlstra .extra1 = &zero, 310ffda12a1SPeter Zijlstra }, 311ffda12a1SPeter Zijlstra { 312ffda12a1SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3131fc84aaaSPeter Zijlstra .procname = "sched_features", 3141fc84aaaSPeter Zijlstra .data = &sysctl_sched_features, 3151fc84aaaSPeter Zijlstra .maxlen = sizeof(unsigned int), 3161fc84aaaSPeter Zijlstra .mode = 0644, 3171fc84aaaSPeter Zijlstra .proc_handler = &proc_dointvec, 3181fc84aaaSPeter Zijlstra }, 319da84d961SIngo Molnar { 320da84d961SIngo Molnar .ctl_name = CTL_UNNUMBERED, 321da84d961SIngo Molnar .procname = "sched_migration_cost", 322da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 323da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 324da84d961SIngo Molnar .mode = 0644, 325da84d961SIngo Molnar .proc_handler = &proc_dointvec, 326da84d961SIngo Molnar }, 327b82d9fddSPeter Zijlstra { 328b82d9fddSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 329b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 330b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 331b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 332fa85ae24SPeter Zijlstra .mode = 0644, 333fa85ae24SPeter Zijlstra .proc_handler = &proc_dointvec, 334fa85ae24SPeter Zijlstra }, 335cd1bb94bSArun R Bharadwaj { 336cd1bb94bSArun R Bharadwaj .ctl_name = CTL_UNNUMBERED, 337e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 338e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 339e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 340e9e9250bSPeter Zijlstra .mode = 0644, 341e9e9250bSPeter Zijlstra .proc_handler = &proc_dointvec, 342e9e9250bSPeter Zijlstra }, 343e9e9250bSPeter Zijlstra { 344e9e9250bSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 345cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 346cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 347cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 348cd1bb94bSArun R Bharadwaj .mode = 0644, 349bfdb4d9fSArun R Bharadwaj .proc_handler = &proc_dointvec_minmax, 350bfdb4d9fSArun R Bharadwaj .strategy = &sysctl_intvec, 351bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 352bfdb4d9fSArun R Bharadwaj .extra2 = &one, 353cd1bb94bSArun R Bharadwaj }, 3541fc84aaaSPeter Zijlstra #endif 3551799e35dSIngo Molnar { 3561799e35dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 3579f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3589f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3599f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3609f0c1e56SPeter Zijlstra .mode = 0644, 361d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3629f0c1e56SPeter Zijlstra }, 3639f0c1e56SPeter Zijlstra { 3649f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3659f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3669f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3679f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3689f0c1e56SPeter Zijlstra .mode = 0644, 369d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3709f0c1e56SPeter Zijlstra }, 3719f0c1e56SPeter Zijlstra { 3729f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3731799e35dSIngo Molnar .procname = "sched_compat_yield", 3741799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3751799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3761799e35dSIngo Molnar .mode = 0644, 3771799e35dSIngo Molnar .proc_handler = &proc_dointvec, 3781799e35dSIngo Molnar }, 379f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 380f20786ffSPeter Zijlstra { 381f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 382f20786ffSPeter Zijlstra .procname = "prove_locking", 383f20786ffSPeter Zijlstra .data = &prove_locking, 384f20786ffSPeter Zijlstra .maxlen = sizeof(int), 385f20786ffSPeter Zijlstra .mode = 0644, 386f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 387f20786ffSPeter Zijlstra }, 388f20786ffSPeter Zijlstra #endif 389f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 390f20786ffSPeter Zijlstra { 391f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 392f20786ffSPeter Zijlstra .procname = "lock_stat", 393f20786ffSPeter Zijlstra .data = &lock_stat, 394f20786ffSPeter Zijlstra .maxlen = sizeof(int), 395f20786ffSPeter Zijlstra .mode = 0644, 396f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 397f20786ffSPeter Zijlstra }, 398f20786ffSPeter Zijlstra #endif 39977e54a1fSIngo Molnar { 4001da177e4SLinus Torvalds .ctl_name = KERN_PANIC, 4011da177e4SLinus Torvalds .procname = "panic", 4021da177e4SLinus Torvalds .data = &panic_timeout, 4031da177e4SLinus Torvalds .maxlen = sizeof(int), 4041da177e4SLinus Torvalds .mode = 0644, 4051da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4061da177e4SLinus Torvalds }, 4071da177e4SLinus Torvalds { 4081da177e4SLinus Torvalds .ctl_name = KERN_CORE_USES_PID, 4091da177e4SLinus Torvalds .procname = "core_uses_pid", 4101da177e4SLinus Torvalds .data = &core_uses_pid, 4111da177e4SLinus Torvalds .maxlen = sizeof(int), 4121da177e4SLinus Torvalds .mode = 0644, 4131da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4141da177e4SLinus Torvalds }, 4151da177e4SLinus Torvalds { 4161da177e4SLinus Torvalds .ctl_name = KERN_CORE_PATTERN, 4171da177e4SLinus Torvalds .procname = "core_pattern", 4181da177e4SLinus Torvalds .data = core_pattern, 41971ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4201da177e4SLinus Torvalds .mode = 0644, 4211da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4221da177e4SLinus Torvalds .strategy = &sysctl_string, 4231da177e4SLinus Torvalds }, 42434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4251da177e4SLinus Torvalds { 4261da177e4SLinus Torvalds .procname = "tainted", 42725ddbb18SAndi Kleen .maxlen = sizeof(long), 42834f5a398STheodore Ts'o .mode = 0644, 42925ddbb18SAndi Kleen .proc_handler = &proc_taint, 4301da177e4SLinus Torvalds }, 43134f5a398STheodore Ts'o #endif 4329745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4339745512cSArjan van de Ven { 4349745512cSArjan van de Ven .procname = "latencytop", 4359745512cSArjan van de Ven .data = &latencytop_enabled, 4369745512cSArjan van de Ven .maxlen = sizeof(int), 4379745512cSArjan van de Ven .mode = 0644, 4389745512cSArjan van de Ven .proc_handler = &proc_dointvec, 4399745512cSArjan van de Ven }, 4409745512cSArjan van de Ven #endif 4411da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4421da177e4SLinus Torvalds { 4431da177e4SLinus Torvalds .ctl_name = KERN_REALROOTDEV, 4441da177e4SLinus Torvalds .procname = "real-root-dev", 4451da177e4SLinus Torvalds .data = &real_root_dev, 4461da177e4SLinus Torvalds .maxlen = sizeof(int), 4471da177e4SLinus Torvalds .mode = 0644, 4481da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4491da177e4SLinus Torvalds }, 4501da177e4SLinus Torvalds #endif 45145807a1dSIngo Molnar { 45245807a1dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 45345807a1dSIngo Molnar .procname = "print-fatal-signals", 45445807a1dSIngo Molnar .data = &print_fatal_signals, 45545807a1dSIngo Molnar .maxlen = sizeof(int), 45645807a1dSIngo Molnar .mode = 0644, 45745807a1dSIngo Molnar .proc_handler = &proc_dointvec, 45845807a1dSIngo Molnar }, 45972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4601da177e4SLinus Torvalds { 4611da177e4SLinus Torvalds .ctl_name = KERN_SPARC_REBOOT, 4621da177e4SLinus Torvalds .procname = "reboot-cmd", 4631da177e4SLinus Torvalds .data = reboot_command, 4641da177e4SLinus Torvalds .maxlen = 256, 4651da177e4SLinus Torvalds .mode = 0644, 4661da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4671da177e4SLinus Torvalds .strategy = &sysctl_string, 4681da177e4SLinus Torvalds }, 4691da177e4SLinus Torvalds { 4701da177e4SLinus Torvalds .ctl_name = KERN_SPARC_STOP_A, 4711da177e4SLinus Torvalds .procname = "stop-a", 4721da177e4SLinus Torvalds .data = &stop_a_enabled, 4731da177e4SLinus Torvalds .maxlen = sizeof (int), 4741da177e4SLinus Torvalds .mode = 0644, 4751da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4761da177e4SLinus Torvalds }, 4771da177e4SLinus Torvalds { 4781da177e4SLinus Torvalds .ctl_name = KERN_SPARC_SCONS_PWROFF, 4791da177e4SLinus Torvalds .procname = "scons-poweroff", 4801da177e4SLinus Torvalds .data = &scons_pwroff, 4811da177e4SLinus Torvalds .maxlen = sizeof (int), 4821da177e4SLinus Torvalds .mode = 0644, 4831da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4841da177e4SLinus Torvalds }, 4851da177e4SLinus Torvalds #endif 4860871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4870871420fSDavid S. Miller { 4880871420fSDavid S. Miller .ctl_name = CTL_UNNUMBERED, 4890871420fSDavid S. Miller .procname = "tsb-ratio", 4900871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4910871420fSDavid S. Miller .maxlen = sizeof (int), 4920871420fSDavid S. Miller .mode = 0644, 4930871420fSDavid S. Miller .proc_handler = &proc_dointvec, 4940871420fSDavid S. Miller }, 4950871420fSDavid S. Miller #endif 4961da177e4SLinus Torvalds #ifdef __hppa__ 4971da177e4SLinus Torvalds { 4981da177e4SLinus Torvalds .ctl_name = KERN_HPPA_PWRSW, 4991da177e4SLinus Torvalds .procname = "soft-power", 5001da177e4SLinus Torvalds .data = &pwrsw_enabled, 5011da177e4SLinus Torvalds .maxlen = sizeof (int), 5021da177e4SLinus Torvalds .mode = 0644, 5031da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5041da177e4SLinus Torvalds }, 5051da177e4SLinus Torvalds { 5061da177e4SLinus Torvalds .ctl_name = KERN_HPPA_UNALIGNED, 5071da177e4SLinus Torvalds .procname = "unaligned-trap", 5081da177e4SLinus Torvalds .data = &unaligned_enabled, 5091da177e4SLinus Torvalds .maxlen = sizeof (int), 5101da177e4SLinus Torvalds .mode = 0644, 5111da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5121da177e4SLinus Torvalds }, 5131da177e4SLinus Torvalds #endif 5141da177e4SLinus Torvalds { 5151da177e4SLinus Torvalds .ctl_name = KERN_CTLALTDEL, 5161da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5171da177e4SLinus Torvalds .data = &C_A_D, 5181da177e4SLinus Torvalds .maxlen = sizeof(int), 5191da177e4SLinus Torvalds .mode = 0644, 5201da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5211da177e4SLinus Torvalds }, 522606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 523b0fc494fSSteven Rostedt { 524b0fc494fSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 525b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 526b0fc494fSSteven Rostedt .data = &ftrace_enabled, 527b0fc494fSSteven Rostedt .maxlen = sizeof(int), 528b0fc494fSSteven Rostedt .mode = 0644, 529b0fc494fSSteven Rostedt .proc_handler = &ftrace_enable_sysctl, 530b0fc494fSSteven Rostedt }, 531b0fc494fSSteven Rostedt #endif 532f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 533f38f1d2aSSteven Rostedt { 534f38f1d2aSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 535f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 536f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 537f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 538f38f1d2aSSteven Rostedt .mode = 0644, 539f38f1d2aSSteven Rostedt .proc_handler = &stack_trace_sysctl, 540f38f1d2aSSteven Rostedt }, 541f38f1d2aSSteven Rostedt #endif 542944ac425SSteven Rostedt #ifdef CONFIG_TRACING 543944ac425SSteven Rostedt { 544944ac425SSteven Rostedt .ctl_name = CTL_UNNUMBERED, 5453299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 546944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 547944ac425SSteven Rostedt .maxlen = sizeof(int), 548944ac425SSteven Rostedt .mode = 0644, 549944ac425SSteven Rostedt .proc_handler = &proc_dointvec, 550944ac425SSteven Rostedt }, 551944ac425SSteven Rostedt #endif 552a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5531da177e4SLinus Torvalds { 5541da177e4SLinus Torvalds .ctl_name = KERN_MODPROBE, 5551da177e4SLinus Torvalds .procname = "modprobe", 5561da177e4SLinus Torvalds .data = &modprobe_path, 5571da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5581da177e4SLinus Torvalds .mode = 0644, 5591da177e4SLinus Torvalds .proc_handler = &proc_dostring, 5601da177e4SLinus Torvalds .strategy = &sysctl_string, 5611da177e4SLinus Torvalds }, 5623d43321bSKees Cook { 5633d43321bSKees Cook .ctl_name = CTL_UNNUMBERED, 5643d43321bSKees Cook .procname = "modules_disabled", 5653d43321bSKees Cook .data = &modules_disabled, 5663d43321bSKees Cook .maxlen = sizeof(int), 5673d43321bSKees Cook .mode = 0644, 5683d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5693d43321bSKees Cook .proc_handler = &proc_dointvec_minmax, 5703d43321bSKees Cook .extra1 = &one, 5713d43321bSKees Cook .extra2 = &one, 5723d43321bSKees Cook }, 5731da177e4SLinus Torvalds #endif 57457ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 5751da177e4SLinus Torvalds { 5761da177e4SLinus Torvalds .ctl_name = KERN_HOTPLUG, 5771da177e4SLinus Torvalds .procname = "hotplug", 578312c004dSKay Sievers .data = &uevent_helper, 579312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5801da177e4SLinus Torvalds .mode = 0644, 5811da177e4SLinus Torvalds .proc_handler = &proc_dostring, 5821da177e4SLinus Torvalds .strategy = &sysctl_string, 5831da177e4SLinus Torvalds }, 5841da177e4SLinus Torvalds #endif 5851da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5861da177e4SLinus Torvalds { 5871da177e4SLinus Torvalds .ctl_name = KERN_SG_BIG_BUFF, 5881da177e4SLinus Torvalds .procname = "sg-big-buff", 5891da177e4SLinus Torvalds .data = &sg_big_buff, 5901da177e4SLinus Torvalds .maxlen = sizeof (int), 5911da177e4SLinus Torvalds .mode = 0444, 5921da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5931da177e4SLinus Torvalds }, 5941da177e4SLinus Torvalds #endif 5951da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5961da177e4SLinus Torvalds { 5971da177e4SLinus Torvalds .ctl_name = KERN_ACCT, 5981da177e4SLinus Torvalds .procname = "acct", 5991da177e4SLinus Torvalds .data = &acct_parm, 6001da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 6011da177e4SLinus Torvalds .mode = 0644, 6021da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6031da177e4SLinus Torvalds }, 6041da177e4SLinus Torvalds #endif 6051da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 6061da177e4SLinus Torvalds { 6071da177e4SLinus Torvalds .ctl_name = KERN_SYSRQ, 6081da177e4SLinus Torvalds .procname = "sysrq", 6095d6f647fSIngo Molnar .data = &__sysrq_enabled, 6101da177e4SLinus Torvalds .maxlen = sizeof (int), 6111da177e4SLinus Torvalds .mode = 0644, 6121da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6131da177e4SLinus Torvalds }, 6141da177e4SLinus Torvalds #endif 615d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 6161da177e4SLinus Torvalds { 6171da177e4SLinus Torvalds .procname = "cad_pid", 6189ec52099SCedric Le Goater .data = NULL, 6191da177e4SLinus Torvalds .maxlen = sizeof (int), 6201da177e4SLinus Torvalds .mode = 0600, 6219ec52099SCedric Le Goater .proc_handler = &proc_do_cad_pid, 6221da177e4SLinus Torvalds }, 623d6f8ff73SRandy Dunlap #endif 6241da177e4SLinus Torvalds { 6251da177e4SLinus Torvalds .ctl_name = KERN_MAX_THREADS, 6261da177e4SLinus Torvalds .procname = "threads-max", 6271da177e4SLinus Torvalds .data = &max_threads, 6281da177e4SLinus Torvalds .maxlen = sizeof(int), 6291da177e4SLinus Torvalds .mode = 0644, 6301da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6311da177e4SLinus Torvalds }, 6321da177e4SLinus Torvalds { 6331da177e4SLinus Torvalds .ctl_name = KERN_RANDOM, 6341da177e4SLinus Torvalds .procname = "random", 6351da177e4SLinus Torvalds .mode = 0555, 6361da177e4SLinus Torvalds .child = random_table, 6371da177e4SLinus Torvalds }, 6381da177e4SLinus Torvalds { 6391da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWUID, 6401da177e4SLinus Torvalds .procname = "overflowuid", 6411da177e4SLinus Torvalds .data = &overflowuid, 6421da177e4SLinus Torvalds .maxlen = sizeof(int), 6431da177e4SLinus Torvalds .mode = 0644, 6441da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6451da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6461da177e4SLinus Torvalds .extra1 = &minolduid, 6471da177e4SLinus Torvalds .extra2 = &maxolduid, 6481da177e4SLinus Torvalds }, 6491da177e4SLinus Torvalds { 6501da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWGID, 6511da177e4SLinus Torvalds .procname = "overflowgid", 6521da177e4SLinus Torvalds .data = &overflowgid, 6531da177e4SLinus Torvalds .maxlen = sizeof(int), 6541da177e4SLinus Torvalds .mode = 0644, 6551da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6561da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6571da177e4SLinus Torvalds .extra1 = &minolduid, 6581da177e4SLinus Torvalds .extra2 = &maxolduid, 6591da177e4SLinus Torvalds }, 660347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6611da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6621da177e4SLinus Torvalds { 6631da177e4SLinus Torvalds .ctl_name = KERN_IEEE_EMULATION_WARNINGS, 6641da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6651da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6661da177e4SLinus Torvalds .maxlen = sizeof(int), 6671da177e4SLinus Torvalds .mode = 0644, 6681da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6691da177e4SLinus Torvalds }, 6701da177e4SLinus Torvalds #endif 6711da177e4SLinus Torvalds { 6721da177e4SLinus Torvalds .ctl_name = KERN_S390_USER_DEBUG_LOGGING, 6731da177e4SLinus Torvalds .procname = "userprocess_debug", 6741da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 6751da177e4SLinus Torvalds .maxlen = sizeof(int), 6761da177e4SLinus Torvalds .mode = 0644, 6771da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6781da177e4SLinus Torvalds }, 6791da177e4SLinus Torvalds #endif 6801da177e4SLinus Torvalds { 6811da177e4SLinus Torvalds .ctl_name = KERN_PIDMAX, 6821da177e4SLinus Torvalds .procname = "pid_max", 6831da177e4SLinus Torvalds .data = &pid_max, 6841da177e4SLinus Torvalds .maxlen = sizeof (int), 6851da177e4SLinus Torvalds .mode = 0644, 6861da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6871da177e4SLinus Torvalds .strategy = sysctl_intvec, 6881da177e4SLinus Torvalds .extra1 = &pid_max_min, 6891da177e4SLinus Torvalds .extra2 = &pid_max_max, 6901da177e4SLinus Torvalds }, 6911da177e4SLinus Torvalds { 6921da177e4SLinus Torvalds .ctl_name = KERN_PANIC_ON_OOPS, 6931da177e4SLinus Torvalds .procname = "panic_on_oops", 6941da177e4SLinus Torvalds .data = &panic_on_oops, 6951da177e4SLinus Torvalds .maxlen = sizeof(int), 6961da177e4SLinus Torvalds .mode = 0644, 6971da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6981da177e4SLinus Torvalds }, 6997ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 7007ef3d2fdSJoe Perches { 7017ef3d2fdSJoe Perches .ctl_name = KERN_PRINTK, 7027ef3d2fdSJoe Perches .procname = "printk", 7037ef3d2fdSJoe Perches .data = &console_loglevel, 7047ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 7057ef3d2fdSJoe Perches .mode = 0644, 7067ef3d2fdSJoe Perches .proc_handler = &proc_dointvec, 7077ef3d2fdSJoe Perches }, 7081da177e4SLinus Torvalds { 7091da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT, 7101da177e4SLinus Torvalds .procname = "printk_ratelimit", 711717115e1SDave Young .data = &printk_ratelimit_state.interval, 7121da177e4SLinus Torvalds .maxlen = sizeof(int), 7131da177e4SLinus Torvalds .mode = 0644, 7141da177e4SLinus Torvalds .proc_handler = &proc_dointvec_jiffies, 7151da177e4SLinus Torvalds .strategy = &sysctl_jiffies, 7161da177e4SLinus Torvalds }, 7171da177e4SLinus Torvalds { 7181da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT_BURST, 7191da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 720717115e1SDave Young .data = &printk_ratelimit_state.burst, 7211da177e4SLinus Torvalds .maxlen = sizeof(int), 7221da177e4SLinus Torvalds .mode = 0644, 7231da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7241da177e4SLinus Torvalds }, 7257ef3d2fdSJoe Perches #endif 7261da177e4SLinus Torvalds { 7271da177e4SLinus Torvalds .ctl_name = KERN_NGROUPS_MAX, 7281da177e4SLinus Torvalds .procname = "ngroups_max", 7291da177e4SLinus Torvalds .data = &ngroups_max, 7301da177e4SLinus Torvalds .maxlen = sizeof (int), 7311da177e4SLinus Torvalds .mode = 0444, 7321da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7331da177e4SLinus Torvalds }, 7341da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7351da177e4SLinus Torvalds { 7361da177e4SLinus Torvalds .ctl_name = KERN_UNKNOWN_NMI_PANIC, 7371da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 7381da177e4SLinus Torvalds .data = &unknown_nmi_panic, 7391da177e4SLinus Torvalds .maxlen = sizeof (int), 7401da177e4SLinus Torvalds .mode = 0644, 7412fbe7b25SDon Zickus .proc_handler = &proc_dointvec, 7421da177e4SLinus Torvalds }, 743407984f1SDon Zickus { 744407984f1SDon Zickus .procname = "nmi_watchdog", 745407984f1SDon Zickus .data = &nmi_watchdog_enabled, 746407984f1SDon Zickus .maxlen = sizeof (int), 747407984f1SDon Zickus .mode = 0644, 748407984f1SDon Zickus .proc_handler = &proc_nmi_enabled, 7491da177e4SLinus Torvalds }, 7501da177e4SLinus Torvalds #endif 7511da177e4SLinus Torvalds #if defined(CONFIG_X86) 7521da177e4SLinus Torvalds { 7538da5addaSDon Zickus .ctl_name = KERN_PANIC_ON_NMI, 7548da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7558da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7568da5addaSDon Zickus .maxlen = sizeof(int), 7578da5addaSDon Zickus .mode = 0644, 7588da5addaSDon Zickus .proc_handler = &proc_dointvec, 7598da5addaSDon Zickus }, 7608da5addaSDon Zickus { 7615211a242SKurt Garloff .ctl_name = CTL_UNNUMBERED, 7625211a242SKurt Garloff .procname = "panic_on_io_nmi", 7635211a242SKurt Garloff .data = &panic_on_io_nmi, 7645211a242SKurt Garloff .maxlen = sizeof(int), 7655211a242SKurt Garloff .mode = 0644, 7665211a242SKurt Garloff .proc_handler = &proc_dointvec, 7675211a242SKurt Garloff }, 7685211a242SKurt Garloff { 7691da177e4SLinus Torvalds .ctl_name = KERN_BOOTLOADER_TYPE, 7701da177e4SLinus Torvalds .procname = "bootloader_type", 7711da177e4SLinus Torvalds .data = &bootloader_type, 7721da177e4SLinus Torvalds .maxlen = sizeof (int), 7731da177e4SLinus Torvalds .mode = 0444, 7741da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7751da177e4SLinus Torvalds }, 7760741f4d2SChuck Ebbert { 7770741f4d2SChuck Ebbert .ctl_name = CTL_UNNUMBERED, 7785031296cSH. Peter Anvin .procname = "bootloader_version", 7795031296cSH. Peter Anvin .data = &bootloader_version, 7805031296cSH. Peter Anvin .maxlen = sizeof (int), 7815031296cSH. Peter Anvin .mode = 0444, 7825031296cSH. Peter Anvin .proc_handler = &proc_dointvec, 7835031296cSH. Peter Anvin }, 7845031296cSH. Peter Anvin { 7855031296cSH. Peter Anvin .ctl_name = CTL_UNNUMBERED, 7860741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 7870741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 7880741f4d2SChuck Ebbert .maxlen = sizeof(int), 7890741f4d2SChuck Ebbert .mode = 0644, 7900741f4d2SChuck Ebbert .proc_handler = &proc_dointvec, 7910741f4d2SChuck Ebbert }, 7926e7c4025SIngo Molnar { 7936e7c4025SIngo Molnar .ctl_name = CTL_UNNUMBERED, 7946e7c4025SIngo Molnar .procname = "io_delay_type", 7956e7c4025SIngo Molnar .data = &io_delay_type, 7966e7c4025SIngo Molnar .maxlen = sizeof(int), 7976e7c4025SIngo Molnar .mode = 0644, 7986e7c4025SIngo Molnar .proc_handler = &proc_dointvec, 7996e7c4025SIngo Molnar }, 8001da177e4SLinus Torvalds #endif 8017a9166e3SLuke Yang #if defined(CONFIG_MMU) 8021da177e4SLinus Torvalds { 8031da177e4SLinus Torvalds .ctl_name = KERN_RANDOMIZE, 8041da177e4SLinus Torvalds .procname = "randomize_va_space", 8051da177e4SLinus Torvalds .data = &randomize_va_space, 8061da177e4SLinus Torvalds .maxlen = sizeof(int), 8071da177e4SLinus Torvalds .mode = 0644, 8081da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8091da177e4SLinus Torvalds }, 8107a9166e3SLuke Yang #endif 8110152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 812951f22d5SMartin Schwidefsky { 813951f22d5SMartin Schwidefsky .ctl_name = KERN_SPIN_RETRY, 814951f22d5SMartin Schwidefsky .procname = "spin_retry", 815951f22d5SMartin Schwidefsky .data = &spin_retry, 816951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 817951f22d5SMartin Schwidefsky .mode = 0644, 818951f22d5SMartin Schwidefsky .proc_handler = &proc_dointvec, 819951f22d5SMartin Schwidefsky }, 820951f22d5SMartin Schwidefsky #endif 821673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 822c255d844SPavel Machek { 823c255d844SPavel Machek .procname = "acpi_video_flags", 82477afcf78SPavel Machek .data = &acpi_realmode_flags, 825c255d844SPavel Machek .maxlen = sizeof (unsigned long), 826c255d844SPavel Machek .mode = 0644, 8277f99f06fSStefan Seyfried .proc_handler = &proc_doulongvec_minmax, 828c255d844SPavel Machek }, 829c255d844SPavel Machek #endif 830d2b176edSJes Sorensen #ifdef CONFIG_IA64 831d2b176edSJes Sorensen { 832d2b176edSJes Sorensen .ctl_name = KERN_IA64_UNALIGNED, 833d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 834d2b176edSJes Sorensen .data = &no_unaligned_warning, 835d2b176edSJes Sorensen .maxlen = sizeof (int), 836d2b176edSJes Sorensen .mode = 0644, 837d2b176edSJes Sorensen .proc_handler = &proc_dointvec, 838d2b176edSJes Sorensen }, 83988fc241fSDoug Chapman { 84088fc241fSDoug Chapman .ctl_name = CTL_UNNUMBERED, 84188fc241fSDoug Chapman .procname = "unaligned-dump-stack", 84288fc241fSDoug Chapman .data = &unaligned_dump_stack, 84388fc241fSDoug Chapman .maxlen = sizeof (int), 84488fc241fSDoug Chapman .mode = 0644, 84588fc241fSDoug Chapman .proc_handler = &proc_dointvec, 84688fc241fSDoug Chapman }, 847d2b176edSJes Sorensen #endif 848c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 849c4f3b63fSRavikiran G Thirumalai { 850c4f3b63fSRavikiran G Thirumalai .ctl_name = CTL_UNNUMBERED, 8519c44bc03SIngo Molnar .procname = "softlockup_panic", 8529c44bc03SIngo Molnar .data = &softlockup_panic, 8539c44bc03SIngo Molnar .maxlen = sizeof(int), 8549c44bc03SIngo Molnar .mode = 0644, 8554dca10a9SHiroshi Shimamoto .proc_handler = &proc_dointvec_minmax, 8569c44bc03SIngo Molnar .strategy = &sysctl_intvec, 8579c44bc03SIngo Molnar .extra1 = &zero, 8589c44bc03SIngo Molnar .extra2 = &one, 8599c44bc03SIngo Molnar }, 8609c44bc03SIngo Molnar { 8619c44bc03SIngo Molnar .ctl_name = CTL_UNNUMBERED, 862c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 863c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 8649383d967SDimitri Sivanich .maxlen = sizeof(int), 865c4f3b63fSRavikiran G Thirumalai .mode = 0644, 866baf48f65SMandeep Singh Baines .proc_handler = &proc_dosoftlockup_thresh, 867c4f3b63fSRavikiran G Thirumalai .strategy = &sysctl_intvec, 8689383d967SDimitri Sivanich .extra1 = &neg_one, 869c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 870c4f3b63fSRavikiran G Thirumalai }, 871e162b39aSMandeep Singh Baines #endif 872e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 873e162b39aSMandeep Singh Baines { 874e162b39aSMandeep Singh Baines .ctl_name = CTL_UNNUMBERED, 875e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 876e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 877e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 878e162b39aSMandeep Singh Baines .mode = 0644, 879e162b39aSMandeep Singh Baines .proc_handler = &proc_dointvec_minmax, 880e162b39aSMandeep Singh Baines .strategy = &sysctl_intvec, 881e162b39aSMandeep Singh Baines .extra1 = &zero, 882e162b39aSMandeep Singh Baines .extra2 = &one, 883e162b39aSMandeep Singh Baines }, 88482a1fcb9SIngo Molnar { 88582a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 88682a1fcb9SIngo Molnar .procname = "hung_task_check_count", 88782a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 88890739081SIngo Molnar .maxlen = sizeof(unsigned long), 88982a1fcb9SIngo Molnar .mode = 0644, 89090739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 89182a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 89282a1fcb9SIngo Molnar }, 89382a1fcb9SIngo Molnar { 89482a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 89582a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 89682a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 89790739081SIngo Molnar .maxlen = sizeof(unsigned long), 89882a1fcb9SIngo Molnar .mode = 0644, 899e162b39aSMandeep Singh Baines .proc_handler = &proc_dohung_task_timeout_secs, 90082a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 90182a1fcb9SIngo Molnar }, 90282a1fcb9SIngo Molnar { 90382a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 90482a1fcb9SIngo Molnar .procname = "hung_task_warnings", 90582a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 90690739081SIngo Molnar .maxlen = sizeof(unsigned long), 90782a1fcb9SIngo Molnar .mode = 0644, 90890739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 90982a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 91082a1fcb9SIngo Molnar }, 911c4f3b63fSRavikiran G Thirumalai #endif 912bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 913bebfa101SAndi Kleen { 914bebfa101SAndi Kleen .ctl_name = KERN_COMPAT_LOG, 915bebfa101SAndi Kleen .procname = "compat-log", 916bebfa101SAndi Kleen .data = &compat_log, 917bebfa101SAndi Kleen .maxlen = sizeof (int), 918bebfa101SAndi Kleen .mode = 0644, 919bebfa101SAndi Kleen .proc_handler = &proc_dointvec, 920bebfa101SAndi Kleen }, 921bebfa101SAndi Kleen #endif 92223f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 92323f78d4aSIngo Molnar { 92423f78d4aSIngo Molnar .ctl_name = KERN_MAX_LOCK_DEPTH, 92523f78d4aSIngo Molnar .procname = "max_lock_depth", 92623f78d4aSIngo Molnar .data = &max_lock_depth, 92723f78d4aSIngo Molnar .maxlen = sizeof(int), 92823f78d4aSIngo Molnar .mode = 0644, 92923f78d4aSIngo Molnar .proc_handler = &proc_dointvec, 93023f78d4aSIngo Molnar }, 93123f78d4aSIngo Molnar #endif 93210a0a8d4SJeremy Fitzhardinge { 93310a0a8d4SJeremy Fitzhardinge .ctl_name = CTL_UNNUMBERED, 93410a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 93510a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 93610a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 93710a0a8d4SJeremy Fitzhardinge .mode = 0644, 93810a0a8d4SJeremy Fitzhardinge .proc_handler = &proc_dostring, 93910a0a8d4SJeremy Fitzhardinge .strategy = &sysctl_string, 94010a0a8d4SJeremy Fitzhardinge }, 9410b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9420b77f5bfSDavid Howells { 9430b77f5bfSDavid Howells .ctl_name = CTL_UNNUMBERED, 9440b77f5bfSDavid Howells .procname = "keys", 9450b77f5bfSDavid Howells .mode = 0555, 9460b77f5bfSDavid Howells .child = key_sysctls, 9470b77f5bfSDavid Howells }, 9480b77f5bfSDavid Howells #endif 94931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 95031a72bceSPaul E. McKenney { 95131a72bceSPaul E. McKenney .ctl_name = CTL_UNNUMBERED, 95231a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 95331a72bceSPaul E. McKenney .data = &rcutorture_runnable, 95431a72bceSPaul E. McKenney .maxlen = sizeof(int), 95531a72bceSPaul E. McKenney .mode = 0644, 95631a72bceSPaul E. McKenney .proc_handler = &proc_dointvec, 95731a72bceSPaul E. McKenney }, 95831a72bceSPaul E. McKenney #endif 95912e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK 96012e22c5eSDavid Howells { 96112e22c5eSDavid Howells .ctl_name = CTL_UNNUMBERED, 96212e22c5eSDavid Howells .procname = "slow-work", 96312e22c5eSDavid Howells .mode = 0555, 96412e22c5eSDavid Howells .child = slow_work_sysctls, 96512e22c5eSDavid Howells }, 96612e22c5eSDavid Howells #endif 967*cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 9681ccd1549SPeter Zijlstra { 9691ccd1549SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 970*cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 971*cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 972*cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9731ccd1549SPeter Zijlstra .mode = 0644, 9741ccd1549SPeter Zijlstra .proc_handler = &proc_dointvec, 9751ccd1549SPeter Zijlstra }, 976c5078f78SPeter Zijlstra { 977c5078f78SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 978*cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 979*cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 980*cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 981c5078f78SPeter Zijlstra .mode = 0644, 982c5078f78SPeter Zijlstra .proc_handler = &proc_dointvec, 983c5078f78SPeter Zijlstra }, 984a78ac325SPeter Zijlstra { 985a78ac325SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 986*cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 987*cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 988*cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 989a78ac325SPeter Zijlstra .mode = 0644, 990a78ac325SPeter Zijlstra .proc_handler = &proc_dointvec, 991a78ac325SPeter Zijlstra }, 9921ccd1549SPeter Zijlstra #endif 993dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 994dfec072eSVegard Nossum { 995dfec072eSVegard Nossum .ctl_name = CTL_UNNUMBERED, 996dfec072eSVegard Nossum .procname = "kmemcheck", 997dfec072eSVegard Nossum .data = &kmemcheck_enabled, 998dfec072eSVegard Nossum .maxlen = sizeof(int), 999dfec072eSVegard Nossum .mode = 0644, 1000dfec072eSVegard Nossum .proc_handler = &proc_dointvec, 1001dfec072eSVegard Nossum }, 1002dfec072eSVegard Nossum #endif 1003cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 10045e605b64SJens Axboe { 10055e605b64SJens Axboe .ctl_name = CTL_UNNUMBERED, 10065e605b64SJens Axboe .procname = "blk_iopoll", 10075e605b64SJens Axboe .data = &blk_iopoll_enabled, 10085e605b64SJens Axboe .maxlen = sizeof(int), 10095e605b64SJens Axboe .mode = 0644, 10105e605b64SJens Axboe .proc_handler = &proc_dointvec, 10115e605b64SJens Axboe }, 1012cb684b5bSJens Axboe #endif 1013ed2c12f3SAndrew Morton /* 1014ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 1015ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 1016ed2c12f3SAndrew Morton */ 10171da177e4SLinus Torvalds { .ctl_name = 0 } 10181da177e4SLinus Torvalds }; 10191da177e4SLinus Torvalds 1020d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 10211da177e4SLinus Torvalds { 10221da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_MEMORY, 10231da177e4SLinus Torvalds .procname = "overcommit_memory", 10241da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 10251da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 10261da177e4SLinus Torvalds .mode = 0644, 10271da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10281da177e4SLinus Torvalds }, 10291da177e4SLinus Torvalds { 1030fadd8fbdSKAMEZAWA Hiroyuki .ctl_name = VM_PANIC_ON_OOM, 1031fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1032fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1033fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1034fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1035fadd8fbdSKAMEZAWA Hiroyuki .proc_handler = &proc_dointvec, 1036fadd8fbdSKAMEZAWA Hiroyuki }, 1037fadd8fbdSKAMEZAWA Hiroyuki { 1038fe071d7eSDavid Rientjes .ctl_name = CTL_UNNUMBERED, 1039fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1040fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1041fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1042fe071d7eSDavid Rientjes .mode = 0644, 1043fe071d7eSDavid Rientjes .proc_handler = &proc_dointvec, 1044fe071d7eSDavid Rientjes }, 1045fe071d7eSDavid Rientjes { 1046fef1bdd6SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 1047fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1048fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1049fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1050fef1bdd6SDavid Rientjes .mode = 0644, 1051fef1bdd6SDavid Rientjes .proc_handler = &proc_dointvec, 1052fef1bdd6SDavid Rientjes }, 1053fef1bdd6SDavid Rientjes { 10541da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_RATIO, 10551da177e4SLinus Torvalds .procname = "overcommit_ratio", 10561da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10571da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10581da177e4SLinus Torvalds .mode = 0644, 10591da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10601da177e4SLinus Torvalds }, 10611da177e4SLinus Torvalds { 10621da177e4SLinus Torvalds .ctl_name = VM_PAGE_CLUSTER, 10631da177e4SLinus Torvalds .procname = "page-cluster", 10641da177e4SLinus Torvalds .data = &page_cluster, 10651da177e4SLinus Torvalds .maxlen = sizeof(int), 10661da177e4SLinus Torvalds .mode = 0644, 10671da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10681da177e4SLinus Torvalds }, 10691da177e4SLinus Torvalds { 10701da177e4SLinus Torvalds .ctl_name = VM_DIRTY_BACKGROUND, 10711da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10721da177e4SLinus Torvalds .data = &dirty_background_ratio, 10731da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10741da177e4SLinus Torvalds .mode = 0644, 10752da02997SDavid Rientjes .proc_handler = &dirty_background_ratio_handler, 10761da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10771da177e4SLinus Torvalds .extra1 = &zero, 10781da177e4SLinus Torvalds .extra2 = &one_hundred, 10791da177e4SLinus Torvalds }, 10801da177e4SLinus Torvalds { 10812da02997SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 10822da02997SDavid Rientjes .procname = "dirty_background_bytes", 10832da02997SDavid Rientjes .data = &dirty_background_bytes, 10842da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10852da02997SDavid Rientjes .mode = 0644, 10862da02997SDavid Rientjes .proc_handler = &dirty_background_bytes_handler, 10872da02997SDavid Rientjes .strategy = &sysctl_intvec, 1088fc3501d4SSven Wegener .extra1 = &one_ul, 10892da02997SDavid Rientjes }, 10902da02997SDavid Rientjes { 10911da177e4SLinus Torvalds .ctl_name = VM_DIRTY_RATIO, 10921da177e4SLinus Torvalds .procname = "dirty_ratio", 10931da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10941da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10951da177e4SLinus Torvalds .mode = 0644, 109604fbfdc1SPeter Zijlstra .proc_handler = &dirty_ratio_handler, 10971da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10981da177e4SLinus Torvalds .extra1 = &zero, 10991da177e4SLinus Torvalds .extra2 = &one_hundred, 11001da177e4SLinus Torvalds }, 11011da177e4SLinus Torvalds { 11022da02997SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 11032da02997SDavid Rientjes .procname = "dirty_bytes", 11042da02997SDavid Rientjes .data = &vm_dirty_bytes, 11052da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 11062da02997SDavid Rientjes .mode = 0644, 11072da02997SDavid Rientjes .proc_handler = &dirty_bytes_handler, 11082da02997SDavid Rientjes .strategy = &sysctl_intvec, 11099e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 11102da02997SDavid Rientjes }, 11112da02997SDavid Rientjes { 11121da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1113f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1114f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 11151da177e4SLinus Torvalds .mode = 0644, 11161da177e4SLinus Torvalds .proc_handler = &dirty_writeback_centisecs_handler, 11171da177e4SLinus Torvalds }, 11181da177e4SLinus Torvalds { 11191da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1120f6ef9438SBart Samwel .data = &dirty_expire_interval, 1121f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 11221da177e4SLinus Torvalds .mode = 0644, 1123704503d8SAlexey Dobriyan .proc_handler = &proc_dointvec, 11241da177e4SLinus Torvalds }, 11251da177e4SLinus Torvalds { 11261da177e4SLinus Torvalds .ctl_name = VM_NR_PDFLUSH_THREADS, 11271da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 11281da177e4SLinus Torvalds .data = &nr_pdflush_threads, 11291da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 11301da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 11311da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11321da177e4SLinus Torvalds }, 11331da177e4SLinus Torvalds { 11341da177e4SLinus Torvalds .ctl_name = VM_SWAPPINESS, 11351da177e4SLinus Torvalds .procname = "swappiness", 11361da177e4SLinus Torvalds .data = &vm_swappiness, 11371da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 11381da177e4SLinus Torvalds .mode = 0644, 11391da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 11401da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11411da177e4SLinus Torvalds .extra1 = &zero, 11421da177e4SLinus Torvalds .extra2 = &one_hundred, 11431da177e4SLinus Torvalds }, 11441da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11451da177e4SLinus Torvalds { 11461da177e4SLinus Torvalds .procname = "nr_hugepages", 1147e5ff2159SAndi Kleen .data = NULL, 11481da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11491da177e4SLinus Torvalds .mode = 0644, 11501da177e4SLinus Torvalds .proc_handler = &hugetlb_sysctl_handler, 11511da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11521da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11531da177e4SLinus Torvalds }, 11541da177e4SLinus Torvalds { 11551da177e4SLinus Torvalds .ctl_name = VM_HUGETLB_GROUP, 11561da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11571da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11581da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11591da177e4SLinus Torvalds .mode = 0644, 11601da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11611da177e4SLinus Torvalds }, 1162396faf03SMel Gorman { 1163396faf03SMel Gorman .ctl_name = CTL_UNNUMBERED, 1164396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1165396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1166396faf03SMel Gorman .maxlen = sizeof(int), 1167396faf03SMel Gorman .mode = 0644, 1168396faf03SMel Gorman .proc_handler = &hugetlb_treat_movable_handler, 1169396faf03SMel Gorman }, 117054f9f80dSAdam Litke { 117154f9f80dSAdam Litke .ctl_name = CTL_UNNUMBERED, 1172d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1173e5ff2159SAndi Kleen .data = NULL, 1174e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1175d1c3fb1fSNishanth Aravamudan .mode = 0644, 1176a3d0c6aaSNishanth Aravamudan .proc_handler = &hugetlb_overcommit_handler, 1177e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1178e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1179d1c3fb1fSNishanth Aravamudan }, 11801da177e4SLinus Torvalds #endif 11811da177e4SLinus Torvalds { 11821da177e4SLinus Torvalds .ctl_name = VM_LOWMEM_RESERVE_RATIO, 11831da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11841da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11851da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11861da177e4SLinus Torvalds .mode = 0644, 11871da177e4SLinus Torvalds .proc_handler = &lowmem_reserve_ratio_sysctl_handler, 11881da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11891da177e4SLinus Torvalds }, 11901da177e4SLinus Torvalds { 11919d0243bcSAndrew Morton .ctl_name = VM_DROP_PAGECACHE, 11929d0243bcSAndrew Morton .procname = "drop_caches", 11939d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11949d0243bcSAndrew Morton .maxlen = sizeof(int), 11959d0243bcSAndrew Morton .mode = 0644, 11969d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 11979d0243bcSAndrew Morton .strategy = &sysctl_intvec, 11989d0243bcSAndrew Morton }, 11999d0243bcSAndrew Morton { 12001da177e4SLinus Torvalds .ctl_name = VM_MIN_FREE_KBYTES, 12011da177e4SLinus Torvalds .procname = "min_free_kbytes", 12021da177e4SLinus Torvalds .data = &min_free_kbytes, 12031da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 12041da177e4SLinus Torvalds .mode = 0644, 12051da177e4SLinus Torvalds .proc_handler = &min_free_kbytes_sysctl_handler, 12061da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12071da177e4SLinus Torvalds .extra1 = &zero, 12081da177e4SLinus Torvalds }, 12098ad4b1fbSRohit Seth { 12108ad4b1fbSRohit Seth .ctl_name = VM_PERCPU_PAGELIST_FRACTION, 12118ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 12128ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 12138ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 12148ad4b1fbSRohit Seth .mode = 0644, 12158ad4b1fbSRohit Seth .proc_handler = &percpu_pagelist_fraction_sysctl_handler, 12168ad4b1fbSRohit Seth .strategy = &sysctl_intvec, 12178ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 12188ad4b1fbSRohit Seth }, 12191da177e4SLinus Torvalds #ifdef CONFIG_MMU 12201da177e4SLinus Torvalds { 12211da177e4SLinus Torvalds .ctl_name = VM_MAX_MAP_COUNT, 12221da177e4SLinus Torvalds .procname = "max_map_count", 12231da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12241da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12251da177e4SLinus Torvalds .mode = 0644, 12261da177e4SLinus Torvalds .proc_handler = &proc_dointvec 12271da177e4SLinus Torvalds }, 1228dd8632a1SPaul Mundt #else 1229dd8632a1SPaul Mundt { 1230dd8632a1SPaul Mundt .ctl_name = CTL_UNNUMBERED, 1231dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1232dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1233dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1234dd8632a1SPaul Mundt .mode = 0644, 1235dd8632a1SPaul Mundt .proc_handler = &proc_dointvec_minmax, 1236dd8632a1SPaul Mundt .strategy = &sysctl_intvec, 1237dd8632a1SPaul Mundt .extra1 = &zero, 1238dd8632a1SPaul Mundt }, 12391da177e4SLinus Torvalds #endif 12401da177e4SLinus Torvalds { 12411da177e4SLinus Torvalds .ctl_name = VM_LAPTOP_MODE, 12421da177e4SLinus Torvalds .procname = "laptop_mode", 12431da177e4SLinus Torvalds .data = &laptop_mode, 12441da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12451da177e4SLinus Torvalds .mode = 0644, 1246ed5b43f1SBart Samwel .proc_handler = &proc_dointvec_jiffies, 1247ed5b43f1SBart Samwel .strategy = &sysctl_jiffies, 12481da177e4SLinus Torvalds }, 12491da177e4SLinus Torvalds { 12501da177e4SLinus Torvalds .ctl_name = VM_BLOCK_DUMP, 12511da177e4SLinus Torvalds .procname = "block_dump", 12521da177e4SLinus Torvalds .data = &block_dump, 12531da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12541da177e4SLinus Torvalds .mode = 0644, 12551da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12561da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12571da177e4SLinus Torvalds .extra1 = &zero, 12581da177e4SLinus Torvalds }, 12591da177e4SLinus Torvalds { 12601da177e4SLinus Torvalds .ctl_name = VM_VFS_CACHE_PRESSURE, 12611da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12621da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12631da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12641da177e4SLinus Torvalds .mode = 0644, 12651da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12661da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12671da177e4SLinus Torvalds .extra1 = &zero, 12681da177e4SLinus Torvalds }, 12691da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12701da177e4SLinus Torvalds { 12711da177e4SLinus Torvalds .ctl_name = VM_LEGACY_VA_LAYOUT, 12721da177e4SLinus Torvalds .procname = "legacy_va_layout", 12731da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12741da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12751da177e4SLinus Torvalds .mode = 0644, 12761da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12771da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12781da177e4SLinus Torvalds .extra1 = &zero, 12791da177e4SLinus Torvalds }, 12801da177e4SLinus Torvalds #endif 12811743660bSChristoph Lameter #ifdef CONFIG_NUMA 12821743660bSChristoph Lameter { 12831743660bSChristoph Lameter .ctl_name = VM_ZONE_RECLAIM_MODE, 12841743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12851743660bSChristoph Lameter .data = &zone_reclaim_mode, 12861743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12871743660bSChristoph Lameter .mode = 0644, 12881743660bSChristoph Lameter .proc_handler = &proc_dointvec, 1289c84db23cSChristoph Lameter .strategy = &sysctl_intvec, 1290c84db23cSChristoph Lameter .extra1 = &zero, 12911743660bSChristoph Lameter }, 12929614634fSChristoph Lameter { 12939614634fSChristoph Lameter .ctl_name = VM_MIN_UNMAPPED, 12949614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12959614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12969614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12979614634fSChristoph Lameter .mode = 0644, 12989614634fSChristoph Lameter .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler, 12999614634fSChristoph Lameter .strategy = &sysctl_intvec, 13009614634fSChristoph Lameter .extra1 = &zero, 13019614634fSChristoph Lameter .extra2 = &one_hundred, 13029614634fSChristoph Lameter }, 13030ff38490SChristoph Lameter { 13040ff38490SChristoph Lameter .ctl_name = VM_MIN_SLAB, 13050ff38490SChristoph Lameter .procname = "min_slab_ratio", 13060ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 13070ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 13080ff38490SChristoph Lameter .mode = 0644, 13090ff38490SChristoph Lameter .proc_handler = &sysctl_min_slab_ratio_sysctl_handler, 13100ff38490SChristoph Lameter .strategy = &sysctl_intvec, 13110ff38490SChristoph Lameter .extra1 = &zero, 13120ff38490SChristoph Lameter .extra2 = &one_hundred, 13130ff38490SChristoph Lameter }, 13141743660bSChristoph Lameter #endif 131577461ab3SChristoph Lameter #ifdef CONFIG_SMP 131677461ab3SChristoph Lameter { 131777461ab3SChristoph Lameter .ctl_name = CTL_UNNUMBERED, 131877461ab3SChristoph Lameter .procname = "stat_interval", 131977461ab3SChristoph Lameter .data = &sysctl_stat_interval, 132077461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 132177461ab3SChristoph Lameter .mode = 0644, 132277461ab3SChristoph Lameter .proc_handler = &proc_dointvec_jiffies, 132377461ab3SChristoph Lameter .strategy = &sysctl_jiffies, 132477461ab3SChristoph Lameter }, 132577461ab3SChristoph Lameter #endif 1326ed032189SEric Paris { 1327ed032189SEric Paris .ctl_name = CTL_UNNUMBERED, 1328ed032189SEric Paris .procname = "mmap_min_addr", 1329788084abSEric Paris .data = &dac_mmap_min_addr, 1330ed032189SEric Paris .maxlen = sizeof(unsigned long), 1331ed032189SEric Paris .mode = 0644, 1332788084abSEric Paris .proc_handler = &mmap_min_addr_handler, 1333ed032189SEric Paris }, 1334f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1335f0c0b2b8SKAMEZAWA Hiroyuki { 1336f0c0b2b8SKAMEZAWA Hiroyuki .ctl_name = CTL_UNNUMBERED, 1337f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1338f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1339f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1340f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 1341f0c0b2b8SKAMEZAWA Hiroyuki .proc_handler = &numa_zonelist_order_handler, 1342f0c0b2b8SKAMEZAWA Hiroyuki .strategy = &sysctl_string, 1343f0c0b2b8SKAMEZAWA Hiroyuki }, 1344f0c0b2b8SKAMEZAWA Hiroyuki #endif 13452b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13465c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1347e6e5494cSIngo Molnar { 1348e6e5494cSIngo Molnar .ctl_name = VM_VDSO_ENABLED, 1349e6e5494cSIngo Molnar .procname = "vdso_enabled", 1350e6e5494cSIngo Molnar .data = &vdso_enabled, 1351e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1352e6e5494cSIngo Molnar .mode = 0644, 1353e6e5494cSIngo Molnar .proc_handler = &proc_dointvec, 1354e6e5494cSIngo Molnar .strategy = &sysctl_intvec, 1355e6e5494cSIngo Molnar .extra1 = &zero, 1356e6e5494cSIngo Molnar }, 1357e6e5494cSIngo Molnar #endif 1358195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1359195cf453SBron Gondwana { 1360195cf453SBron Gondwana .ctl_name = CTL_UNNUMBERED, 1361195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1362195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1363195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1364195cf453SBron Gondwana .mode = 0644, 1365195cf453SBron Gondwana .proc_handler = &proc_dointvec_minmax, 1366195cf453SBron Gondwana .strategy = &sysctl_intvec, 1367195cf453SBron Gondwana .extra1 = &zero, 1368195cf453SBron Gondwana .extra2 = &one, 1369195cf453SBron Gondwana }, 1370195cf453SBron Gondwana #endif 13714be6f6bbSPeter Zijlstra { 13724be6f6bbSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 13734be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13744be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13754be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13764be6f6bbSPeter Zijlstra .mode = 0644, 13774be6f6bbSPeter Zijlstra .proc_handler = &scan_unevictable_handler, 13784be6f6bbSPeter Zijlstra }, 13792be7fe07SAndrew Morton /* 13802be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 13812be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 13822be7fe07SAndrew Morton */ 13831da177e4SLinus Torvalds { .ctl_name = 0 } 13841da177e4SLinus Torvalds }; 13851da177e4SLinus Torvalds 13862abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1387d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13882abc26fcSEric W. Biederman { .ctl_name = 0 } 13892abc26fcSEric W. Biederman }; 13902abc26fcSEric W. Biederman #endif 13912abc26fcSEric W. Biederman 1392d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13931da177e4SLinus Torvalds { 13941da177e4SLinus Torvalds .ctl_name = FS_NRINODE, 13951da177e4SLinus Torvalds .procname = "inode-nr", 13961da177e4SLinus Torvalds .data = &inodes_stat, 13971da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13981da177e4SLinus Torvalds .mode = 0444, 13991da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14001da177e4SLinus Torvalds }, 14011da177e4SLinus Torvalds { 14021da177e4SLinus Torvalds .ctl_name = FS_STATINODE, 14031da177e4SLinus Torvalds .procname = "inode-state", 14041da177e4SLinus Torvalds .data = &inodes_stat, 14051da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 14061da177e4SLinus Torvalds .mode = 0444, 14071da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14081da177e4SLinus Torvalds }, 14091da177e4SLinus Torvalds { 14101da177e4SLinus Torvalds .procname = "file-nr", 14111da177e4SLinus Torvalds .data = &files_stat, 14121da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 14131da177e4SLinus Torvalds .mode = 0444, 1414529bf6beSDipankar Sarma .proc_handler = &proc_nr_files, 14151da177e4SLinus Torvalds }, 14161da177e4SLinus Torvalds { 14171da177e4SLinus Torvalds .ctl_name = FS_MAXFILE, 14181da177e4SLinus Torvalds .procname = "file-max", 14191da177e4SLinus Torvalds .data = &files_stat.max_files, 14201da177e4SLinus Torvalds .maxlen = sizeof(int), 14211da177e4SLinus Torvalds .mode = 0644, 14221da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14231da177e4SLinus Torvalds }, 14241da177e4SLinus Torvalds { 14259cfe015aSEric Dumazet .ctl_name = CTL_UNNUMBERED, 14269cfe015aSEric Dumazet .procname = "nr_open", 14279cfe015aSEric Dumazet .data = &sysctl_nr_open, 14289cfe015aSEric Dumazet .maxlen = sizeof(int), 14299cfe015aSEric Dumazet .mode = 0644, 1430eceea0b3SAl Viro .proc_handler = &proc_dointvec_minmax, 1431eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1432eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14339cfe015aSEric Dumazet }, 14349cfe015aSEric Dumazet { 14351da177e4SLinus Torvalds .ctl_name = FS_DENTRY, 14361da177e4SLinus Torvalds .procname = "dentry-state", 14371da177e4SLinus Torvalds .data = &dentry_stat, 14381da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14391da177e4SLinus Torvalds .mode = 0444, 14401da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14411da177e4SLinus Torvalds }, 14421da177e4SLinus Torvalds { 14431da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWUID, 14441da177e4SLinus Torvalds .procname = "overflowuid", 14451da177e4SLinus Torvalds .data = &fs_overflowuid, 14461da177e4SLinus Torvalds .maxlen = sizeof(int), 14471da177e4SLinus Torvalds .mode = 0644, 14481da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 14491da177e4SLinus Torvalds .strategy = &sysctl_intvec, 14501da177e4SLinus Torvalds .extra1 = &minolduid, 14511da177e4SLinus Torvalds .extra2 = &maxolduid, 14521da177e4SLinus Torvalds }, 14531da177e4SLinus Torvalds { 14541da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWGID, 14551da177e4SLinus Torvalds .procname = "overflowgid", 14561da177e4SLinus Torvalds .data = &fs_overflowgid, 14571da177e4SLinus Torvalds .maxlen = sizeof(int), 14581da177e4SLinus Torvalds .mode = 0644, 14591da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 14601da177e4SLinus Torvalds .strategy = &sysctl_intvec, 14611da177e4SLinus Torvalds .extra1 = &minolduid, 14621da177e4SLinus Torvalds .extra2 = &maxolduid, 14631da177e4SLinus Torvalds }, 1464bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14651da177e4SLinus Torvalds { 14661da177e4SLinus Torvalds .ctl_name = FS_LEASES, 14671da177e4SLinus Torvalds .procname = "leases-enable", 14681da177e4SLinus Torvalds .data = &leases_enable, 14691da177e4SLinus Torvalds .maxlen = sizeof(int), 14701da177e4SLinus Torvalds .mode = 0644, 14711da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14721da177e4SLinus Torvalds }, 1473bfcd17a6SThomas Petazzoni #endif 14741da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14751da177e4SLinus Torvalds { 14761da177e4SLinus Torvalds .ctl_name = FS_DIR_NOTIFY, 14771da177e4SLinus Torvalds .procname = "dir-notify-enable", 14781da177e4SLinus Torvalds .data = &dir_notify_enable, 14791da177e4SLinus Torvalds .maxlen = sizeof(int), 14801da177e4SLinus Torvalds .mode = 0644, 14811da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14821da177e4SLinus Torvalds }, 14831da177e4SLinus Torvalds #endif 14841da177e4SLinus Torvalds #ifdef CONFIG_MMU 1485bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14861da177e4SLinus Torvalds { 14871da177e4SLinus Torvalds .ctl_name = FS_LEASE_TIME, 14881da177e4SLinus Torvalds .procname = "lease-break-time", 14891da177e4SLinus Torvalds .data = &lease_break_time, 14901da177e4SLinus Torvalds .maxlen = sizeof(int), 14911da177e4SLinus Torvalds .mode = 0644, 14928e654fbaSMatthew Wilcox .proc_handler = &proc_dointvec, 14931da177e4SLinus Torvalds }, 1494bfcd17a6SThomas Petazzoni #endif 1495ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14961da177e4SLinus Torvalds { 14971da177e4SLinus Torvalds .procname = "aio-nr", 14981da177e4SLinus Torvalds .data = &aio_nr, 14991da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 15001da177e4SLinus Torvalds .mode = 0444, 1501d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 15021da177e4SLinus Torvalds }, 15031da177e4SLinus Torvalds { 15041da177e4SLinus Torvalds .procname = "aio-max-nr", 15051da177e4SLinus Torvalds .data = &aio_max_nr, 15061da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 15071da177e4SLinus Torvalds .mode = 0644, 1508d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 15091da177e4SLinus Torvalds }, 1510ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 15112d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 15120399cb08SRobert Love { 15130399cb08SRobert Love .ctl_name = FS_INOTIFY, 15140399cb08SRobert Love .procname = "inotify", 15150399cb08SRobert Love .mode = 0555, 15160399cb08SRobert Love .child = inotify_table, 15170399cb08SRobert Love }, 15180399cb08SRobert Love #endif 15197ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 15207ef9964eSDavide Libenzi { 15217ef9964eSDavide Libenzi .procname = "epoll", 15227ef9964eSDavide Libenzi .mode = 0555, 15237ef9964eSDavide Libenzi .child = epoll_table, 15247ef9964eSDavide Libenzi }, 15257ef9964eSDavide Libenzi #endif 15261da177e4SLinus Torvalds #endif 1527d6e71144SAlan Cox { 1528d6e71144SAlan Cox .ctl_name = KERN_SETUID_DUMPABLE, 1529d6e71144SAlan Cox .procname = "suid_dumpable", 1530d6e71144SAlan Cox .data = &suid_dumpable, 1531d6e71144SAlan Cox .maxlen = sizeof(int), 1532d6e71144SAlan Cox .mode = 0644, 15338e654fbaSMatthew Wilcox .proc_handler = &proc_dointvec_minmax, 15348e654fbaSMatthew Wilcox .strategy = &sysctl_intvec, 15358e654fbaSMatthew Wilcox .extra1 = &zero, 15368e654fbaSMatthew Wilcox .extra2 = &two, 1537d6e71144SAlan Cox }, 15382abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 15392abc26fcSEric W. Biederman { 15402abc26fcSEric W. Biederman .ctl_name = CTL_UNNUMBERED, 15412abc26fcSEric W. Biederman .procname = "binfmt_misc", 15422abc26fcSEric W. Biederman .mode = 0555, 15432abc26fcSEric W. Biederman .child = binfmt_misc_table, 15442abc26fcSEric W. Biederman }, 15452abc26fcSEric W. Biederman #endif 15462be7fe07SAndrew Morton /* 15472be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 15482be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 15492be7fe07SAndrew Morton */ 15501da177e4SLinus Torvalds { .ctl_name = 0 } 15511da177e4SLinus Torvalds }; 15521da177e4SLinus Torvalds 1553d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1554d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC) 1555abd4f750SMasoud Asgharifard Sharbiani { 1556abd4f750SMasoud Asgharifard Sharbiani .ctl_name = CTL_UNNUMBERED, 1557abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1558abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1559abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1560abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1561abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1562abd4f750SMasoud Asgharifard Sharbiani }, 1563abd4f750SMasoud Asgharifard Sharbiani #endif 15641da177e4SLinus Torvalds { .ctl_name = 0 } 15651da177e4SLinus Torvalds }; 15661da177e4SLinus Torvalds 1567d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15681da177e4SLinus Torvalds { .ctl_name = 0 } 15691da177e4SLinus Torvalds }; 15701da177e4SLinus Torvalds 1571330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1572330d57fbSAl Viro 1573330d57fbSAl Viro /* called under sysctl_lock */ 1574330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1575330d57fbSAl Viro { 1576330d57fbSAl Viro if (unlikely(p->unregistering)) 1577330d57fbSAl Viro return 0; 1578330d57fbSAl Viro p->used++; 1579330d57fbSAl Viro return 1; 1580330d57fbSAl Viro } 1581330d57fbSAl Viro 1582330d57fbSAl Viro /* called under sysctl_lock */ 1583330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1584330d57fbSAl Viro { 1585330d57fbSAl Viro if (!--p->used) 1586330d57fbSAl Viro if (unlikely(p->unregistering)) 1587330d57fbSAl Viro complete(p->unregistering); 1588330d57fbSAl Viro } 1589330d57fbSAl Viro 1590330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1591330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1592330d57fbSAl Viro { 1593330d57fbSAl Viro /* 1594330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1595330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1596330d57fbSAl Viro */ 1597330d57fbSAl Viro if (unlikely(p->used)) { 1598330d57fbSAl Viro struct completion wait; 1599330d57fbSAl Viro init_completion(&wait); 1600330d57fbSAl Viro p->unregistering = &wait; 1601330d57fbSAl Viro spin_unlock(&sysctl_lock); 1602330d57fbSAl Viro wait_for_completion(&wait); 1603330d57fbSAl Viro spin_lock(&sysctl_lock); 1604f7e6ced4SAl Viro } else { 1605f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1606f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1607330d57fbSAl Viro } 1608330d57fbSAl Viro /* 1609330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1610330d57fbSAl Viro * list in do_sysctl() relies on that. 1611330d57fbSAl Viro */ 1612330d57fbSAl Viro list_del_init(&p->ctl_entry); 1613330d57fbSAl Viro } 1614330d57fbSAl Viro 1615f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1616f7e6ced4SAl Viro { 1617f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1618f7e6ced4SAl Viro head->count++; 1619f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1620f7e6ced4SAl Viro } 1621f7e6ced4SAl Viro 1622f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1623f7e6ced4SAl Viro { 1624f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1625f7e6ced4SAl Viro if (!--head->count) 1626f7e6ced4SAl Viro kfree(head); 1627f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1628f7e6ced4SAl Viro } 1629f7e6ced4SAl Viro 1630f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1631f7e6ced4SAl Viro { 1632f7e6ced4SAl Viro if (!head) 1633f7e6ced4SAl Viro BUG(); 1634f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1635f7e6ced4SAl Viro if (!use_table(head)) 1636f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1637f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1638f7e6ced4SAl Viro return head; 1639f7e6ced4SAl Viro } 1640f7e6ced4SAl Viro 1641805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1642805b5d5eSEric W. Biederman { 1643805b5d5eSEric W. Biederman if (!head) 1644805b5d5eSEric W. Biederman return; 1645805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1646805b5d5eSEric W. Biederman unuse_table(head); 1647805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1648805b5d5eSEric W. Biederman } 1649805b5d5eSEric W. Biederman 165073455092SAl Viro static struct ctl_table_set * 165173455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 165273455092SAl Viro { 165373455092SAl Viro struct ctl_table_set *set = &root->default_set; 165473455092SAl Viro if (root->lookup) 165573455092SAl Viro set = root->lookup(root, namespaces); 165673455092SAl Viro return set; 165773455092SAl Viro } 165873455092SAl Viro 1659e51b6ba0SEric W. Biederman static struct list_head * 1660e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1661805b5d5eSEric W. Biederman { 166273455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 166373455092SAl Viro return &set->list; 1664e51b6ba0SEric W. Biederman } 1665e51b6ba0SEric W. Biederman 1666e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1667e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1668e51b6ba0SEric W. Biederman { 1669e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1670e51b6ba0SEric W. Biederman struct list_head *header_list; 1671805b5d5eSEric W. Biederman struct ctl_table_header *head; 1672805b5d5eSEric W. Biederman struct list_head *tmp; 1673e51b6ba0SEric W. Biederman 1674805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1675805b5d5eSEric W. Biederman if (prev) { 1676e51b6ba0SEric W. Biederman head = prev; 1677805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1678805b5d5eSEric W. Biederman unuse_table(prev); 1679805b5d5eSEric W. Biederman goto next; 1680805b5d5eSEric W. Biederman } 1681805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1682805b5d5eSEric W. Biederman for (;;) { 1683805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1684805b5d5eSEric W. Biederman 1685805b5d5eSEric W. Biederman if (!use_table(head)) 1686805b5d5eSEric W. Biederman goto next; 1687805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1688805b5d5eSEric W. Biederman return head; 1689805b5d5eSEric W. Biederman next: 1690e51b6ba0SEric W. Biederman root = head->root; 1691805b5d5eSEric W. Biederman tmp = tmp->next; 1692e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1693e51b6ba0SEric W. Biederman if (tmp != header_list) 1694e51b6ba0SEric W. Biederman continue; 1695e51b6ba0SEric W. Biederman 1696e51b6ba0SEric W. Biederman do { 1697e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1698e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1699e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1700e51b6ba0SEric W. Biederman goto out; 1701e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1702e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1703e51b6ba0SEric W. Biederman tmp = header_list->next; 1704805b5d5eSEric W. Biederman } 1705e51b6ba0SEric W. Biederman out: 1706805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1707805b5d5eSEric W. Biederman return NULL; 1708805b5d5eSEric W. Biederman } 1709805b5d5eSEric W. Biederman 1710e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1711e51b6ba0SEric W. Biederman { 1712e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1713e51b6ba0SEric W. Biederman } 1714e51b6ba0SEric W. Biederman 1715e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1716e51b6ba0SEric W. Biederman { 1717e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1718e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1719e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1720e51b6ba0SEric W. Biederman } 1721e51b6ba0SEric W. Biederman 1722b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 17232c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */ 1724d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root, 1725d7321cd6SPavel Emelyanov struct ctl_table *table, 17262c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 17272c4c7155SPavel Emelyanov void __user *newval, size_t newlen) 17282c4c7155SPavel Emelyanov { 17292c4c7155SPavel Emelyanov int op = 0, rc; 17302c4c7155SPavel Emelyanov 17312c4c7155SPavel Emelyanov if (oldval) 1732e6305c43SAl Viro op |= MAY_READ; 17332c4c7155SPavel Emelyanov if (newval) 1734e6305c43SAl Viro op |= MAY_WRITE; 1735d7321cd6SPavel Emelyanov if (sysctl_perm(root, table, op)) 17362c4c7155SPavel Emelyanov return -EPERM; 17372c4c7155SPavel Emelyanov 17382c4c7155SPavel Emelyanov if (table->strategy) { 1739f221e726SAlexey Dobriyan rc = table->strategy(table, oldval, oldlenp, newval, newlen); 17402c4c7155SPavel Emelyanov if (rc < 0) 17412c4c7155SPavel Emelyanov return rc; 17422c4c7155SPavel Emelyanov if (rc > 0) 17432c4c7155SPavel Emelyanov return 0; 17442c4c7155SPavel Emelyanov } 17452c4c7155SPavel Emelyanov 17462c4c7155SPavel Emelyanov /* If there is no strategy routine, or if the strategy returns 17472c4c7155SPavel Emelyanov * zero, proceed with automatic r/w */ 17482c4c7155SPavel Emelyanov if (table->data && table->maxlen) { 1749f221e726SAlexey Dobriyan rc = sysctl_data(table, oldval, oldlenp, newval, newlen); 17502c4c7155SPavel Emelyanov if (rc < 0) 17512c4c7155SPavel Emelyanov return rc; 17522c4c7155SPavel Emelyanov } 17532c4c7155SPavel Emelyanov return 0; 17542c4c7155SPavel Emelyanov } 17552c4c7155SPavel Emelyanov 17562c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen, 17572c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 17582c4c7155SPavel Emelyanov void __user *newval, size_t newlen, 1759d7321cd6SPavel Emelyanov struct ctl_table_root *root, 17602c4c7155SPavel Emelyanov struct ctl_table *table) 17612c4c7155SPavel Emelyanov { 17622c4c7155SPavel Emelyanov int n; 17632c4c7155SPavel Emelyanov repeat: 17642c4c7155SPavel Emelyanov if (!nlen) 17652c4c7155SPavel Emelyanov return -ENOTDIR; 17662c4c7155SPavel Emelyanov if (get_user(n, name)) 17672c4c7155SPavel Emelyanov return -EFAULT; 17682c4c7155SPavel Emelyanov for ( ; table->ctl_name || table->procname; table++) { 17692c4c7155SPavel Emelyanov if (!table->ctl_name) 17702c4c7155SPavel Emelyanov continue; 17712c4c7155SPavel Emelyanov if (n == table->ctl_name) { 17722c4c7155SPavel Emelyanov int error; 17732c4c7155SPavel Emelyanov if (table->child) { 1774e6305c43SAl Viro if (sysctl_perm(root, table, MAY_EXEC)) 17752c4c7155SPavel Emelyanov return -EPERM; 17762c4c7155SPavel Emelyanov name++; 17772c4c7155SPavel Emelyanov nlen--; 17782c4c7155SPavel Emelyanov table = table->child; 17792c4c7155SPavel Emelyanov goto repeat; 17802c4c7155SPavel Emelyanov } 1781f221e726SAlexey Dobriyan error = do_sysctl_strategy(root, table, 17822c4c7155SPavel Emelyanov oldval, oldlenp, 17832c4c7155SPavel Emelyanov newval, newlen); 17842c4c7155SPavel Emelyanov return error; 17852c4c7155SPavel Emelyanov } 17862c4c7155SPavel Emelyanov } 17872c4c7155SPavel Emelyanov return -ENOTDIR; 17882c4c7155SPavel Emelyanov } 17892c4c7155SPavel Emelyanov 17901da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 17911da177e4SLinus Torvalds void __user *newval, size_t newlen) 17921da177e4SLinus Torvalds { 1793805b5d5eSEric W. Biederman struct ctl_table_header *head; 1794330d57fbSAl Viro int error = -ENOTDIR; 17951da177e4SLinus Torvalds 17961da177e4SLinus Torvalds if (nlen <= 0 || nlen >= CTL_MAXNAME) 17971da177e4SLinus Torvalds return -ENOTDIR; 17981da177e4SLinus Torvalds if (oldval) { 17991da177e4SLinus Torvalds int old_len; 18001da177e4SLinus Torvalds if (!oldlenp || get_user(old_len, oldlenp)) 18011da177e4SLinus Torvalds return -EFAULT; 18021da177e4SLinus Torvalds } 1803330d57fbSAl Viro 1804805b5d5eSEric W. Biederman for (head = sysctl_head_next(NULL); head; 1805805b5d5eSEric W. Biederman head = sysctl_head_next(head)) { 1806330d57fbSAl Viro error = parse_table(name, nlen, oldval, oldlenp, 1807d7321cd6SPavel Emelyanov newval, newlen, 1808d7321cd6SPavel Emelyanov head->root, head->ctl_table); 1809805b5d5eSEric W. Biederman if (error != -ENOTDIR) { 1810805b5d5eSEric W. Biederman sysctl_head_finish(head); 1811330d57fbSAl Viro break; 1812805b5d5eSEric W. Biederman } 1813805b5d5eSEric W. Biederman } 18141da177e4SLinus Torvalds return error; 18151da177e4SLinus Torvalds } 18161da177e4SLinus Torvalds 18171e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) 18181da177e4SLinus Torvalds { 18191da177e4SLinus Torvalds struct __sysctl_args tmp; 18201da177e4SLinus Torvalds int error; 18211da177e4SLinus Torvalds 18221da177e4SLinus Torvalds if (copy_from_user(&tmp, args, sizeof(tmp))) 18231da177e4SLinus Torvalds return -EFAULT; 18241da177e4SLinus Torvalds 18257058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 18267058cb02SEric W. Biederman if (error) 18277058cb02SEric W. Biederman goto out; 18287058cb02SEric W. Biederman 18291da177e4SLinus Torvalds lock_kernel(); 18301da177e4SLinus Torvalds error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, 18311da177e4SLinus Torvalds tmp.newval, tmp.newlen); 18321da177e4SLinus Torvalds unlock_kernel(); 18337058cb02SEric W. Biederman out: 18341da177e4SLinus Torvalds return error; 18351da177e4SLinus Torvalds } 1836b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 18371da177e4SLinus Torvalds 18381da177e4SLinus Torvalds /* 18391ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 18401da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 18411da177e4SLinus Torvalds */ 18421da177e4SLinus Torvalds 18431da177e4SLinus Torvalds static int test_perm(int mode, int op) 18441da177e4SLinus Torvalds { 184576aac0e9SDavid Howells if (!current_euid()) 18461da177e4SLinus Torvalds mode >>= 6; 18471da177e4SLinus Torvalds else if (in_egroup_p(0)) 18481da177e4SLinus Torvalds mode >>= 3; 1849e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 18501da177e4SLinus Torvalds return 0; 18511da177e4SLinus Torvalds return -EACCES; 18521da177e4SLinus Torvalds } 18531da177e4SLinus Torvalds 1854d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 18551da177e4SLinus Torvalds { 18561da177e4SLinus Torvalds int error; 1857d7321cd6SPavel Emelyanov int mode; 1858d7321cd6SPavel Emelyanov 1859e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 18601da177e4SLinus Torvalds if (error) 18611da177e4SLinus Torvalds return error; 1862d7321cd6SPavel Emelyanov 1863d7321cd6SPavel Emelyanov if (root->permissions) 1864d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1865d7321cd6SPavel Emelyanov else 1866d7321cd6SPavel Emelyanov mode = table->mode; 1867d7321cd6SPavel Emelyanov 1868d7321cd6SPavel Emelyanov return test_perm(mode, op); 18691da177e4SLinus Torvalds } 18701da177e4SLinus Torvalds 1871d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1872d912b0ccSEric W. Biederman { 1873d912b0ccSEric W. Biederman for (; table->ctl_name || table->procname; table++) { 1874d912b0ccSEric W. Biederman table->parent = parent; 1875d912b0ccSEric W. Biederman if (table->child) 1876d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1877d912b0ccSEric W. Biederman } 1878d912b0ccSEric W. Biederman } 1879d912b0ccSEric W. Biederman 1880d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1881d912b0ccSEric W. Biederman { 1882d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 188388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 188488f458e4SHolger Schurig { 188588f458e4SHolger Schurig int err; 1886e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 188788f458e4SHolger Schurig } 188888f458e4SHolger Schurig #endif 1889d912b0ccSEric W. Biederman return 0; 1890d912b0ccSEric W. Biederman } 1891d912b0ccSEric W. Biederman 1892d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1893d912b0ccSEric W. Biederman 1894bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1895bfbcf034SAl Viro struct ctl_table *table) 1896ae7edeccSAl Viro { 1897ae7edeccSAl Viro struct ctl_table *p; 1898ae7edeccSAl Viro const char *s = branch->procname; 1899ae7edeccSAl Viro 1900ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1901ae7edeccSAl Viro if (!s || !branch->child) 1902bfbcf034SAl Viro return NULL; 1903ae7edeccSAl Viro 1904ae7edeccSAl Viro /* ... and nothing else */ 1905ae7edeccSAl Viro if (branch[1].procname || branch[1].ctl_name) 1906bfbcf034SAl Viro return NULL; 1907ae7edeccSAl Viro 1908ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 1909ae7edeccSAl Viro for (p = table; p->procname || p->ctl_name; p++) { 1910ae7edeccSAl Viro if (!p->child) 1911ae7edeccSAl Viro continue; 1912ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1913bfbcf034SAl Viro return p; 1914ae7edeccSAl Viro } 1915bfbcf034SAl Viro return NULL; 1916ae7edeccSAl Viro } 1917ae7edeccSAl Viro 1918ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1919ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1920ae7edeccSAl Viro { 1921ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1922bfbcf034SAl Viro struct ctl_table *next; 1923ae7edeccSAl Viro int is_better = 0; 1924ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1925ae7edeccSAl Viro 1926bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1927ae7edeccSAl Viro if (by == q->attached_by) 1928ae7edeccSAl Viro is_better = 1; 1929ae7edeccSAl Viro if (to == p->attached_by) 1930ae7edeccSAl Viro not_in_parent = 1; 1931ae7edeccSAl Viro by = by->child; 1932bfbcf034SAl Viro to = next->child; 1933ae7edeccSAl Viro } 1934ae7edeccSAl Viro 1935ae7edeccSAl Viro if (is_better && not_in_parent) { 1936ae7edeccSAl Viro q->attached_by = by; 1937ae7edeccSAl Viro q->attached_to = to; 1938ae7edeccSAl Viro q->parent = p; 1939ae7edeccSAl Viro } 1940ae7edeccSAl Viro } 1941ae7edeccSAl Viro 19421da177e4SLinus Torvalds /** 1943e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1944e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1945e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 194629e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 19471da177e4SLinus Torvalds * @table: the top-level table structure 19481da177e4SLinus Torvalds * 19491da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 195029e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 19511da177e4SLinus Torvalds * 1952d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 19531da177e4SLinus Torvalds * 19541da177e4SLinus Torvalds * ctl_name - This is the numeric sysctl value used by sysctl(2). The number 19551da177e4SLinus Torvalds * must be unique within that level of sysctl 19561da177e4SLinus Torvalds * 19571da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 19581da177e4SLinus Torvalds * enter a sysctl file 19591da177e4SLinus Torvalds * 19601da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 19611da177e4SLinus Torvalds * 19621da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 19631da177e4SLinus Torvalds * 19641da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 19651da177e4SLinus Torvalds * 19661da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 19671da177e4SLinus Torvalds * %NULL. 19681da177e4SLinus Torvalds * 19691da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 19701da177e4SLinus Torvalds * 19711da177e4SLinus Torvalds * strategy - the strategy routine (described below) 19721da177e4SLinus Torvalds * 19731da177e4SLinus Torvalds * de - for internal use by the sysctl routines 19741da177e4SLinus Torvalds * 19751da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 19761da177e4SLinus Torvalds * 19771da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 19781da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 19791da177e4SLinus Torvalds * 19801da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 19811da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 19821da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 19831da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 19841da177e4SLinus Torvalds * 19851da177e4SLinus Torvalds * More sophisticated management can be enabled by the provision of a 19861da177e4SLinus Torvalds * strategy routine with the table entry. This will be called before 19871da177e4SLinus Torvalds * any automatic read or write of the data is performed. 19881da177e4SLinus Torvalds * 19891da177e4SLinus Torvalds * The strategy routine may return 19901da177e4SLinus Torvalds * 19911da177e4SLinus Torvalds * < 0 - Error occurred (error is passed to user process) 19921da177e4SLinus Torvalds * 19931da177e4SLinus Torvalds * 0 - OK - proceed with automatic read or write. 19941da177e4SLinus Torvalds * 19951da177e4SLinus Torvalds * > 0 - OK - read or write has been done by the strategy routine, so 19961da177e4SLinus Torvalds * return immediately. 19971da177e4SLinus Torvalds * 19981da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 19991da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 20001da177e4SLinus Torvalds * directory handler). Several default handlers are available to 20011da177e4SLinus Torvalds * cover common cases - 20021da177e4SLinus Torvalds * 20031da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 20041da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 20051da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 20061da177e4SLinus Torvalds * 20071da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 20081da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 20091da177e4SLinus Torvalds * 20101da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 20111da177e4SLinus Torvalds * to the table header on success. 20121da177e4SLinus Torvalds */ 2013e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 2014e51b6ba0SEric W. Biederman struct ctl_table_root *root, 2015e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 2016e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 20171da177e4SLinus Torvalds { 201829e796fdSEric W. Biederman struct ctl_table_header *header; 201929e796fdSEric W. Biederman struct ctl_table *new, **prevp; 202029e796fdSEric W. Biederman unsigned int n, npath; 2021ae7edeccSAl Viro struct ctl_table_set *set; 202229e796fdSEric W. Biederman 202329e796fdSEric W. Biederman /* Count the path components */ 202429e796fdSEric W. Biederman for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath) 202529e796fdSEric W. Biederman ; 202629e796fdSEric W. Biederman 202729e796fdSEric W. Biederman /* 202829e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 202929e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 203029e796fdSEric W. Biederman * for this, the second will be the sentinel (ctl_name == 0). 203129e796fdSEric W. Biederman * 203229e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 203329e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 203429e796fdSEric W. Biederman */ 203529e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 203629e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 203729e796fdSEric W. Biederman if (!header) 20381da177e4SLinus Torvalds return NULL; 203929e796fdSEric W. Biederman 204029e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 204129e796fdSEric W. Biederman 204229e796fdSEric W. Biederman /* Now connect the dots */ 204329e796fdSEric W. Biederman prevp = &header->ctl_table; 204429e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 204529e796fdSEric W. Biederman /* Copy the procname */ 204629e796fdSEric W. Biederman new->procname = path->procname; 204729e796fdSEric W. Biederman new->ctl_name = path->ctl_name; 204829e796fdSEric W. Biederman new->mode = 0555; 204929e796fdSEric W. Biederman 205029e796fdSEric W. Biederman *prevp = new; 205129e796fdSEric W. Biederman prevp = &new->child; 205229e796fdSEric W. Biederman 205329e796fdSEric W. Biederman new += 2; 205429e796fdSEric W. Biederman } 205529e796fdSEric W. Biederman *prevp = table; 205623eb06deSEric W. Biederman header->ctl_table_arg = table; 205729e796fdSEric W. Biederman 205829e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 205929e796fdSEric W. Biederman header->used = 0; 206029e796fdSEric W. Biederman header->unregistering = NULL; 2061e51b6ba0SEric W. Biederman header->root = root; 206229e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 2063f7e6ced4SAl Viro header->count = 1; 206488f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 2065e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 206629e796fdSEric W. Biederman kfree(header); 2067fc6cd25bSEric W. Biederman return NULL; 2068fc6cd25bSEric W. Biederman } 206988f458e4SHolger Schurig #endif 2070330d57fbSAl Viro spin_lock(&sysctl_lock); 207173455092SAl Viro header->set = lookup_header_set(root, namespaces); 2072ae7edeccSAl Viro header->attached_by = header->ctl_table; 2073ae7edeccSAl Viro header->attached_to = root_table; 2074ae7edeccSAl Viro header->parent = &root_table_header; 2075ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 2076ae7edeccSAl Viro struct ctl_table_header *p; 2077ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 2078ae7edeccSAl Viro if (p->unregistering) 2079ae7edeccSAl Viro continue; 2080ae7edeccSAl Viro try_attach(p, header); 2081ae7edeccSAl Viro } 2082ae7edeccSAl Viro } 2083ae7edeccSAl Viro header->parent->count++; 208473455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 2085330d57fbSAl Viro spin_unlock(&sysctl_lock); 208629e796fdSEric W. Biederman 208729e796fdSEric W. Biederman return header; 208829e796fdSEric W. Biederman } 208929e796fdSEric W. Biederman 209029e796fdSEric W. Biederman /** 2091e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 2092e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 2093e51b6ba0SEric W. Biederman * @table: the top-level table structure 2094e51b6ba0SEric W. Biederman * 2095e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 2096e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 2097e51b6ba0SEric W. Biederman * 2098e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 2099e51b6ba0SEric W. Biederman */ 2100e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 2101e51b6ba0SEric W. Biederman struct ctl_table *table) 2102e51b6ba0SEric W. Biederman { 2103e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 2104e51b6ba0SEric W. Biederman path, table); 2105e51b6ba0SEric W. Biederman } 2106e51b6ba0SEric W. Biederman 2107e51b6ba0SEric W. Biederman /** 210829e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 210929e796fdSEric W. Biederman * @table: the top-level table structure 211029e796fdSEric W. Biederman * 211129e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 211229e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 211329e796fdSEric W. Biederman * 211429e796fdSEric W. Biederman * See register_sysctl_paths for more details. 211529e796fdSEric W. Biederman */ 211629e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 211729e796fdSEric W. Biederman { 211829e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 211929e796fdSEric W. Biederman 212029e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 21211da177e4SLinus Torvalds } 21221da177e4SLinus Torvalds 21231da177e4SLinus Torvalds /** 21241da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 21251da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 21261da177e4SLinus Torvalds * 21271da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 21281da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 21291da177e4SLinus Torvalds */ 21301da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 21311da177e4SLinus Torvalds { 2132330d57fbSAl Viro might_sleep(); 2133f1dad166SPavel Emelyanov 2134f1dad166SPavel Emelyanov if (header == NULL) 2135f1dad166SPavel Emelyanov return; 2136f1dad166SPavel Emelyanov 2137330d57fbSAl Viro spin_lock(&sysctl_lock); 2138330d57fbSAl Viro start_unregistering(header); 2139ae7edeccSAl Viro if (!--header->parent->count) { 2140ae7edeccSAl Viro WARN_ON(1); 2141ae7edeccSAl Viro kfree(header->parent); 2142ae7edeccSAl Viro } 2143f7e6ced4SAl Viro if (!--header->count) 21441da177e4SLinus Torvalds kfree(header); 2145f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 21461da177e4SLinus Torvalds } 21471da177e4SLinus Torvalds 21489043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 21499043476fSAl Viro { 21509043476fSAl Viro struct ctl_table_set *set = p->set; 21519043476fSAl Viro int res; 21529043476fSAl Viro spin_lock(&sysctl_lock); 21539043476fSAl Viro if (p->unregistering) 21549043476fSAl Viro res = 0; 21559043476fSAl Viro else if (!set->is_seen) 21569043476fSAl Viro res = 1; 21579043476fSAl Viro else 21589043476fSAl Viro res = set->is_seen(set); 21599043476fSAl Viro spin_unlock(&sysctl_lock); 21609043476fSAl Viro return res; 21619043476fSAl Viro } 21629043476fSAl Viro 216373455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 216473455092SAl Viro struct ctl_table_set *parent, 216573455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 216673455092SAl Viro { 216773455092SAl Viro INIT_LIST_HEAD(&p->list); 216873455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 216973455092SAl Viro p->is_seen = is_seen; 217073455092SAl Viro } 217173455092SAl Viro 2172b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 2173d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 2174b89a8171SEric W. Biederman { 2175b89a8171SEric W. Biederman return NULL; 2176b89a8171SEric W. Biederman } 2177b89a8171SEric W. Biederman 217829e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 217929e796fdSEric W. Biederman struct ctl_table *table) 218029e796fdSEric W. Biederman { 218129e796fdSEric W. Biederman return NULL; 218229e796fdSEric W. Biederman } 218329e796fdSEric W. Biederman 2184b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2185b89a8171SEric W. Biederman { 2186b89a8171SEric W. Biederman } 2187b89a8171SEric W. Biederman 218873455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 218973455092SAl Viro struct ctl_table_set *parent, 219073455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 219173455092SAl Viro { 219273455092SAl Viro } 219373455092SAl Viro 2194f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2195f7e6ced4SAl Viro { 2196f7e6ced4SAl Viro } 2197f7e6ced4SAl Viro 2198b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2199b89a8171SEric W. Biederman 22001da177e4SLinus Torvalds /* 22011da177e4SLinus Torvalds * /proc/sys support 22021da177e4SLinus Torvalds */ 22031da177e4SLinus Torvalds 2204b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 22051da177e4SLinus Torvalds 2206b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 2207b1ba4dddSAdrian Bunk struct file *filp, void __user *buffer, 2208b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2209f5dd3d6fSSam Vilain { 2210f5dd3d6fSSam Vilain size_t len; 2211f5dd3d6fSSam Vilain char __user *p; 2212f5dd3d6fSSam Vilain char c; 2213f5dd3d6fSSam Vilain 22148d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2215f5dd3d6fSSam Vilain *lenp = 0; 2216f5dd3d6fSSam Vilain return 0; 2217f5dd3d6fSSam Vilain } 2218f5dd3d6fSSam Vilain 2219f5dd3d6fSSam Vilain if (write) { 2220f5dd3d6fSSam Vilain len = 0; 2221f5dd3d6fSSam Vilain p = buffer; 2222f5dd3d6fSSam Vilain while (len < *lenp) { 2223f5dd3d6fSSam Vilain if (get_user(c, p++)) 2224f5dd3d6fSSam Vilain return -EFAULT; 2225f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2226f5dd3d6fSSam Vilain break; 2227f5dd3d6fSSam Vilain len++; 2228f5dd3d6fSSam Vilain } 2229f5dd3d6fSSam Vilain if (len >= maxlen) 2230f5dd3d6fSSam Vilain len = maxlen-1; 2231f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2232f5dd3d6fSSam Vilain return -EFAULT; 2233f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2234f5dd3d6fSSam Vilain *ppos += *lenp; 2235f5dd3d6fSSam Vilain } else { 2236f5dd3d6fSSam Vilain len = strlen(data); 2237f5dd3d6fSSam Vilain if (len > maxlen) 2238f5dd3d6fSSam Vilain len = maxlen; 22398d060877SOleg Nesterov 22408d060877SOleg Nesterov if (*ppos > len) { 22418d060877SOleg Nesterov *lenp = 0; 22428d060877SOleg Nesterov return 0; 22438d060877SOleg Nesterov } 22448d060877SOleg Nesterov 22458d060877SOleg Nesterov data += *ppos; 22468d060877SOleg Nesterov len -= *ppos; 22478d060877SOleg Nesterov 2248f5dd3d6fSSam Vilain if (len > *lenp) 2249f5dd3d6fSSam Vilain len = *lenp; 2250f5dd3d6fSSam Vilain if (len) 2251f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2252f5dd3d6fSSam Vilain return -EFAULT; 2253f5dd3d6fSSam Vilain if (len < *lenp) { 2254f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2255f5dd3d6fSSam Vilain return -EFAULT; 2256f5dd3d6fSSam Vilain len++; 2257f5dd3d6fSSam Vilain } 2258f5dd3d6fSSam Vilain *lenp = len; 2259f5dd3d6fSSam Vilain *ppos += len; 2260f5dd3d6fSSam Vilain } 2261f5dd3d6fSSam Vilain return 0; 2262f5dd3d6fSSam Vilain } 2263f5dd3d6fSSam Vilain 22641da177e4SLinus Torvalds /** 22651da177e4SLinus Torvalds * proc_dostring - read a string sysctl 22661da177e4SLinus Torvalds * @table: the sysctl table 22671da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22681da177e4SLinus Torvalds * @filp: the file structure 22691da177e4SLinus Torvalds * @buffer: the user buffer 22701da177e4SLinus Torvalds * @lenp: the size of the user buffer 22711da177e4SLinus Torvalds * @ppos: file position 22721da177e4SLinus Torvalds * 22731da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 22741da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 22751da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 22761da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 22771da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 22781da177e4SLinus Torvalds * not large enough. 22791da177e4SLinus Torvalds * 22801da177e4SLinus Torvalds * Returns 0 on success. 22811da177e4SLinus Torvalds */ 2282d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp, 22831da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22841da177e4SLinus Torvalds { 2285f5dd3d6fSSam Vilain return _proc_do_string(table->data, table->maxlen, write, filp, 2286f5dd3d6fSSam Vilain buffer, lenp, ppos); 22871da177e4SLinus Torvalds } 22881da177e4SLinus Torvalds 22891da177e4SLinus Torvalds 22901da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 22911da177e4SLinus Torvalds int *valp, 22921da177e4SLinus Torvalds int write, void *data) 22931da177e4SLinus Torvalds { 22941da177e4SLinus Torvalds if (write) { 22951da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 22961da177e4SLinus Torvalds } else { 22971da177e4SLinus Torvalds int val = *valp; 22981da177e4SLinus Torvalds if (val < 0) { 22991da177e4SLinus Torvalds *negp = -1; 23001da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 23011da177e4SLinus Torvalds } else { 23021da177e4SLinus Torvalds *negp = 0; 23031da177e4SLinus Torvalds *lvalp = (unsigned long)val; 23041da177e4SLinus Torvalds } 23051da177e4SLinus Torvalds } 23061da177e4SLinus Torvalds return 0; 23071da177e4SLinus Torvalds } 23081da177e4SLinus Torvalds 2309d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 2310fcfbd547SKirill Korotaev int write, struct file *filp, void __user *buffer, 2311fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 23121da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 23131da177e4SLinus Torvalds int write, void *data), 23141da177e4SLinus Torvalds void *data) 23151da177e4SLinus Torvalds { 23161da177e4SLinus Torvalds #define TMPBUFLEN 21 23177338f299SSukanto Ghosh int *i, vleft, first = 1, neg; 23181da177e4SLinus Torvalds unsigned long lval; 23191da177e4SLinus Torvalds size_t left, len; 23201da177e4SLinus Torvalds 23211da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 23221da177e4SLinus Torvalds char __user *s = buffer; 23231da177e4SLinus Torvalds 2324fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 23251da177e4SLinus Torvalds (*ppos && !write)) { 23261da177e4SLinus Torvalds *lenp = 0; 23271da177e4SLinus Torvalds return 0; 23281da177e4SLinus Torvalds } 23291da177e4SLinus Torvalds 2330fcfbd547SKirill Korotaev i = (int *) tbl_data; 23311da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 23321da177e4SLinus Torvalds left = *lenp; 23331da177e4SLinus Torvalds 23341da177e4SLinus Torvalds if (!conv) 23351da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 23361da177e4SLinus Torvalds 23371da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 23381da177e4SLinus Torvalds if (write) { 23391da177e4SLinus Torvalds while (left) { 23401da177e4SLinus Torvalds char c; 23411da177e4SLinus Torvalds if (get_user(c, s)) 23421da177e4SLinus Torvalds return -EFAULT; 23431da177e4SLinus Torvalds if (!isspace(c)) 23441da177e4SLinus Torvalds break; 23451da177e4SLinus Torvalds left--; 23461da177e4SLinus Torvalds s++; 23471da177e4SLinus Torvalds } 23481da177e4SLinus Torvalds if (!left) 23491da177e4SLinus Torvalds break; 23501da177e4SLinus Torvalds neg = 0; 23511da177e4SLinus Torvalds len = left; 23521da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 23531da177e4SLinus Torvalds len = sizeof(buf) - 1; 23541da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 23551da177e4SLinus Torvalds return -EFAULT; 23561da177e4SLinus Torvalds buf[len] = 0; 23571da177e4SLinus Torvalds p = buf; 23581da177e4SLinus Torvalds if (*p == '-' && left > 1) { 23591da177e4SLinus Torvalds neg = 1; 2360bd9b0bacSBP, Praveen p++; 23611da177e4SLinus Torvalds } 23621da177e4SLinus Torvalds if (*p < '0' || *p > '9') 23631da177e4SLinus Torvalds break; 23641da177e4SLinus Torvalds 23651da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 23661da177e4SLinus Torvalds 23671da177e4SLinus Torvalds len = p-buf; 23681da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 23691da177e4SLinus Torvalds break; 23701da177e4SLinus Torvalds s += len; 23711da177e4SLinus Torvalds left -= len; 23721da177e4SLinus Torvalds 23731da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 23741da177e4SLinus Torvalds break; 23751da177e4SLinus Torvalds } else { 23761da177e4SLinus Torvalds p = buf; 23771da177e4SLinus Torvalds if (!first) 23781da177e4SLinus Torvalds *p++ = '\t'; 23791da177e4SLinus Torvalds 23801da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 23811da177e4SLinus Torvalds break; 23821da177e4SLinus Torvalds 23831da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 23841da177e4SLinus Torvalds len = strlen(buf); 23851da177e4SLinus Torvalds if (len > left) 23861da177e4SLinus Torvalds len = left; 23871da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 23881da177e4SLinus Torvalds return -EFAULT; 23891da177e4SLinus Torvalds left -= len; 23901da177e4SLinus Torvalds s += len; 23911da177e4SLinus Torvalds } 23921da177e4SLinus Torvalds } 23931da177e4SLinus Torvalds 23941da177e4SLinus Torvalds if (!write && !first && left) { 23951da177e4SLinus Torvalds if(put_user('\n', s)) 23961da177e4SLinus Torvalds return -EFAULT; 23971da177e4SLinus Torvalds left--, s++; 23981da177e4SLinus Torvalds } 23991da177e4SLinus Torvalds if (write) { 24001da177e4SLinus Torvalds while (left) { 24011da177e4SLinus Torvalds char c; 24021da177e4SLinus Torvalds if (get_user(c, s++)) 24031da177e4SLinus Torvalds return -EFAULT; 24041da177e4SLinus Torvalds if (!isspace(c)) 24051da177e4SLinus Torvalds break; 24061da177e4SLinus Torvalds left--; 24071da177e4SLinus Torvalds } 24081da177e4SLinus Torvalds } 24091da177e4SLinus Torvalds if (write && first) 24101da177e4SLinus Torvalds return -EINVAL; 24111da177e4SLinus Torvalds *lenp -= left; 24121da177e4SLinus Torvalds *ppos += *lenp; 24131da177e4SLinus Torvalds return 0; 24141da177e4SLinus Torvalds #undef TMPBUFLEN 24151da177e4SLinus Torvalds } 24161da177e4SLinus Torvalds 2417d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp, 2418fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2419fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2420fcfbd547SKirill Korotaev int write, void *data), 2421fcfbd547SKirill Korotaev void *data) 2422fcfbd547SKirill Korotaev { 2423fcfbd547SKirill Korotaev return __do_proc_dointvec(table->data, table, write, filp, 2424fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2425fcfbd547SKirill Korotaev } 2426fcfbd547SKirill Korotaev 24271da177e4SLinus Torvalds /** 24281da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 24291da177e4SLinus Torvalds * @table: the sysctl table 24301da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24311da177e4SLinus Torvalds * @filp: the file structure 24321da177e4SLinus Torvalds * @buffer: the user buffer 24331da177e4SLinus Torvalds * @lenp: the size of the user buffer 24341da177e4SLinus Torvalds * @ppos: file position 24351da177e4SLinus Torvalds * 24361da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24371da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24381da177e4SLinus Torvalds * 24391da177e4SLinus Torvalds * Returns 0 on success. 24401da177e4SLinus Torvalds */ 2441d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp, 24421da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24431da177e4SLinus Torvalds { 24441da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 24451da177e4SLinus Torvalds NULL,NULL); 24461da177e4SLinus Torvalds } 24471da177e4SLinus Torvalds 244834f5a398STheodore Ts'o /* 244934f5a398STheodore Ts'o * Taint values can only be increased 245025ddbb18SAndi Kleen * This means we can safely use a temporary. 245134f5a398STheodore Ts'o */ 245225ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp, 245334f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 245434f5a398STheodore Ts'o { 245525ddbb18SAndi Kleen struct ctl_table t; 245625ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 245725ddbb18SAndi Kleen int err; 245834f5a398STheodore Ts'o 245991fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 246034f5a398STheodore Ts'o return -EPERM; 246134f5a398STheodore Ts'o 246225ddbb18SAndi Kleen t = *table; 246325ddbb18SAndi Kleen t.data = &tmptaint; 246425ddbb18SAndi Kleen err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos); 246525ddbb18SAndi Kleen if (err < 0) 246625ddbb18SAndi Kleen return err; 246725ddbb18SAndi Kleen 246825ddbb18SAndi Kleen if (write) { 246925ddbb18SAndi Kleen /* 247025ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 247125ddbb18SAndi Kleen * to everyone's atomic.h for this 247225ddbb18SAndi Kleen */ 247325ddbb18SAndi Kleen int i; 247425ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 247525ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 247625ddbb18SAndi Kleen add_taint(i); 247725ddbb18SAndi Kleen } 247825ddbb18SAndi Kleen } 247925ddbb18SAndi Kleen 248025ddbb18SAndi Kleen return err; 248134f5a398STheodore Ts'o } 248234f5a398STheodore Ts'o 24831da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 24841da177e4SLinus Torvalds int *min; 24851da177e4SLinus Torvalds int *max; 24861da177e4SLinus Torvalds }; 24871da177e4SLinus Torvalds 24881da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 24891da177e4SLinus Torvalds int *valp, 24901da177e4SLinus Torvalds int write, void *data) 24911da177e4SLinus Torvalds { 24921da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 24931da177e4SLinus Torvalds if (write) { 24941da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 24951da177e4SLinus Torvalds if ((param->min && *param->min > val) || 24961da177e4SLinus Torvalds (param->max && *param->max < val)) 24971da177e4SLinus Torvalds return -EINVAL; 24981da177e4SLinus Torvalds *valp = val; 24991da177e4SLinus Torvalds } else { 25001da177e4SLinus Torvalds int val = *valp; 25011da177e4SLinus Torvalds if (val < 0) { 25021da177e4SLinus Torvalds *negp = -1; 25031da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 25041da177e4SLinus Torvalds } else { 25051da177e4SLinus Torvalds *negp = 0; 25061da177e4SLinus Torvalds *lvalp = (unsigned long)val; 25071da177e4SLinus Torvalds } 25081da177e4SLinus Torvalds } 25091da177e4SLinus Torvalds return 0; 25101da177e4SLinus Torvalds } 25111da177e4SLinus Torvalds 25121da177e4SLinus Torvalds /** 25131da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 25141da177e4SLinus Torvalds * @table: the sysctl table 25151da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25161da177e4SLinus Torvalds * @filp: the file structure 25171da177e4SLinus Torvalds * @buffer: the user buffer 25181da177e4SLinus Torvalds * @lenp: the size of the user buffer 25191da177e4SLinus Torvalds * @ppos: file position 25201da177e4SLinus Torvalds * 25211da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25221da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25231da177e4SLinus Torvalds * 25241da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25251da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25261da177e4SLinus Torvalds * 25271da177e4SLinus Torvalds * Returns 0 on success. 25281da177e4SLinus Torvalds */ 2529d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, 25301da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25311da177e4SLinus Torvalds { 25321da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 25331da177e4SLinus Torvalds .min = (int *) table->extra1, 25341da177e4SLinus Torvalds .max = (int *) table->extra2, 25351da177e4SLinus Torvalds }; 25361da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 25371da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 25381da177e4SLinus Torvalds } 25391da177e4SLinus Torvalds 2540d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 25411da177e4SLinus Torvalds struct file *filp, 25421da177e4SLinus Torvalds void __user *buffer, 25431da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 25441da177e4SLinus Torvalds unsigned long convmul, 25451da177e4SLinus Torvalds unsigned long convdiv) 25461da177e4SLinus Torvalds { 25471da177e4SLinus Torvalds #define TMPBUFLEN 21 25481da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 25491da177e4SLinus Torvalds int vleft, first=1, neg; 25501da177e4SLinus Torvalds size_t len, left; 25511da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 25521da177e4SLinus Torvalds char __user *s = buffer; 25531da177e4SLinus Torvalds 2554fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 25551da177e4SLinus Torvalds (*ppos && !write)) { 25561da177e4SLinus Torvalds *lenp = 0; 25571da177e4SLinus Torvalds return 0; 25581da177e4SLinus Torvalds } 25591da177e4SLinus Torvalds 2560fcfbd547SKirill Korotaev i = (unsigned long *) data; 25611da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 25621da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 25631da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 25641da177e4SLinus Torvalds left = *lenp; 25651da177e4SLinus Torvalds 25661da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 25671da177e4SLinus Torvalds if (write) { 25681da177e4SLinus Torvalds while (left) { 25691da177e4SLinus Torvalds char c; 25701da177e4SLinus Torvalds if (get_user(c, s)) 25711da177e4SLinus Torvalds return -EFAULT; 25721da177e4SLinus Torvalds if (!isspace(c)) 25731da177e4SLinus Torvalds break; 25741da177e4SLinus Torvalds left--; 25751da177e4SLinus Torvalds s++; 25761da177e4SLinus Torvalds } 25771da177e4SLinus Torvalds if (!left) 25781da177e4SLinus Torvalds break; 25791da177e4SLinus Torvalds neg = 0; 25801da177e4SLinus Torvalds len = left; 25811da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 25821da177e4SLinus Torvalds len = TMPBUFLEN-1; 25831da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 25841da177e4SLinus Torvalds return -EFAULT; 25851da177e4SLinus Torvalds buf[len] = 0; 25861da177e4SLinus Torvalds p = buf; 25871da177e4SLinus Torvalds if (*p == '-' && left > 1) { 25881da177e4SLinus Torvalds neg = 1; 2589bd9b0bacSBP, Praveen p++; 25901da177e4SLinus Torvalds } 25911da177e4SLinus Torvalds if (*p < '0' || *p > '9') 25921da177e4SLinus Torvalds break; 25931da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 25941da177e4SLinus Torvalds len = p-buf; 25951da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 25961da177e4SLinus Torvalds break; 25971da177e4SLinus Torvalds if (neg) 25981da177e4SLinus Torvalds val = -val; 25991da177e4SLinus Torvalds s += len; 26001da177e4SLinus Torvalds left -= len; 26011da177e4SLinus Torvalds 26021da177e4SLinus Torvalds if(neg) 26031da177e4SLinus Torvalds continue; 26041da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 26051da177e4SLinus Torvalds continue; 26061da177e4SLinus Torvalds *i = val; 26071da177e4SLinus Torvalds } else { 26081da177e4SLinus Torvalds p = buf; 26091da177e4SLinus Torvalds if (!first) 26101da177e4SLinus Torvalds *p++ = '\t'; 26111da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 26121da177e4SLinus Torvalds len = strlen(buf); 26131da177e4SLinus Torvalds if (len > left) 26141da177e4SLinus Torvalds len = left; 26151da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 26161da177e4SLinus Torvalds return -EFAULT; 26171da177e4SLinus Torvalds left -= len; 26181da177e4SLinus Torvalds s += len; 26191da177e4SLinus Torvalds } 26201da177e4SLinus Torvalds } 26211da177e4SLinus Torvalds 26221da177e4SLinus Torvalds if (!write && !first && left) { 26231da177e4SLinus Torvalds if(put_user('\n', s)) 26241da177e4SLinus Torvalds return -EFAULT; 26251da177e4SLinus Torvalds left--, s++; 26261da177e4SLinus Torvalds } 26271da177e4SLinus Torvalds if (write) { 26281da177e4SLinus Torvalds while (left) { 26291da177e4SLinus Torvalds char c; 26301da177e4SLinus Torvalds if (get_user(c, s++)) 26311da177e4SLinus Torvalds return -EFAULT; 26321da177e4SLinus Torvalds if (!isspace(c)) 26331da177e4SLinus Torvalds break; 26341da177e4SLinus Torvalds left--; 26351da177e4SLinus Torvalds } 26361da177e4SLinus Torvalds } 26371da177e4SLinus Torvalds if (write && first) 26381da177e4SLinus Torvalds return -EINVAL; 26391da177e4SLinus Torvalds *lenp -= left; 26401da177e4SLinus Torvalds *ppos += *lenp; 26411da177e4SLinus Torvalds return 0; 26421da177e4SLinus Torvalds #undef TMPBUFLEN 26431da177e4SLinus Torvalds } 26441da177e4SLinus Torvalds 2645d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2646fcfbd547SKirill Korotaev struct file *filp, 2647fcfbd547SKirill Korotaev void __user *buffer, 2648fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2649fcfbd547SKirill Korotaev unsigned long convmul, 2650fcfbd547SKirill Korotaev unsigned long convdiv) 2651fcfbd547SKirill Korotaev { 2652fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 2653fcfbd547SKirill Korotaev filp, buffer, lenp, ppos, convmul, convdiv); 2654fcfbd547SKirill Korotaev } 2655fcfbd547SKirill Korotaev 26561da177e4SLinus Torvalds /** 26571da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 26581da177e4SLinus Torvalds * @table: the sysctl table 26591da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26601da177e4SLinus Torvalds * @filp: the file structure 26611da177e4SLinus Torvalds * @buffer: the user buffer 26621da177e4SLinus Torvalds * @lenp: the size of the user buffer 26631da177e4SLinus Torvalds * @ppos: file position 26641da177e4SLinus Torvalds * 26651da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26661da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 26671da177e4SLinus Torvalds * 26681da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26691da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26701da177e4SLinus Torvalds * 26711da177e4SLinus Torvalds * Returns 0 on success. 26721da177e4SLinus Torvalds */ 2673d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, 26741da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26751da177e4SLinus Torvalds { 26761da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l); 26771da177e4SLinus Torvalds } 26781da177e4SLinus Torvalds 26791da177e4SLinus Torvalds /** 26801da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 26811da177e4SLinus Torvalds * @table: the sysctl table 26821da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26831da177e4SLinus Torvalds * @filp: the file structure 26841da177e4SLinus Torvalds * @buffer: the user buffer 26851da177e4SLinus Torvalds * @lenp: the size of the user buffer 26861da177e4SLinus Torvalds * @ppos: file position 26871da177e4SLinus Torvalds * 26881da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26891da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 26901da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 26911da177e4SLinus Torvalds * 26921da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26931da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26941da177e4SLinus Torvalds * 26951da177e4SLinus Torvalds * Returns 0 on success. 26961da177e4SLinus Torvalds */ 2697d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26981da177e4SLinus Torvalds struct file *filp, 26991da177e4SLinus Torvalds void __user *buffer, 27001da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 27011da177e4SLinus Torvalds { 27021da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, 27031da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 27041da177e4SLinus Torvalds } 27051da177e4SLinus Torvalds 27061da177e4SLinus Torvalds 27071da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 27081da177e4SLinus Torvalds int *valp, 27091da177e4SLinus Torvalds int write, void *data) 27101da177e4SLinus Torvalds { 27111da177e4SLinus Torvalds if (write) { 2712cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2713cba9f33dSBart Samwel return 1; 27141da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 27151da177e4SLinus Torvalds } else { 27161da177e4SLinus Torvalds int val = *valp; 27171da177e4SLinus Torvalds unsigned long lval; 27181da177e4SLinus Torvalds if (val < 0) { 27191da177e4SLinus Torvalds *negp = -1; 27201da177e4SLinus Torvalds lval = (unsigned long)-val; 27211da177e4SLinus Torvalds } else { 27221da177e4SLinus Torvalds *negp = 0; 27231da177e4SLinus Torvalds lval = (unsigned long)val; 27241da177e4SLinus Torvalds } 27251da177e4SLinus Torvalds *lvalp = lval / HZ; 27261da177e4SLinus Torvalds } 27271da177e4SLinus Torvalds return 0; 27281da177e4SLinus Torvalds } 27291da177e4SLinus Torvalds 27301da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 27311da177e4SLinus Torvalds int *valp, 27321da177e4SLinus Torvalds int write, void *data) 27331da177e4SLinus Torvalds { 27341da177e4SLinus Torvalds if (write) { 2735cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2736cba9f33dSBart Samwel return 1; 27371da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 27381da177e4SLinus Torvalds } else { 27391da177e4SLinus Torvalds int val = *valp; 27401da177e4SLinus Torvalds unsigned long lval; 27411da177e4SLinus Torvalds if (val < 0) { 27421da177e4SLinus Torvalds *negp = -1; 27431da177e4SLinus Torvalds lval = (unsigned long)-val; 27441da177e4SLinus Torvalds } else { 27451da177e4SLinus Torvalds *negp = 0; 27461da177e4SLinus Torvalds lval = (unsigned long)val; 27471da177e4SLinus Torvalds } 27481da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 27491da177e4SLinus Torvalds } 27501da177e4SLinus Torvalds return 0; 27511da177e4SLinus Torvalds } 27521da177e4SLinus Torvalds 27531da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 27541da177e4SLinus Torvalds int *valp, 27551da177e4SLinus Torvalds int write, void *data) 27561da177e4SLinus Torvalds { 27571da177e4SLinus Torvalds if (write) { 27581da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 27591da177e4SLinus Torvalds } else { 27601da177e4SLinus Torvalds int val = *valp; 27611da177e4SLinus Torvalds unsigned long lval; 27621da177e4SLinus Torvalds if (val < 0) { 27631da177e4SLinus Torvalds *negp = -1; 27641da177e4SLinus Torvalds lval = (unsigned long)-val; 27651da177e4SLinus Torvalds } else { 27661da177e4SLinus Torvalds *negp = 0; 27671da177e4SLinus Torvalds lval = (unsigned long)val; 27681da177e4SLinus Torvalds } 27691da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 27701da177e4SLinus Torvalds } 27711da177e4SLinus Torvalds return 0; 27721da177e4SLinus Torvalds } 27731da177e4SLinus Torvalds 27741da177e4SLinus Torvalds /** 27751da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 27761da177e4SLinus Torvalds * @table: the sysctl table 27771da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27781da177e4SLinus Torvalds * @filp: the file structure 27791da177e4SLinus Torvalds * @buffer: the user buffer 27801da177e4SLinus Torvalds * @lenp: the size of the user buffer 27811da177e4SLinus Torvalds * @ppos: file position 27821da177e4SLinus Torvalds * 27831da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27841da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27851da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 27861da177e4SLinus Torvalds * jiffies. 27871da177e4SLinus Torvalds * 27881da177e4SLinus Torvalds * Returns 0 on success. 27891da177e4SLinus Torvalds */ 2790d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, 27911da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27921da177e4SLinus Torvalds { 27931da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 27941da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 27951da177e4SLinus Torvalds } 27961da177e4SLinus Torvalds 27971da177e4SLinus Torvalds /** 27981da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 27991da177e4SLinus Torvalds * @table: the sysctl table 28001da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 28011da177e4SLinus Torvalds * @filp: the file structure 28021da177e4SLinus Torvalds * @buffer: the user buffer 28031da177e4SLinus Torvalds * @lenp: the size of the user buffer 28041e5d5331SRandy Dunlap * @ppos: pointer to the file position 28051da177e4SLinus Torvalds * 28061da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 28071da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 28081da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 28091da177e4SLinus Torvalds * are converted into jiffies. 28101da177e4SLinus Torvalds * 28111da177e4SLinus Torvalds * Returns 0 on success. 28121da177e4SLinus Torvalds */ 2813d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, 28141da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28151da177e4SLinus Torvalds { 28161da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 28171da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 28181da177e4SLinus Torvalds } 28191da177e4SLinus Torvalds 28201da177e4SLinus Torvalds /** 28211da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 28221da177e4SLinus Torvalds * @table: the sysctl table 28231da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 28241da177e4SLinus Torvalds * @filp: the file structure 28251da177e4SLinus Torvalds * @buffer: the user buffer 28261da177e4SLinus Torvalds * @lenp: the size of the user buffer 282767be2dd1SMartin Waitz * @ppos: file position 282867be2dd1SMartin Waitz * @ppos: the current position in the file 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 1/1000 seconds, and 28331da177e4SLinus Torvalds * are converted into jiffies. 28341da177e4SLinus Torvalds * 28351da177e4SLinus Torvalds * Returns 0 on success. 28361da177e4SLinus Torvalds */ 2837d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, 28381da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28391da177e4SLinus Torvalds { 28401da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 28411da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 28421da177e4SLinus Torvalds } 28431da177e4SLinus Torvalds 2844d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 28459ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 28469ec52099SCedric Le Goater { 28479ec52099SCedric Le Goater struct pid *new_pid; 28489ec52099SCedric Le Goater pid_t tmp; 28499ec52099SCedric Le Goater int r; 28509ec52099SCedric Le Goater 28516c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 28529ec52099SCedric Le Goater 28539ec52099SCedric Le Goater r = __do_proc_dointvec(&tmp, table, write, filp, buffer, 28549ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 28559ec52099SCedric Le Goater if (r || !write) 28569ec52099SCedric Le Goater return r; 28579ec52099SCedric Le Goater 28589ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 28599ec52099SCedric Le Goater if (!new_pid) 28609ec52099SCedric Le Goater return -ESRCH; 28619ec52099SCedric Le Goater 28629ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 28639ec52099SCedric Le Goater return 0; 28649ec52099SCedric Le Goater } 28659ec52099SCedric Le Goater 28661da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 28671da177e4SLinus Torvalds 2868d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp, 28691da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28701da177e4SLinus Torvalds { 28711da177e4SLinus Torvalds return -ENOSYS; 28721da177e4SLinus Torvalds } 28731da177e4SLinus Torvalds 2874d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp, 28751da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28761da177e4SLinus Torvalds { 28771da177e4SLinus Torvalds return -ENOSYS; 28781da177e4SLinus Torvalds } 28791da177e4SLinus Torvalds 2880d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, 28811da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28821da177e4SLinus Torvalds { 28831da177e4SLinus Torvalds return -ENOSYS; 28841da177e4SLinus Torvalds } 28851da177e4SLinus Torvalds 2886d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, 28871da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28881da177e4SLinus Torvalds { 28891da177e4SLinus Torvalds return -ENOSYS; 28901da177e4SLinus Torvalds } 28911da177e4SLinus Torvalds 2892d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, 28931da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28941da177e4SLinus Torvalds { 28951da177e4SLinus Torvalds return -ENOSYS; 28961da177e4SLinus Torvalds } 28971da177e4SLinus Torvalds 2898d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, 28991da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29001da177e4SLinus Torvalds { 29011da177e4SLinus Torvalds return -ENOSYS; 29021da177e4SLinus Torvalds } 29031da177e4SLinus Torvalds 2904d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, 29051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29061da177e4SLinus Torvalds { 29071da177e4SLinus Torvalds return -ENOSYS; 29081da177e4SLinus Torvalds } 29091da177e4SLinus Torvalds 2910d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 29111da177e4SLinus Torvalds struct file *filp, 29121da177e4SLinus Torvalds void __user *buffer, 29131da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 29141da177e4SLinus Torvalds { 29151da177e4SLinus Torvalds return -ENOSYS; 29161da177e4SLinus Torvalds } 29171da177e4SLinus Torvalds 29181da177e4SLinus Torvalds 29191da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 29201da177e4SLinus Torvalds 29211da177e4SLinus Torvalds 2922b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 29231da177e4SLinus Torvalds /* 29241da177e4SLinus Torvalds * General sysctl support routines 29251da177e4SLinus Torvalds */ 29261da177e4SLinus Torvalds 292749a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */ 2928f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table, 292949a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 293049a0c458SEric W. Biederman void __user *newval, size_t newlen) 293149a0c458SEric W. Biederman { 293249a0c458SEric W. Biederman size_t len; 293349a0c458SEric W. Biederman 293449a0c458SEric W. Biederman /* Get out of I don't have a variable */ 293549a0c458SEric W. Biederman if (!table->data || !table->maxlen) 293649a0c458SEric W. Biederman return -ENOTDIR; 293749a0c458SEric W. Biederman 293849a0c458SEric W. Biederman if (oldval && oldlenp) { 293949a0c458SEric W. Biederman if (get_user(len, oldlenp)) 294049a0c458SEric W. Biederman return -EFAULT; 294149a0c458SEric W. Biederman if (len) { 294249a0c458SEric W. Biederman if (len > table->maxlen) 294349a0c458SEric W. Biederman len = table->maxlen; 294449a0c458SEric W. Biederman if (copy_to_user(oldval, table->data, len)) 294549a0c458SEric W. Biederman return -EFAULT; 294649a0c458SEric W. Biederman if (put_user(len, oldlenp)) 294749a0c458SEric W. Biederman return -EFAULT; 294849a0c458SEric W. Biederman } 294949a0c458SEric W. Biederman } 295049a0c458SEric W. Biederman 295149a0c458SEric W. Biederman if (newval && newlen) { 295249a0c458SEric W. Biederman if (newlen > table->maxlen) 295349a0c458SEric W. Biederman newlen = table->maxlen; 295449a0c458SEric W. Biederman 295549a0c458SEric W. Biederman if (copy_from_user(table->data, newval, newlen)) 295649a0c458SEric W. Biederman return -EFAULT; 295749a0c458SEric W. Biederman } 295849a0c458SEric W. Biederman return 1; 295949a0c458SEric W. Biederman } 296049a0c458SEric W. Biederman 29611da177e4SLinus Torvalds /* The generic string strategy routine: */ 2962f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table, 29631da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 29641f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 29651da177e4SLinus Torvalds { 29661da177e4SLinus Torvalds if (!table->data || !table->maxlen) 29671da177e4SLinus Torvalds return -ENOTDIR; 29681da177e4SLinus Torvalds 29691da177e4SLinus Torvalds if (oldval && oldlenp) { 2970de9e007dSLinus Torvalds size_t bufsize; 2971de9e007dSLinus Torvalds if (get_user(bufsize, oldlenp)) 29721da177e4SLinus Torvalds return -EFAULT; 2973de9e007dSLinus Torvalds if (bufsize) { 2974de9e007dSLinus Torvalds size_t len = strlen(table->data), copied; 2975de9e007dSLinus Torvalds 2976de9e007dSLinus Torvalds /* This shouldn't trigger for a well-formed sysctl */ 2977de9e007dSLinus Torvalds if (len > table->maxlen) 29781da177e4SLinus Torvalds len = table->maxlen; 2979de9e007dSLinus Torvalds 2980de9e007dSLinus Torvalds /* Copy up to a max of bufsize-1 bytes of the string */ 2981de9e007dSLinus Torvalds copied = (len >= bufsize) ? bufsize - 1 : len; 2982de9e007dSLinus Torvalds 2983de9e007dSLinus Torvalds if (copy_to_user(oldval, table->data, copied) || 2984de9e007dSLinus Torvalds put_user(0, (char __user *)(oldval + copied))) 29851da177e4SLinus Torvalds return -EFAULT; 29861da177e4SLinus Torvalds if (put_user(len, oldlenp)) 29871da177e4SLinus Torvalds return -EFAULT; 29881da177e4SLinus Torvalds } 29891da177e4SLinus Torvalds } 29901da177e4SLinus Torvalds if (newval && newlen) { 2991de9e007dSLinus Torvalds size_t len = newlen; 29921da177e4SLinus Torvalds if (len > table->maxlen) 29931da177e4SLinus Torvalds len = table->maxlen; 29941da177e4SLinus Torvalds if(copy_from_user(table->data, newval, len)) 29951da177e4SLinus Torvalds return -EFAULT; 29961da177e4SLinus Torvalds if (len == table->maxlen) 29971da177e4SLinus Torvalds len--; 29981da177e4SLinus Torvalds ((char *) table->data)[len] = 0; 29991da177e4SLinus Torvalds } 300082c9df82SYi Yang return 1; 30011da177e4SLinus Torvalds } 30021da177e4SLinus Torvalds 30031da177e4SLinus Torvalds /* 30041da177e4SLinus Torvalds * This function makes sure that all of the integers in the vector 30051da177e4SLinus Torvalds * are between the minimum and maximum values given in the arrays 30061da177e4SLinus Torvalds * table->extra1 and table->extra2, respectively. 30071da177e4SLinus Torvalds */ 3008f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table, 30091da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30101f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30111da177e4SLinus Torvalds { 30121da177e4SLinus Torvalds 30131da177e4SLinus Torvalds if (newval && newlen) { 30141da177e4SLinus Torvalds int __user *vec = (int __user *) newval; 30151da177e4SLinus Torvalds int *min = (int *) table->extra1; 30161da177e4SLinus Torvalds int *max = (int *) table->extra2; 30171da177e4SLinus Torvalds size_t length; 30181da177e4SLinus Torvalds int i; 30191da177e4SLinus Torvalds 30201da177e4SLinus Torvalds if (newlen % sizeof(int) != 0) 30211da177e4SLinus Torvalds return -EINVAL; 30221da177e4SLinus Torvalds 30231da177e4SLinus Torvalds if (!table->extra1 && !table->extra2) 30241da177e4SLinus Torvalds return 0; 30251da177e4SLinus Torvalds 30261da177e4SLinus Torvalds if (newlen > table->maxlen) 30271da177e4SLinus Torvalds newlen = table->maxlen; 30281da177e4SLinus Torvalds length = newlen / sizeof(int); 30291da177e4SLinus Torvalds 30301da177e4SLinus Torvalds for (i = 0; i < length; i++) { 30311da177e4SLinus Torvalds int value; 30321da177e4SLinus Torvalds if (get_user(value, vec + i)) 30331da177e4SLinus Torvalds return -EFAULT; 30341da177e4SLinus Torvalds if (min && value < min[i]) 30351da177e4SLinus Torvalds return -EINVAL; 30361da177e4SLinus Torvalds if (max && value > max[i]) 30371da177e4SLinus Torvalds return -EINVAL; 30381da177e4SLinus Torvalds } 30391da177e4SLinus Torvalds } 30401da177e4SLinus Torvalds return 0; 30411da177e4SLinus Torvalds } 30421da177e4SLinus Torvalds 30431da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 3044f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table, 30451da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30461f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30471da177e4SLinus Torvalds { 30483ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 30491da177e4SLinus Torvalds size_t olen; 30503ee75ac3SAlexey Dobriyan 30511da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 30521da177e4SLinus Torvalds return -EFAULT; 30533ee75ac3SAlexey Dobriyan if (olen) { 30543ee75ac3SAlexey Dobriyan int val; 30553ee75ac3SAlexey Dobriyan 30563ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 30571da177e4SLinus Torvalds return -EINVAL; 30583ee75ac3SAlexey Dobriyan 30593ee75ac3SAlexey Dobriyan val = *(int *)(table->data) / HZ; 30603ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 30611da177e4SLinus Torvalds return -EFAULT; 30623ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 30633ee75ac3SAlexey Dobriyan return -EFAULT; 30643ee75ac3SAlexey Dobriyan } 30651da177e4SLinus Torvalds } 30661da177e4SLinus Torvalds if (newval && newlen) { 30671da177e4SLinus Torvalds int new; 30681da177e4SLinus Torvalds if (newlen != sizeof(int)) 30691da177e4SLinus Torvalds return -EINVAL; 30701da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 30711da177e4SLinus Torvalds return -EFAULT; 30721da177e4SLinus Torvalds *(int *)(table->data) = new*HZ; 30731da177e4SLinus Torvalds } 30741da177e4SLinus Torvalds return 1; 30751da177e4SLinus Torvalds } 30761da177e4SLinus Torvalds 30771da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 3078f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table, 30791da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30801f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30811da177e4SLinus Torvalds { 30823ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 30831da177e4SLinus Torvalds size_t olen; 30843ee75ac3SAlexey Dobriyan 30851da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 30861da177e4SLinus Torvalds return -EFAULT; 30873ee75ac3SAlexey Dobriyan if (olen) { 30883ee75ac3SAlexey Dobriyan int val; 30893ee75ac3SAlexey Dobriyan 30903ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 30911da177e4SLinus Torvalds return -EINVAL; 30923ee75ac3SAlexey Dobriyan 30933ee75ac3SAlexey Dobriyan val = jiffies_to_msecs(*(int *)(table->data)); 30943ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 30951da177e4SLinus Torvalds return -EFAULT; 30963ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 30973ee75ac3SAlexey Dobriyan return -EFAULT; 30983ee75ac3SAlexey Dobriyan } 30991da177e4SLinus Torvalds } 31001da177e4SLinus Torvalds if (newval && newlen) { 31011da177e4SLinus Torvalds int new; 31021da177e4SLinus Torvalds if (newlen != sizeof(int)) 31031da177e4SLinus Torvalds return -EINVAL; 31041da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 31051da177e4SLinus Torvalds return -EFAULT; 31061da177e4SLinus Torvalds *(int *)(table->data) = msecs_to_jiffies(new); 31071da177e4SLinus Torvalds } 31081da177e4SLinus Torvalds return 1; 31091da177e4SLinus Torvalds } 31101da177e4SLinus Torvalds 3111c4b8b769SEric W. Biederman 3112c4b8b769SEric W. Biederman 3113b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */ 31141da177e4SLinus Torvalds 31151da177e4SLinus Torvalds 31161e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) 31171da177e4SLinus Torvalds { 31180e009be8SEric W. Biederman struct __sysctl_args tmp; 31197058cb02SEric W. Biederman int error; 31200e009be8SEric W. Biederman 31210e009be8SEric W. Biederman if (copy_from_user(&tmp, args, sizeof(tmp))) 31220e009be8SEric W. Biederman return -EFAULT; 31230e009be8SEric W. Biederman 31247058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 3125b89a8171SEric W. Biederman 31267058cb02SEric W. Biederman /* If no error reading the parameters then just -ENOSYS ... */ 31277058cb02SEric W. Biederman if (!error) 31287058cb02SEric W. Biederman error = -ENOSYS; 31297058cb02SEric W. Biederman 31307058cb02SEric W. Biederman return error; 31311da177e4SLinus Torvalds } 31321da177e4SLinus Torvalds 3133f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table, 313449a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 313549a0c458SEric W. Biederman void __user *newval, size_t newlen) 313649a0c458SEric W. Biederman { 313749a0c458SEric W. Biederman return -ENOSYS; 313849a0c458SEric W. Biederman } 313949a0c458SEric W. Biederman 3140f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table, 31411da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31421f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31431da177e4SLinus Torvalds { 31441da177e4SLinus Torvalds return -ENOSYS; 31451da177e4SLinus Torvalds } 31461da177e4SLinus Torvalds 3147f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table, 31481da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31491f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31501da177e4SLinus Torvalds { 31511da177e4SLinus Torvalds return -ENOSYS; 31521da177e4SLinus Torvalds } 31531da177e4SLinus Torvalds 3154f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table, 31551da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31561f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31571da177e4SLinus Torvalds { 31581da177e4SLinus Torvalds return -ENOSYS; 31591da177e4SLinus Torvalds } 31601da177e4SLinus Torvalds 3161f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table, 31621da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 31631f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 31641da177e4SLinus Torvalds { 31651da177e4SLinus Torvalds return -ENOSYS; 31661da177e4SLinus Torvalds } 31671da177e4SLinus Torvalds 3168b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 31691da177e4SLinus Torvalds 31707058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args) 31717058cb02SEric W. Biederman { 31727058cb02SEric W. Biederman static int msg_count; 31737058cb02SEric W. Biederman int name[CTL_MAXNAME]; 31747058cb02SEric W. Biederman int i; 31757058cb02SEric W. Biederman 31766fc48af8STetsuo Handa /* Check args->nlen. */ 31776fc48af8STetsuo Handa if (args->nlen < 0 || args->nlen > CTL_MAXNAME) 31786fc48af8STetsuo Handa return -ENOTDIR; 31796fc48af8STetsuo Handa 31807058cb02SEric W. Biederman /* Read in the sysctl name for better debug message logging */ 31817058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 31827058cb02SEric W. Biederman if (get_user(name[i], args->name + i)) 31837058cb02SEric W. Biederman return -EFAULT; 31847058cb02SEric W. Biederman 31857058cb02SEric W. Biederman /* Ignore accesses to kernel.version */ 31867058cb02SEric W. Biederman if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION)) 31877058cb02SEric W. Biederman return 0; 31887058cb02SEric W. Biederman 31897058cb02SEric W. Biederman if (msg_count < 5) { 31907058cb02SEric W. Biederman msg_count++; 31917058cb02SEric W. Biederman printk(KERN_INFO 31927058cb02SEric W. Biederman "warning: process `%s' used the deprecated sysctl " 31937058cb02SEric W. Biederman "system call with ", current->comm); 31947058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 31957058cb02SEric W. Biederman printk("%d.", name[i]); 31967058cb02SEric W. Biederman printk("\n"); 31977058cb02SEric W. Biederman } 31987058cb02SEric W. Biederman return 0; 31997058cb02SEric W. Biederman } 32007058cb02SEric W. Biederman 32011da177e4SLinus Torvalds /* 32021da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 32031da177e4SLinus Torvalds * exception granted :-) 32041da177e4SLinus Torvalds */ 32051da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 32061da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 32071da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 32081da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 32091da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 32101da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 32111da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 32121da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 32131da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 321429e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 32151da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec); 32161da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies); 32171da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies); 32181da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string); 321949a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data); 32201da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 3221